comparison gen/asmstmt.cpp @ 1571:8d086d552909

IntegerType is now contextifed. Requires llvm >= 78969. resistor says this will be the last context API change :)
author Benjamin Kramer <benny.kra@gmail.com>
date Fri, 14 Aug 2009 00:39:18 +0200
parents d6e8d5db259f
children 40bd4a0d4870
comparison
equal deleted inserted replaced
1570:ab03cfb3a212 1571:8d086d552909
701 // build return types 701 // build return types
702 const LLType* retty; 702 const LLType* retty;
703 if (asmblock->retn) 703 if (asmblock->retn)
704 retty = asmblock->retty; 704 retty = asmblock->retty;
705 else 705 else
706 retty = llvm::Type::VoidTy; 706 retty = llvm::Type::getVoidTy(gIR->context());
707 707
708 // build argument types 708 // build argument types
709 std::vector<const LLType*> types; 709 std::vector<const LLType*> types;
710 types.insert(types.end(), outtypes.begin(), outtypes.end()); 710 types.insert(types.end(), outtypes.begin(), outtypes.end());
711 types.insert(types.end(), intypes.begin(), intypes.end()); 711 types.insert(types.end(), intypes.begin(), intypes.end());
730 } 730 }
731 731
732 llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true); 732 llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true);
733 733
734 llvm::CallInst* call = p->ir->CreateCall(ia, args.begin(), args.end(), 734 llvm::CallInst* call = p->ir->CreateCall(ia, args.begin(), args.end(),
735 retty == LLType::VoidTy ? "" : "asm"); 735 retty == LLType::getVoidTy(gIR->context()) ? "" : "asm");
736 736
737 if (Logger::enabled()) 737 if (Logger::enabled())
738 Logger::cout() << "Complete asm statement: " << *call << '\n'; 738 Logger::cout() << "Complete asm statement: " << *call << '\n';
739 739
740 // capture abi return value 740 // capture abi return value
757 { 757 {
758 assert(jump_target); 758 assert(jump_target);
759 759
760 // make new blocks 760 // make new blocks
761 llvm::BasicBlock* oldend = gIR->scopeend(); 761 llvm::BasicBlock* oldend = gIR->scopeend();
762 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterasmgotoforwarder", p->topfunc(), oldend); 762 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterasmgotoforwarder", p->topfunc(), oldend);
763 763
764 llvm::LoadInst* val = p->ir->CreateLoad(jump_target, "__llvm_jump_target_value"); 764 llvm::LoadInst* val = p->ir->CreateLoad(jump_target, "__llvm_jump_target_value");
765 llvm::SwitchInst* sw = p->ir->CreateSwitch(val, bb, gotoToVal.size()); 765 llvm::SwitchInst* sw = p->ir->CreateSwitch(val, bb, gotoToVal.size());
766 766
767 // add all cases 767 // add all cases
768 std::map<Identifier*, int>::iterator it, end = gotoToVal.end(); 768 std::map<Identifier*, int>::iterator it, end = gotoToVal.end();
769 for(it = gotoToVal.begin(); it != end; ++it) 769 for(it = gotoToVal.begin(); it != end; ++it)
770 { 770 {
771 llvm::BasicBlock* casebb = llvm::BasicBlock::Create("case", p->topfunc(), bb); 771 llvm::BasicBlock* casebb = llvm::BasicBlock::Create(gIR->context(), "case", p->topfunc(), bb);
772 sw->addCase(LLConstantInt::get(llvm::IntegerType::get(32), it->second), casebb); 772 sw->addCase(LLConstantInt::get(llvm::IntegerType::get(gIR->context(), 32), it->second), casebb);
773 773
774 p->scope() = IRScope(casebb,bb); 774 p->scope() = IRScope(casebb,bb);
775 DtoGoto(loc, it->first, enclosingFinally); 775 DtoGoto(loc, it->first, enclosingFinally);
776 } 776 }
777 777