Skip to content

Commit d3f70db

Browse files
authored
[X86][MC] Support instructions of MSR_IMM (#113524)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
1 parent 99b2fea commit d3f70db

File tree

8 files changed

+107
-1
lines changed

8 files changed

+107
-1
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Changes to the X86 Backend
221221

222222
* Supported ISA of `SM4(EVEX)`.
223223

224+
* Supported ISA of `MSR_IMM`.
225+
224226
Changes to the OCaml bindings
225227
-----------------------------
226228

llvm/lib/Target/X86/X86InstrSystem.td

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ multiclass Urdwrmsr<Map rrmap, string suffix> {
466466
"urdmsr\t{$imm, $dst|$dst, $imm}",
467467
[(set GR64:$dst, (int_x86_urdmsr i64immSExt32_su:$imm))]>,
468468
T_MAP7, VEX, XD, NoCD8;
469-
}
469+
def RDMSRri#suffix : Ii32<0xf6, MRM0r, (outs GR64:$dst), (ins i64i32imm:$imm),
470+
"rdmsr\t{$imm, $dst|$dst, $imm}", []>,
471+
T_MAP7, VEX, XD, NoCD8;
472+
}
470473
let mayStore = 1 in {
471474
let OpMap = rrmap in
472475
def UWRMSRrr#suffix : I<0xf8, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2),
@@ -476,6 +479,9 @@ multiclass Urdwrmsr<Map rrmap, string suffix> {
476479
"uwrmsr\t{$src, $imm|$imm, $src}",
477480
[(int_x86_uwrmsr i64immSExt32_su:$imm, GR64:$src)]>,
478481
T_MAP7, VEX, XS, NoCD8;
482+
def WRMSRNSir#suffix : Ii32<0xf6, MRM0r, (outs), (ins GR64:$src, i64i32imm:$imm),
483+
"wrmsrns\t{$src, $imm|$imm, $src}",
484+
[]>, T_MAP7, VEX, XS, NoCD8;
479485
}
480486
}
481487

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT
2+
# RUN: llvm-mc --disassemble %s -triple=x86_64 -x86-asm-syntax=intel --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL
3+
4+
# ATT: rdmsr $123, %r9
5+
# INTEL: rdmsr r9, 123
6+
0x62,0xd7,0x7f,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00
7+
8+
# ATT: rdmsr $123, %r19
9+
# INTEL: rdmsr r19, 123
10+
0x62,0xff,0x7f,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00
11+
12+
# ATT: wrmsrns %r9, $123
13+
# INTEL: wrmsrns 123, r9
14+
0x62,0xd7,0x7e,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00
15+
16+
# ATT: wrmsrns %r19, $123
17+
# INTEL: wrmsrns 123, r19
18+
0x62,0xff,0x7e,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT
2+
# RUN: llvm-mc --disassemble %s -triple=x86_64 -x86-asm-syntax=intel --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL
3+
4+
# ATT: rdmsr $123, %r9
5+
# INTEL: rdmsr r9, 123
6+
0xc4,0xc7,0x7b,0xf6,0xc1,0x7b,0x00,0x00,0x00
7+
8+
# ATT: wrmsrns %r9, $123
9+
# INTEL: wrmsrns 123, r9
10+
0xc4,0xc7,0x7a,0xf6,0xc1,0x7b,0x00,0x00,0x00

llvm/test/MC/X86/apx/msrimm-att.s

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s
2+
# RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
3+
4+
# ERROR-COUNT-4: error:
5+
# ERROR-NOT: error:
6+
7+
## rdmsr
8+
9+
// CHECK: {evex} rdmsr $123, %r9
10+
// CHECK: encoding: [0x62,0xd7,0x7f,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00]
11+
{evex} rdmsr $123, %r9
12+
13+
// CHECK: rdmsr $123, %r19
14+
// CHECK: encoding: [0x62,0xff,0x7f,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00]
15+
rdmsr $123, %r19
16+
17+
## wrmsrns
18+
19+
# CHECK: {evex} wrmsrns %r9, $123
20+
# CHECK: encoding: [0x62,0xd7,0x7e,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00]
21+
{evex} wrmsrns %r9, $123
22+
23+
# CHECK: wrmsrns %r19, $123
24+
# CHECK: encoding: [0x62,0xff,0x7e,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00]
25+
wrmsrns %r19, $123

llvm/test/MC/X86/apx/msrimm-intel.s

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# RUN: llvm-mc -triple x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
2+
3+
## urdmsr
4+
5+
# CHECK: {evex} rdmsr r9, 123
6+
# CHECK: encoding: [0x62,0xd7,0x7f,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00]
7+
{evex} rdmsr r9, 123
8+
9+
# CHECK: rdmsr r19, 123
10+
# CHECK: encoding: [0x62,0xff,0x7f,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00]
11+
rdmsr r19, 123
12+
13+
## uwrmsr
14+
15+
# CHECK: {evex} wrmsrns 123, r9
16+
# CHECK: encoding: [0x62,0xd7,0x7e,0x08,0xf6,0xc1,0x7b,0x00,0x00,0x00]
17+
{evex} wrmsrns 123, r9
18+
19+
# CHECK: wrmsrns 123, r19
20+
# CHECK: encoding: [0x62,0xff,0x7e,0x08,0xf6,0xc3,0x7b,0x00,0x00,0x00]
21+
wrmsrns 123, r19

llvm/test/MC/X86/msrimm-64-att.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s
2+
// RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
3+
4+
// ERROR-COUNT-2: error:
5+
// ERROR-NOT: error:
6+
7+
// CHECK: rdmsr $123, %r9
8+
// CHECK: encoding: [0xc4,0xc7,0x7b,0xf6,0xc1,0x7b,0x00,0x00,0x00]
9+
rdmsr $123, %r9
10+
11+
// CHECK: wrmsrns %r9, $123
12+
// CHECK: encoding: [0xc4,0xc7,0x7a,0xf6,0xc1,0x7b,0x00,0x00,0x00]
13+
wrmsrns %r9, $123
14+

llvm/test/MC/X86/msrimm-64-intel.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: llvm-mc -triple x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
2+
3+
// CHECK: rdmsr r9, 123
4+
// CHECK: encoding: [0xc4,0xc7,0x7b,0xf6,0xc1,0x7b,0x00,0x00,0x00]
5+
rdmsr r9, 123
6+
7+
// CHECK: wrmsrns 123, r9
8+
// CHECK: encoding: [0xc4,0xc7,0x7a,0xf6,0xc1,0x7b,0x00,0x00,0x00]
9+
wrmsrns 123, r9
10+

0 commit comments

Comments
 (0)