summaryrefslogtreecommitdiff
path: root/utils/TableGen/AsmWriterEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-26 23:45:08 +0000
committerChris Lattner <sabre@nondot.org>2006-09-26 23:45:08 +0000
commit1bf6361dfde21fcc0f433c8cf53d5c366225ee3f (patch)
tree5d96b39685e2ee0c0d31c4fa30b6cb5a5a4ec153 /utils/TableGen/AsmWriterEmitter.cpp
parent692d4e0823774730b90e8e2d7bf58119397f0535 (diff)
downloadllvm-1bf6361dfde21fcc0f433c8cf53d5c366225ee3f.tar.gz
llvm-1bf6361dfde21fcc0f433c8cf53d5c366225ee3f.tar.bz2
llvm-1bf6361dfde21fcc0f433c8cf53d5c366225ee3f.tar.xz
Add support for ${:foo} syntax, where "foo" is passed into "printSpecial" and
has no associated operand. This is useful for portably encoding stuff like the comment character into an asm string. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30617 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/AsmWriterEmitter.cpp')
-rw-r--r--utils/TableGen/AsmWriterEmitter.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp
index 2ea74494f2..a67ee531a6 100644
--- a/utils/TableGen/AsmWriterEmitter.cpp
+++ b/utils/TableGen/AsmWriterEmitter.cpp
@@ -98,7 +98,9 @@ std::string AsmWriterOperand::getCode() const {
if (OperandType == isLiteralTextOperand)
return "O << \"" + Str + "\"; ";
- std::string Result = Str + "(MI, " + utostr(MIOpNo);
+ std::string Result = Str + "(MI";
+ if (MIOpNo != ~0U)
+ Result += ", " + utostr(MIOpNo);
if (!MiModifier.empty())
Result += ", \"" + MiModifier + '"';
return Result + "); ";
@@ -172,7 +174,8 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
AsmString.begin()+VarEnd);
// Modifier - Support ${foo:modifier} syntax, where "modifier" is passed
- // into printOperand.
+ // into printOperand. Also support ${:feature}, which is passed into
+ // printSpecial.
std::string Modifier;
// In order to avoid starting the next string at the terminating curly
@@ -204,23 +207,29 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
+ CGI.TheDef->getName() + "'";
++VarEnd;
}
- if (VarName.empty())
+ if (VarName.empty() && Modifier.empty())
throw "Stray '$' in '" + CGI.TheDef->getName() +
"' asm string, maybe you want $$?";
- unsigned OpNo = CGI.getOperandNamed(VarName);
- CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
-
- // If this is a two-address instruction, verify the second operand isn't
- // used.
- unsigned MIOp = OpInfo.MIOperandNo;
- if (CGI.isTwoAddress && MIOp == 1)
- throw "Should refer to operand #0 instead of #1 for two-address"
- " instruction '" + CGI.TheDef->getName() + "'!";
-
- if (CurVariant == Variant || CurVariant == ~0U)
- Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName, MIOp,
- Modifier));
+ if (VarName.empty()) {
+ // Just a modifier, pass this into printSpecial.
+ Operands.push_back(AsmWriterOperand("printSpecial", ~0U, Modifier));
+ } else {
+ // Otherwise, normal operand.
+ unsigned OpNo = CGI.getOperandNamed(VarName);
+ CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
+
+ // If this is a two-address instruction, verify the second operand isn't
+ // used.
+ unsigned MIOp = OpInfo.MIOperandNo;
+ if (CGI.isTwoAddress && MIOp == 1)
+ throw "Should refer to operand #0 instead of #1 for two-address"
+ " instruction '" + CGI.TheDef->getName() + "'!";
+
+ if (CurVariant == Variant || CurVariant == ~0U)
+ Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName, MIOp,
+ Modifier));
+ }
LastEmitted = VarEnd;
}
}