blob: f93d0e8c540653257475dce6ddd00e4088fc9f15 [file] [log] [blame]
Tony Linthicum1213a7a2011-12-12 21:14:40 +00001//===- HexagonIntrinsicsV4.td - V4 Instruction intrinsics --*- tablegen -*-===//
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// This is populated based on the following specs:
10// Hexagon V4 Architecture Extensions
11// Application-Level Specification
12// 80-V9418-12 Rev. A
13// June 15, 2010
14
Colin LeMahieu94c33212015-01-28 19:16:17 +000015// Polynomial multiply words
16// Rdd=pmpyw(Rs,Rt)
17def : T_RR_pat <M4_pmpyw, int_hexagon_M4_pmpyw>;
18// Rxx^=pmpyw(Rs,Rt)
19def : T_PRR_pat <M4_pmpyw_acc, int_hexagon_M4_pmpyw_acc>;
20
21//Rxx^=asr(Rss,Rt)
22def : T_PPR_pat <S2_asr_r_p_xor, int_hexagon_S2_asr_r_p_xor>;
23//Rxx^=asl(Rss,Rt)
24def : T_PPR_pat <S2_asl_r_p_xor, int_hexagon_S2_asl_r_p_xor>;
25//Rxx^=lsr(Rss,Rt)
26def : T_PPR_pat <S2_lsr_r_p_xor, int_hexagon_S2_lsr_r_p_xor>;
27//Rxx^=lsl(Rss,Rt)
28def : T_PPR_pat <S2_lsl_r_p_xor, int_hexagon_S2_lsl_r_p_xor>;
29
30// Multiply and use upper result
31def : MType_R32_pat <int_hexagon_M2_mpysu_up, M2_mpysu_up>;
32def : MType_R32_pat <int_hexagon_M2_mpy_up_s1, M2_mpy_up_s1>;
33def : MType_R32_pat <int_hexagon_M2_hmmpyh_s1, M2_hmmpyh_s1>;
34def : MType_R32_pat <int_hexagon_M2_hmmpyl_s1, M2_hmmpyl_s1>;
35def : MType_R32_pat <int_hexagon_M2_mpy_up_s1_sat, M2_mpy_up_s1_sat>;
36
Colin LeMahieucdba4e12015-02-03 18:01:45 +000037// Vector reduce add unsigned halfwords
38def : Pat <(int_hexagon_M2_vraddh DoubleRegs:$src1, DoubleRegs:$src2),
39 (M2_vraddh DoubleRegs:$src1, DoubleRegs:$src2)>;
40
Colin LeMahieu39b846c2015-01-28 18:06:23 +000041def : T_P_pat <S2_brevp, int_hexagon_S2_brevp>;
42
43def: T_P_pat <S2_ct0p, int_hexagon_S2_ct0p>;
44def: T_P_pat <S2_ct1p, int_hexagon_S2_ct1p>;
45def: T_RR_pat<C4_nbitsset, int_hexagon_C4_nbitsset>;
46def: T_RR_pat<C4_nbitsclr, int_hexagon_C4_nbitsclr>;
47def: T_RI_pat<C4_nbitsclri, int_hexagon_C4_nbitsclri>;
48
Colin LeMahieua749b3e2015-01-29 16:08:43 +000049def : T_RR_pat<A4_cmpbeq, int_hexagon_A4_cmpbeq>;
50def : T_RR_pat<A4_cmpbgt, int_hexagon_A4_cmpbgt>;
51def : T_RR_pat<A4_cmpbgtu, int_hexagon_A4_cmpbgtu>;
52def : T_RR_pat<A4_cmpheq, int_hexagon_A4_cmpheq>;
53def : T_RR_pat<A4_cmphgt, int_hexagon_A4_cmphgt>;
54def : T_RR_pat<A4_cmphgtu, int_hexagon_A4_cmphgtu>;
55
56def : T_RI_pat<A4_cmpbeqi, int_hexagon_A4_cmpbeqi>;
57def : T_RI_pat<A4_cmpbgti, int_hexagon_A4_cmpbgti>;
58def : T_RI_pat<A4_cmpbgtui, int_hexagon_A4_cmpbgtui>;
59
60def : T_RI_pat<A4_cmpheqi, int_hexagon_A4_cmpheqi>;
61def : T_RI_pat<A4_cmphgti, int_hexagon_A4_cmphgti>;
62def : T_RI_pat<A4_cmphgtui, int_hexagon_A4_cmphgtui>;
63
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +000064def : T_RP_pat <A4_boundscheck, int_hexagon_A4_boundscheck>;
65
66def : T_PR_pat<A4_tlbmatch, int_hexagon_A4_tlbmatch>;
67
Colin LeMahieu94c33212015-01-28 19:16:17 +000068def : Pat <(int_hexagon_M4_mpyrr_addr IntRegs:$src1, IntRegs:$src2,
69 IntRegs:$src3),
70 (M4_mpyrr_addr IntRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
71
72def : T_IRR_pat <M4_mpyrr_addi, int_hexagon_M4_mpyrr_addi>;
73def : T_IRI_pat <M4_mpyri_addi, int_hexagon_M4_mpyri_addi>;
74def : T_RIR_pat <M4_mpyri_addr_u2, int_hexagon_M4_mpyri_addr_u2>;
75def : T_RRI_pat <M4_mpyri_addr, int_hexagon_M4_mpyri_addr>;
76// Multiply 32x32 and use upper result
77def : T_RRR_pat <M4_mac_up_s1_sat, int_hexagon_M4_mac_up_s1_sat>;
78def : T_RRR_pat <M4_nac_up_s1_sat, int_hexagon_M4_nac_up_s1_sat>;
79
Colin LeMahieua6632452015-02-03 18:16:28 +000080// Complex multiply 32x16
81def : T_PR_pat <M4_cmpyi_wh, int_hexagon_M4_cmpyi_wh>;
82def : T_PR_pat <M4_cmpyr_wh, int_hexagon_M4_cmpyr_wh>;
83
84def : T_PR_pat <M4_cmpyi_whc, int_hexagon_M4_cmpyi_whc>;
85def : T_PR_pat <M4_cmpyr_whc, int_hexagon_M4_cmpyr_whc>;
86
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +000087def : T_PP_pat<A4_andnp, int_hexagon_A4_andnp>;
88def : T_PP_pat<A4_ornp, int_hexagon_A4_ornp>;
89
Colin LeMahieua6632452015-02-03 18:16:28 +000090// Complex add/sub halfwords/words
91def : T_PP_pat <S4_vxaddsubw, int_hexagon_S4_vxaddsubw>;
92def : T_PP_pat <S4_vxsubaddw, int_hexagon_S4_vxsubaddw>;
93def : T_PP_pat <S4_vxaddsubh, int_hexagon_S4_vxaddsubh>;
94def : T_PP_pat <S4_vxsubaddh, int_hexagon_S4_vxsubaddh>;
95
96def : T_PP_pat <S4_vxaddsubhr, int_hexagon_S4_vxaddsubhr>;
97def : T_PP_pat <S4_vxsubaddhr, int_hexagon_S4_vxsubaddhr>;
98
Colin LeMahieu39b846c2015-01-28 18:06:23 +000099// Extract bitfield
100def : T_PP_pat <S4_extractp_rp, int_hexagon_S4_extractp_rp>;
101def : T_RP_pat <S4_extract_rp, int_hexagon_S4_extract_rp>;
102def : T_PII_pat <S4_extractp, int_hexagon_S4_extractp>;
103def : T_RII_pat <S4_extract, int_hexagon_S4_extract>;
104
Colin LeMahieucdba4e12015-02-03 18:01:45 +0000105// Vector conditional negate
106// Rdd=vcnegh(Rss,Rt)
107def : T_PR_pat <S2_vcnegh, int_hexagon_S2_vcnegh>;
108
Colin LeMahieufe03c9a2015-01-28 17:37:59 +0000109// Shift an immediate left by register amount
110def : T_IR_pat<S4_lsli, int_hexagon_S4_lsli>;
111
Colin LeMahieucdba4e12015-02-03 18:01:45 +0000112// Vector reduce maximum halfwords
113def : T_PPR_pat <A4_vrmaxh, int_hexagon_A4_vrmaxh>;
114def : T_PPR_pat <A4_vrmaxuh, int_hexagon_A4_vrmaxuh>;
115
116// Vector reduce maximum words
117def : T_PPR_pat <A4_vrmaxw, int_hexagon_A4_vrmaxw>;
118def : T_PPR_pat <A4_vrmaxuw, int_hexagon_A4_vrmaxuw>;
119
120// Vector reduce minimum halfwords
121def : T_PPR_pat <A4_vrminh, int_hexagon_A4_vrminh>;
122def : T_PPR_pat <A4_vrminuh, int_hexagon_A4_vrminuh>;
123
124// Vector reduce minimum words
125def : T_PPR_pat <A4_vrminw, int_hexagon_A4_vrminw>;
126def : T_PPR_pat <A4_vrminuw, int_hexagon_A4_vrminuw>;
127
Colin LeMahieua6632452015-02-03 18:16:28 +0000128// Rotate and reduce bytes
129def : Pat <(int_hexagon_S4_vrcrotate DoubleRegs:$src1, IntRegs:$src2,
130 u2ImmPred:$src3),
131 (S4_vrcrotate DoubleRegs:$src1, IntRegs:$src2, u2ImmPred:$src3)>;
132
133// Rotate and reduce bytes with accumulation
134// Rxx+=vrcrotate(Rss,Rt,#u2)
135def : Pat <(int_hexagon_S4_vrcrotate_acc DoubleRegs:$src1, DoubleRegs:$src2,
136 IntRegs:$src3, u2ImmPred:$src4),
137 (S4_vrcrotate_acc DoubleRegs:$src1, DoubleRegs:$src2,
138 IntRegs:$src3, u2ImmPred:$src4)>;
139
Colin LeMahieucdba4e12015-02-03 18:01:45 +0000140// Vector conditional negate
141def : T_PPR_pat<S2_vrcnegh, int_hexagon_S2_vrcnegh>;
142
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000143// Logical xor with xor accumulation
144def : T_PPP_pat<M4_xor_xacc, int_hexagon_M4_xor_xacc>;
145
Colin LeMahieucdba4e12015-02-03 18:01:45 +0000146// ALU64 - Vector min/max byte
147def : T_PP_pat <A2_vminb, int_hexagon_A2_vminb>;
148def : T_PP_pat <A2_vmaxb, int_hexagon_A2_vmaxb>;
149
Colin LeMahieufe03c9a2015-01-28 17:37:59 +0000150// Shift and add/sub/and/or
151def : T_IRI_pat <S4_andi_asl_ri, int_hexagon_S4_andi_asl_ri>;
152def : T_IRI_pat <S4_ori_asl_ri, int_hexagon_S4_ori_asl_ri>;
153def : T_IRI_pat <S4_addi_asl_ri, int_hexagon_S4_addi_asl_ri>;
154def : T_IRI_pat <S4_subi_asl_ri, int_hexagon_S4_subi_asl_ri>;
155def : T_IRI_pat <S4_andi_lsr_ri, int_hexagon_S4_andi_lsr_ri>;
156def : T_IRI_pat <S4_ori_lsr_ri, int_hexagon_S4_ori_lsr_ri>;
157def : T_IRI_pat <S4_addi_lsr_ri, int_hexagon_S4_addi_lsr_ri>;
158def : T_IRI_pat <S4_subi_lsr_ri, int_hexagon_S4_subi_lsr_ri>;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000159
Colin LeMahieu39b846c2015-01-28 18:06:23 +0000160// Split bitfield
161def : T_RI_pat <A4_bitspliti, int_hexagon_A4_bitspliti>;
162def : T_RR_pat <A4_bitsplit, int_hexagon_A4_bitsplit>;
163
164def: T_RR_pat<S4_parity, int_hexagon_S4_parity>;
165
166def: T_RI_pat<S4_ntstbit_i, int_hexagon_S4_ntstbit_i>;
167def: T_RR_pat<S4_ntstbit_r, int_hexagon_S4_ntstbit_r>;
168
169def: T_RI_pat<S4_clbaddi, int_hexagon_S4_clbaddi>;
170def: T_PI_pat<S4_clbpaddi, int_hexagon_S4_clbpaddi>;
171def: T_P_pat <S4_clbpnorm, int_hexagon_S4_clbpnorm>;
172
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000173/********************************************************************
174* ALU32/ALU *
175*********************************************************************/
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000176
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000177// ALU32 / ALU / Logical Operations.
178def: T_RR_pat<A4_andn, int_hexagon_A4_andn>;
179def: T_RR_pat<A4_orn, int_hexagon_A4_orn>;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000180
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000181/********************************************************************
182* ALU32/PERM *
183*********************************************************************/
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000184
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000185// Combine Words Into Doublewords.
186def: T_RI_pat<A4_combineri, int_hexagon_A4_combineri, s8ExtPred>;
187def: T_IR_pat<A4_combineir, int_hexagon_A4_combineir, s8ExtPred>;
188
189/********************************************************************
190* ALU32/PRED *
191*********************************************************************/
192
Colin LeMahieu860210b2015-01-29 16:55:37 +0000193// Compare
194def : T_RI_pat<C4_cmpneqi, int_hexagon_C4_cmpneqi, s10ExtPred>;
195def : T_RI_pat<C4_cmpltei, int_hexagon_C4_cmpltei, s10ExtPred>;
196def : T_RI_pat<C4_cmplteui, int_hexagon_C4_cmplteui, u9ExtPred>;
197
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000198def: T_RR_pat<A4_rcmpeq, int_hexagon_A4_rcmpeq>;
199def: T_RR_pat<A4_rcmpneq, int_hexagon_A4_rcmpneq>;
200
201def: T_RI_pat<A4_rcmpeqi, int_hexagon_A4_rcmpeqi>;
202def: T_RI_pat<A4_rcmpneqi, int_hexagon_A4_rcmpneqi>;
203
204/********************************************************************
Colin LeMahieu860210b2015-01-29 16:55:37 +0000205* CR *
206*********************************************************************/
207
208// CR / Logical Operations On Predicates.
209
210class qi_CRInst_qiqiqi_pat<Intrinsic IntID, InstHexagon Inst> :
211 Pat<(i32 (IntID IntRegs:$Rs, IntRegs:$Rt, IntRegs:$Ru)),
212 (i32 (C2_tfrpr (Inst (C2_tfrrp IntRegs:$Rs),
213 (C2_tfrrp IntRegs:$Rt),
214 (C2_tfrrp IntRegs:$Ru))))>;
215
216def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_and_and, C4_and_and>;
217def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_and_andn, C4_and_andn>;
218def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_and_or, C4_and_or>;
219def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_and_orn, C4_and_orn>;
220def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_or_and, C4_or_and>;
221def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_or_andn, C4_or_andn>;
222def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_or_or, C4_or_or>;
223def: qi_CRInst_qiqiqi_pat<int_hexagon_C4_or_orn, C4_or_orn>;
224
225/********************************************************************
Colin LeMahieu1de7e0d2015-01-28 19:39:09 +0000226* XTYPE/ALU *
227*********************************************************************/
228
229// Add And Accumulate.
230
231def : T_RRI_pat <S4_addaddi, int_hexagon_S4_addaddi>;
232def : T_RIR_pat <S4_subaddi, int_hexagon_S4_subaddi>;
233
234
235// XTYPE / ALU / Logical-logical Words.
236def : T_RRR_pat <M4_or_xor, int_hexagon_M4_or_xor>;
237def : T_RRR_pat <M4_and_xor, int_hexagon_M4_and_xor>;
238def : T_RRR_pat <M4_or_and, int_hexagon_M4_or_and>;
239def : T_RRR_pat <M4_and_and, int_hexagon_M4_and_and>;
240def : T_RRR_pat <M4_xor_and, int_hexagon_M4_xor_and>;
241def : T_RRR_pat <M4_or_or, int_hexagon_M4_or_or>;
242def : T_RRR_pat <M4_and_or, int_hexagon_M4_and_or>;
243def : T_RRR_pat <M4_xor_or, int_hexagon_M4_xor_or>;
244def : T_RRR_pat <M4_or_andn, int_hexagon_M4_or_andn>;
245def : T_RRR_pat <M4_and_andn, int_hexagon_M4_and_andn>;
246def : T_RRR_pat <M4_xor_andn, int_hexagon_M4_xor_andn>;
247
248def : T_RRI_pat <S4_or_andi, int_hexagon_S4_or_andi>;
249def : T_RRI_pat <S4_or_andix, int_hexagon_S4_or_andix>;
250def : T_RRI_pat <S4_or_ori, int_hexagon_S4_or_ori>;
251
252// Modulo wrap.
253def : T_RR_pat <A4_modwrapu, int_hexagon_A4_modwrapu>;
254
255// Arithmetic/Convergent round
256// Rd=[cround|round](Rs,Rt)[:sat]
257// Rd=[cround|round](Rs,#u5)[:sat]
258def : T_RI_pat <A4_cround_ri, int_hexagon_A4_cround_ri>;
259def : T_RR_pat <A4_cround_rr, int_hexagon_A4_cround_rr>;
260
261def : T_RI_pat <A4_round_ri, int_hexagon_A4_round_ri>;
262def : T_RR_pat <A4_round_rr, int_hexagon_A4_round_rr>;
263
264def : T_RI_pat <A4_round_ri_sat, int_hexagon_A4_round_ri_sat>;
265def : T_RR_pat <A4_round_rr_sat, int_hexagon_A4_round_rr_sat>;
266
267def : T_P_pat <A2_roundsat, int_hexagon_A2_roundsat>;