From: Chris Lattner Date: Sun, 3 Oct 2004 19:34:31 +0000 (+0000) Subject: Add initial support for variants. This just parses the new format, no X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=560a79f1ea4d1a04bd1da7fd0ca57cfe80620c5a;p=oota-llvm.git Add initial support for variants. This just parses the new format, no functionality is added git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16636 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index f7225f081d0..4c882ad5557 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -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 +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 @@ Record *CodeGenTarget::getInstructionSet() const { /// 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(LI->getElement(AsmWriterNum)); + if (!DI) throw std::string("AssemblyWriter list should be a list of defs!"); + return DI->getDef(); } void CodeGenTarget::ReadRegisters() const {