[PATCH] D88137: [X86] Parse data32 call in .code16 as CALLpcrel32
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 00:11:41 PDT 2020
MaskRay created this revision.
MaskRay added reviewers: craig.topper, RKSimon.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
MaskRay requested review of this revision.
Used by kexec-tools (PR46942)
In GNU as, tc-i386.c:output_jump uses 4-byte immediate if a data32 prefix is present.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88137
Files:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/MC/X86/data-prefix-fail.s
llvm/test/MC/X86/x86-16.s
Index: llvm/test/MC/X86/x86-16.s
===================================================================
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -546,8 +546,12 @@
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
Index: llvm/test/MC/X86/data-prefix-fail.s
===================================================================
--- llvm/test/MC/X86/data-prefix-fail.s
+++ llvm/test/MC/X86/data-prefix-fail.s
@@ -23,3 +23,6 @@
// 32: encoding: [0x0f,0x01,0x15,0x00,0x00,0x00,0x00]
// ERR16: error: redundant data16 prefix
data16 lgdt 0
+
+// ERR16: {{.*}}.s:[[#@LINE+1]]:1: error: redundant data16 prefix
+data16 call 0
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3012,6 +3012,17 @@
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88137.293662.patch
Type: text/x-patch
Size: 1581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200923/bb02df35/attachment.bin>
More information about the llvm-commits
mailing list