08c468d31588b678c03843aa39ef549bcaab58f4
[oota-llvm.git] / lib / Target / R600 / CIInstructions.td
1 //===-- CIInstructions.td - CI Instruction Defintions ---------------------===//
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 // Instruction definitions for CI and newer.
10 //===----------------------------------------------------------------------===//
11
12
13 def isCIVI : Predicate <
14   "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
15   "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
16 >, AssemblerPredicate<"FeatureCIInsts">;
17
18 def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
19
20 //===----------------------------------------------------------------------===//
21 // VOP1 Instructions
22 //===----------------------------------------------------------------------===//
23
24 let SubtargetPredicate = isCIVI in {
25
26 defm V_TRUNC_F64 : VOP1Inst <vop1<0x17>, "v_trunc_f64",
27   VOP_F64_F64, ftrunc
28 >;
29 defm V_CEIL_F64 : VOP1Inst <vop1<0x18>, "v_ceil_f64",
30   VOP_F64_F64, fceil
31 >;
32 defm V_FLOOR_F64 : VOP1Inst <vop1<0x1A>, "v_floor_f64",
33   VOP_F64_F64, ffloor
34 >;
35 defm V_RNDNE_F64 : VOP1Inst <vop1<0x19>, "v_rndne_f64",
36   VOP_F64_F64, frint
37 >;
38 defm V_LOG_LEGACY_F32 : VOP1Inst <vop1<0x45, 0x4c>, "v_log_legacy_f32",
39   VOP_F32_F32
40 >;
41 defm V_EXP_LEGACY_F32 : VOP1Inst <vop1<0x46, 0x4b>, "v_exp_legacy_f32",
42   VOP_F32_F32
43 >;
44 } // End SubtargetPredicate = isCIVI
45
46 //===----------------------------------------------------------------------===//
47 // Flat Instructions
48 //===----------------------------------------------------------------------===//
49
50 let Predicates = [HasFlatAddressSpace] in {
51 def FLAT_LOAD_UBYTE : FLAT_Load_Helper <0x00000008, "flat_load_ubyte", VGPR_32>;
52 def FLAT_LOAD_SBYTE : FLAT_Load_Helper <0x00000009, "flat_load_sbyte", VGPR_32>;
53 def FLAT_LOAD_USHORT : FLAT_Load_Helper <0x0000000a, "flat_load_ushort", VGPR_32>;
54 def FLAT_LOAD_SSHORT : FLAT_Load_Helper <0x0000000b, "flat_load_sshort", VGPR_32>;
55 def FLAT_LOAD_DWORD : FLAT_Load_Helper <0x0000000c, "flat_load_dword", VGPR_32>;
56 def FLAT_LOAD_DWORDX2 : FLAT_Load_Helper <0x0000000d, "flat_load_dwordx2", VReg_64>;
57 def FLAT_LOAD_DWORDX4 : FLAT_Load_Helper <0x0000000e, "flat_load_dwordx4", VReg_128>;
58 def FLAT_LOAD_DWORDX3 : FLAT_Load_Helper <0x00000010, "flat_load_dwordx3", VReg_96>;
59
60 def FLAT_STORE_BYTE : FLAT_Store_Helper <
61   0x00000018, "flat_store_byte", VGPR_32
62 >;
63
64 def FLAT_STORE_SHORT : FLAT_Store_Helper <
65   0x0000001a, "flat_store_short", VGPR_32
66 >;
67
68 def FLAT_STORE_DWORD : FLAT_Store_Helper <
69   0x0000001c, "flat_store_dword", VGPR_32
70 >;
71
72 def FLAT_STORE_DWORDX2 : FLAT_Store_Helper <
73   0x0000001d, "flat_store_dwordx2", VReg_64
74 >;
75
76 def FLAT_STORE_DWORDX4 : FLAT_Store_Helper <
77   0x0000001e, "flat_store_dwordx4", VReg_128
78 >;
79
80 def FLAT_STORE_DWORDX3 : FLAT_Store_Helper <
81   0x0000001e, "flat_store_dwordx3", VReg_96
82 >;
83
84 //def FLAT_ATOMIC_SWAP : FLAT_ <0x00000030, "flat_atomic_swap", []>;
85 //def FLAT_ATOMIC_CMPSWAP : FLAT_ <0x00000031, "flat_atomic_cmpswap", []>;
86 //def FLAT_ATOMIC_ADD : FLAT_ <0x00000032, "flat_atomic_add", []>;
87 //def FLAT_ATOMIC_SUB : FLAT_ <0x00000033, "flat_atomic_sub", []>;
88 //def FLAT_ATOMIC_RSUB : FLAT_ <0x00000034, "flat_atomic_rsub", []>;
89 //def FLAT_ATOMIC_SMIN : FLAT_ <0x00000035, "flat_atomic_smin", []>;
90 //def FLAT_ATOMIC_UMIN : FLAT_ <0x00000036, "flat_atomic_umin", []>;
91 //def FLAT_ATOMIC_SMAX : FLAT_ <0x00000037, "flat_atomic_smax", []>;
92 //def FLAT_ATOMIC_UMAX : FLAT_ <0x00000038, "flat_atomic_umax", []>;
93 //def FLAT_ATOMIC_AND : FLAT_ <0x00000039, "flat_atomic_and", []>;
94 //def FLAT_ATOMIC_OR : FLAT_ <0x0000003a, "flat_atomic_or", []>;
95 //def FLAT_ATOMIC_XOR : FLAT_ <0x0000003b, "flat_atomic_xor", []>;
96 //def FLAT_ATOMIC_INC : FLAT_ <0x0000003c, "flat_atomic_inc", []>;
97 //def FLAT_ATOMIC_DEC : FLAT_ <0x0000003d, "flat_atomic_dec", []>;
98 //def FLAT_ATOMIC_FCMPSWAP : FLAT_ <0x0000003e, "flat_atomic_fcmpswap", []>;
99 //def FLAT_ATOMIC_FMIN : FLAT_ <0x0000003f, "flat_atomic_fmin", []>;
100 //def FLAT_ATOMIC_FMAX : FLAT_ <0x00000040, "flat_atomic_fmax", []>;
101 //def FLAT_ATOMIC_SWAP_X2 : FLAT_X2 <0x00000050, "flat_atomic_swap_x2", []>;
102 //def FLAT_ATOMIC_CMPSWAP_X2 : FLAT_X2 <0x00000051, "flat_atomic_cmpswap_x2", []>;
103 //def FLAT_ATOMIC_ADD_X2 : FLAT_X2 <0x00000052, "flat_atomic_add_x2", []>;
104 //def FLAT_ATOMIC_SUB_X2 : FLAT_X2 <0x00000053, "flat_atomic_sub_x2", []>;
105 //def FLAT_ATOMIC_RSUB_X2 : FLAT_X2 <0x00000054, "flat_atomic_rsub_x2", []>;
106 //def FLAT_ATOMIC_SMIN_X2 : FLAT_X2 <0x00000055, "flat_atomic_smin_x2", []>;
107 //def FLAT_ATOMIC_UMIN_X2 : FLAT_X2 <0x00000056, "flat_atomic_umin_x2", []>;
108 //def FLAT_ATOMIC_SMAX_X2 : FLAT_X2 <0x00000057, "flat_atomic_smax_x2", []>;
109 //def FLAT_ATOMIC_UMAX_X2 : FLAT_X2 <0x00000058, "flat_atomic_umax_x2", []>;
110 //def FLAT_ATOMIC_AND_X2 : FLAT_X2 <0x00000059, "flat_atomic_and_x2", []>;
111 //def FLAT_ATOMIC_OR_X2 : FLAT_X2 <0x0000005a, "flat_atomic_or_x2", []>;
112 //def FLAT_ATOMIC_XOR_X2 : FLAT_X2 <0x0000005b, "flat_atomic_xor_x2", []>;
113 //def FLAT_ATOMIC_INC_X2 : FLAT_X2 <0x0000005c, "flat_atomic_inc_x2", []>;
114 //def FLAT_ATOMIC_DEC_X2 : FLAT_X2 <0x0000005d, "flat_atomic_dec_x2", []>;
115 //def FLAT_ATOMIC_FCMPSWAP_X2 : FLAT_X2 <0x0000005e, "flat_atomic_fcmpswap_x2", []>;
116 //def FLAT_ATOMIC_FMIN_X2 : FLAT_X2 <0x0000005f, "flat_atomic_fmin_x2", []>;
117 //def FLAT_ATOMIC_FMAX_X2 : FLAT_X2 <0x00000060, "flat_atomic_fmax_x2", []>;
118
119 //===----------------------------------------------------------------------===//
120 // Flat Patterns
121 //===----------------------------------------------------------------------===//
122
123 class FLATLoad_Pattern <FLAT Instr_ADDR64, ValueType vt,
124                              PatFrag flat_ld> :
125   Pat <(vt (flat_ld i64:$ptr)),
126        (Instr_ADDR64 $ptr)
127 >;
128
129 def : FLATLoad_Pattern <FLAT_LOAD_SBYTE, i32, sextloadi8_flat>;
130 def : FLATLoad_Pattern <FLAT_LOAD_UBYTE, i32, az_extloadi8_flat>;
131 def : FLATLoad_Pattern <FLAT_LOAD_SSHORT, i32, sextloadi16_flat>;
132 def : FLATLoad_Pattern <FLAT_LOAD_USHORT, i32, az_extloadi16_flat>;
133 def : FLATLoad_Pattern <FLAT_LOAD_DWORD, i32, flat_load>;
134 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, i64, flat_load>;
135 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, i64, az_extloadi32_flat>;
136 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, v2i32, flat_load>;
137 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX4, v4i32, flat_load>;
138
139 class FLATStore_Pattern <FLAT Instr, ValueType vt, PatFrag st> :
140   Pat <(st vt:$value, i64:$ptr),
141         (Instr $value, $ptr)
142   >;
143
144 def : FLATStore_Pattern <FLAT_STORE_BYTE, i32, truncstorei8_flat>;
145 def : FLATStore_Pattern <FLAT_STORE_SHORT, i32, truncstorei16_flat>;
146 def : FLATStore_Pattern <FLAT_STORE_DWORD, i32, flat_store>;
147 def : FLATStore_Pattern <FLAT_STORE_DWORDX2, i64, flat_store>;
148 def : FLATStore_Pattern <FLAT_STORE_DWORDX2, v2i32, flat_store>;
149 def : FLATStore_Pattern <FLAT_STORE_DWORDX4, v4i32, flat_store>;
150
151 } // End HasFlatAddressSpace predicate
152