llvm.org GIT mirror llvm / be4bc89
[X86] Fix for bugzilla 31576 - add support for "data32" instruction prefix This patch fixes bugzilla 31576 (https://llvm.org/bugs/show_bug.cgi?id=31576). "data32" instruction prefix was not defined in the llvm. An exception had to be added to the X86 tablegen and AsmPrinter because both "data16" and "data32" are encoded to 0x66 (but in different modes). Differential Revision: https://reviews.llvm.org/D28468 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292352 91177308-0d34-0410-b5e6-96231b3b80d8 Marina Yatsina 3 years ago
11 changed file(s) with 100 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
23592359 Name == "lock" || Name == "rep" ||
23602360 Name == "repe" || Name == "repz" ||
23612361 Name == "repne" || Name == "repnz" ||
2362 Name == "rex64" || Name == "data16";
2362 Name == "rex64" || Name == "data16" || Name == "data32";
23632363
23642364 bool CurlyAsEndOfStatement = false;
23652365 // This does the actual operand parsing. Don't parse any more if we have a
5959 (STI.getFeatureBits()[X86::Mode64Bit])) {
6060 OS << "\tcallq\t";
6161 printPCRelImm(MI, 0, OS);
62 }
63 // data16 and data32 both have the same encoding of 0x66. While data32 is
64 // valid only in 16 bit systems, data16 is valid in the rest.
65 // There seems to be some lack of support of the Requires clause that causes
66 // 0x66 to be interpreted as "data16" by the asm printer.
67 // Thus we add an adjustment here in order to print the "right" instruction.
68 else if (MI->getOpcode() == X86::DATA16_PREFIX &&
69 (STI.getFeatureBits()[X86::Mode16Bit])) {
70 MCInst Data32MI(*MI);
71 Data32MI.setOpcode(X86::DATA32_PREFIX);
72 printInstruction(&Data32MI, OS);
6273 }
6374 // Try to print any aliases first.
6475 else if (!printAliasInstr(MI, OS))
19661966 Requires<[In64BitMode]>;
19671967
19681968 // Data16 instruction prefix
1969 def DATA16_PREFIX : I<0x66, RawFrm, (outs), (ins), "data16", []>;
1969 def DATA16_PREFIX : I<0x66, RawFrm, (outs), (ins), "data16", []>,
1970 Requires<[Not16BitMode]>;
1971
1972 // Data instruction prefix
1973 def DATA32_PREFIX : I<0x66, RawFrm, (outs), (ins), "data32", []>,
1974 Requires<[In16BitMode]>;
19701975
19711976 // Repeat string operation instruction prefixes
19721977 // These uses the DF flag in the EFLAGS register to inc or dec ECX
0 // RUN: not llvm-mc -triple x86_64-unknown-unknown --show-encoding %s 2> %t.err | FileCheck --check-prefix=64 %s
1 // RUN: FileCheck --check-prefix=ERR64 < %t.err %s
2 // RUN: not llvm-mc -triple i386-unknown-unknown --show-encoding %s 2> %t.err | FileCheck --check-prefix=32 %s
3 // RUN: FileCheck --check-prefix=ERR32 < %t.err %s
4 // RUN: not llvm-mc -triple i386-unknown-unknown-code16 --show-encoding %s 2> %t.err | FileCheck --check-prefix=16 %s
5 // RUN: FileCheck --check-prefix=ERR16 < %t.err %s
6
7 // ERR64: error: instruction requires: 16-bit mode
8 // ERR32: error: instruction requires: 16-bit mode
9 // 16: data32
10 // 16: encoding: [0x66]
11 // 16: lgdtw 0
12 // 16: encoding: [0x0f,0x01,0x16,0x00,0x00]
13 data32 lgdt 0
14
15 // 64: data16
16 // 64: encoding: [0x66]
17 // 64: lgdtq 0
18 // 64: encoding: [0x0f,0x01,0x14,0x25,0x00,0x00,0x00,0x00]
19 // 32: data16
20 // 32: encoding: [0x66]
21 // 32: lgdtl 0
22 // 32: encoding: [0x0f,0x01,0x15,0x00,0x00,0x00,0x00]
23 // ERR16: error: instruction requires: Not 16-bit mode
24 data16 lgdt 0
0 # RUN: llvm-mc -triple i386-unknown-unknown-code16 -filetype=obj %s -o - | llvm-objdump -triple i386-unknown-unknown-code16 -d - | FileCheck %s
1
2 # CHECK: 66 0f 01 16 00 00
3 # CHECK: lgdtl 0
4 data32 lgdt 0
5
6 # CHECK: 66
7 # CHECK: data32
8 data32
0 # RUN: llvm-mc -triple=i386-unknown-unknown -filetype=obj %s -o - | llvm-objdump -triple=i386-unknown-unknown -d - | FileCheck %s
1
2 # CHECK: 66 0f 01 15 00 00 00 00
3 # CHECK: lgdtw 0
4 data16 lgdt 0
5
6 # CHECK: 66
7 # CHECK: data16
8 data16
0 # RUN: llvm-mc -triple=x86_64-unknown-unknown -filetype=obj %s -o - | llvm-objdump -triple=x86_64-unknown-unknown -d - | FileCheck %s
1
2 # CHECK: 66 0f 01 14 25 00 00 00 00
3 # CHECK: lgdtq 0
4 data16 lgdt 0
5
6 # CHECK: 66
7 # CHECK: data16
8 data16
958958 // CHECK: lretl
959959 // CHECK: encoding: [0x66,0xcb]
960960 lretl
961
962 // CHECK: data32
963 // CHECK: encoding: [0x66]
964 data32
965
966 // CHECK: data32
967 // CHECK: encoding: [0x66]
968 // CHECK: lgdtw 4(%eax)
969 // CHECK: encoding: [0x67,0x0f,0x01,0x50,0x04]
970 data32 lgdt 4(%eax)
10781078 // CHECK: lretw
10791079 // CHECK: encoding: [0x66,0xcb]
10801080 lretw
1081
1082 // CHECK: data16
1083 // CHECK: encoding: [0x66]
1084 data16
1085
1086 // CHECK: data16
1087 // CHECK: encoding: [0x66]
1088 // CHECK: lgdtl 4(%eax)
1089 // CHECK: encoding: [0x0f,0x01,0x50,0x04]
1090 data16 lgdt 4(%eax)
11181118 rex64 // CHECK: rex64 # encoding: [0x48]
11191119 data16 // CHECK: data16 # encoding: [0x66]
11201120
1121 // CHECK: data16
1122 // CHECK: encoding: [0x66]
1123 // CHECK: lgdtq 4(%rax)
1124 // CHECK: encoding: [0x0f,0x01,0x50,0x04]
1125 data16 lgdt 4(%rax)
1126
11211127 // PR8855
11221128 movq 18446744073709551615,%rbx // CHECK: movq -1, %rbx
11231129
878878 newInfo.name == "XCHG64ar"))
879879 continue; // special case for XCHG*ar and NOOP
880880
881 if (previousInfo.name == "DATA16_PREFIX" &&
882 newInfo.name == "DATA32_PREFIX")
883 continue; // special case for data16 and data32
884
881885 if (outranks(previousInfo.insnContext, newInfo.insnContext))
882886 continue;
883887