mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-20 09:24:58 +00:00
Refactor the setName stuff, moving it down the inheritance hierarchy, to
solve a crash in -instcombine -debug that was hit while investigating PR1217 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e36126e474
commit
910c80a075
@ -29,19 +29,14 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class TerminatorInst : public Instruction {
|
class TerminatorInst : public Instruction {
|
||||||
protected:
|
protected:
|
||||||
TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps,
|
|
||||||
Instruction *InsertBefore = 0);
|
|
||||||
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
||||||
Use *Ops, unsigned NumOps,
|
Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name = "", Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0)
|
||||||
: Instruction(Ty, iType, Ops, NumOps, Name, InsertBefore) {}
|
: Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
|
||||||
|
|
||||||
TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps,
|
|
||||||
BasicBlock *InsertAtEnd);
|
|
||||||
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
||||||
Use *Ops, unsigned NumOps,
|
Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
: Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
|
||||||
: Instruction(Ty, iType, Ops, NumOps, Name, InsertAtEnd) {}
|
|
||||||
|
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
~TerminatorInst();
|
~TerminatorInst();
|
||||||
@ -90,13 +85,11 @@ public:
|
|||||||
class UnaryInstruction : public Instruction {
|
class UnaryInstruction : public Instruction {
|
||||||
Use Op;
|
Use Op;
|
||||||
protected:
|
protected:
|
||||||
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0)
|
||||||
const char *Name = 0, Instruction *IB = 0)
|
: Instruction(Ty, iType, &Op, 1, IB), Op(V, this) {
|
||||||
: Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) {
|
|
||||||
}
|
}
|
||||||
UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
|
UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
|
||||||
const char *Name, BasicBlock *IAE)
|
: Instruction(Ty, iType, &Op, 1, IAE), Op(V, this) {
|
||||||
: Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) {
|
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
@ -123,20 +116,9 @@ class BinaryOperator : public Instruction {
|
|||||||
protected:
|
protected:
|
||||||
void init(BinaryOps iType);
|
void init(BinaryOps iType);
|
||||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
|
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
|
||||||
const std::string &Name, Instruction *InsertBefore)
|
const std::string &Name, Instruction *InsertBefore);
|
||||||
: Instruction(Ty, iType, Ops, 2, Name, InsertBefore) {
|
|
||||||
Ops[0].init(S1, this);
|
|
||||||
Ops[1].init(S2, this);
|
|
||||||
init(iType);
|
|
||||||
}
|
|
||||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
|
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd);
|
||||||
: Instruction(Ty, iType, Ops, 2, Name, InsertAtEnd) {
|
|
||||||
Ops[0].init(S1, this);
|
|
||||||
Ops[1].init(S2, this);
|
|
||||||
init(iType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Transparently provide more efficient getOperand methods.
|
/// Transparently provide more efficient getOperand methods.
|
||||||
@ -264,13 +246,13 @@ protected:
|
|||||||
/// @brief Constructor with insert-before-instruction semantics for subclasses
|
/// @brief Constructor with insert-before-instruction semantics for subclasses
|
||||||
CastInst(const Type *Ty, unsigned iType, Value *S,
|
CastInst(const Type *Ty, unsigned iType, Value *S,
|
||||||
const std::string &Name = "", Instruction *InsertBefore = 0)
|
const std::string &Name = "", Instruction *InsertBefore = 0)
|
||||||
: UnaryInstruction(Ty, iType, S, 0, InsertBefore) {
|
: UnaryInstruction(Ty, iType, S, InsertBefore) {
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
|
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
|
||||||
CastInst(const Type *Ty, unsigned iType, Value *S,
|
CastInst(const Type *Ty, unsigned iType, Value *S,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Ty, iType, S, 0, InsertAtEnd) {
|
: UnaryInstruction(Ty, iType, S, InsertAtEnd) {
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
@ -41,13 +41,9 @@ class Instruction : public User {
|
|||||||
void setParent(BasicBlock *P);
|
void setParent(BasicBlock *P);
|
||||||
protected:
|
protected:
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name, Instruction *InsertBefore = 0);
|
Instruction *InsertBefore = 0);
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd);
|
BasicBlock *InsertAtEnd);
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
|
||||||
const char *Name = 0, Instruction *InsertBefore = 0);
|
|
||||||
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
|
|
||||||
const char *Name, BasicBlock *InsertAtEnd);
|
|
||||||
public:
|
public:
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
~Instruction();
|
~Instruction();
|
||||||
|
@ -773,15 +773,15 @@ class SelectInst : public Instruction {
|
|||||||
public:
|
public:
|
||||||
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
|
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0)
|
||||||
: Instruction(S1->getType(), Instruction::Select, Ops, 3,
|
: Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) {
|
||||||
Name, InsertBefore) {
|
|
||||||
init(C, S1, S2);
|
init(C, S1, S2);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
|
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(S1->getType(), Instruction::Select, Ops, 3,
|
: Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) {
|
||||||
Name, InsertAtEnd) {
|
|
||||||
init(C, S1, S2);
|
init(C, S1, S2);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *getCondition() const { return Ops[0]; }
|
Value *getCondition() const { return Ops[0]; }
|
||||||
@ -828,12 +828,12 @@ class VAArgInst : public UnaryInstruction {
|
|||||||
public:
|
public:
|
||||||
VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
|
VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0)
|
||||||
: UnaryInstruction(Ty, VAArg, List, 0, InsertBefore) {
|
: UnaryInstruction(Ty, VAArg, List, InsertBefore) {
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
VAArgInst(Value *List, const Type *Ty, const std::string &Name,
|
VAArgInst(Value *List, const Type *Ty, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Ty, VAArg, List, 0, InsertAtEnd) {
|
: UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1022,13 +1022,15 @@ class PHINode : public Instruction {
|
|||||||
public:
|
public:
|
||||||
explicit PHINode(const Type *Ty, const std::string &Name = "",
|
explicit PHINode(const Type *Ty, const std::string &Name = "",
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0)
|
||||||
: Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertBefore),
|
: Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
|
||||||
ReservedSpace(0) {
|
ReservedSpace(0) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
|
PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertAtEnd),
|
: Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
|
||||||
ReservedSpace(0) {
|
ReservedSpace(0) {
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
~PHINode();
|
~PHINode();
|
||||||
@ -1143,13 +1145,8 @@ public:
|
|||||||
/// does not continue in this function any longer.
|
/// does not continue in this function any longer.
|
||||||
///
|
///
|
||||||
class ReturnInst : public TerminatorInst {
|
class ReturnInst : public TerminatorInst {
|
||||||
Use RetVal; // Possibly null retval.
|
Use RetVal; // Return Value: null if 'void'.
|
||||||
ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret, &RetVal,
|
ReturnInst(const ReturnInst &RI);
|
||||||
RI.getNumOperands()) {
|
|
||||||
if (RI.getNumOperands())
|
|
||||||
RetVal.init(RI.RetVal, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(Value *RetVal);
|
void init(Value *RetVal);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1164,17 +1161,9 @@ public:
|
|||||||
//
|
//
|
||||||
// NOTE: If the Value* passed is of type void then the constructor behaves as
|
// NOTE: If the Value* passed is of type void then the constructor behaves as
|
||||||
// if it was passed NULL.
|
// if it was passed NULL.
|
||||||
explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0)
|
explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Ret, &RetVal, 0, InsertBefore) {
|
ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
|
||||||
init(retVal);
|
explicit ReturnInst(BasicBlock *InsertAtEnd);
|
||||||
}
|
|
||||||
ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
|
|
||||||
: TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) {
|
|
||||||
init(retVal);
|
|
||||||
}
|
|
||||||
explicit ReturnInst(BasicBlock *InsertAtEnd)
|
|
||||||
: TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ReturnInst *clone() const;
|
virtual ReturnInst *clone() const;
|
||||||
|
|
||||||
@ -1228,39 +1217,12 @@ public:
|
|||||||
// BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
|
// BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
|
||||||
// BranchInst(BB* B, BB *I) - 'br B' insert at end
|
// BranchInst(BB* B, BB *I) - 'br B' insert at end
|
||||||
// BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end
|
// BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end
|
||||||
explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0)
|
explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Br, Ops, 1, InsertBefore) {
|
|
||||||
assert(IfTrue != 0 && "Branch destination may not be null!");
|
|
||||||
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
|
||||||
}
|
|
||||||
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Br, Ops, 3, InsertBefore) {
|
BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
|
||||||
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
|
||||||
Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
|
|
||||||
Ops[2].init(Cond, this);
|
|
||||||
#ifndef NDEBUG
|
|
||||||
AssertOK();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
|
|
||||||
: TerminatorInst(Instruction::Br, Ops, 1, InsertAtEnd) {
|
|
||||||
assert(IfTrue != 0 && "Branch destination may not be null!");
|
|
||||||
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd);
|
||||||
: TerminatorInst(Instruction::Br, Ops, 3, InsertAtEnd) {
|
|
||||||
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
|
||||||
Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
|
|
||||||
Ops[2].init(Cond, this);
|
|
||||||
#ifndef NDEBUG
|
|
||||||
AssertOK();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Transparently provide more efficient getOperand methods.
|
/// Transparently provide more efficient getOperand methods.
|
||||||
Value *getOperand(unsigned i) const {
|
Value *getOperand(unsigned i) const {
|
||||||
@ -1348,20 +1310,14 @@ public:
|
|||||||
/// be specified here to make memory allocation more efficient. This
|
/// be specified here to make memory allocation more efficient. This
|
||||||
/// constructor can also autoinsert before another instruction.
|
/// constructor can also autoinsert before another instruction.
|
||||||
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
||||||
Instruction *InsertBefore = 0)
|
Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Switch, 0, 0, InsertBefore) {
|
|
||||||
init(Value, Default, NumCases);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
||||||
/// switch on and a default destination. The number of additional cases can
|
/// switch on and a default destination. The number of additional cases can
|
||||||
/// be specified here to make memory allocation more efficient. This
|
/// be specified here to make memory allocation more efficient. This
|
||||||
/// constructor also autoinserts at the end of the specified BasicBlock.
|
/// constructor also autoinserts at the end of the specified BasicBlock.
|
||||||
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd);
|
||||||
: TerminatorInst(Instruction::Switch, 0, 0, InsertAtEnd) {
|
|
||||||
init(Value, Default, NumCases);
|
|
||||||
}
|
|
||||||
~SwitchInst();
|
~SwitchInst();
|
||||||
|
|
||||||
|
|
||||||
@ -1554,12 +1510,8 @@ private:
|
|||||||
///
|
///
|
||||||
class UnwindInst : public TerminatorInst {
|
class UnwindInst : public TerminatorInst {
|
||||||
public:
|
public:
|
||||||
explicit UnwindInst(Instruction *InsertBefore = 0)
|
explicit UnwindInst(Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Unwind, 0, 0, InsertBefore) {
|
explicit UnwindInst(BasicBlock *InsertAtEnd);
|
||||||
}
|
|
||||||
explicit UnwindInst(BasicBlock *InsertAtEnd)
|
|
||||||
: TerminatorInst(Instruction::Unwind, 0, 0, InsertAtEnd) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual UnwindInst *clone() const;
|
virtual UnwindInst *clone() const;
|
||||||
|
|
||||||
@ -1590,12 +1542,8 @@ private:
|
|||||||
///
|
///
|
||||||
class UnreachableInst : public TerminatorInst {
|
class UnreachableInst : public TerminatorInst {
|
||||||
public:
|
public:
|
||||||
explicit UnreachableInst(Instruction *InsertBefore = 0)
|
explicit UnreachableInst(Instruction *InsertBefore = 0);
|
||||||
: TerminatorInst(Instruction::Unreachable, 0, 0, InsertBefore) {
|
explicit UnreachableInst(BasicBlock *InsertAtEnd);
|
||||||
}
|
|
||||||
explicit UnreachableInst(BasicBlock *InsertAtEnd)
|
|
||||||
: TerminatorInst(Instruction::Unreachable, 0, 0, InsertAtEnd) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual UnreachableInst *clone() const;
|
virtual UnreachableInst *clone() const;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name, Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
||||||
// Make sure that we get added to a basicblock
|
// Make sure that we get added to a basicblock
|
||||||
LeakDetector::addGarbageObject(this);
|
LeakDetector::addGarbageObject(this);
|
||||||
@ -30,11 +30,10 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
|||||||
"Instruction to insert before is not in a basic block!");
|
"Instruction to insert before is not in a basic block!");
|
||||||
InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
|
InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
|
||||||
}
|
}
|
||||||
setName(Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
||||||
// Make sure that we get added to a basicblock
|
// Make sure that we get added to a basicblock
|
||||||
LeakDetector::addGarbageObject(this);
|
LeakDetector::addGarbageObject(this);
|
||||||
@ -42,34 +41,6 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
|||||||
// append this instruction into the basic block
|
// append this instruction into the basic block
|
||||||
assert(InsertAtEnd && "Basic block to append to may not be NULL!");
|
assert(InsertAtEnd && "Basic block to append to may not be NULL!");
|
||||||
InsertAtEnd->getInstList().push_back(this);
|
InsertAtEnd->getInstList().push_back(this);
|
||||||
setName(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
|
||||||
const char *Name, Instruction *InsertBefore)
|
|
||||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
|
||||||
// Make sure that we get added to a basicblock
|
|
||||||
LeakDetector::addGarbageObject(this);
|
|
||||||
|
|
||||||
// If requested, insert this instruction into a basic block...
|
|
||||||
if (InsertBefore) {
|
|
||||||
assert(InsertBefore->getParent() &&
|
|
||||||
"Instruction to insert before is not in a basic block!");
|
|
||||||
InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
|
|
||||||
}
|
|
||||||
if (Name && *Name) setName(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
|
|
||||||
const char *Name, BasicBlock *InsertAtEnd)
|
|
||||||
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
|
|
||||||
// Make sure that we get added to a basicblock
|
|
||||||
LeakDetector::addGarbageObject(this);
|
|
||||||
|
|
||||||
// append this instruction into the basic block
|
|
||||||
assert(InsertAtEnd && "Basic block to append to may not be NULL!");
|
|
||||||
InsertAtEnd->getInstList().push_back(this);
|
|
||||||
if (Name && *Name) setName(Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,16 +40,6 @@ void CallSite::setCallingConv(unsigned CC) {
|
|||||||
// TerminatorInst Class
|
// TerminatorInst Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
TerminatorInst::TerminatorInst(Instruction::TermOps iType,
|
|
||||||
Use *Ops, unsigned NumOps, Instruction *IB)
|
|
||||||
: Instruction(Type::VoidTy, iType, Ops, NumOps, "", IB) {
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminatorInst::TerminatorInst(Instruction::TermOps iType,
|
|
||||||
Use *Ops, unsigned NumOps, BasicBlock *IAE)
|
|
||||||
: Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Out of line virtual method, so the vtable, etc has a home.
|
// Out of line virtual method, so the vtable, etc has a home.
|
||||||
TerminatorInst::~TerminatorInst() {
|
TerminatorInst::~TerminatorInst() {
|
||||||
}
|
}
|
||||||
@ -272,63 +262,71 @@ CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
|
|||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertAtEnd) {
|
Instruction::Call, 0, 0, InsertAtEnd) {
|
||||||
init(Func, Args, NumArgs);
|
init(Func, Args, NumArgs);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
|
CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
|
||||||
const std::string &Name, Instruction *InsertBefore)
|
const std::string &Name, Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertBefore) {
|
Instruction::Call, 0, 0, InsertBefore) {
|
||||||
init(Func, Args, NumArgs);
|
init(Func, Args, NumArgs);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
|
CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
|
||||||
const std::string &Name, Instruction *InsertBefore)
|
const std::string &Name, Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertBefore) {
|
Instruction::Call, 0, 0, InsertBefore) {
|
||||||
init(Func, Actual1, Actual2);
|
init(Func, Actual1, Actual2);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
|
CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertAtEnd) {
|
Instruction::Call, 0, 0, InsertAtEnd) {
|
||||||
init(Func, Actual1, Actual2);
|
init(Func, Actual1, Actual2);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
|
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertBefore) {
|
Instruction::Call, 0, 0, InsertBefore) {
|
||||||
init(Func, Actual);
|
init(Func, Actual);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
|
CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertAtEnd) {
|
Instruction::Call, 0, 0, InsertAtEnd) {
|
||||||
init(Func, Actual);
|
init(Func, Actual);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, const std::string &Name,
|
CallInst::CallInst(Value *Func, const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertBefore) {
|
Instruction::Call, 0, 0, InsertBefore) {
|
||||||
init(Func);
|
init(Func);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(Value *Func, const std::string &Name,
|
CallInst::CallInst(Value *Func, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Call, 0, 0, Name, InsertAtEnd) {
|
Instruction::Call, 0, 0, InsertAtEnd) {
|
||||||
init(Func);
|
init(Func);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallInst::CallInst(const CallInst &CI)
|
CallInst::CallInst(const CallInst &CI)
|
||||||
@ -380,8 +378,9 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
|
|||||||
const std::string &Name, Instruction *InsertBefore)
|
const std::string &Name, Instruction *InsertBefore)
|
||||||
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
|
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Invoke, 0, 0, Name, InsertBefore) {
|
Instruction::Invoke, 0, 0, InsertBefore) {
|
||||||
init(Fn, IfNormal, IfException, Args, NumArgs);
|
init(Fn, IfNormal, IfException, Args, NumArgs);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
|
InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
|
||||||
@ -390,8 +389,9 @@ InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,
|
|||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
|
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Fn->getType())
|
||||||
->getElementType())->getReturnType(),
|
->getElementType())->getReturnType(),
|
||||||
Instruction::Invoke, 0, 0, Name, InsertAtEnd) {
|
Instruction::Invoke, 0, 0, InsertAtEnd) {
|
||||||
init(Fn, IfNormal, IfException, Args, NumArgs);
|
init(Fn, IfNormal, IfException, Args, NumArgs);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokeInst::InvokeInst(const InvokeInst &II)
|
InvokeInst::InvokeInst(const InvokeInst &II)
|
||||||
@ -418,6 +418,27 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
|
|||||||
// ReturnInst Implementation
|
// ReturnInst Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
ReturnInst::ReturnInst(const ReturnInst &RI)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Ret,
|
||||||
|
&RetVal, RI.getNumOperands()) {
|
||||||
|
if (RI.getNumOperands())
|
||||||
|
RetVal.init(RI.RetVal, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) {
|
||||||
|
init(retVal);
|
||||||
|
}
|
||||||
|
ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
|
||||||
|
init(retVal);
|
||||||
|
}
|
||||||
|
ReturnInst::ReturnInst(BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ReturnInst::init(Value *retVal) {
|
void ReturnInst::init(Value *retVal) {
|
||||||
if (retVal && retVal->getType() != Type::VoidTy) {
|
if (retVal && retVal->getType() != Type::VoidTy) {
|
||||||
assert(!isa<BasicBlock>(retVal) &&
|
assert(!isa<BasicBlock>(retVal) &&
|
||||||
@ -448,6 +469,14 @@ BasicBlock *ReturnInst::getSuccessorV(unsigned idx) const {
|
|||||||
// UnwindInst Implementation
|
// UnwindInst Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
UnwindInst::UnwindInst(Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Unwind, 0, 0, InsertBefore) {
|
||||||
|
}
|
||||||
|
UnwindInst::UnwindInst(BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Unwind, 0, 0, InsertAtEnd) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned UnwindInst::getNumSuccessorsV() const {
|
unsigned UnwindInst::getNumSuccessorsV() const {
|
||||||
return getNumSuccessors();
|
return getNumSuccessors();
|
||||||
}
|
}
|
||||||
@ -466,6 +495,13 @@ BasicBlock *UnwindInst::getSuccessorV(unsigned idx) const {
|
|||||||
// UnreachableInst Implementation
|
// UnreachableInst Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
UnreachableInst::UnreachableInst(Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Unreachable, 0, 0, InsertBefore) {
|
||||||
|
}
|
||||||
|
UnreachableInst::UnreachableInst(BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Unreachable, 0, 0, InsertAtEnd) {
|
||||||
|
}
|
||||||
|
|
||||||
unsigned UnreachableInst::getNumSuccessorsV() const {
|
unsigned UnreachableInst::getNumSuccessorsV() const {
|
||||||
return getNumSuccessors();
|
return getNumSuccessors();
|
||||||
}
|
}
|
||||||
@ -490,8 +526,42 @@ void BranchInst::AssertOK() {
|
|||||||
"May only branch on boolean predicates!");
|
"May only branch on boolean predicates!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertBefore) {
|
||||||
|
assert(IfTrue != 0 && "Branch destination may not be null!");
|
||||||
|
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
||||||
|
}
|
||||||
|
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||||
|
Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertBefore) {
|
||||||
|
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
||||||
|
Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
|
||||||
|
Ops[2].init(Cond, this);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
AssertOK();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertAtEnd) {
|
||||||
|
assert(IfTrue != 0 && "Branch destination may not be null!");
|
||||||
|
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||||
|
BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertAtEnd) {
|
||||||
|
Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
|
||||||
|
Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
|
||||||
|
Ops[2].init(Cond, this);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
AssertOK();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BranchInst::BranchInst(const BranchInst &BI) :
|
BranchInst::BranchInst(const BranchInst &BI) :
|
||||||
TerminatorInst(Instruction::Br, Ops, BI.getNumOperands()) {
|
TerminatorInst(Type::VoidTy, Instruction::Br, Ops, BI.getNumOperands()) {
|
||||||
OperandList[0].init(BI.getOperand(0), this);
|
OperandList[0].init(BI.getOperand(0), this);
|
||||||
if (BI.getNumOperands() != 1) {
|
if (BI.getNumOperands() != 1) {
|
||||||
assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
|
assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
|
||||||
@ -531,7 +601,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
|||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||||
0, InsertBefore), Alignment(Align) {
|
InsertBefore), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -541,7 +611,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
|||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
||||||
0, InsertAtEnd), Alignment(Align) {
|
InsertAtEnd), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -581,12 +651,12 @@ void FreeInst::AssertOK() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
|
FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
|
||||||
: UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertBefore) {
|
: UnaryInstruction(Type::VoidTy, Free, Ptr, InsertBefore) {
|
||||||
AssertOK();
|
AssertOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
|
FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertAtEnd) {
|
: UnaryInstruction(Type::VoidTy, Free, Ptr, InsertAtEnd) {
|
||||||
AssertOK();
|
AssertOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,7 +672,7 @@ void LoadInst::AssertOK() {
|
|||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, 0, InsertBef) {
|
Load, Ptr, InsertBef) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -610,7 +680,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
|
|||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, 0, InsertAE) {
|
Load, Ptr, InsertAE) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -619,7 +689,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
|
|||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, 0, InsertBef) {
|
Load, Ptr, InsertBef) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -628,7 +698,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
|||||||
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, 0, InsertAE) {
|
Load, Ptr, InsertAE) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -637,33 +707,37 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
|
|||||||
|
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef)
|
LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertBef) {
|
Load, Ptr, InsertBef) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
if (Name && Name[0]) setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE)
|
LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertAE) {
|
Load, Ptr, InsertAE) {
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
if (Name && Name[0]) setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertBef) {
|
Load, Ptr, InsertBef) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
if (Name && Name[0]) setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||||
Load, Ptr, Name, InsertAE) {
|
Load, Ptr, InsertAE) {
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
AssertOK();
|
AssertOK();
|
||||||
|
if (Name && Name[0]) setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -681,7 +755,7 @@ void StoreInst::AssertOK() {
|
|||||||
|
|
||||||
|
|
||||||
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
|
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
|
||||||
: Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore) {
|
: Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
|
||||||
Ops[0].init(val, this);
|
Ops[0].init(val, this);
|
||||||
Ops[1].init(addr, this);
|
Ops[1].init(addr, this);
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
@ -689,7 +763,7 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
|
StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd) {
|
: Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) {
|
||||||
Ops[0].init(val, this);
|
Ops[0].init(val, this);
|
||||||
Ops[1].init(addr, this);
|
Ops[1].init(addr, this);
|
||||||
setVolatile(false);
|
setVolatile(false);
|
||||||
@ -698,7 +772,7 @@ StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
|
|||||||
|
|
||||||
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore) {
|
: Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
|
||||||
Ops[0].init(val, this);
|
Ops[0].init(val, this);
|
||||||
Ops[1].init(addr, this);
|
Ops[1].init(addr, this);
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
@ -707,7 +781,7 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
|||||||
|
|
||||||
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd) {
|
: Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) {
|
||||||
Ops[0].init(val, this);
|
Ops[0].init(val, this);
|
||||||
Ops[1].init(addr, this);
|
Ops[1].init(addr, this);
|
||||||
setVolatile(isVolatile);
|
setVolatile(isVolatile);
|
||||||
@ -756,8 +830,9 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx,
|
|||||||
const std::string &Name, Instruction *InBe)
|
const std::string &Name, Instruction *InBe)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||||
Idx, NumIdx, true))),
|
Idx, NumIdx, true))),
|
||||||
GetElementPtr, 0, 0, Name, InBe) {
|
GetElementPtr, 0, 0, InBe) {
|
||||||
init(Ptr, Idx, NumIdx);
|
init(Ptr, Idx, NumIdx);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx,
|
||||||
@ -765,40 +840,43 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx,
|
|||||||
const std::string &Name, BasicBlock *IAE)
|
const std::string &Name, BasicBlock *IAE)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||||
Idx, NumIdx, true))),
|
Idx, NumIdx, true))),
|
||||||
GetElementPtr, 0, 0, Name, IAE) {
|
GetElementPtr, 0, 0, IAE) {
|
||||||
init(Ptr, Idx, NumIdx);
|
init(Ptr, Idx, NumIdx);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||||
const std::string &Name, Instruction *InBe)
|
const std::string &Name, Instruction *InBe)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))),
|
||||||
Idx))),
|
GetElementPtr, 0, 0, InBe) {
|
||||||
GetElementPtr, 0, 0, Name, InBe) {
|
|
||||||
init(Ptr, Idx);
|
init(Ptr, Idx);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||||
const std::string &Name, BasicBlock *IAE)
|
const std::string &Name, BasicBlock *IAE)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))),
|
||||||
Idx))),
|
GetElementPtr, 0, 0, IAE) {
|
||||||
GetElementPtr, 0, 0, Name, IAE) {
|
|
||||||
init(Ptr, Idx);
|
init(Ptr, Idx);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
|
||||||
const std::string &Name, Instruction *InBe)
|
const std::string &Name, Instruction *InBe)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||||
Idx0, Idx1, true))),
|
Idx0, Idx1, true))),
|
||||||
GetElementPtr, 0, 0, Name, InBe) {
|
GetElementPtr, 0, 0, InBe) {
|
||||||
init(Ptr, Idx0, Idx1);
|
init(Ptr, Idx0, Idx1);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
|
||||||
const std::string &Name, BasicBlock *IAE)
|
const std::string &Name, BasicBlock *IAE)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||||
Idx0, Idx1, true))),
|
Idx0, Idx1, true))),
|
||||||
GetElementPtr, 0, 0, Name, IAE) {
|
GetElementPtr, 0, 0, IAE) {
|
||||||
init(Ptr, Idx0, Idx1);
|
init(Ptr, Idx0, Idx1);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst::~GetElementPtrInst() {
|
GetElementPtrInst::~GetElementPtrInst() {
|
||||||
@ -885,23 +963,25 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
|
|||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
||||||
ExtractElement, Ops, 2, Name, InsertBef) {
|
ExtractElement, Ops, 2, InsertBef) {
|
||||||
assert(isValidOperands(Val, Index) &&
|
assert(isValidOperands(Val, Index) &&
|
||||||
"Invalid extractelement instruction operands!");
|
"Invalid extractelement instruction operands!");
|
||||||
Ops[0].init(Val, this);
|
Ops[0].init(Val, this);
|
||||||
Ops[1].init(Index, this);
|
Ops[1].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
|
ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
||||||
ExtractElement, Ops, 2, Name, InsertBef) {
|
ExtractElement, Ops, 2, InsertBef) {
|
||||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||||
assert(isValidOperands(Val, Index) &&
|
assert(isValidOperands(Val, Index) &&
|
||||||
"Invalid extractelement instruction operands!");
|
"Invalid extractelement instruction operands!");
|
||||||
Ops[0].init(Val, this);
|
Ops[0].init(Val, this);
|
||||||
Ops[1].init(Index, this);
|
Ops[1].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -909,25 +989,27 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
|
|||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
||||||
ExtractElement, Ops, 2, Name, InsertAE) {
|
ExtractElement, Ops, 2, InsertAE) {
|
||||||
assert(isValidOperands(Val, Index) &&
|
assert(isValidOperands(Val, Index) &&
|
||||||
"Invalid extractelement instruction operands!");
|
"Invalid extractelement instruction operands!");
|
||||||
|
|
||||||
Ops[0].init(Val, this);
|
Ops[0].init(Val, this);
|
||||||
Ops[1].init(Index, this);
|
Ops[1].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
|
ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
|
||||||
ExtractElement, Ops, 2, Name, InsertAE) {
|
ExtractElement, Ops, 2, InsertAE) {
|
||||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||||
assert(isValidOperands(Val, Index) &&
|
assert(isValidOperands(Val, Index) &&
|
||||||
"Invalid extractelement instruction operands!");
|
"Invalid extractelement instruction operands!");
|
||||||
|
|
||||||
Ops[0].init(Val, this);
|
Ops[0].init(Val, this);
|
||||||
Ops[1].init(Index, this);
|
Ops[1].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -951,43 +1033,46 @@ InsertElementInst::InsertElementInst(const InsertElementInst &IE)
|
|||||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) {
|
: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) {
|
||||||
assert(isValidOperands(Vec, Elt, Index) &&
|
assert(isValidOperands(Vec, Elt, Index) &&
|
||||||
"Invalid insertelement instruction operands!");
|
"Invalid insertelement instruction operands!");
|
||||||
Ops[0].init(Vec, this);
|
Ops[0].init(Vec, this);
|
||||||
Ops[1].init(Elt, this);
|
Ops[1].init(Elt, this);
|
||||||
Ops[2].init(Index, this);
|
Ops[2].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
|
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
Instruction *InsertBef)
|
Instruction *InsertBef)
|
||||||
: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) {
|
: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) {
|
||||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||||
assert(isValidOperands(Vec, Elt, Index) &&
|
assert(isValidOperands(Vec, Elt, Index) &&
|
||||||
"Invalid insertelement instruction operands!");
|
"Invalid insertelement instruction operands!");
|
||||||
Ops[0].init(Vec, this);
|
Ops[0].init(Vec, this);
|
||||||
Ops[1].init(Elt, this);
|
Ops[1].init(Elt, this);
|
||||||
Ops[2].init(Index, this);
|
Ops[2].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) {
|
: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) {
|
||||||
assert(isValidOperands(Vec, Elt, Index) &&
|
assert(isValidOperands(Vec, Elt, Index) &&
|
||||||
"Invalid insertelement instruction operands!");
|
"Invalid insertelement instruction operands!");
|
||||||
|
|
||||||
Ops[0].init(Vec, this);
|
Ops[0].init(Vec, this);
|
||||||
Ops[1].init(Elt, this);
|
Ops[1].init(Elt, this);
|
||||||
Ops[2].init(Index, this);
|
Ops[2].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
|
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
BasicBlock *InsertAE)
|
BasicBlock *InsertAE)
|
||||||
: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) {
|
: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) {
|
||||||
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
|
||||||
assert(isValidOperands(Vec, Elt, Index) &&
|
assert(isValidOperands(Vec, Elt, Index) &&
|
||||||
"Invalid insertelement instruction operands!");
|
"Invalid insertelement instruction operands!");
|
||||||
@ -995,6 +1080,7 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
|
|||||||
Ops[0].init(Vec, this);
|
Ops[0].init(Vec, this);
|
||||||
Ops[1].init(Elt, this);
|
Ops[1].init(Elt, this);
|
||||||
Ops[2].init(Index, this);
|
Ops[2].init(Index, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt,
|
bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt,
|
||||||
@ -1025,24 +1111,26 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
|
|||||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(V1->getType(), ShuffleVector, Ops, 3, Name, InsertBefore) {
|
: Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertBefore) {
|
||||||
assert(isValidOperands(V1, V2, Mask) &&
|
assert(isValidOperands(V1, V2, Mask) &&
|
||||||
"Invalid shuffle vector instruction operands!");
|
"Invalid shuffle vector instruction operands!");
|
||||||
Ops[0].init(V1, this);
|
Ops[0].init(V1, this);
|
||||||
Ops[1].init(V2, this);
|
Ops[1].init(V2, this);
|
||||||
Ops[2].init(Mask, this);
|
Ops[2].init(Mask, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
|
||||||
const std::string &Name,
|
const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(V1->getType(), ShuffleVector, Ops, 3, Name, InsertAtEnd) {
|
: Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertAtEnd) {
|
||||||
assert(isValidOperands(V1, V2, Mask) &&
|
assert(isValidOperands(V1, V2, Mask) &&
|
||||||
"Invalid shuffle vector instruction operands!");
|
"Invalid shuffle vector instruction operands!");
|
||||||
|
|
||||||
Ops[0].init(V1, this);
|
Ops[0].init(V1, this);
|
||||||
Ops[1].init(V2, this);
|
Ops[1].init(V2, this);
|
||||||
Ops[2].init(Mask, this);
|
Ops[2].init(Mask, this);
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
||||||
@ -1062,8 +1150,28 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
|
|||||||
// BinaryOperator Class
|
// BinaryOperator Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void BinaryOperator::init(BinaryOps iType)
|
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||||
{
|
const Type *Ty, const std::string &Name,
|
||||||
|
Instruction *InsertBefore)
|
||||||
|
: Instruction(Ty, iType, Ops, 2, InsertBefore) {
|
||||||
|
Ops[0].init(S1, this);
|
||||||
|
Ops[1].init(S2, this);
|
||||||
|
init(iType);
|
||||||
|
setName(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||||
|
const Type *Ty, const std::string &Name,
|
||||||
|
BasicBlock *InsertAtEnd)
|
||||||
|
: Instruction(Ty, iType, Ops, 2, InsertAtEnd) {
|
||||||
|
Ops[0].init(S1, this);
|
||||||
|
Ops[1].init(S2, this);
|
||||||
|
init(iType);
|
||||||
|
setName(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BinaryOperator::init(BinaryOps iType) {
|
||||||
Value *LHS = getOperand(0), *RHS = getOperand(1);
|
Value *LHS = getOperand(0), *RHS = getOperand(1);
|
||||||
LHS = LHS; RHS = RHS; // Silence warnings.
|
LHS = LHS; RHS = RHS; // Silence warnings.
|
||||||
assert(LHS->getType() == RHS->getType() &&
|
assert(LHS->getType() == RHS->getType() &&
|
||||||
@ -1947,7 +2055,7 @@ BitCastInst::BitCastInst(
|
|||||||
|
|
||||||
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||||
const std::string &Name, Instruction *InsertBefore)
|
const std::string &Name, Instruction *InsertBefore)
|
||||||
: Instruction(Type::Int1Ty, op, Ops, 2, Name, InsertBefore) {
|
: Instruction(Type::Int1Ty, op, Ops, 2, InsertBefore) {
|
||||||
Ops[0].init(LHS, this);
|
Ops[0].init(LHS, this);
|
||||||
Ops[1].init(RHS, this);
|
Ops[1].init(RHS, this);
|
||||||
SubclassData = predicate;
|
SubclassData = predicate;
|
||||||
@ -1974,11 +2082,12 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isFloatingPoint() &&
|
assert(Op0Ty->isFloatingPoint() &&
|
||||||
"Invalid operand types for FCmp instruction");
|
"Invalid operand types for FCmp instruction");
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||||
const std::string &Name, BasicBlock *InsertAtEnd)
|
const std::string &Name, BasicBlock *InsertAtEnd)
|
||||||
: Instruction(Type::Int1Ty, op, Ops, 2, Name, InsertAtEnd) {
|
: Instruction(Type::Int1Ty, op, Ops, 2, InsertAtEnd) {
|
||||||
Ops[0].init(LHS, this);
|
Ops[0].init(LHS, this);
|
||||||
Ops[1].init(RHS, this);
|
Ops[1].init(RHS, this);
|
||||||
SubclassData = predicate;
|
SubclassData = predicate;
|
||||||
@ -2006,6 +2115,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isFloatingPoint() &&
|
assert(Op0Ty->isFloatingPoint() &&
|
||||||
"Invalid operand types for FCmp instruction");
|
"Invalid operand types for FCmp instruction");
|
||||||
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CmpInst *
|
CmpInst *
|
||||||
@ -2197,9 +2307,29 @@ void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumCases) {
|
|||||||
OperandList[1].init(Default, this);
|
OperandList[1].init(Default, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
||||||
|
/// switch on and a default destination. The number of additional cases can
|
||||||
|
/// be specified here to make memory allocation more efficient. This
|
||||||
|
/// constructor can also autoinsert before another instruction.
|
||||||
|
SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
||||||
|
Instruction *InsertBefore)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Switch, 0, 0, InsertBefore) {
|
||||||
|
init(Value, Default, NumCases);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
|
||||||
|
/// switch on and a default destination. The number of additional cases can
|
||||||
|
/// be specified here to make memory allocation more efficient. This
|
||||||
|
/// constructor also autoinserts at the end of the specified BasicBlock.
|
||||||
|
SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
|
||||||
|
BasicBlock *InsertAtEnd)
|
||||||
|
: TerminatorInst(Type::VoidTy, Instruction::Switch, 0, 0, InsertAtEnd) {
|
||||||
|
init(Value, Default, NumCases);
|
||||||
|
}
|
||||||
|
|
||||||
SwitchInst::SwitchInst(const SwitchInst &SI)
|
SwitchInst::SwitchInst(const SwitchInst &SI)
|
||||||
: TerminatorInst(Instruction::Switch, new Use[SI.getNumOperands()],
|
: TerminatorInst(Type::VoidTy, Instruction::Switch,
|
||||||
SI.getNumOperands()) {
|
new Use[SI.getNumOperands()], SI.getNumOperands()) {
|
||||||
Use *OL = OperandList, *InOL = SI.OperandList;
|
Use *OL = OperandList, *InOL = SI.OperandList;
|
||||||
for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) {
|
for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) {
|
||||||
OL[i].init(InOL[i], this);
|
OL[i].init(InOL[i], this);
|
||||||
|
Loading…
Reference in New Issue
Block a user