aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-11-08 04:50:33 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-11-08 04:50:33 +0000
commite8f1e44fd760165bd9ac05c01e08bf5d3b14f979 (patch)
tree626270861c3df1ec50166cf4f52b74739a4cd4c4
parent38f5d46affe2cd8837c69918b6387783cf73bff3 (diff)
downloadexternal_llvm-e8f1e44fd760165bd9ac05c01e08bf5d3b14f979.zip
external_llvm-e8f1e44fd760165bd9ac05c01e08bf5d3b14f979.tar.gz
external_llvm-e8f1e44fd760165bd9ac05c01e08bf5d3b14f979.tar.bz2
Added a second constructor for and improved class TmpInstruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1188 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/InstrSelection.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/include/llvm/CodeGen/InstrSelection.h b/include/llvm/CodeGen/InstrSelection.h
index 341f8b1..1f68e38 100644
--- a/include/llvm/CodeGen/InstrSelection.h
+++ b/include/llvm/CodeGen/InstrSelection.h
@@ -75,27 +75,46 @@ bool SelectInstructionsForMethod (Method* method,
//---------------------------------------------------------------------------
class TmpInstruction : public Instruction {
- TmpInstruction (const TmpInstruction &CI) : Instruction(CI.getType(), CI.getOpcode()) {
+ TmpInstruction (const TmpInstruction &ci)
+ : Instruction(ci.getType(), ci.getOpcode())
+ {
Operands.reserve(2);
Operands.push_back(Use(Operands[0], this));
Operands.push_back(Use(Operands[1], this));
}
public:
- TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
- : Instruction(S1->getType(), Opcode, Name)
+ // Constructor that uses the type of S1 as the type of the temporary.
+ // s1 must be a valid value. s2 may be NULL.
+ TmpInstruction(OtherOps opcode, Value *s1, Value* s2, const string &name="")
+ : Instruction(s1->getType(), opcode, name)
+ {
+ assert(s1 != NULL && "Use different constructor if both operands are 0");
+ Initialize(opcode, s1, s2);
+ }
+
+ // Constructor that allows the type of the temporary to be specified.
+ // Both S1 and S2 may be NULL.
+ TmpInstruction(OtherOps opcode, const Type* tmpType,
+ Value *s1, Value* s2, const string &name = "")
+ : Instruction(tmpType, opcode, name)
{
- assert(Opcode == TMP_INSTRUCTION_OPCODE &&
- "Tmp instruction opcode invalid!");
- Operands.reserve(S2? 2 : 1);
- Operands.push_back(Use(S1, this));
- if (S2)
- Operands.push_back(Use(S2, this));
+ Initialize(opcode, s1, s2);
}
virtual Instruction *clone() const { return new TmpInstruction(*this); }
virtual const char *getOpcodeName() const {
return "userOp1";
}
+
+private:
+ void Initialize(OtherOps opcode, Value *s1, Value* s2) {
+ assert(opcode==TMP_INSTRUCTION_OPCODE && "Tmp instruction opcode invalid");
+ Operands.reserve(s1 && s2? 2 : ((s1 || s2)? 1 : 0));
+ if (s1)
+ Operands.push_back(Use(s1, this));
+ if (s2)
+ Operands.push_back(Use(s2, this));
+ }
};
//**************************************************************************/