summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenTarget.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-14 22:50:53 +0000
committerChris Lattner <sabre@nondot.org>2004-08-14 22:50:53 +0000
commit6ffa501d9f879dd55101e29bbaa7a9167abc5a07 (patch)
tree264bf7c27b072a186d32beda376939811a0512fc /llvm/utils/TableGen/CodeGenTarget.cpp
parent412602d7d9ff3a50eb1bb7ba9f06d28c7ed97fe8 (diff)
downloadbcm5719-llvm-6ffa501d9f879dd55101e29bbaa7a9167abc5a07.tar.gz
bcm5719-llvm-6ffa501d9f879dd55101e29bbaa7a9167abc5a07.zip
Make the AsmWriter a first-class tblgen object. Allow targets to specify
name of the generated asmwriter class, and the name of the format string. llvm-svn: 15747
Diffstat (limited to 'llvm/utils/TableGen/CodeGenTarget.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index e7ca8570280..9e52cbc39a2 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -97,14 +97,27 @@ Record *CodeGenTarget::getInstructionSet() const {
return TargetRec->getValueAsDef("InstructionSet");
}
+/// getAsmWriter - Return the AssemblyWriter definition for this target.
+///
+Record *CodeGenTarget::getAsmWriter() const {
+ return TargetRec->getValueAsDef("AssemblyWriter");
+}
+
+
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]));
+ std::string InstFormatName =
+ getAsmWriter()->getValueAsString("InstFormatName");
+
+ for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
+ std::string AsmStr = Insts[i]->getValueAsString(InstFormatName);
+ Instructions.insert(std::make_pair(Insts[i]->getName(),
+ CodeGenInstruction(Insts[i], AsmStr)));
+ }
}
/// getPHIInstruction - Return the designated PHI instruction.
@@ -117,10 +130,10 @@ const CodeGenInstruction &CodeGenTarget::getPHIInstruction() const {
return I->second;
}
-CodeGenInstruction::CodeGenInstruction(Record *R) : TheDef(R) {
+CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
+ : TheDef(R), AsmString(AsmStr) {
Name = R->getValueAsString("Name");
Namespace = R->getValueAsString("Namespace");
- AsmString = R->getValueAsString("AsmString");
isReturn = R->getValueAsBit("isReturn");
isBranch = R->getValueAsBit("isBranch");
OpenPOWER on IntegriCloud