Skip to content

Commit 3c2a56a

Browse files
committed
[X86] Teach assembler parser to accept lsl and lar with a 64 or 32 source register when the destination is a 64 register.
Previously we only accepted a 32-bit source with a 64-bit dest. Accepting 64-bit as well is more consistent with gas behavior. I think maybe we should accept 16 bit register as well, but I'm not sure.
1 parent fa5e448 commit 3c2a56a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

llvm/lib/Target/X86/X86InstrSystem.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
223223
let mayLoad = 1 in
224224
def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
225225
"lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
226-
def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
226+
def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32orGR64:$src),
227227
"lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
228228

229229
// i16mem operand in LSL32rm and GR32 operand in LSL32rr is not a typo.
@@ -245,7 +245,7 @@ def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
245245
let mayLoad = 1 in
246246
def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
247247
"lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
248-
def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
248+
def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32orGR64:$src),
249249
"lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
250250

251251
def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;

llvm/test/MC/X86/I286-64.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ larl %r13d, %r13d
3232
// CHECK: encoding: [0x44,0x0f,0x02,0x2a]
3333
larl (%rdx), %r13d
3434

35+
// CHECK: larq %eax, %rax
36+
// CHECK: encoding: [0x48,0x0f,0x02,0xc0]
37+
lar %rax, %rax
38+
3539
// CHECK: lgdtq 485498096
3640
// CHECK: encoding: [0x0f,0x01,0x14,0x25,0xf0,0x1c,0xf0,0x1c]
3741
lgdtq 485498096
@@ -164,6 +168,10 @@ lsll %r13d, %r13d
164168
// CHECK: encoding: [0x44,0x0f,0x03,0x2a]
165169
lsll (%rdx), %r13d
166170

171+
// CHECK: lslq %eax, %rax
172+
// CHECK: encoding: [0x48,0x0f,0x03,0xc0]
173+
lsl %rax, %rax
174+
167175
// CHECK: ltrw 485498096
168176
// CHECK: encoding: [0x0f,0x00,0x1c,0x25,0xf0,0x1c,0xf0,0x1c]
169177
ltrw 485498096

0 commit comments

Comments
 (0)