aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/CodeGenTarget.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-01 05:04:00 +0000
committerChris Lattner <sabre@nondot.org>2004-08-01 05:04:00 +0000
commitec3524064c57fbc2c5976ca301bbaadc94006d07 (patch)
tree3573ecb2d47dc12b96dfd076e79b71eeb848ea0c /utils/TableGen/CodeGenTarget.cpp
parentc139203f049e1a10e19f3ec4f6785e21323dec6e (diff)
Add, and start using, the CodeGenInstruction class. This class represents
an instance of the Instruction tablegen class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenTarget.cpp')
-rw-r--r--utils/TableGen/CodeGenTarget.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp
index eef94db0b9..026119d8d0 100644
--- a/utils/TableGen/CodeGenTarget.cpp
+++ b/utils/TableGen/CodeGenTarget.cpp
@@ -97,3 +97,39 @@ Record *CodeGenTarget::getInstructionSet() const {
return TargetRec->getValueAsDef("InstructionSet");
}
+void CodeGenTarget::ReadInstructions() const {
+ std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
+
+ if (Insts.size() == 0)
+ throw std::string("No 'Instruction' subclasses defined!");
+
+ for (unsigned i = 0, e = Insts.size(); i != e; ++i)
+ Instructions.insert(std::make_pair(Insts[i]->getName(), Insts[i]));
+}
+
+/// getPHIInstruction - Return the designated PHI instruction.
+const CodeGenInstruction &CodeGenTarget::getPHIInstruction() const {
+ Record *PHI = getInstructionSet()->getValueAsDef("PHIInst");
+ std::map<std::string, CodeGenInstruction>::const_iterator I =
+ getInstructions().find(PHI->getName());
+ if (I == Instructions.end())
+ throw "Could not find PHI instruction named '" + PHI->getName() + "'!";
+ return I->second;
+}
+
+CodeGenInstruction::CodeGenInstruction(Record *R) : TheDef(R) {
+ Name = R->getValueAsString("Name");
+ Namespace = R->getValueAsString("Namespace");
+ AsmString = R->getValueAsString("AsmString");
+
+ //TODO: Parse OperandList
+
+ isReturn = R->getValueAsBit("isReturn");
+ isBranch = R->getValueAsBit("isBranch");
+ isBarrier = R->getValueAsBit("isBarrier");
+ isCall = R->getValueAsBit("isCall");
+ isTwoAddress = R->getValueAsBit("isTwoAddress");
+ isTerminator = R->getValueAsBit("isTerminator");
+}
+
+