[llvm] f09e200 - [ms] [llvm-ml] When parsing MASM, "jmp short" instructions are case insensitive

Eric Astor via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 13 15:37:02 PDT 2021


Author: Eric Astor
Date: 2021-06-13T18:36:00-04:00
New Revision: f09e200b31f443d972f6723fb9d78638bb38b45c

URL: https://github.com/llvm/llvm-project/commit/f09e200b31f443d972f6723fb9d78638bb38b45c
DIFF: https://github.com/llvm/llvm-project/commit/f09e200b31f443d972f6723fb9d78638bb38b45c.diff

LOG: [ms] [llvm-ml] When parsing MASM, "jmp short" instructions are case insensitive

Handle "short" in a case-insensitive fashion in MASM.

Required to correctly parse z_Windows_NT-586_asm.asm from the OpenMP runtime.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D104195

Added: 
    llvm/test/tools/llvm-ml/jmp_short.asm

Modified: 
    llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 7f01f81605a5..c25e8b3d2db1 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3105,7 +3105,8 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
        (PatchedName.startswith("j") &&
         ParseConditionCode(PatchedName.substr(1)) != X86::COND_INVALID))) {
     StringRef NextTok = Parser.getTok().getString();
-    if (NextTok == "short") {
+    if (Parser.isParsingMasm() ? NextTok.equals_lower("short")
+                               : NextTok == "short") {
       SMLoc NameEndLoc =
           NameLoc.getFromPointer(NameLoc.getPointer() + Name.size());
       // Eat the short keyword.

diff  --git a/llvm/test/tools/llvm-ml/jmp_short.asm b/llvm/test/tools/llvm-ml/jmp_short.asm
new file mode 100644
index 000000000000..d9bd41a34c56
--- /dev/null
+++ b/llvm/test/tools/llvm-ml/jmp_short.asm
@@ -0,0 +1,21 @@
+; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
+
+.code
+
+t1:
+  jmp short t1_label
+  jmp SHORT t1_label
+  JmP Short t1_label
+  JMP SHORT t1_label
+  mov eax, eax
+t1_label:
+  ret
+
+; CHECK-LABEL: t1:
+; CHECK-NEXT: jmp t1_label
+; CHECK-NEXT: jmp t1_label
+; CHECK-NEXT: jmp t1_label
+; CHECK-NEXT: jmp t1_label
+; CHECK-NEXT: mov eax, eax
+
+end


        


More information about the llvm-commits mailing list