Debian Codegraph @

suite/synctools/tablegen/PPC/PPCInstrHTM.td

raw
1 //===-- PPCInstrHTM.td - The PowerPC Hardware Transactional Memory -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the Hardware Transactional Memory extension to the
11 // PowerPC instruction set.
12 //
13 //===----------------------------------------------------------------------===//
14
15
16
17 def HasHTM : Predicate<"PPCSubTarget->hasHTM()">;
18
19 def HTM_get_imm : SDNodeXForm<imm, [{
20 return getI32Imm (N->getZExtValue(), SDLoc(N));
21 }]>;
22
23 let hasSideEffects = 1, usesCustomInserter = 1 in {
24 def TCHECK_RET : Pseudo<(outs gprc:$out), (ins), "#TCHECK_RET", []>;
25 def TBEGIN_RET : PPCCustomInserterPseudo<(outs gprc:$out), (ins u1imm:$R), "#TBEGIN_RET", []>;
26 }
27
28
29 let Predicates = [HasHTM] in {
30
31 let Defs = [CR0] in {
32 def TBEGIN : XForm_htm0 <31, 654,
33 (outs), (ins u1imm:$R), "tbegin. $R", IIC_SprMTSPR, []>;
34
35 def TEND : XForm_htm1 <31, 686,
36 (outs), (ins u1imm:$A), "tend. $A", IIC_SprMTSPR, []>;
37
38 def TABORT : XForm_base_r3xo <31, 910,
39 (outs), (ins gprc:$A), "tabort. $A", IIC_SprMTSPR,
40 []>, isDOT {
41 let RST = 0;
42 let B = 0;
43 }
44
45 def TABORTWC : XForm_base_r3xo <31, 782,
46 (outs), (ins u5imm:$RTS, gprc:$A, gprc:$B),
47 "tabortwc. $RTS, $A, $B", IIC_SprMTSPR, []>,
48 isDOT;
49
50 def TABORTWCI : XForm_base_r3xo <31, 846,
51 (outs), (ins u5imm:$RTS, gprc:$A, u5imm:$B),
52 "tabortwci. $RTS, $A, $B", IIC_SprMTSPR, []>,
53 isDOT;
54
55 def TABORTDC : XForm_base_r3xo <31, 814,
56 (outs), (ins u5imm:$RTS, gprc:$A, gprc:$B),
57 "tabortdc. $RTS, $A, $B", IIC_SprMTSPR, []>,
58 isDOT;
59
60 def TABORTDCI : XForm_base_r3xo <31, 878,
61 (outs), (ins u5imm:$RTS, gprc:$A, u5imm:$B),
62 "tabortdci. $RTS, $A, $B", IIC_SprMTSPR, []>,
63 isDOT;
64
65 def TSR : XForm_htm2 <31, 750,
66 (outs), (ins u1imm:$L), "tsr. $L", IIC_SprMTSPR, []>,
67 isDOT;
68
69 def TRECLAIM : XForm_base_r3xo <31, 942,
70 (outs), (ins gprc:$A), "treclaim. $A",
71 IIC_SprMTSPR, []>,
72 isDOT {
73 let RST = 0;
74 let B = 0;
75 }
76
77 def TRECHKPT : XForm_base_r3xo <31, 1006,
78 (outs), (ins), "trechkpt.", IIC_SprMTSPR, []>,
79 isDOT {
80 let RST = 0;
81 let A = 0;
82 let B = 0;
83 }
84
85 }//Defs = [CR0]
86
87 def TCHECK : XForm_htm3 <31, 718,
88 (outs crrc:$BF), (ins), "tcheck $BF", IIC_SprMTSPR, []>;
89 // Builtins
90
91 // All HTM instructions, with the exception of tcheck, set CR0 with the
92 // value of the MSR Transaction State (TS) bits that exist before the
93 // instruction is executed. For tbegin., the EQ bit in CR0 can be used
94 // to determine whether the transaction was successfully started (0) or
95 // failed (1). We use an XORI pattern to 'flip' the bit to match the
96 // tbegin builtin API which defines a return value of 1 as success.
97
98 def : Pat<(int_ppc_tbegin i32:$R),
99 (XORI (TBEGIN_RET(HTM_get_imm imm:$R)), 1)>;
100
101 def : Pat<(int_ppc_tend i32:$R),
102 (TEND (HTM_get_imm imm:$R))>;
103
104 def : Pat<(int_ppc_tabort i32:$R),
105 (TABORT $R)>;
106
107 def : Pat<(int_ppc_tabortwc i32:$TO, i32:$RA, i32:$RB),
108 (TABORTWC (HTM_get_imm imm:$TO), $RA, $RB)>;
109
110 def : Pat<(int_ppc_tabortwci i32:$TO, i32:$RA, i32:$SI),
111 (TABORTWCI (HTM_get_imm imm:$TO), $RA, (HTM_get_imm imm:$SI))>;
112
113 def : Pat<(int_ppc_tabortdc i32:$TO, i32:$RA, i32:$RB),
114 (TABORTDC (HTM_get_imm imm:$TO), $RA, $RB)>;
115
116 def : Pat<(int_ppc_tabortdci i32:$TO, i32:$RA, i32:$SI),
117 (TABORTDCI (HTM_get_imm imm:$TO), $RA, (HTM_get_imm imm:$SI))>;
118
119 def : Pat<(int_ppc_tcheck),
120 (TCHECK_RET)>;
121
122 def : Pat<(int_ppc_treclaim i32:$RA),
123 (TRECLAIM $RA)>;
124
125 def : Pat<(int_ppc_trechkpt),
126 (TRECHKPT)>;
127
128 def : Pat<(int_ppc_tsr i32:$L),
129 (TSR (HTM_get_imm imm:$L))>;
130
131 def : Pat<(int_ppc_get_texasr),
132 (MFSPR8 130)>;
133
134 def : Pat<(int_ppc_get_texasru),
135 (MFSPR8 131)>;
136
137 def : Pat<(int_ppc_get_tfhar),
138 (MFSPR8 128)>;
139
140 def : Pat<(int_ppc_get_tfiar),
141 (MFSPR8 129)>;
142
143
144 def : Pat<(int_ppc_set_texasr i64:$V),
145 (MTSPR8 130, $V)>;
146
147 def : Pat<(int_ppc_set_texasru i64:$V),
148 (MTSPR8 131, $V)>;
149
150 def : Pat<(int_ppc_set_tfhar i64:$V),
151 (MTSPR8 128, $V)>;
152
153 def : Pat<(int_ppc_set_tfiar i64:$V),
154 (MTSPR8 129, $V)>;
155
156
157 // Extended mnemonics
158 def : Pat<(int_ppc_tendall),
159 (TEND 1)>;
160
161 def : Pat<(int_ppc_tresume),
162 (TSR 1)>;
163
164 def : Pat<(int_ppc_tsuspend),
165 (TSR 0)>;
166
167 def : Pat<(i64 (int_ppc_ttest)),
168 (RLDICL (i64 (COPY (TABORTWCI 0, ZERO, 0))), 36, 28)>;
169
170 } // [HasHTM]