diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-07-14 22:50:30 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-07-14 22:50:30 +0000 |
commit | afc545616a5a062e6872114f9f1c23070e5e753b (patch) | |
tree | ee12a1451d5b7bd2bdb0c1b0ee7224402367ab3f /utils/TableGen/AsmWriterEmitter.cpp | |
parent | 8bf0f649234fe47e4755bfd816a9877a9e86f3b5 (diff) | |
download | external_llvm-afc545616a5a062e6872114f9f1c23070e5e753b.zip external_llvm-afc545616a5a062e6872114f9f1c23070e5e753b.tar.gz external_llvm-afc545616a5a062e6872114f9f1c23070e5e753b.tar.bz2 |
Add support for a TODO; instructions in .td files can now have arguments
printed as part of the opcode. This allows something like
cmp${cc}ss in the x86 backed to be printed as cmpltss, cmpless, etc.
depending on what the value of $cc is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/AsmWriterEmitter.cpp')
-rw-r--r-- | utils/TableGen/AsmWriterEmitter.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index 41ecc40..34aaf15 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -155,12 +155,35 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) { LastEmitted = DollarPos+2; } else { // Get the name of the variable. - // TODO: should eventually handle ${foo}bar as $foo std::string::size_type VarEnd = DollarPos+1; + + // handle ${foo}bar as $foo by detecting whether the character following + // the dollar sign is a curly brace. If so, advance VarEnd and DollarPos + // so the variable name does not contain the leading curly brace. + bool hasCurlyBraces = false; + if (VarEnd < AsmString.size() && '{' == AsmString[VarEnd]) { + hasCurlyBraces = true; + ++DollarPos; + ++VarEnd; + } + while (VarEnd < AsmString.size() && isIdentChar(AsmString[VarEnd])) ++VarEnd; std::string VarName(AsmString.begin()+DollarPos+1, AsmString.begin()+VarEnd); + + // In order to avoid starting the next string at the terminating curly + // brace, advance the end position past it if we found an opening curly + // brace. + if (hasCurlyBraces) { + if (VarEnd >= AsmString.size()) + throw "Reached end of string before terminating curly brace in '" + + CGI.Name + "'"; + if (AsmString[VarEnd] != '}') + throw "Variant name beginning with '{' did not end with '}' in '" + + CGI.Name + "'"; + ++VarEnd; + } if (VarName.empty()) throw "Stray '$' in '" + CGI.Name + "' asm string, maybe you want $$?"; |