[PATCH] D131524: [ms] [llvm-ml] Handle OPTION PROLOGUE/EPILOGUE:NONE
Eric Astor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 08:52:59 PDT 2022
epastor updated this revision to Diff 451508.
epastor added a comment.
Fix remaining nit
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131524/new/
https://reviews.llvm.org/D131524
Files:
llvm/lib/MC/MCParser/COFFMasmParser.cpp
llvm/test/tools/llvm-ml/option_prologue_epilogue_none.asm
Index: llvm/test/tools/llvm-ml/option_prologue_epilogue_none.asm
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/option_prologue_epilogue_none.asm
@@ -0,0 +1,17 @@
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
+
+OPTION pRoLoGuE:nOnE, EPILogue:None
+
+.code
+
+t1 PROC
+ ret
+t1 ENDP
+
+; CHECK-LABEL: t1:
+; CHECK-NOT: pop
+; CHECK-NOT: push
+; CHECK: {{^ *}}ret{{ *$}}
+
+end
+
Index: llvm/lib/MC/MCParser/COFFMasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -45,6 +45,7 @@
bool ParseDirectiveSegment(StringRef, SMLoc);
bool ParseDirectiveSegmentEnd(StringRef, SMLoc);
bool ParseDirectiveIncludelib(StringRef, SMLoc);
+ bool ParseDirectiveOption(StringRef, SMLoc);
bool ParseDirectiveAlias(StringRef, SMLoc);
@@ -118,7 +119,7 @@
// .fpo
addDirectiveHandler<&COFFMasmParser::ParseDirectiveIncludelib>(
"includelib");
- // option
+ addDirectiveHandler<&COFFMasmParser::ParseDirectiveOption>("option");
// popcontext
// pushcontext
// .safeseh
@@ -303,6 +304,43 @@
return false;
}
+/// ParseDirectiveOption
+/// ::= "option" option-list
+bool COFFMasmParser::ParseDirectiveOption(StringRef Directive, SMLoc Loc) {
+ auto parseOption = [&]() -> bool {
+ StringRef Option;
+ if (getParser().parseIdentifier(Option))
+ return TokError("expected identifier for option name");
+ if (Option.equals_insensitive("prologue")) {
+ StringRef MacroId;
+ if (parseToken(AsmToken::Colon) || getParser().parseIdentifier(MacroId))
+ return TokError("expected :macroId after OPTION PROLOGUE");
+ if (MacroId.equals_insensitive("none")) {
+ // Since we currently don't implement prologues/epilogues, NONE is our
+ // default.
+ return false;
+ }
+ return TokError("OPTION PROLOGUE is currently unsupported");
+ }
+ if (Option.equals_insensitive("epilogue")) {
+ StringRef MacroId;
+ if (parseToken(AsmToken::Colon) || getParser().parseIdentifier(MacroId))
+ return TokError("expected :macroId after OPTION EPILOGUE");
+ if (MacroId.equals_insensitive("none")) {
+ // Since we currently don't implement prologues/epilogues, NONE is our
+ // default.
+ return false;
+ }
+ return TokError("OPTION EPILOGUE is currently unsupported");
+ }
+ return TokError("OPTION '" + Option + "' is currently unsupported");
+ };
+
+ if (parseMany(parseOption))
+ return addErrorSuffix(" in OPTION directive");
+ return false;
+}
+
/// ParseDirectiveProc
/// TODO(epastor): Implement parameters and other attributes.
/// ::= label "proc" [[distance]]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131524.451508.patch
Type: text/x-patch
Size: 2815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220810/09ef9c9a/attachment.bin>
More information about the llvm-commits
mailing list