1 //===-- PPCInstrHTM.td - The PowerPC Hardware Transactional Memory -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Hardware Transactional Memory extension to the
11 // PowerPC instruction set.
13 //===----------------------------------------------------------------------===//
17 def HasHTM : Predicate<"PPCSubTarget->hasHTM()">;
19 def HTM_get_imm : SDNodeXForm<imm, [{
20 return getI32Imm (N->getZExtValue(), SDLoc(N));
23 let hasSideEffects = 1, usesCustomInserter = 1 in {
24 def TCHECK_RET : Pseudo<(outs crrc:$out), (ins), "#TCHECK_RET", []>;
28 let Predicates = [HasHTM] in {
30 def TBEGIN : XForm_htm0 <31, 654,
31 (outs crrc0:$ret), (ins u1imm:$R), "tbegin. $R", IIC_SprMTSPR, []>;
33 def TEND : XForm_htm1 <31, 686,
34 (outs crrc0:$ret), (ins u1imm:$A), "tend. $A", IIC_SprMTSPR, []>;
36 def TABORT : XForm_base_r3xo <31, 910,
37 (outs crrc0:$ret), (ins gprc:$A), "tabort. $A", IIC_SprMTSPR,
43 def TABORTWC : XForm_base_r3xo <31, 782,
44 (outs crrc0:$ret), (ins u5imm:$RTS, gprc:$A, gprc:$B),
45 "tabortwc. $RTS, $A, $B", IIC_SprMTSPR, []>,
48 def TABORTWCI : XForm_base_r3xo <31, 846,
49 (outs crrc0:$ret), (ins u5imm:$RTS, gprc:$A, u5imm:$B),
50 "tabortwci. $RTS, $A, $B", IIC_SprMTSPR, []>,
53 def TABORTDC : XForm_base_r3xo <31, 814,
54 (outs crrc0:$ret), (ins u5imm:$RTS, gprc:$A, gprc:$B),
55 "tabortdc. $RTS, $A, $B", IIC_SprMTSPR, []>,
58 def TABORTDCI : XForm_base_r3xo <31, 878,
59 (outs crrc0:$ret), (ins u5imm:$RTS, gprc:$A, u5imm:$B),
60 "tabortdci. $RTS, $A, $B", IIC_SprMTSPR, []>,
63 def TSR : XForm_htm2 <31, 750,
64 (outs crrc0:$ret), (ins u1imm:$L), "tsr. $L", IIC_SprMTSPR, []>,
67 def TCHECK : XForm_htm3 <31, 718,
68 (outs), (ins crrc:$BF), "tcheck $BF", IIC_SprMTSPR, []>;
71 def TRECLAIM : XForm_base_r3xo <31, 942,
72 (outs crrc:$ret), (ins gprc:$A), "treclaim. $A",
79 def TRECHKPT : XForm_base_r3xo <31, 1006,
80 (outs crrc:$ret), (ins), "trechkpt.", IIC_SprMTSPR, []>,
89 // All HTM instructions, with the exception of tcheck, set CR0 with the
90 // value of the MSR Transaction State (TS) bits that exist before the
91 // instruction is executed. For tbegin., the EQ bit in CR0 can be used
92 // to determine whether the transaction was successfully started (0) or
93 // failed (1). We use an XORI pattern to 'flip' the bit to match the
94 // tbegin builtin API which defines a return value of 1 as success.
96 def : Pat<(int_ppc_tbegin i32:$R),
99 TBEGIN (HTM_get_imm imm:$R)), sub_eq),
102 def : Pat<(int_ppc_tend i32:$R),
103 (TEND (HTM_get_imm imm:$R))>;
106 def : Pat<(int_ppc_tabort i32:$R),
109 def : Pat<(int_ppc_tabortwc i32:$TO, i32:$RA, i32:$RB),
110 (TABORTWC (HTM_get_imm imm:$TO), $RA, $RB)>;
112 def : Pat<(int_ppc_tabortwci i32:$TO, i32:$RA, i32:$SI),
113 (TABORTWCI (HTM_get_imm imm:$TO), $RA, (HTM_get_imm imm:$SI))>;
115 def : Pat<(int_ppc_tabortdc i32:$TO, i32:$RA, i32:$RB),
116 (TABORTDC (HTM_get_imm imm:$TO), $RA, $RB)>;
118 def : Pat<(int_ppc_tabortdci i32:$TO, i32:$RA, i32:$SI),
119 (TABORTDCI (HTM_get_imm imm:$TO), $RA, (HTM_get_imm imm:$SI))>;
121 def : Pat<(int_ppc_tcheck),
124 def : Pat<(int_ppc_treclaim i32:$RA),
127 def : Pat<(int_ppc_trechkpt),
130 def : Pat<(int_ppc_tsr i32:$L),
131 (TSR (HTM_get_imm imm:$L))>;
133 def : Pat<(int_ppc_get_texasr),
136 def : Pat<(int_ppc_get_texasru),
139 def : Pat<(int_ppc_get_tfhar),
142 def : Pat<(int_ppc_get_tfiar),
146 def : Pat<(int_ppc_set_texasr i64:$V),
149 def : Pat<(int_ppc_set_texasru i64:$V),
152 def : Pat<(int_ppc_set_tfhar i64:$V),
155 def : Pat<(int_ppc_set_tfiar i64:$V),
159 // Extended mnemonics
160 def : Pat<(int_ppc_tendall),
163 def : Pat<(int_ppc_tresume),
166 def : Pat<(int_ppc_tsuspend),
169 def : Pat<(i64 (int_ppc_ttest)),
170 (RLDICL (i64 (COPY (TABORTWCI 0, ZERO, 0))), 36, 28)>;