[llvm-commits] CVS: llvm/utils/TableGen/CodeGenTarget.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 3 12:34:44 PDT 2004



Changes in directory llvm/utils/TableGen:

CodeGenTarget.cpp updated: 1.23 -> 1.24
---
Log message:

Add initial support for variants.  This just parses the new format, no
functionality is added



---
Diffs of the changes:  (+12 -1)

Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.23 llvm/utils/TableGen/CodeGenTarget.cpp:1.24
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.23	Tue Sep 28 16:01:45 2004
+++ llvm/utils/TableGen/CodeGenTarget.cpp	Sun Oct  3 14:34:31 2004
@@ -16,8 +16,14 @@
 
 #include "CodeGenTarget.h"
 #include "Record.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
+static cl::opt<unsigned>
+AsmWriterNum("asmwriternum", cl::init(0),
+             cl::desc("Make -gen-asm-writer emit assembly writer #N"));
+
 /// getValueType - Return the MCV::ValueType that the specified TableGen record
 /// corresponds to.
 MVT::ValueType llvm::getValueType(Record *Rec) {
@@ -100,7 +106,12 @@
 /// getAsmWriter - Return the AssemblyWriter definition for this target.
 ///
 Record *CodeGenTarget::getAsmWriter() const {
-  return TargetRec->getValueAsDef("AssemblyWriter");
+  ListInit *LI = TargetRec->getValueAsListInit("AssemblyWriters");
+  if (AsmWriterNum >= LI->getSize())
+    throw "Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!";
+  DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(AsmWriterNum));
+  if (!DI) throw std::string("AssemblyWriter list should be a list of defs!");
+  return DI->getDef();
 }
 
 void CodeGenTarget::ReadRegisters() const {






More information about the llvm-commits mailing list