diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-07-30 17:37:43 +0000 | 
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-30 17:37:43 +0000 | 
| commit | 132f78395a9b15aa3aa1a54951060871ca5fefc2 (patch) | |
| tree | be5462895e1e9ca860653b133bbf95dbffab1517 /llvm/utils/TableGen/AsmMatcherEmitter.cpp | |
| parent | 5262314b8d4b6a944a62744d65f20136986eb6ac (diff) | |
| download | bcm5719-llvm-132f78395a9b15aa3aa1a54951060871ca5fefc2.tar.gz bcm5719-llvm-132f78395a9b15aa3aa1a54951060871ca5fefc2.zip  | |
Twines: Don't allow implicit conversion from integers, this is too tricky.
llvm-svn: 77605
Diffstat (limited to 'llvm/utils/TableGen/AsmMatcherEmitter.cpp')
| -rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 51 | 
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index d00ff202ad0..45a1c8622aa 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -17,6 +17,32 @@  #include "Record.h"  using namespace llvm; +static std::string FlattenVariants(const std::string &AsmString, +                                   unsigned Index) { +  StringRef Cur = AsmString; +  std::string Res = ""; +   +  for (;;) { +    std::pair<StringRef, StringRef> Split = Cur.split('{'); + +    Res += Split.first; +    if (Split.second.empty()) +      break; + +    std::pair<StringRef, StringRef> Inner = Cur.split('}'); +    StringRef Selection = Inner.first; +    for (unsigned i = 0; i != Index; ++i) +      Selection = Selection.split('|').second; +    Selection = Selection.split('|').first; + +    Res += Selection; + +    Cur = Inner.second; +  }  + +  return Res; +} +  void AsmMatcherEmitter::run(raw_ostream &OS) {    CodeGenTarget Target;    const std::vector<CodeGenRegister> &Registers = Target.getRegisters(); @@ -44,4 +70,29 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {    }    OS << "  return true;\n";    OS << "}\n"; + +  // Emit the function to match instructions.   +  std::vector<const CodeGenInstruction*> NumberedInstructions; +  Target.getInstructionsByEnumValue(NumberedInstructions); + +  const std::map<std::string, CodeGenInstruction> &Instructions = +    Target.getInstructions(); +  for (std::map<std::string, CodeGenInstruction>::const_iterator  +         it = Instructions.begin(), ie = Instructions.end(); it != ie; ++it) { +    const CodeGenInstruction &CGI = it->second; + +    if (it->first != "SUB8rr") +      continue; + +    /* +def SUB8rr  : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2), +                "sub{b}\t{$src2, $dst|$dst, $src2}", +                [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)), +                 (implicit EFLAGS)]>; +    */ + +    outs() << it->first << " " +           << FlattenVariants(CGI.AsmString, 0) +           << "\n"; +  }  }  | 

