1 //===-- X86InstrMPX.td - MPX Instruction Set ---------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the X86 MPX instruction set, defining the
10 // instructions, and properties of the instructions which are needed for code
11 // generation, machine code emission, and analysis.
13 //===----------------------------------------------------------------------===//
15 // FIXME: Investigate a better scheduler class once MPX is used inside LLVM.
16 let SchedRW = [WriteSystem] in {
18 multiclass mpx_bound_make<bits<8> opc, string OpcodeStr> {
19 def 32rm: I<opc, MRMSrcMem, (outs BNDR:$dst), (ins anymem:$src),
20 OpcodeStr#"\t{$src, $dst|$dst, $src}", []>,
21 Requires<[HasMPX, Not64BitMode]>;
22 def 64rm: I<opc, MRMSrcMem, (outs BNDR:$dst), (ins anymem:$src),
23 OpcodeStr#"\t{$src, $dst|$dst, $src}", []>,
24 Requires<[HasMPX, In64BitMode]>;
27 defm BNDMK : mpx_bound_make<0x1B, "bndmk">, XS;
29 multiclass mpx_bound_check<bits<8> opc, string OpcodeStr> {
30 def 32rm: I<opc, MRMSrcMem, (outs), (ins BNDR:$src1, anymem:$src2),
31 OpcodeStr#"\t{$src2, $src1|$src1, $src2}", []>,
32 Requires<[HasMPX, Not64BitMode]>;
33 def 64rm: I<opc, MRMSrcMem, (outs), (ins BNDR:$src1, anymem:$src2),
34 OpcodeStr#"\t{$src2, $src1|$src1, $src2}", []>,
35 Requires<[HasMPX, In64BitMode]>;
37 def 32rr: I<opc, MRMSrcReg, (outs), (ins BNDR:$src1, GR32:$src2),
38 OpcodeStr#"\t{$src2, $src1|$src1, $src2}", []>,
39 Requires<[HasMPX, Not64BitMode]>;
40 def 64rr: I<opc, MRMSrcReg, (outs), (ins BNDR:$src1, GR64:$src2),
41 OpcodeStr#"\t{$src2, $src1|$src1, $src2}", []>,
42 Requires<[HasMPX, In64BitMode]>;
44 defm BNDCL : mpx_bound_check<0x1A, "bndcl">, XS, NotMemoryFoldable;
45 defm BNDCU : mpx_bound_check<0x1A, "bndcu">, XD, NotMemoryFoldable;
46 defm BNDCN : mpx_bound_check<0x1B, "bndcn">, XD, NotMemoryFoldable;
48 def BNDMOVrr : I<0x1A, MRMSrcReg, (outs BNDR:$dst), (ins BNDR:$src),
49 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
50 Requires<[HasMPX]>, NotMemoryFoldable;
52 def BNDMOV32rm : I<0x1A, MRMSrcMem, (outs BNDR:$dst), (ins i64mem:$src),
53 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
54 Requires<[HasMPX, Not64BitMode]>, NotMemoryFoldable;
55 def BNDMOV64rm : I<0x1A, MRMSrcMem, (outs BNDR:$dst), (ins i128mem:$src),
56 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
57 Requires<[HasMPX, In64BitMode]>, NotMemoryFoldable;
59 let isCodeGenOnly = 1, ForceDisassemble = 1 in
60 def BNDMOVrr_REV : I<0x1B, MRMDestReg, (outs BNDR:$dst), (ins BNDR:$src),
61 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
62 Requires<[HasMPX]>, NotMemoryFoldable;
64 def BNDMOV32mr : I<0x1B, MRMDestMem, (outs), (ins i64mem:$dst, BNDR:$src),
65 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
66 Requires<[HasMPX, Not64BitMode]>, NotMemoryFoldable;
67 def BNDMOV64mr : I<0x1B, MRMDestMem, (outs), (ins i128mem:$dst, BNDR:$src),
68 "bndmov\t{$src, $dst|$dst, $src}", []>, PD,
69 Requires<[HasMPX, In64BitMode]>, NotMemoryFoldable;
71 def BNDSTXmr: I<0x1B, MRMDestMem, (outs), (ins anymem:$dst, BNDR:$src),
72 "bndstx\t{$src, $dst|$dst, $src}", []>, PS,
76 def BNDLDXrm: I<0x1A, MRMSrcMem, (outs BNDR:$dst), (ins anymem:$src),
77 "bndldx\t{$src, $dst|$dst, $src}", []>, PS,