aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-29 00:02:19 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-29 00:02:19 +0000
commit0e2771f4c4a6e1ffc664eb23487087f824340255 (patch)
treea0909e6d1508b498f26d13ce72b842b8fed77780 /utils/TableGen
parent55e459aa7508fb7f7de89886060f5fb5526efa44 (diff)
downloadexternal_llvm-0e2771f4c4a6e1ffc664eb23487087f824340255.zip
external_llvm-0e2771f4c4a6e1ffc664eb23487087f824340255.tar.gz
external_llvm-0e2771f4c4a6e1ffc664eb23487087f824340255.tar.bz2
Match X86 register names to number.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77404 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp12
-rw-r--r--utils/TableGen/CodeGenTarget.cpp13
-rw-r--r--utils/TableGen/CodeGenTarget.h4
3 files changed, 21 insertions, 8 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index 1d4ad09..d00ff20 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -20,17 +20,17 @@ using namespace llvm;
void AsmMatcherEmitter::run(raw_ostream &OS) {
CodeGenTarget Target;
const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
+ Record *AsmParser = Target.getAsmParser();
+ std::string ClassName = AsmParser->getValueAsString("AsmParserClassName");
std::string Namespace = Registers[0].TheDef->getValueAsString("Namespace");
EmitSourceFileHeader("Assembly Matcher Source Fragment", OS);
- OS << "namespace llvm {\n\n";
// Emit the function to match a register name to number.
- if (!Namespace.empty())
- OS << "namespace " << Namespace << " {\n";
- OS << "bool MatchRegisterName(const std::string &Name, unsigned &RegNo) {\n";
+ OS << "bool " << Target.getName() << ClassName
+ << "::MatchRegisterName(const StringRef &Name, unsigned &RegNo) {\n";
// FIXME: TableGen should have a fast string matcher generator.
for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
@@ -44,8 +44,4 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
}
OS << " return true;\n";
OS << "}\n";
-
- if (!Namespace.empty())
- OS << "}\n";
- OS << "} // End llvm namespace \n";
}
diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp
index ed703be..0849d4f 100644
--- a/utils/TableGen/CodeGenTarget.cpp
+++ b/utils/TableGen/CodeGenTarget.cpp
@@ -23,6 +23,10 @@
using namespace llvm;
static cl::opt<unsigned>
+AsmParserNum("asmparsernum", cl::init(0),
+ cl::desc("Make -gen-asm-parser emit assembly parser #N"));
+
+static cl::opt<unsigned>
AsmWriterNum("asmwriternum", cl::init(0),
cl::desc("Make -gen-asm-writer emit assembly writer #N"));
@@ -133,6 +137,15 @@ Record *CodeGenTarget::getInstructionSet() const {
return TargetRec->getValueAsDef("InstructionSet");
}
+/// getAsmParser - Return the AssemblyParser definition for this target.
+///
+Record *CodeGenTarget::getAsmParser() const {
+ std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyParsers");
+ if (AsmParserNum >= LI.size())
+ throw "Target does not have an AsmParser #" + utostr(AsmParserNum) + "!";
+ return LI[AsmParserNum];
+}
+
/// getAsmWriter - Return the AssemblyWriter definition for this target.
///
Record *CodeGenTarget::getAsmWriter() const {
diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h
index 0ec9955..e763795 100644
--- a/utils/TableGen/CodeGenTarget.h
+++ b/utils/TableGen/CodeGenTarget.h
@@ -87,6 +87,10 @@ public:
///
Record *getInstructionSet() const;
+ /// getAsmParser - Return the AssemblyParser definition for this target.
+ ///
+ Record *getAsmParser() const;
+
/// getAsmWriter - Return the AssemblyWriter definition for this target.
///
Record *getAsmWriter() const;