diff options
author | Chris Lattner <sabre@nondot.org> | 2004-08-01 05:04:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-08-01 05:04:00 +0000 |
commit | c860ecafe1586342a9e13763991b279895adc399 (patch) | |
tree | 2c0fa3d39bd0cad4d36f4d0d4c73ff0e070bdec8 /llvm/utils/TableGen/CodeGenTarget.cpp | |
parent | fd6893837c4d2659e5f59e66ade0d0142c3aed54 (diff) | |
download | bcm5719-llvm-c860ecafe1586342a9e13763991b279895adc399.tar.gz bcm5719-llvm-c860ecafe1586342a9e13763991b279895adc399.zip |
Add, and start using, the CodeGenInstruction class. This class represents
an instance of the Instruction tablegen class.
llvm-svn: 15385
Diffstat (limited to 'llvm/utils/TableGen/CodeGenTarget.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeGenTarget.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp index eef94db0b99..026119d8d0a 100644 --- a/llvm/utils/TableGen/CodeGenTarget.cpp +++ b/llvm/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"); +} + + |