[llvm] 3d38a97 - [X86] Parse data32 call in .code16 as CALLpcrel32
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 18:37:49 PDT 2020
Author: Fangrui Song
Date: 2020-09-23T18:37:41-07:00
New Revision: 3d38a975d72c8711a123d1862e517bcbdab7d700
URL: https://github.com/llvm/llvm-project/commit/3d38a975d72c8711a123d1862e517bcbdab7d700
DIFF: https://github.com/llvm/llvm-project/commit/3d38a975d72c8711a123d1862e517bcbdab7d700.diff
LOG: [X86] Parse data32 call in .code16 as CALLpcrel32
Used by kexec-tools (PR46942)
In GNU as, tc-i386.c:output_jump uses 4-byte immediate if a data32 prefix is present.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D88137
Added:
Modified:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/MC/X86/data-prefix-fail.s
llvm/test/MC/X86/x86-16.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 3270932a76d0..2b48d4bd8abe 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3012,6 +3012,17 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
return Error(NameLoc, "'data32' is not supported in 64-bit mode");
// Hack to 'data16' for the table lookup.
PatchedName = "data16";
+
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ StringRef Next = Parser.getTok().getString();
+ // Parse data32 call as calll.
+ if (Next == "call" || Next == "callw") {
+ getLexer().Lex();
+ Name = "calll";
+ PatchedName = Name;
+ isPrefix = false;
+ }
+ }
}
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
diff --git a/llvm/test/MC/X86/data-prefix-fail.s b/llvm/test/MC/X86/data-prefix-fail.s
index 1d2b528a4518..638e972ad478 100644
--- a/llvm/test/MC/X86/data-prefix-fail.s
+++ b/llvm/test/MC/X86/data-prefix-fail.s
@@ -23,3 +23,10 @@ data32 lgdt 0
// 32: encoding: [0x0f,0x01,0x15,0x00,0x00,0x00,0x00]
// ERR16: error: redundant data16 prefix
data16 lgdt 0
+
+// 64: data16 # encoding: [0x66]
+// 64-NEXT: callq 0 # encoding: [0xe8,A,A,A,A]
+// 32: data16 # encoding: [0x66]
+// 32-NEXT: calll 0 # encoding: [0xe8,A,A,A,A]
+// ERR16: {{.*}}.s:[[#@LINE+1]]:1: error: redundant data16 prefix
+data16 call 0
diff --git a/llvm/test/MC/X86/x86-16.s b/llvm/test/MC/X86/x86-16.s
index f1b4428703f1..277d8a010358 100644
--- a/llvm/test/MC/X86/x86-16.s
+++ b/llvm/test/MC/X86/x86-16.s
@@ -546,8 +546,12 @@ lcall $0x7ace,$0x7ace
jmp $0x7ace,$0x7ace
ljmp $0x7ace,$0x7ace
+// CHECK: calll a
+// CHECK: calll a
// CHECK: calll a
calll a
+data32 call a
+data32 callw a
// CHECK: incb %al # encoding: [0xfe,0xc0]
incb %al
More information about the llvm-commits
mailing list