summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-06 19:11:01 +0000
committerChris Lattner <sabre@nondot.org>2010-09-06 19:11:01 +0000
commit0692ee676f8cdad25ad09a868bf597af4115c9d9 (patch)
treeb167a962f508eed9184c75af1fc5d7b347bebadf /utils
parentb26697ca9ea415de8545a81577a374cdc3b3a45b (diff)
downloadllvm-0692ee676f8cdad25ad09a868bf597af4115c9d9.tar.gz
llvm-0692ee676f8cdad25ad09a868bf597af4115c9d9.tar.bz2
llvm-0692ee676f8cdad25ad09a868bf597af4115c9d9.tar.xz
have AsmMatcherEmitter.cpp produce the hunk of code that gets included
into the middle of the class, and rework how the different sections of the generated file are conditionally included for simplicity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/AsmMatcherEmitter.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp
index 799a58a511..515916efde 100644
--- a/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/utils/TableGen/AsmMatcherEmitter.cpp
@@ -1541,13 +1541,32 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
EmitSourceFileHeader("Assembly Matcher Source Fragment", OS);
+ // Information for the class declaration.
+ OS << "\n#ifdef GET_ASSEMBLER_HEADER\n";
+ OS << "#undef GET_ASSEMBLER_HEADER\n";
+ OS << " unsigned ComputeAvailableFeatures(const " <<
+ Target.getName() << "Subtarget *Subtarget) const;\n";
+ OS << "bool MatchInstructionImpl(const SmallVectorImpl<MCParsedAsmOperand*>"
+ << " &Operands, MCInst &Inst);\n\n";
+ OS << "#endif // GET_ASSEMBLER_HEADER_INFO\n\n";
+
+
+
+
+ OS << "\n#ifdef GET_REGISTER_MATCHER\n";
+ OS << "#undef GET_REGISTER_MATCHER\n\n";
+
// Emit the subtarget feature enumeration.
EmitSubtargetFeatureFlagEnumeration(Target, Info, OS);
// Emit the function to match a register name to number.
EmitMatchRegisterName(Target, AsmParser, OS);
+
+ OS << "#endif // GET_REGISTER_MATCHER\n\n";
- OS << "#ifndef REGISTERS_ONLY\n\n";
+
+ OS << "\n#ifdef GET_MATCHER_IMPLEMENTATION\n";
+ OS << "#undef GET_MATCHER_IMPLEMENTATION\n\n";
// Generate the unified function to convert operands into an MCInst.
EmitConvertToMCInst(Target, Info.Instructions, OS);
@@ -1658,16 +1677,17 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
<< "; it != ie; ++it) {\n";
// Emit check that the required features are available.
- OS << " if ((AvailableFeatures & it->RequiredFeatures) "
- << "!= it->RequiredFeatures)\n";
- OS << " continue;\n";
-
+ OS << " if ((AvailableFeatures & it->RequiredFeatures) "
+ << "!= it->RequiredFeatures)\n";
+ OS << " continue;\n";
+
// Emit check that the subclasses match.
for (unsigned i = 0; i != MaxNumOperands; ++i) {
OS << " if (!IsSubclass(Classes["
<< i << "], it->Classes[" << i << "]))\n";
OS << " continue;\n";
}
+
OS << "\n";
OS << " ConvertToMCInst(it->ConvertFn, Inst, it->Opcode, Operands);\n";
@@ -1683,5 +1703,5 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " return true;\n";
OS << "}\n\n";
- OS << "#endif // REGISTERS_ONLY\n";
+ OS << "#endif // GET_MATCHER_IMPLEMENTATION\n\n";
}