mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-22 10:36:10 +00:00
* Finegrainify namespacification
* Add new constructors to allow insertion of terminator instructions at the end of basic blocks. * Move a ReturnInst method out-of-line, so that the vtable and type info don't need to be emitted to every translation unit that uses the class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10107 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dd56927846
commit
4b74c83334
@ -18,8 +18,7 @@
|
||||
#include "llvm/Constant.h"
|
||||
#include "llvm/Type.h"
|
||||
#include <algorithm> // find
|
||||
|
||||
namespace llvm {
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TerminatorInst Class
|
||||
@ -29,6 +28,13 @@ TerminatorInst::TerminatorInst(Instruction::TermOps iType, Instruction *IB)
|
||||
: Instruction(Type::VoidTy, iType, "", IB) {
|
||||
}
|
||||
|
||||
TerminatorInst::TerminatorInst(Instruction::TermOps iType, BasicBlock *IAE)
|
||||
: Instruction(Type::VoidTy, iType) {
|
||||
if (IAE) IAE->getInstList().push_back(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PHINode Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -58,5 +64,3 @@ Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
|
||||
}
|
||||
return Removed;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -15,8 +15,7 @@
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "Support/LeakDetector.h"
|
||||
|
||||
namespace llvm {
|
||||
using namespace llvm;
|
||||
|
||||
Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name,
|
||||
Instruction *InsertBefore)
|
||||
@ -165,5 +164,3 @@ bool Instruction::isTrapping(unsigned op) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -15,8 +15,15 @@
|
||||
#include "llvm/iTerminators.h"
|
||||
#include "llvm/BasicBlock.h"
|
||||
#include "llvm/Type.h"
|
||||
using namespace llvm;
|
||||
|
||||
// Out-of-line ReturnInst method, put here so the C++ compiler can choose to
|
||||
// emit the vtable for the class in this translation unit.
|
||||
void ReturnInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) {
|
||||
assert(0 && "ReturnInst has no successors!");
|
||||
}
|
||||
|
||||
|
||||
namespace llvm {
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
|
||||
Instruction *InsertBefore)
|
||||
@ -35,6 +42,23 @@ BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
|
||||
"May only branch on boolean predicates!!!!");
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: TerminatorInst(Instruction::Br, InsertAtEnd) {
|
||||
assert(True != 0 && "True branch destination may not be null!!!");
|
||||
Operands.reserve(False ? 3 : 1);
|
||||
Operands.push_back(Use(True, this));
|
||||
if (False) {
|
||||
Operands.push_back(Use(False, this));
|
||||
Operands.push_back(Use(Cond, this));
|
||||
}
|
||||
|
||||
assert(!!False == !!Cond &&
|
||||
"Either both cond and false or neither can be specified!");
|
||||
assert((Cond == 0 || Cond->getType() == Type::BoolTy) &&
|
||||
"May only branch on boolean predicates!!!!");
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *True, Instruction *InsertBefore)
|
||||
: TerminatorInst(Instruction::Br, InsertBefore) {
|
||||
assert(True != 0 && "True branch destination may not be null!!!");
|
||||
@ -42,6 +66,13 @@ BranchInst::BranchInst(BasicBlock *True, Instruction *InsertBefore)
|
||||
Operands.push_back(Use(True, this));
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(BasicBlock *True, BasicBlock *InsertAtEnd)
|
||||
: TerminatorInst(Instruction::Br, InsertAtEnd) {
|
||||
assert(True != 0 && "True branch destination may not be null!!!");
|
||||
Operands.reserve(1);
|
||||
Operands.push_back(Use(True, this));
|
||||
}
|
||||
|
||||
BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) {
|
||||
Operands.reserve(BI.Operands.size());
|
||||
Operands.push_back(Use(BI.Operands[0], this));
|
||||
@ -51,5 +82,3 @@ BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) {
|
||||
Operands.push_back(Use(BI.Operands[2], this));
|
||||
}
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Function.h"
|
||||
|
||||
namespace llvm {
|
||||
#include "llvm/Support/CallSite.h"
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// CallInst Implementation
|
||||
@ -124,6 +124,32 @@ InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal,
|
||||
Operands.push_back(Use(params[i], this));
|
||||
}
|
||||
|
||||
InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal,
|
||||
BasicBlock *IfException,
|
||||
const std::vector<Value*> ¶ms,
|
||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||
->getElementType())->getReturnType(),
|
||||
Instruction::Invoke, Name) {
|
||||
Operands.reserve(3+params.size());
|
||||
Operands.push_back(Use(Func, this));
|
||||
Operands.push_back(Use((Value*)IfNormal, this));
|
||||
Operands.push_back(Use((Value*)IfException, this));
|
||||
const FunctionType *MTy =
|
||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
|
||||
|
||||
const FunctionType::ParamTypes &PL = MTy->getParamTypes();
|
||||
assert((params.size() == PL.size()) ||
|
||||
(MTy->isVarArg() && params.size() > PL.size()) &&
|
||||
"Calling a function with bad signature");
|
||||
|
||||
for (unsigned i = 0; i < params.size(); i++)
|
||||
Operands.push_back(Use(params[i], this));
|
||||
|
||||
if (InsertAtEnd)
|
||||
InsertAtEnd->getInstList().push_back(this);
|
||||
}
|
||||
|
||||
InvokeInst::InvokeInst(const InvokeInst &CI)
|
||||
: TerminatorInst(CI.getType(), Instruction::Invoke) {
|
||||
Operands.reserve(CI.Operands.size());
|
||||
@ -146,12 +172,6 @@ Function *InvokeInst::getCalledFunction() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#include "llvm/Support/CallSite.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
Function *CallSite::getCalledFunction() const {
|
||||
Value *Callee = getCalledValue();
|
||||
if (Function *F = dyn_cast<Function>(Callee))
|
||||
@ -160,5 +180,3 @@ Function *CallSite::getCalledFunction() const {
|
||||
return cast<Function>(CPR->getValue());
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -15,8 +15,7 @@
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/BasicBlock.h"
|
||||
|
||||
namespace llvm {
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BinaryOperator Class
|
||||
@ -196,5 +195,3 @@ Instruction::BinaryOps SetCondInst::getSwappedCondition(BinaryOps Opcode) {
|
||||
case SetLE: return SetGE;
|
||||
}
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
#include "llvm/iTerminators.h"
|
||||
#include "llvm/BasicBlock.h"
|
||||
|
||||
namespace llvm {
|
||||
using namespace llvm;
|
||||
|
||||
SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest,
|
||||
Instruction *InsertBefore)
|
||||
@ -24,6 +23,14 @@ SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest,
|
||||
Operands.push_back(Use(DefaultDest, this));
|
||||
}
|
||||
|
||||
SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: TerminatorInst(Instruction::Switch, InsertAtEnd) {
|
||||
assert(V && DefaultDest);
|
||||
Operands.push_back(Use(V, this));
|
||||
Operands.push_back(Use(DefaultDest, this));
|
||||
}
|
||||
|
||||
SwitchInst::SwitchInst(const SwitchInst &SI)
|
||||
: TerminatorInst(Instruction::Switch) {
|
||||
Operands.reserve(SI.Operands.size());
|
||||
@ -50,5 +57,3 @@ void SwitchInst::removeCase(unsigned idx) {
|
||||
assert(idx*2 < Operands.size() && "Successor index out of range!!!");
|
||||
Operands.erase(Operands.begin()+idx*2, Operands.begin()+(idx+1)*2);
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user