[ms] [llvm-ml] When parsing MASM, "jmp short" instructions are case insensitive
authorEric Astor <epastor@google.com>
Sun, 13 Jun 2021 22:35:51 +0000 (18:35 -0400)
committerEric Astor <epastor@google.com>
Sun, 13 Jun 2021 22:36:00 +0000 (18:36 -0400)
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

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/tools/llvm-ml/jmp_short.asm [new file with mode: 0644]

index 7f01f81..c25e8b3 100644 (file)
@@ -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 (file)
index 0000000..d9bd41a
--- /dev/null
@@ -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