mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Push LLVMContexts through the IntegerType APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -379,9 +379,9 @@ value as a 1-bit (bool) value.</p>
|
||||
|
||||
// Create blocks for the then and else cases. Insert the 'then' block at the
|
||||
// end of the function.
|
||||
BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
|
||||
BasicBlock *ElseBB = BasicBlock::Create("else");
|
||||
BasicBlock *MergeBB = BasicBlock::Create("ifcont");
|
||||
BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
|
||||
BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
|
||||
BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
|
||||
|
||||
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
|
||||
</pre>
|
||||
@ -472,7 +472,7 @@ are emitted, we can finish up with the merge code:</p>
|
||||
// Emit merge block.
|
||||
TheFunction->getBasicBlockList().push_back(MergeBB);
|
||||
Builder.SetInsertPoint(MergeBB);
|
||||
PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
|
||||
PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
|
||||
|
||||
PN->addIncoming(ThenV, ThenBB);
|
||||
PN->addIncoming(ElseV, ElseBB);
|
||||
@ -727,7 +727,7 @@ block, but remember that the body code itself could consist of multiple blocks
|
||||
// block.
|
||||
Function *TheFunction = Builder.GetInsertBlock()->getParent();
|
||||
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
|
||||
BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
|
||||
BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
|
||||
|
||||
// Insert an explicit fall through from the current block to the LoopBB.
|
||||
Builder.CreateBr(LoopBB);
|
||||
@ -745,7 +745,7 @@ create an unconditional branch for the fall-through between the two blocks.</p>
|
||||
Builder.SetInsertPoint(LoopBB);
|
||||
|
||||
// Start the PHI node with an entry for Start.
|
||||
PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
|
||||
PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), VarName.c_str());
|
||||
Variable->addIncoming(StartVal, PreheaderBB);
|
||||
</pre>
|
||||
</div>
|
||||
@ -828,7 +828,7 @@ statement.</p>
|
||||
<pre>
|
||||
// Create the "after loop" block and insert it.
|
||||
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
|
||||
BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
|
||||
BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
|
||||
|
||||
// Insert the conditional branch into the end of LoopEndBB.
|
||||
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
|
||||
@ -856,7 +856,7 @@ the loop again and exiting the loop. Any future code is emitted in the
|
||||
NamedValues.erase(VarName);
|
||||
|
||||
// for expr always returns 0.0.
|
||||
return Constant::getNullValue(Type::DoubleTy);
|
||||
return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
@ -1381,7 +1381,7 @@ Value *BinaryExprAST::Codegen() {
|
||||
case '<':
|
||||
L = Builder.CreateFCmpULT(L, R, "cmptmp");
|
||||
// Convert bool 0/1 to double 0.0 or 1.0
|
||||
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
|
||||
return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
|
||||
default: return ErrorV("invalid binary operator");
|
||||
}
|
||||
}
|
||||
@ -1418,9 +1418,9 @@ Value *IfExprAST::Codegen() {
|
||||
|
||||
// Create blocks for the then and else cases. Insert the 'then' block at the
|
||||
// end of the function.
|
||||
BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
|
||||
BasicBlock *ElseBB = BasicBlock::Create("else");
|
||||
BasicBlock *MergeBB = BasicBlock::Create("ifcont");
|
||||
BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
|
||||
BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
|
||||
BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
|
||||
|
||||
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
|
||||
|
||||
@ -1448,7 +1448,7 @@ Value *IfExprAST::Codegen() {
|
||||
// Emit merge block.
|
||||
TheFunction->getBasicBlockList().push_back(MergeBB);
|
||||
Builder.SetInsertPoint(MergeBB);
|
||||
PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
|
||||
PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
|
||||
|
||||
PN->addIncoming(ThenV, ThenBB);
|
||||
PN->addIncoming(ElseV, ElseBB);
|
||||
@ -1480,7 +1480,7 @@ Value *ForExprAST::Codegen() {
|
||||
// block.
|
||||
Function *TheFunction = Builder.GetInsertBlock()->getParent();
|
||||
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
|
||||
BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
|
||||
BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
|
||||
|
||||
// Insert an explicit fall through from the current block to the LoopBB.
|
||||
Builder.CreateBr(LoopBB);
|
||||
@ -1489,7 +1489,7 @@ Value *ForExprAST::Codegen() {
|
||||
Builder.SetInsertPoint(LoopBB);
|
||||
|
||||
// Start the PHI node with an entry for Start.
|
||||
PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
|
||||
PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), VarName.c_str());
|
||||
Variable->addIncoming(StartVal, PreheaderBB);
|
||||
|
||||
// Within the loop, the variable is defined equal to the PHI node. If it
|
||||
@ -1526,7 +1526,7 @@ Value *ForExprAST::Codegen() {
|
||||
|
||||
// Create the "after loop" block and insert it.
|
||||
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
|
||||
BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
|
||||
BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
|
||||
|
||||
// Insert the conditional branch into the end of LoopEndBB.
|
||||
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
|
||||
@ -1545,13 +1545,13 @@ Value *ForExprAST::Codegen() {
|
||||
|
||||
|
||||
// for expr always returns 0.0.
|
||||
return getGlobalContext().getNullValue(Type::DoubleTy);
|
||||
return getGlobalContext().getNullValue(Type::getDoubleTy(getGlobalContext()));
|
||||
}
|
||||
|
||||
Function *PrototypeAST::Codegen() {
|
||||
// Make the function type: double(double,double) etc.
|
||||
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
|
||||
FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
|
||||
std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
|
||||
FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
|
||||
|
||||
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
|
||||
|
||||
@ -1596,7 +1596,7 @@ Function *FunctionAST::Codegen() {
|
||||
return 0;
|
||||
|
||||
// Create a new basic block to start insertion into.
|
||||
BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
|
||||
BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
|
||||
Builder.SetInsertPoint(BB);
|
||||
|
||||
if (Value *RetVal = Body->Codegen()) {
|
||||
|
Reference in New Issue
Block a user