aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-05-26 21:41:09 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-05-26 21:41:09 +0000
commite5828f1fa7c2691f747f5060ce11b8e55cea03ab (patch)
treeb9334e44ca7630cc55600d097c560d02bc72b3e2 /include
parent99c58f4910c898981f96f065065c3e47c94fec40 (diff)
downloadexternal_llvm-e5828f1fa7c2691f747f5060ce11b8e55cea03ab.zip
external_llvm-e5828f1fa7c2691f747f5060ce11b8e55cea03ab.tar.gz
external_llvm-e5828f1fa7c2691f747f5060ce11b8e55cea03ab.tar.bz2
Refactor common initialization code in private init() functions.
This is a first step in supplying append to basic block constructors for all instruction types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/InstrTypes.h8
-rw-r--r--include/llvm/Instruction.h4
-rw-r--r--include/llvm/iMemory.h11
-rw-r--r--include/llvm/iTerminators.h24
4 files changed, 37 insertions, 10 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 30ba130..df64c9b 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -32,9 +32,13 @@ protected:
TerminatorInst(Instruction::TermOps iType, Instruction *InsertBefore = 0);
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
const std::string &Name = "", Instruction *InsertBefore = 0)
- : Instruction(Ty, iType, Name, InsertBefore) {
- }
+ : Instruction(Ty, iType, Name, InsertBefore) {}
+
TerminatorInst(Instruction::TermOps iType, BasicBlock *InsertAtEnd);
+ TerminatorInst(const Type *Ty, Instruction::TermOps iType,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+ : Instruction(Ty, iType, Name, InsertAtEnd) {}
+
public:
/// Terminators must implement the methods required by Instruction...
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index fae6d2a..17eec87 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -36,11 +36,15 @@ class Instruction : public User, public Annotable {
friend class SymbolTableListTraits<Instruction, BasicBlock, Function,
ilist_traits<Instruction> >;
void setParent(BasicBlock *P);
+ void init();
+
protected:
unsigned iType; // InstructionType: The opcode of the instruction
Instruction(const Type *Ty, unsigned iType, const std::string &Name = "",
Instruction *InsertBefore = 0);
+ Instruction(const Type *Ty, unsigned iType, const std::string &Name,
+ BasicBlock *InsertAtEnd);
public:
~Instruction() {
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index 64a546d..a794ca5 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -163,6 +163,10 @@ class LoadInst : public Instruction {
Operands.push_back(Use(LI.Operands[0], this));
}
bool Volatile; // True if this is a volatile load
+ void init(Value *Ptr) {
+ Operands.reserve(1);
+ Operands.push_back(Use(Ptr, this));
+ }
public:
LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
LoadInst(Value *Ptr, const std::string &Name = "", bool isVolatile = false,
@@ -210,6 +214,11 @@ class StoreInst : public Instruction {
Operands.push_back(Use(SI.Operands[1], this));
}
bool Volatile; // True if this is a volatile store
+ void init(Value *Val, Value *Ptr) {
+ Operands.reserve(2);
+ Operands.push_back(Use(Val, this));
+ Operands.push_back(Use(Ptr, this));
+ }
public:
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
@@ -258,6 +267,8 @@ class GetElementPtrInst : public Instruction {
for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
Operands.push_back(Use(EPI.Operands[i], this));
}
+ void init(Value *Ptr, const std::vector<Value*> &Idx);
+
public:
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name = "", Instruction *InsertBefore =0);
diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h
index f6e1c36..78a1b74 100644
--- a/include/llvm/iTerminators.h
+++ b/include/llvm/iTerminators.h
@@ -32,6 +32,14 @@ class ReturnInst : public TerminatorInst {
Operands.push_back(Use(RI.Operands[0], this));
}
}
+
+ void init(Value *RetVal) {
+ if (RetVal) {
+ Operands.reserve(1);
+ Operands.push_back(Use(RetVal, this));
+ }
+ }
+
public:
// ReturnInst constructors:
// ReturnInst() - 'ret void' instruction
@@ -42,17 +50,11 @@ public:
// ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of BB
ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0)
: TerminatorInst(Instruction::Ret, InsertBefore) {
- if (RetVal) {
- Operands.reserve(1);
- Operands.push_back(Use(RetVal, this));
- }
+ init(RetVal);
}
ReturnInst(Value *RetVal, BasicBlock *InsertAtEnd)
: TerminatorInst(Instruction::Ret, InsertAtEnd) {
- if (RetVal) {
- Operands.reserve(1);
- Operands.push_back(Use(RetVal, this));
- }
+ init(RetVal);
}
virtual Instruction *clone() const { return new ReturnInst(*this); }
@@ -87,6 +89,8 @@ public:
///
class BranchInst : public TerminatorInst {
BranchInst(const BranchInst &BI);
+ void init(BasicBlock *IfTrue);
+ void init(BasicBlock *True, BasicBlock *False, Value *Cond);
public:
// BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
// BranchInst(BB *B) - 'br B'
@@ -161,6 +165,8 @@ class SwitchInst : public TerminatorInst {
// Operand[2n ] = Value to match
// Operand[2n+1] = BasicBlock to go to on match
SwitchInst(const SwitchInst &RI);
+ void init(Value *Value, BasicBlock *Default);
+
public:
SwitchInst(Value *Value, BasicBlock *Default, Instruction *InsertBefore = 0);
SwitchInst(Value *Value, BasicBlock *Default, BasicBlock *InsertAtEnd);
@@ -259,6 +265,8 @@ public:
///
class InvokeInst : public TerminatorInst {
InvokeInst(const InvokeInst &BI);
+ void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
+ const std::vector<Value*> &Params);
public:
InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
const std::vector<Value*> &Params, const std::string &Name = "",