[PATCH] D38448: [AsmParser] Support GAS's .print directive
coby via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 07:38:17 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314674: [AsmParser] Support GAS's .print directive (authored by coby).
Changed prior to commit:
https://reviews.llvm.org/D38448?vs=117293&id=117348#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38448
Files:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/directive_print.s
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -538,6 +538,7 @@
DK_ERR,
DK_ERROR,
DK_WARNING,
+ DK_PRINT,
DK_END
};
@@ -682,6 +683,9 @@
// ".warning"
bool parseDirectiveWarning(SMLoc DirectiveLoc);
+ // .print <double-quotes-string>
+ bool parseDirectivePrint(SMLoc DirectiveLoc);
+
void initializeDirectiveKindMap();
};
@@ -2130,6 +2134,8 @@
case DK_DS_P:
case DK_DS_X:
return parseDirectiveDS(IDVal, 12);
+ case DK_PRINT:
+ return parseDirectivePrint(IDLoc);
}
return Error(IDLoc, "unknown directive");
@@ -5228,6 +5234,7 @@
DirectiveKindMap[".ds.s"] = DK_DS_S;
DirectiveKindMap[".ds.w"] = DK_DS_W;
DirectiveKindMap[".ds.x"] = DK_DS_X;
+ DirectiveKindMap[".print"] = DK_PRINT;
}
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
@@ -5456,6 +5463,17 @@
return false;
}
+bool AsmParser::parseDirectivePrint(SMLoc DirectiveLoc) {
+ const AsmToken StrTok = getTok();
+ Lex();
+ if (StrTok.isNot(AsmToken::String) || StrTok.getString().front() != '"')
+ return Error(DirectiveLoc, "expected double quoted string after .print");
+ if (parseToken(AsmToken::EndOfStatement, "expected end of statement"))
+ return true;
+ llvm::outs() << StrTok.getStringContents() << '\n';
+ return false;
+}
+
// We are comparing pointers, but the pointers are relative to a single string.
// Thus, this should always be deterministic.
static int rewritesSort(const AsmRewrite *AsmRewriteA,
Index: llvm/trunk/test/MC/AsmParser/directive_print.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/directive_print.s
+++ llvm/trunk/test/MC/AsmParser/directive_print.s
@@ -0,0 +1,18 @@
+# RUN: not llvm-mc -triple i386-linux-gnu %s 2> %t.err | FileCheck %s
+# RUN: FileCheck < %t.err %s --check-prefix=CHECK-ERR
+
+T1:
+# CHECK: e
+# CHECK: 2.718281828459045235
+.print "e"
+.print "2.718281828459045235"
+
+T2:
+# CHECK-ERR: expected double quoted string after .print
+.altmacro
+.print <pi>
+.noaltmacro
+
+T3:
+# CHECK-ERR: expected end of statement
+.print "a" "misplaced-string"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38448.117348.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171002/e19ba80f/attachment-0001.bin>
More information about the llvm-commits
mailing list