1 //===-- R600Instructions.td - R600 Instruction defs -------*- tablegen -*-===//
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 // R600 Tablegen instruction definitions
12 //===----------------------------------------------------------------------===//
14 include "R600Intrinsics.td"
15 include "R600InstrFormats.td"
17 class InstR600ISA <dag outs, dag ins, string asm, list<dag> pattern> :
18 InstR600 <outs, ins, asm, pattern, NullALU> {
20 let Namespace = "AMDGPU";
23 def MEMxi : Operand<iPTR> {
24 let MIOperandInfo = (ops R600_TReg32_X:$ptr, i32imm:$index);
25 let PrintMethod = "printMemOperand";
28 def MEMrr : Operand<iPTR> {
29 let MIOperandInfo = (ops R600_Reg32:$ptr, R600_Reg32:$index);
32 // Operands for non-registers
34 class InstFlag<string PM = "printOperand", int Default = 0>
35 : OperandWithDefaultOps <i32, (ops (i32 Default))> {
39 // src_sel for ALU src operands, see also ALU_CONST, ALU_PARAM registers
40 def SEL : OperandWithDefaultOps <i32, (ops (i32 -1))> {
41 let PrintMethod = "printSel";
43 def BANK_SWIZZLE : OperandWithDefaultOps <i32, (ops (i32 0))> {
44 let PrintMethod = "printBankSwizzle";
47 def LITERAL : InstFlag<"printLiteral">;
49 def WRITE : InstFlag <"printWrite", 1>;
50 def OMOD : InstFlag <"printOMOD">;
51 def REL : InstFlag <"printRel">;
52 def CLAMP : InstFlag <"printClamp">;
53 def NEG : InstFlag <"printNeg">;
54 def ABS : InstFlag <"printAbs">;
55 def UEM : InstFlag <"printUpdateExecMask">;
56 def UP : InstFlag <"printUpdatePred">;
58 // XXX: The r600g finalizer in Mesa expects last to be one in most cases.
59 // Once we start using the packetizer in this backend we should have this
61 def LAST : InstFlag<"printLast", 1>;
62 def RSel : Operand<i32> {
63 let PrintMethod = "printRSel";
65 def CT: Operand<i32> {
66 let PrintMethod = "printCT";
69 def FRAMEri : Operand<iPTR> {
70 let MIOperandInfo = (ops R600_Reg32:$ptr, i32imm:$index);
73 def ADDRParam : ComplexPattern<i32, 2, "SelectADDRParam", [], []>;
74 def ADDRDWord : ComplexPattern<i32, 1, "SelectADDRDWord", [], []>;
75 def ADDRVTX_READ : ComplexPattern<i32, 2, "SelectADDRVTX_READ", [], []>;
76 def ADDRGA_CONST_OFFSET : ComplexPattern<i32, 1, "SelectGlobalValueConstantOffset", [], []>;
77 def ADDRGA_VAR_OFFSET : ComplexPattern<i32, 2, "SelectGlobalValueVariableOffset", [], []>;
78 def ADDRIndirect : ComplexPattern<iPTR, 2, "SelectADDRIndirect", [], []>;
81 def R600_Pred : PredicateOperand<i32, (ops R600_Predicate),
85 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
87 // Class for instructions with only one source register.
88 // If you add new ins to this instruction, make sure they are listed before
89 // $literal, because the backend currently assumes that the last operand is
90 // a literal. Also be sure to update the enum R600Op1OperandIndex::ROI in
91 // R600Defines.h, R600InstrInfo::buildDefaultInstruction(),
92 // and R600InstrInfo::getOperandIdx().
93 class R600_1OP <bits<11> inst, string opName, list<dag> pattern,
94 InstrItinClass itin = AnyALU> :
95 InstR600 <(outs R600_Reg32:$dst),
96 (ins WRITE:$write, OMOD:$omod, REL:$dst_rel, CLAMP:$clamp,
97 R600_Reg32:$src0, NEG:$src0_neg, REL:$src0_rel, ABS:$src0_abs, SEL:$src0_sel,
98 LAST:$last, R600_Pred:$pred_sel, LITERAL:$literal,
99 BANK_SWIZZLE:$bank_swizzle),
100 !strconcat(" ", opName,
101 "$clamp $last $dst$write$dst_rel$omod, "
102 "$src0_neg$src0_abs$src0$src0_abs$src0_rel, "
103 "$pred_sel $bank_swizzle"),
107 R600ALU_Word1_OP2 <inst> {
113 let update_exec_mask = 0;
115 let HasNativeOperands = 1;
117 let DisableEncoding = "$literal";
119 let Inst{31-0} = Word0;
120 let Inst{63-32} = Word1;
123 class R600_1OP_Helper <bits<11> inst, string opName, SDPatternOperator node,
124 InstrItinClass itin = AnyALU> :
125 R600_1OP <inst, opName,
126 [(set R600_Reg32:$dst, (node R600_Reg32:$src0))]
129 // If you add our change the operands for R600_2OP instructions, you must
130 // also update the R600Op2OperandIndex::ROI enum in R600Defines.h,
131 // R600InstrInfo::buildDefaultInstruction(), and R600InstrInfo::getOperandIdx().
132 class R600_2OP <bits<11> inst, string opName, list<dag> pattern,
133 InstrItinClass itin = AnyALU> :
134 InstR600 <(outs R600_Reg32:$dst),
135 (ins UEM:$update_exec_mask, UP:$update_pred, WRITE:$write,
136 OMOD:$omod, REL:$dst_rel, CLAMP:$clamp,
137 R600_Reg32:$src0, NEG:$src0_neg, REL:$src0_rel, ABS:$src0_abs, SEL:$src0_sel,
138 R600_Reg32:$src1, NEG:$src1_neg, REL:$src1_rel, ABS:$src1_abs, SEL:$src1_sel,
139 LAST:$last, R600_Pred:$pred_sel, LITERAL:$literal,
140 BANK_SWIZZLE:$bank_swizzle),
141 !strconcat(" ", opName,
142 "$clamp $last $update_exec_mask$update_pred$dst$write$dst_rel$omod, "
143 "$src0_neg$src0_abs$src0$src0_abs$src0_rel, "
144 "$src1_neg$src1_abs$src1$src1_abs$src1_rel, "
145 "$pred_sel $bank_swizzle"),
149 R600ALU_Word1_OP2 <inst> {
151 let HasNativeOperands = 1;
153 let DisableEncoding = "$literal";
155 let Inst{31-0} = Word0;
156 let Inst{63-32} = Word1;
159 class R600_2OP_Helper <bits<11> inst, string opName, SDPatternOperator node,
160 InstrItinClass itim = AnyALU> :
161 R600_2OP <inst, opName,
162 [(set R600_Reg32:$dst, (node R600_Reg32:$src0,
166 // If you add our change the operands for R600_3OP instructions, you must
167 // also update the R600Op3OperandIndex::ROI enum in R600Defines.h,
168 // R600InstrInfo::buildDefaultInstruction(), and
169 // R600InstrInfo::getOperandIdx().
170 class R600_3OP <bits<5> inst, string opName, list<dag> pattern,
171 InstrItinClass itin = AnyALU> :
172 InstR600 <(outs R600_Reg32:$dst),
173 (ins REL:$dst_rel, CLAMP:$clamp,
174 R600_Reg32:$src0, NEG:$src0_neg, REL:$src0_rel, SEL:$src0_sel,
175 R600_Reg32:$src1, NEG:$src1_neg, REL:$src1_rel, SEL:$src1_sel,
176 R600_Reg32:$src2, NEG:$src2_neg, REL:$src2_rel, SEL:$src2_sel,
177 LAST:$last, R600_Pred:$pred_sel, LITERAL:$literal,
178 BANK_SWIZZLE:$bank_swizzle),
179 !strconcat(" ", opName, "$clamp $last $dst$dst_rel, "
180 "$src0_neg$src0$src0_rel, "
181 "$src1_neg$src1$src1_rel, "
182 "$src2_neg$src2$src2_rel, "
188 R600ALU_Word1_OP3<inst>{
190 let HasNativeOperands = 1;
191 let DisableEncoding = "$literal";
194 let Inst{31-0} = Word0;
195 let Inst{63-32} = Word1;
198 class R600_REDUCTION <bits<11> inst, dag ins, string asm, list<dag> pattern,
199 InstrItinClass itin = VecALU> :
200 InstR600 <(outs R600_Reg32:$dst),
208 } // End mayLoad = 1, mayStore = 0, hasSideEffects = 0
210 def TEX_SHADOW : PatLeaf<
212 [{uint32_t TType = (uint32_t)N->getZExtValue();
213 return (TType >= 6 && TType <= 8) || (TType >= 11 && TType <= 13);
217 def TEX_RECT : PatLeaf<
219 [{uint32_t TType = (uint32_t)N->getZExtValue();
224 def TEX_ARRAY : PatLeaf<
226 [{uint32_t TType = (uint32_t)N->getZExtValue();
227 return TType == 9 || TType == 10 || TType == 15 || TType == 16;
231 def TEX_SHADOW_ARRAY : PatLeaf<
233 [{uint32_t TType = (uint32_t)N->getZExtValue();
234 return TType == 11 || TType == 12 || TType == 17;
238 class EG_CF_RAT <bits <8> cfinst, bits <6> ratinst, bits<4> mask, dag outs,
239 dag ins, string asm, list<dag> pattern> :
240 InstR600ISA <outs, ins, asm, pattern>,
241 CF_ALLOC_EXPORT_WORD0_RAT, CF_ALLOC_EXPORT_WORD1_BUF {
244 let rat_inst = ratinst;
246 // XXX: Have a separate instruction for non-indexed writes.
252 let comp_mask = mask;
255 let cf_inst = cfinst;
259 let Inst{31-0} = Word0;
260 let Inst{63-32} = Word1;
264 class LoadParamFrag <PatFrag load_type> : PatFrag <
265 (ops node:$ptr), (load_type node:$ptr),
266 [{ return isParamLoad(dyn_cast<LoadSDNode>(N)); }]
269 def load_param : LoadParamFrag<load>;
270 def load_param_zexti8 : LoadParamFrag<zextloadi8>;
271 def load_param_zexti16 : LoadParamFrag<zextloadi16>;
273 def isR600 : Predicate<"Subtarget.getGeneration() <= AMDGPUSubtarget::R700">;
274 def isR700 : Predicate<"Subtarget.getGeneration() == AMDGPUSubtarget::R700">;
275 def isEG : Predicate<
276 "Subtarget.getGeneration() >= AMDGPUSubtarget::EVERGREEN && "
277 "Subtarget.getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS && "
278 "!Subtarget.hasCaymanISA()">;
280 def isCayman : Predicate<"Subtarget.hasCaymanISA()">;
281 def isEGorCayman : Predicate<"Subtarget.getGeneration() == "
282 "AMDGPUSubtarget::EVERGREEN"
283 "|| Subtarget.getGeneration() =="
284 "AMDGPUSubtarget::NORTHERN_ISLANDS">;
286 def isR600toCayman : Predicate<
287 "Subtarget.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS">;
289 //===----------------------------------------------------------------------===//
291 //===----------------------------------------------------------------------===//
293 def INTERP_PAIR_XY : AMDGPUShaderInst <
294 (outs R600_TReg32_X:$dst0, R600_TReg32_Y:$dst1),
295 (ins i32imm:$src0, R600_TReg32_Y:$src1, R600_TReg32_X:$src2),
296 "INTERP_PAIR_XY $src0 $src1 $src2 : $dst0 dst1",
299 def INTERP_PAIR_ZW : AMDGPUShaderInst <
300 (outs R600_TReg32_Z:$dst0, R600_TReg32_W:$dst1),
301 (ins i32imm:$src0, R600_TReg32_Y:$src1, R600_TReg32_X:$src2),
302 "INTERP_PAIR_ZW $src0 $src1 $src2 : $dst0 dst1",
305 def CONST_ADDRESS: SDNode<"AMDGPUISD::CONST_ADDRESS",
306 SDTypeProfile<1, -1, [SDTCisInt<0>, SDTCisPtrTy<1>]>,
310 def DOT4 : SDNode<"AMDGPUISD::DOT4",
311 SDTypeProfile<1, 8, [SDTCisFP<0>, SDTCisVT<1, f32>, SDTCisVT<2, f32>,
312 SDTCisVT<3, f32>, SDTCisVT<4, f32>, SDTCisVT<5, f32>,
313 SDTCisVT<6, f32>, SDTCisVT<7, f32>, SDTCisVT<8, f32>]>,
317 def TEXTURE_FETCH_Type : SDTypeProfile<1, 19, [SDTCisFP<0>]>;
319 def TEXTURE_FETCH: SDNode<"AMDGPUISD::TEXTURE_FETCH", TEXTURE_FETCH_Type, []>;
321 multiclass TexPattern<bits<32> TextureOp, Instruction inst, ValueType vt = v4f32> {
322 def : Pat<(TEXTURE_FETCH (i32 TextureOp), vt:$SRC_GPR,
323 (i32 imm:$srcx), (i32 imm:$srcy), (i32 imm:$srcz), (i32 imm:$srcw),
324 (i32 imm:$offsetx), (i32 imm:$offsety), (i32 imm:$offsetz),
325 (i32 imm:$DST_SEL_X), (i32 imm:$DST_SEL_Y), (i32 imm:$DST_SEL_Z),
326 (i32 imm:$DST_SEL_W),
327 (i32 imm:$RESOURCE_ID), (i32 imm:$SAMPLER_ID),
328 (i32 imm:$COORD_TYPE_X), (i32 imm:$COORD_TYPE_Y), (i32 imm:$COORD_TYPE_Z),
329 (i32 imm:$COORD_TYPE_W)),
330 (inst R600_Reg128:$SRC_GPR,
331 imm:$srcx, imm:$srcy, imm:$srcz, imm:$srcw,
332 imm:$offsetx, imm:$offsety, imm:$offsetz,
333 imm:$DST_SEL_X, imm:$DST_SEL_Y, imm:$DST_SEL_Z,
335 imm:$RESOURCE_ID, imm:$SAMPLER_ID,
336 imm:$COORD_TYPE_X, imm:$COORD_TYPE_Y, imm:$COORD_TYPE_Z,
340 //===----------------------------------------------------------------------===//
341 // Interpolation Instructions
342 //===----------------------------------------------------------------------===//
344 def INTERP_VEC_LOAD : AMDGPUShaderInst <
345 (outs R600_Reg128:$dst),
347 "INTERP_LOAD $src0 : $dst",
350 def INTERP_XY : R600_2OP <0xD6, "INTERP_XY", []> {
351 let bank_swizzle = 5;
354 def INTERP_ZW : R600_2OP <0xD7, "INTERP_ZW", []> {
355 let bank_swizzle = 5;
358 def INTERP_LOAD_P0 : R600_1OP <0xE0, "INTERP_LOAD_P0", []>;
360 //===----------------------------------------------------------------------===//
361 // Export Instructions
362 //===----------------------------------------------------------------------===//
364 def ExportType : SDTypeProfile<0, 7, [SDTCisFP<0>, SDTCisInt<1>]>;
366 def EXPORT: SDNode<"AMDGPUISD::EXPORT", ExportType,
367 [SDNPHasChain, SDNPSideEffect]>;
370 field bits<32> Word0;
377 let Word0{12-0} = arraybase;
378 let Word0{14-13} = type;
379 let Word0{21-15} = gpr;
380 let Word0{22} = 0; // RW_REL
381 let Word0{29-23} = 0; // INDEX_GPR
382 let Word0{31-30} = elem_size;
385 class ExportSwzWord1 {
386 field bits<32> Word1;
395 let Word1{2-0} = sw_x;
396 let Word1{5-3} = sw_y;
397 let Word1{8-6} = sw_z;
398 let Word1{11-9} = sw_w;
401 class ExportBufWord1 {
402 field bits<32> Word1;
409 let Word1{11-0} = arraySize;
410 let Word1{15-12} = compMask;
413 multiclass ExportPattern<Instruction ExportInst, bits<8> cf_inst> {
414 def : Pat<(int_R600_store_pixel_depth R600_Reg32:$reg),
416 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), R600_Reg32:$reg, sub0),
417 0, 61, 0, 7, 7, 7, cf_inst, 0)
420 def : Pat<(int_R600_store_pixel_stencil R600_Reg32:$reg),
422 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), R600_Reg32:$reg, sub0),
423 0, 61, 7, 0, 7, 7, cf_inst, 0)
426 def : Pat<(int_R600_store_dummy (i32 imm:$type)),
428 (v4f32 (IMPLICIT_DEF)), imm:$type, 0, 7, 7, 7, 7, cf_inst, 0)
431 def : Pat<(int_R600_store_dummy 1),
433 (v4f32 (IMPLICIT_DEF)), 1, 60, 7, 7, 7, 7, cf_inst, 0)
436 def : Pat<(EXPORT (v4f32 R600_Reg128:$src), (i32 imm:$base), (i32 imm:$type),
437 (i32 imm:$swz_x), (i32 imm:$swz_y), (i32 imm:$swz_z), (i32 imm:$swz_w)),
438 (ExportInst R600_Reg128:$src, imm:$type, imm:$base,
439 imm:$swz_x, imm:$swz_y, imm:$swz_z, imm:$swz_w, cf_inst, 0)
444 multiclass SteamOutputExportPattern<Instruction ExportInst,
445 bits<8> buf0inst, bits<8> buf1inst, bits<8> buf2inst, bits<8> buf3inst> {
447 def : Pat<(int_R600_store_stream_output (v4f32 R600_Reg128:$src),
448 (i32 imm:$arraybase), (i32 0), (i32 imm:$mask)),
449 (ExportInst R600_Reg128:$src, 0, imm:$arraybase,
450 4095, imm:$mask, buf0inst, 0)>;
452 def : Pat<(int_R600_store_stream_output (v4f32 R600_Reg128:$src),
453 (i32 imm:$arraybase), (i32 1), (i32 imm:$mask)),
454 (ExportInst R600_Reg128:$src, 0, imm:$arraybase,
455 4095, imm:$mask, buf1inst, 0)>;
457 def : Pat<(int_R600_store_stream_output (v4f32 R600_Reg128:$src),
458 (i32 imm:$arraybase), (i32 2), (i32 imm:$mask)),
459 (ExportInst R600_Reg128:$src, 0, imm:$arraybase,
460 4095, imm:$mask, buf2inst, 0)>;
462 def : Pat<(int_R600_store_stream_output (v4f32 R600_Reg128:$src),
463 (i32 imm:$arraybase), (i32 3), (i32 imm:$mask)),
464 (ExportInst R600_Reg128:$src, 0, imm:$arraybase,
465 4095, imm:$mask, buf3inst, 0)>;
468 // Export Instructions should not be duplicated by TailDuplication pass
469 // (which assumes that duplicable instruction are affected by exec mask)
470 let usesCustomInserter = 1, isNotDuplicable = 1 in {
472 class ExportSwzInst : InstR600ISA<(
474 (ins R600_Reg128:$gpr, i32imm:$type, i32imm:$arraybase,
475 i32imm:$sw_x, i32imm:$sw_y, i32imm:$sw_z, i32imm:$sw_w, i32imm:$inst,
477 !strconcat("EXPORT", " $gpr"),
478 []>, ExportWord0, ExportSwzWord1 {
480 let Inst{31-0} = Word0;
481 let Inst{63-32} = Word1;
484 } // End usesCustomInserter = 1
486 class ExportBufInst : InstR600ISA<(
488 (ins R600_Reg128:$gpr, i32imm:$type, i32imm:$arraybase,
489 i32imm:$arraySize, i32imm:$compMask, i32imm:$inst, i32imm:$eop),
490 !strconcat("EXPORT", " $gpr"),
491 []>, ExportWord0, ExportBufWord1 {
493 let Inst{31-0} = Word0;
494 let Inst{63-32} = Word1;
497 //===----------------------------------------------------------------------===//
498 // Control Flow Instructions
499 //===----------------------------------------------------------------------===//
502 def KCACHE : InstFlag<"printKCache">;
504 class ALU_CLAUSE<bits<4> inst, string OpName> : AMDGPUInst <(outs),
505 (ins i32imm:$ADDR, i32imm:$KCACHE_BANK0, i32imm:$KCACHE_BANK1,
506 KCACHE:$KCACHE_MODE0, KCACHE:$KCACHE_MODE1,
507 i32imm:$KCACHE_ADDR0, i32imm:$KCACHE_ADDR1,
509 !strconcat(OpName, " $COUNT, @$ADDR, "
510 "KC0[$KCACHE_MODE0], KC1[$KCACHE_MODE1]"),
511 [] >, CF_ALU_WORD0, CF_ALU_WORD1 {
516 let WHOLE_QUAD_MODE = 0;
519 let Inst{31-0} = Word0;
520 let Inst{63-32} = Word1;
523 class CF_WORD0_R600 {
524 field bits<32> Word0;
531 class CF_CLAUSE_R600 <bits<7> inst, dag ins, string AsmPrint> : AMDGPUInst <(outs),
532 ins, AsmPrint, [] >, CF_WORD0_R600, CF_WORD1_R600 {
538 let VALID_PIXEL_MODE = 0;
542 let END_OF_PROGRAM = 0;
543 let WHOLE_QUAD_MODE = 0;
545 let Inst{31-0} = Word0;
546 let Inst{63-32} = Word1;
549 class CF_CLAUSE_EG <bits<8> inst, dag ins, string AsmPrint> : AMDGPUInst <(outs),
550 ins, AsmPrint, [] >, CF_WORD0_EG, CF_WORD1_EG {
555 let JUMPTABLE_SEL = 0;
557 let VALID_PIXEL_MODE = 0;
559 let END_OF_PROGRAM = 0;
561 let Inst{31-0} = Word0;
562 let Inst{63-32} = Word1;
565 def CF_ALU : ALU_CLAUSE<8, "ALU">;
566 def CF_ALU_PUSH_BEFORE : ALU_CLAUSE<9, "ALU_PUSH_BEFORE">;
568 def FETCH_CLAUSE : AMDGPUInst <(outs),
569 (ins i32imm:$addr), "Fetch clause starting at $addr:", [] > {
575 def ALU_CLAUSE : AMDGPUInst <(outs),
576 (ins i32imm:$addr), "ALU clause starting at $addr:", [] > {
582 def LITERALS : AMDGPUInst <(outs),
583 (ins LITERAL:$literal1, LITERAL:$literal2), "$literal1, $literal2", [] > {
588 let Inst{31-0} = literal1;
589 let Inst{63-32} = literal2;
592 def PAD : AMDGPUInst <(outs), (ins), "PAD", [] > {
596 let Predicates = [isR600toCayman] in {
598 //===----------------------------------------------------------------------===//
599 // Common Instructions R600, R700, Evergreen, Cayman
600 //===----------------------------------------------------------------------===//
602 def ADD : R600_2OP_Helper <0x0, "ADD", fadd>;
603 // Non-IEEE MUL: 0 * anything = 0
604 def MUL : R600_2OP_Helper <0x1, "MUL NON-IEEE", int_AMDGPU_mul>;
605 def MUL_IEEE : R600_2OP_Helper <0x2, "MUL_IEEE", fmul>;
606 def MAX : R600_2OP_Helper <0x3, "MAX", AMDGPUfmax>;
607 def MIN : R600_2OP_Helper <0x4, "MIN", AMDGPUfmin>;
609 // For the SET* instructions there is a naming conflict in TargetSelectionDAG.td,
610 // so some of the instruction names don't match the asm string.
611 // XXX: Use the defs in TargetSelectionDAG.td instead of intrinsics.
612 def SETE : R600_2OP <
614 [(set f32:$dst, (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_EQ))]
619 [(set f32:$dst, (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_GT))]
624 [(set f32:$dst, (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_GE))]
629 [(set f32:$dst, (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_NE))]
632 def SETE_DX10 : R600_2OP <
634 [(set i32:$dst, (selectcc f32:$src0, f32:$src1, -1, 0, COND_EQ))]
637 def SETGT_DX10 : R600_2OP <
639 [(set i32:$dst, (selectcc f32:$src0, f32:$src1, -1, 0, COND_GT))]
642 def SETGE_DX10 : R600_2OP <
644 [(set i32:$dst, (selectcc f32:$src0, f32:$src1, -1, 0, COND_GE))]
647 def SETNE_DX10 : R600_2OP <
649 [(set i32:$dst, (selectcc f32:$src0, f32:$src1, -1, 0, COND_NE))]
652 def FRACT : R600_1OP_Helper <0x10, "FRACT", AMDGPUfract>;
653 def TRUNC : R600_1OP_Helper <0x11, "TRUNC", int_AMDGPU_trunc>;
654 def CEIL : R600_1OP_Helper <0x12, "CEIL", fceil>;
655 def RNDNE : R600_1OP_Helper <0x13, "RNDNE", frint>;
656 def FLOOR : R600_1OP_Helper <0x14, "FLOOR", ffloor>;
658 def MOV : R600_1OP <0x19, "MOV", []>;
660 let isPseudo = 1, isCodeGenOnly = 1, usesCustomInserter = 1 in {
662 class MOV_IMM <ValueType vt, Operand immType> : AMDGPUInst <
663 (outs R600_Reg32:$dst),
669 } // end let isPseudo = 1, isCodeGenOnly = 1, usesCustomInserter = 1
671 def MOV_IMM_I32 : MOV_IMM<i32, i32imm>;
674 (MOV_IMM_I32 imm:$val)
677 def MOV_IMM_F32 : MOV_IMM<f32, f32imm>;
680 (MOV_IMM_F32 fpimm:$val)
683 def PRED_SETE : R600_2OP <0x20, "PRED_SETE", []>;
684 def PRED_SETGT : R600_2OP <0x21, "PRED_SETGT", []>;
685 def PRED_SETGE : R600_2OP <0x22, "PRED_SETGE", []>;
686 def PRED_SETNE : R600_2OP <0x23, "PRED_SETNE", []>;
688 let hasSideEffects = 1 in {
690 def KILLGT : R600_2OP <0x2D, "KILLGT", []>;
692 } // end hasSideEffects
694 def AND_INT : R600_2OP_Helper <0x30, "AND_INT", and>;
695 def OR_INT : R600_2OP_Helper <0x31, "OR_INT", or>;
696 def XOR_INT : R600_2OP_Helper <0x32, "XOR_INT", xor>;
697 def NOT_INT : R600_1OP_Helper <0x33, "NOT_INT", not>;
698 def ADD_INT : R600_2OP_Helper <0x34, "ADD_INT", add>;
699 def SUB_INT : R600_2OP_Helper <0x35, "SUB_INT", sub>;
700 def MAX_INT : R600_2OP_Helper <0x36, "MAX_INT", AMDGPUsmax>;
701 def MIN_INT : R600_2OP_Helper <0x37, "MIN_INT", AMDGPUsmin>;
702 def MAX_UINT : R600_2OP_Helper <0x38, "MAX_UINT", AMDGPUumax>;
703 def MIN_UINT : R600_2OP_Helper <0x39, "MIN_UINT", AMDGPUumin>;
705 def SETE_INT : R600_2OP <
707 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETEQ))]
710 def SETGT_INT : R600_2OP <
712 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETGT))]
715 def SETGE_INT : R600_2OP <
717 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETGE))]
720 def SETNE_INT : R600_2OP <
722 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETNE))]
725 def SETGT_UINT : R600_2OP <
727 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETUGT))]
730 def SETGE_UINT : R600_2OP <
732 [(set i32:$dst, (selectcc i32:$src0, i32:$src1, -1, 0, SETUGE))]
735 def PRED_SETE_INT : R600_2OP <0x42, "PRED_SETE_INT", []>;
736 def PRED_SETGT_INT : R600_2OP <0x43, "PRED_SETGE_INT", []>;
737 def PRED_SETGE_INT : R600_2OP <0x44, "PRED_SETGE_INT", []>;
738 def PRED_SETNE_INT : R600_2OP <0x45, "PRED_SETNE_INT", []>;
740 def CNDE_INT : R600_3OP <
742 [(set i32:$dst, (selectcc i32:$src0, 0, i32:$src1, i32:$src2, COND_EQ))]
745 def CNDGE_INT : R600_3OP <
747 [(set i32:$dst, (selectcc i32:$src0, 0, i32:$src1, i32:$src2, COND_GE))]
750 def CNDGT_INT : R600_3OP <
752 [(set i32:$dst, (selectcc i32:$src0, 0, i32:$src1, i32:$src2, COND_GT))]
755 //===----------------------------------------------------------------------===//
756 // Texture instructions
757 //===----------------------------------------------------------------------===//
759 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
761 class R600_TEX <bits<11> inst, string opName> :
762 InstR600 <(outs R600_Reg128:$DST_GPR),
763 (ins R600_Reg128:$SRC_GPR,
764 RSel:$srcx, RSel:$srcy, RSel:$srcz, RSel:$srcw,
765 i32imm:$offsetx, i32imm:$offsety, i32imm:$offsetz,
766 RSel:$DST_SEL_X, RSel:$DST_SEL_Y, RSel:$DST_SEL_Z, RSel:$DST_SEL_W,
767 i32imm:$RESOURCE_ID, i32imm:$SAMPLER_ID,
768 CT:$COORD_TYPE_X, CT:$COORD_TYPE_Y, CT:$COORD_TYPE_Z,
771 " $DST_GPR.$DST_SEL_X$DST_SEL_Y$DST_SEL_Z$DST_SEL_W, "
772 "$SRC_GPR.$srcx$srcy$srcz$srcw "
773 "RID:$RESOURCE_ID SID:$SAMPLER_ID "
774 "CT:$COORD_TYPE_X$COORD_TYPE_Y$COORD_TYPE_Z$COORD_TYPE_W"),
776 NullALU>, TEX_WORD0, TEX_WORD1, TEX_WORD2 {
777 let Inst{31-0} = Word0;
778 let Inst{63-32} = Word1;
780 let TEX_INST = inst{4-0};
786 let FETCH_WHOLE_QUAD = 0;
788 let SAMPLER_INDEX_MODE = 0;
789 let RESOURCE_INDEX_MODE = 0;
794 } // End mayLoad = 0, mayStore = 0, hasSideEffects = 0
798 def TEX_SAMPLE : R600_TEX <0x10, "TEX_SAMPLE">;
799 def TEX_SAMPLE_C : R600_TEX <0x18, "TEX_SAMPLE_C">;
800 def TEX_SAMPLE_L : R600_TEX <0x11, "TEX_SAMPLE_L">;
801 def TEX_SAMPLE_C_L : R600_TEX <0x19, "TEX_SAMPLE_C_L">;
802 def TEX_SAMPLE_LB : R600_TEX <0x12, "TEX_SAMPLE_LB">;
803 def TEX_SAMPLE_C_LB : R600_TEX <0x1A, "TEX_SAMPLE_C_LB">;
804 def TEX_LD : R600_TEX <0x03, "TEX_LD">;
805 def TEX_GET_TEXTURE_RESINFO : R600_TEX <0x04, "TEX_GET_TEXTURE_RESINFO">;
806 def TEX_GET_GRADIENTS_H : R600_TEX <0x07, "TEX_GET_GRADIENTS_H">;
807 def TEX_GET_GRADIENTS_V : R600_TEX <0x08, "TEX_GET_GRADIENTS_V">;
808 def TEX_SET_GRADIENTS_H : R600_TEX <0x0B, "TEX_SET_GRADIENTS_H">;
809 def TEX_SET_GRADIENTS_V : R600_TEX <0x0C, "TEX_SET_GRADIENTS_V">;
810 def TEX_SAMPLE_G : R600_TEX <0x14, "TEX_SAMPLE_G">;
811 def TEX_SAMPLE_C_G : R600_TEX <0x1C, "TEX_SAMPLE_C_G">;
813 defm : TexPattern<0, TEX_SAMPLE>;
814 defm : TexPattern<1, TEX_SAMPLE_C>;
815 defm : TexPattern<2, TEX_SAMPLE_L>;
816 defm : TexPattern<3, TEX_SAMPLE_C_L>;
817 defm : TexPattern<4, TEX_SAMPLE_LB>;
818 defm : TexPattern<5, TEX_SAMPLE_C_LB>;
819 defm : TexPattern<6, TEX_LD, v4i32>;
820 defm : TexPattern<7, TEX_GET_TEXTURE_RESINFO, v4i32>;
821 defm : TexPattern<8, TEX_GET_GRADIENTS_H>;
822 defm : TexPattern<9, TEX_GET_GRADIENTS_V>;
824 //===----------------------------------------------------------------------===//
825 // Helper classes for common instructions
826 //===----------------------------------------------------------------------===//
828 class MUL_LIT_Common <bits<5> inst> : R600_3OP <
833 class MULADD_Common <bits<5> inst> : R600_3OP <
838 class MULADD_IEEE_Common <bits<5> inst> : R600_3OP <
840 [(set f32:$dst, (fadd (fmul f32:$src0, f32:$src1), f32:$src2))]
843 class CNDE_Common <bits<5> inst> : R600_3OP <
845 [(set f32:$dst, (selectcc f32:$src0, FP_ZERO, f32:$src1, f32:$src2, COND_EQ))]
848 class CNDGT_Common <bits<5> inst> : R600_3OP <
850 [(set f32:$dst, (selectcc f32:$src0, FP_ZERO, f32:$src1, f32:$src2, COND_GT))]
853 class CNDGE_Common <bits<5> inst> : R600_3OP <
855 [(set f32:$dst, (selectcc f32:$src0, FP_ZERO, f32:$src1, f32:$src2, COND_GE))]
859 let isCodeGenOnly = 1, isPseudo = 1, Namespace = "AMDGPU" in {
860 class R600_VEC2OP<list<dag> pattern> : InstR600 <(outs R600_Reg32:$dst), (ins
862 UEM:$update_exec_mask_X, UP:$update_pred_X, WRITE:$write_X,
863 OMOD:$omod_X, REL:$dst_rel_X, CLAMP:$clamp_X,
864 R600_TReg32_X:$src0_X, NEG:$src0_neg_X, REL:$src0_rel_X, ABS:$src0_abs_X, SEL:$src0_sel_X,
865 R600_TReg32_X:$src1_X, NEG:$src1_neg_X, REL:$src1_rel_X, ABS:$src1_abs_X, SEL:$src1_sel_X,
866 R600_Pred:$pred_sel_X,
868 UEM:$update_exec_mask_Y, UP:$update_pred_Y, WRITE:$write_Y,
869 OMOD:$omod_Y, REL:$dst_rel_Y, CLAMP:$clamp_Y,
870 R600_TReg32_Y:$src0_Y, NEG:$src0_neg_Y, REL:$src0_rel_Y, ABS:$src0_abs_Y, SEL:$src0_sel_Y,
871 R600_TReg32_Y:$src1_Y, NEG:$src1_neg_Y, REL:$src1_rel_Y, ABS:$src1_abs_Y, SEL:$src1_sel_Y,
872 R600_Pred:$pred_sel_Y,
874 UEM:$update_exec_mask_Z, UP:$update_pred_Z, WRITE:$write_Z,
875 OMOD:$omod_Z, REL:$dst_rel_Z, CLAMP:$clamp_Z,
876 R600_TReg32_Z:$src0_Z, NEG:$src0_neg_Z, REL:$src0_rel_Z, ABS:$src0_abs_Z, SEL:$src0_sel_Z,
877 R600_TReg32_Z:$src1_Z, NEG:$src1_neg_Z, REL:$src1_rel_Z, ABS:$src1_abs_Z, SEL:$src1_sel_Z,
878 R600_Pred:$pred_sel_Z,
880 UEM:$update_exec_mask_W, UP:$update_pred_W, WRITE:$write_W,
881 OMOD:$omod_W, REL:$dst_rel_W, CLAMP:$clamp_W,
882 R600_TReg32_W:$src0_W, NEG:$src0_neg_W, REL:$src0_rel_W, ABS:$src0_abs_W, SEL:$src0_sel_W,
883 R600_TReg32_W:$src1_W, NEG:$src1_neg_W, REL:$src1_rel_W, ABS:$src1_abs_W, SEL:$src1_sel_W,
884 R600_Pred:$pred_sel_W,
885 LITERAL:$literal0, LITERAL:$literal1),
891 def DOT_4 : R600_VEC2OP<[(set R600_Reg32:$dst, (DOT4
892 R600_TReg32_X:$src0_X, R600_TReg32_X:$src1_X,
893 R600_TReg32_Y:$src0_Y, R600_TReg32_Y:$src1_Y,
894 R600_TReg32_Z:$src0_Z, R600_TReg32_Z:$src1_Z,
895 R600_TReg32_W:$src0_W, R600_TReg32_W:$src1_W))]>;
898 class DOT4_Common <bits<11> inst> : R600_2OP <inst, "DOT4", []>;
901 let mayLoad = 0, mayStore = 0, hasSideEffects = 0 in {
902 multiclass CUBE_Common <bits<11> inst> {
904 def _pseudo : InstR600 <
905 (outs R600_Reg128:$dst),
906 (ins R600_Reg128:$src),
908 [(set v4f32:$dst, (int_AMDGPU_cube v4f32:$src))],
914 def _real : R600_2OP <inst, "CUBE", []>;
916 } // End mayLoad = 0, mayStore = 0, hasSideEffects = 0
918 class EXP_IEEE_Common <bits<11> inst> : R600_1OP_Helper <
919 inst, "EXP_IEEE", fexp2
922 let Itinerary = TransALU;
925 class FLT_TO_INT_Common <bits<11> inst> : R600_1OP_Helper <
926 inst, "FLT_TO_INT", fp_to_sint
929 let Itinerary = TransALU;
932 class INT_TO_FLT_Common <bits<11> inst> : R600_1OP_Helper <
933 inst, "INT_TO_FLT", sint_to_fp
936 let Itinerary = TransALU;
939 class FLT_TO_UINT_Common <bits<11> inst> : R600_1OP_Helper <
940 inst, "FLT_TO_UINT", fp_to_uint
943 let Itinerary = TransALU;
946 class UINT_TO_FLT_Common <bits<11> inst> : R600_1OP_Helper <
947 inst, "UINT_TO_FLT", uint_to_fp
950 let Itinerary = TransALU;
953 class LOG_CLAMPED_Common <bits<11> inst> : R600_1OP <
954 inst, "LOG_CLAMPED", []
957 class LOG_IEEE_Common <bits<11> inst> : R600_1OP_Helper <
958 inst, "LOG_IEEE", flog2
961 let Itinerary = TransALU;
964 class LSHL_Common <bits<11> inst> : R600_2OP_Helper <inst, "LSHL", shl>;
965 class LSHR_Common <bits<11> inst> : R600_2OP_Helper <inst, "LSHR", srl>;
966 class ASHR_Common <bits<11> inst> : R600_2OP_Helper <inst, "ASHR", sra>;
967 class MULHI_INT_Common <bits<11> inst> : R600_2OP_Helper <
968 inst, "MULHI_INT", mulhs
971 let Itinerary = TransALU;
973 class MULHI_UINT_Common <bits<11> inst> : R600_2OP_Helper <
977 let Itinerary = TransALU;
979 class MULLO_INT_Common <bits<11> inst> : R600_2OP_Helper <
980 inst, "MULLO_INT", mul
983 let Itinerary = TransALU;
985 class MULLO_UINT_Common <bits<11> inst> : R600_2OP <inst, "MULLO_UINT", []> {
987 let Itinerary = TransALU;
990 class RECIP_CLAMPED_Common <bits<11> inst> : R600_1OP <
991 inst, "RECIP_CLAMPED", []
994 let Itinerary = TransALU;
997 class RECIP_IEEE_Common <bits<11> inst> : R600_1OP <
998 inst, "RECIP_IEEE", [(set f32:$dst, (fdiv FP_ONE, f32:$src0))]
1001 let Itinerary = TransALU;
1004 class RECIP_UINT_Common <bits<11> inst> : R600_1OP_Helper <
1005 inst, "RECIP_UINT", AMDGPUurecip
1008 let Itinerary = TransALU;
1011 class RECIPSQRT_CLAMPED_Common <bits<11> inst> : R600_1OP_Helper <
1012 inst, "RECIPSQRT_CLAMPED", int_AMDGPU_rsq
1015 let Itinerary = TransALU;
1018 class RECIPSQRT_IEEE_Common <bits<11> inst> : R600_1OP <
1019 inst, "RECIPSQRT_IEEE", []
1022 let Itinerary = TransALU;
1025 class SIN_Common <bits<11> inst> : R600_1OP <
1029 let Itinerary = TransALU;
1032 class COS_Common <bits<11> inst> : R600_1OP <
1036 let Itinerary = TransALU;
1039 //===----------------------------------------------------------------------===//
1040 // Helper patterns for complex intrinsics
1041 //===----------------------------------------------------------------------===//
1043 multiclass DIV_Common <InstR600 recip_ieee> {
1045 (int_AMDGPU_div f32:$src0, f32:$src1),
1046 (MUL_IEEE $src0, (recip_ieee $src1))
1050 (fdiv f32:$src0, f32:$src1),
1051 (MUL_IEEE $src0, (recip_ieee $src1))
1055 class TGSI_LIT_Z_Common <InstR600 mul_lit, InstR600 log_clamped, InstR600 exp_ieee>
1057 (int_TGSI_lit_z f32:$src_x, f32:$src_y, f32:$src_w),
1058 (exp_ieee (mul_lit (log_clamped (MAX $src_y, (f32 ZERO))), $src_w, $src_x))
1061 //===----------------------------------------------------------------------===//
1062 // R600 / R700 Instructions
1063 //===----------------------------------------------------------------------===//
1065 let Predicates = [isR600] in {
1067 def MUL_LIT_r600 : MUL_LIT_Common<0x0C>;
1068 def MULADD_r600 : MULADD_Common<0x10>;
1069 def MULADD_IEEE_r600 : MULADD_IEEE_Common<0x14>;
1070 def CNDE_r600 : CNDE_Common<0x18>;
1071 def CNDGT_r600 : CNDGT_Common<0x19>;
1072 def CNDGE_r600 : CNDGE_Common<0x1A>;
1073 def DOT4_r600 : DOT4_Common<0x50>;
1074 defm CUBE_r600 : CUBE_Common<0x52>;
1075 def EXP_IEEE_r600 : EXP_IEEE_Common<0x61>;
1076 def LOG_CLAMPED_r600 : LOG_CLAMPED_Common<0x62>;
1077 def LOG_IEEE_r600 : LOG_IEEE_Common<0x63>;
1078 def RECIP_CLAMPED_r600 : RECIP_CLAMPED_Common<0x64>;
1079 def RECIP_IEEE_r600 : RECIP_IEEE_Common<0x66>;
1080 def RECIPSQRT_CLAMPED_r600 : RECIPSQRT_CLAMPED_Common<0x67>;
1081 def RECIPSQRT_IEEE_r600 : RECIPSQRT_IEEE_Common<0x69>;
1082 def FLT_TO_INT_r600 : FLT_TO_INT_Common<0x6b>;
1083 def INT_TO_FLT_r600 : INT_TO_FLT_Common<0x6c>;
1084 def FLT_TO_UINT_r600 : FLT_TO_UINT_Common<0x79>;
1085 def UINT_TO_FLT_r600 : UINT_TO_FLT_Common<0x6d>;
1086 def SIN_r600 : SIN_Common<0x6E>;
1087 def COS_r600 : COS_Common<0x6F>;
1088 def ASHR_r600 : ASHR_Common<0x70>;
1089 def LSHR_r600 : LSHR_Common<0x71>;
1090 def LSHL_r600 : LSHL_Common<0x72>;
1091 def MULLO_INT_r600 : MULLO_INT_Common<0x73>;
1092 def MULHI_INT_r600 : MULHI_INT_Common<0x74>;
1093 def MULLO_UINT_r600 : MULLO_UINT_Common<0x75>;
1094 def MULHI_UINT_r600 : MULHI_UINT_Common<0x76>;
1095 def RECIP_UINT_r600 : RECIP_UINT_Common <0x78>;
1097 defm DIV_r600 : DIV_Common<RECIP_IEEE_r600>;
1098 def : POW_Common <LOG_IEEE_r600, EXP_IEEE_r600, MUL>;
1099 def TGSI_LIT_Z_r600 : TGSI_LIT_Z_Common<MUL_LIT_r600, LOG_CLAMPED_r600, EXP_IEEE_r600>;
1101 def : Pat<(fsqrt f32:$src), (MUL $src, (RECIPSQRT_CLAMPED_r600 $src))>;
1103 def R600_ExportSwz : ExportSwzInst {
1104 let Word1{20-17} = 0; // BURST_COUNT
1105 let Word1{21} = eop;
1106 let Word1{22} = 1; // VALID_PIXEL_MODE
1107 let Word1{30-23} = inst;
1108 let Word1{31} = 1; // BARRIER
1110 defm : ExportPattern<R600_ExportSwz, 39>;
1112 def R600_ExportBuf : ExportBufInst {
1113 let Word1{20-17} = 0; // BURST_COUNT
1114 let Word1{21} = eop;
1115 let Word1{22} = 1; // VALID_PIXEL_MODE
1116 let Word1{30-23} = inst;
1117 let Word1{31} = 1; // BARRIER
1119 defm : SteamOutputExportPattern<R600_ExportBuf, 0x20, 0x21, 0x22, 0x23>;
1121 def CF_TC_R600 : CF_CLAUSE_R600<1, (ins i32imm:$ADDR, i32imm:$COUNT),
1122 "TEX $COUNT @$ADDR"> {
1125 def CF_VC_R600 : CF_CLAUSE_R600<2, (ins i32imm:$ADDR, i32imm:$COUNT),
1126 "VTX $COUNT @$ADDR"> {
1129 def WHILE_LOOP_R600 : CF_CLAUSE_R600<6, (ins i32imm:$ADDR),
1130 "LOOP_START_DX10 @$ADDR"> {
1134 def END_LOOP_R600 : CF_CLAUSE_R600<5, (ins i32imm:$ADDR), "END_LOOP @$ADDR"> {
1138 def LOOP_BREAK_R600 : CF_CLAUSE_R600<9, (ins i32imm:$ADDR),
1139 "LOOP_BREAK @$ADDR"> {
1143 def CF_CONTINUE_R600 : CF_CLAUSE_R600<8, (ins i32imm:$ADDR),
1144 "CONTINUE @$ADDR"> {
1148 def CF_JUMP_R600 : CF_CLAUSE_R600<10, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1149 "JUMP @$ADDR POP:$POP_COUNT"> {
1152 def CF_ELSE_R600 : CF_CLAUSE_R600<13, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1153 "ELSE @$ADDR POP:$POP_COUNT"> {
1156 def CF_CALL_FS_R600 : CF_CLAUSE_R600<19, (ins), "CALL_FS"> {
1161 def POP_R600 : CF_CLAUSE_R600<14, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1162 "POP @$ADDR POP:$POP_COUNT"> {
1165 def CF_END_R600 : CF_CLAUSE_R600<0, (ins), "CF_END"> {
1169 let END_OF_PROGRAM = 1;
1174 // Helper pattern for normalizing inputs to triginomic instructions for R700+
1176 class COS_PAT <InstR600 trig> : Pat<
1178 (trig (MUL_IEEE (MOV_IMM_I32 CONST.TWO_PI_INV), $src))
1181 class SIN_PAT <InstR600 trig> : Pat<
1183 (trig (MUL_IEEE (MOV_IMM_I32 CONST.TWO_PI_INV), $src))
1186 //===----------------------------------------------------------------------===//
1187 // R700 Only instructions
1188 //===----------------------------------------------------------------------===//
1190 let Predicates = [isR700] in {
1191 def SIN_r700 : SIN_Common<0x6E>;
1192 def COS_r700 : COS_Common<0x6F>;
1194 // R700 normalizes inputs to SIN/COS the same as EG
1195 def : SIN_PAT <SIN_r700>;
1196 def : COS_PAT <COS_r700>;
1199 //===----------------------------------------------------------------------===//
1200 // Evergreen Only instructions
1201 //===----------------------------------------------------------------------===//
1203 let Predicates = [isEG] in {
1205 def RECIP_IEEE_eg : RECIP_IEEE_Common<0x86>;
1206 defm DIV_eg : DIV_Common<RECIP_IEEE_eg>;
1208 def MULLO_INT_eg : MULLO_INT_Common<0x8F>;
1209 def MULHI_INT_eg : MULHI_INT_Common<0x90>;
1210 def MULLO_UINT_eg : MULLO_UINT_Common<0x91>;
1211 def MULHI_UINT_eg : MULHI_UINT_Common<0x92>;
1212 def RECIP_UINT_eg : RECIP_UINT_Common<0x94>;
1213 def RECIPSQRT_CLAMPED_eg : RECIPSQRT_CLAMPED_Common<0x87>;
1214 def EXP_IEEE_eg : EXP_IEEE_Common<0x81>;
1215 def LOG_IEEE_eg : LOG_IEEE_Common<0x83>;
1216 def RECIP_CLAMPED_eg : RECIP_CLAMPED_Common<0x84>;
1217 def RECIPSQRT_IEEE_eg : RECIPSQRT_IEEE_Common<0x89>;
1218 def SIN_eg : SIN_Common<0x8D>;
1219 def COS_eg : COS_Common<0x8E>;
1221 def : POW_Common <LOG_IEEE_eg, EXP_IEEE_eg, MUL>;
1222 def : SIN_PAT <SIN_eg>;
1223 def : COS_PAT <COS_eg>;
1224 def : Pat<(fsqrt f32:$src), (MUL $src, (RECIPSQRT_CLAMPED_eg $src))>;
1226 //===----------------------------------------------------------------------===//
1227 // Memory read/write instructions
1228 //===----------------------------------------------------------------------===//
1229 let usesCustomInserter = 1 in {
1231 class RAT_WRITE_CACHELESS_eg <dag ins, bits<4> mask, string name,
1233 : EG_CF_RAT <0x57, 0x2, mask, (outs), ins, name, pattern> {
1236 } // End usesCustomInserter = 1
1239 def RAT_WRITE_CACHELESS_32_eg : RAT_WRITE_CACHELESS_eg <
1240 (ins R600_TReg32_X:$rw_gpr, R600_TReg32_X:$index_gpr, InstFlag:$eop),
1241 0x1, "RAT_WRITE_CACHELESS_32_eg $rw_gpr, $index_gpr, $eop",
1242 [(global_store i32:$rw_gpr, i32:$index_gpr)]
1246 def RAT_WRITE_CACHELESS_128_eg : RAT_WRITE_CACHELESS_eg <
1247 (ins R600_Reg128:$rw_gpr, R600_TReg32_X:$index_gpr, InstFlag:$eop),
1248 0xf, "RAT_WRITE_CACHELESS_128 $rw_gpr.XYZW, $index_gpr, $eop",
1249 [(global_store v4i32:$rw_gpr, i32:$index_gpr)]
1252 } // End Predicates = [isEG]
1254 //===----------------------------------------------------------------------===//
1255 // Evergreen / Cayman Instructions
1256 //===----------------------------------------------------------------------===//
1258 let Predicates = [isEGorCayman] in {
1260 // BFE_UINT - bit_extract, an optimization for mask and shift
1265 // bit_extract = (Input << (32 - Offset - Width)) >> (32 - Width)
1270 // (0, 8) = (Input << 24) >> 24 = (Input & 0xff) >> 0
1271 // (8, 8) = (Input << 16) >> 24 = (Input & 0xffff) >> 8
1272 // (16,8) = (Input << 8) >> 24 = (Input & 0xffffff) >> 16
1273 // (24,8) = (Input << 0) >> 24 = (Input & 0xffffffff) >> 24
1274 def BFE_UINT_eg : R600_3OP <0x4, "BFE_UINT",
1275 [(set i32:$dst, (int_AMDIL_bit_extract_u32 i32:$src0, i32:$src1,
1279 def : BFEPattern <BFE_UINT_eg>;
1281 def BFI_INT_eg : R600_3OP <0x06, "BFI_INT", [], VecALU>;
1282 defm : BFIPatterns <BFI_INT_eg>;
1284 def BIT_ALIGN_INT_eg : R600_3OP <0xC, "BIT_ALIGN_INT", [], VecALU>;
1285 def : ROTRPattern <BIT_ALIGN_INT_eg>;
1287 def MULADD_eg : MULADD_Common<0x14>;
1288 def MULADD_IEEE_eg : MULADD_IEEE_Common<0x18>;
1289 def ASHR_eg : ASHR_Common<0x15>;
1290 def LSHR_eg : LSHR_Common<0x16>;
1291 def LSHL_eg : LSHL_Common<0x17>;
1292 def CNDE_eg : CNDE_Common<0x19>;
1293 def CNDGT_eg : CNDGT_Common<0x1A>;
1294 def CNDGE_eg : CNDGE_Common<0x1B>;
1295 def MUL_LIT_eg : MUL_LIT_Common<0x1F>;
1296 def LOG_CLAMPED_eg : LOG_CLAMPED_Common<0x82>;
1297 def DOT4_eg : DOT4_Common<0xBE>;
1298 defm CUBE_eg : CUBE_Common<0xC0>;
1300 let hasSideEffects = 1 in {
1301 def MOVA_INT_eg : R600_1OP <0xCC, "MOVA_INT", []>;
1304 def TGSI_LIT_Z_eg : TGSI_LIT_Z_Common<MUL_LIT_eg, LOG_CLAMPED_eg, EXP_IEEE_eg>;
1306 def FLT_TO_INT_eg : FLT_TO_INT_Common<0x50> {
1310 def INT_TO_FLT_eg : INT_TO_FLT_Common<0x9B>;
1312 def FLT_TO_UINT_eg : FLT_TO_UINT_Common<0x9A> {
1316 def UINT_TO_FLT_eg : UINT_TO_FLT_Common<0x9C>;
1318 // TRUNC is used for the FLT_TO_INT instructions to work around a
1319 // perceived problem where the rounding modes are applied differently
1320 // depending on the instruction and the slot they are in.
1322 // https://bugs.freedesktop.org/show_bug.cgi?id=50232
1323 // Mesa commit: a1a0974401c467cb86ef818f22df67c21774a38c
1325 // XXX: Lowering SELECT_CC will sometimes generate fp_to_[su]int nodes,
1326 // which do not need to be truncated since the fp values are 0.0f or 1.0f.
1327 // We should look into handling these cases separately.
1328 def : Pat<(fp_to_sint f32:$src0), (FLT_TO_INT_eg (TRUNC $src0))>;
1330 def : Pat<(fp_to_uint f32:$src0), (FLT_TO_UINT_eg (TRUNC $src0))>;
1333 def : SHA256MaPattern <BFI_INT_eg, XOR_INT>;
1335 def EG_ExportSwz : ExportSwzInst {
1336 let Word1{19-16} = 0; // BURST_COUNT
1337 let Word1{20} = 1; // VALID_PIXEL_MODE
1338 let Word1{21} = eop;
1339 let Word1{29-22} = inst;
1340 let Word1{30} = 0; // MARK
1341 let Word1{31} = 1; // BARRIER
1343 defm : ExportPattern<EG_ExportSwz, 83>;
1345 def EG_ExportBuf : ExportBufInst {
1346 let Word1{19-16} = 0; // BURST_COUNT
1347 let Word1{20} = 1; // VALID_PIXEL_MODE
1348 let Word1{21} = eop;
1349 let Word1{29-22} = inst;
1350 let Word1{30} = 0; // MARK
1351 let Word1{31} = 1; // BARRIER
1353 defm : SteamOutputExportPattern<EG_ExportBuf, 0x40, 0x41, 0x42, 0x43>;
1355 def CF_TC_EG : CF_CLAUSE_EG<1, (ins i32imm:$ADDR, i32imm:$COUNT),
1356 "TEX $COUNT @$ADDR"> {
1359 def CF_VC_EG : CF_CLAUSE_EG<2, (ins i32imm:$ADDR, i32imm:$COUNT),
1360 "VTX $COUNT @$ADDR"> {
1363 def WHILE_LOOP_EG : CF_CLAUSE_EG<6, (ins i32imm:$ADDR),
1364 "LOOP_START_DX10 @$ADDR"> {
1368 def END_LOOP_EG : CF_CLAUSE_EG<5, (ins i32imm:$ADDR), "END_LOOP @$ADDR"> {
1372 def LOOP_BREAK_EG : CF_CLAUSE_EG<9, (ins i32imm:$ADDR),
1373 "LOOP_BREAK @$ADDR"> {
1377 def CF_CONTINUE_EG : CF_CLAUSE_EG<8, (ins i32imm:$ADDR),
1378 "CONTINUE @$ADDR"> {
1382 def CF_JUMP_EG : CF_CLAUSE_EG<10, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1383 "JUMP @$ADDR POP:$POP_COUNT"> {
1386 def CF_ELSE_EG : CF_CLAUSE_EG<13, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1387 "ELSE @$ADDR POP:$POP_COUNT"> {
1390 def CF_CALL_FS_EG : CF_CLAUSE_EG<19, (ins), "CALL_FS"> {
1395 def POP_EG : CF_CLAUSE_EG<14, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
1396 "POP @$ADDR POP:$POP_COUNT"> {
1399 def CF_END_EG : CF_CLAUSE_EG<0, (ins), "CF_END"> {
1403 let END_OF_PROGRAM = 1;
1406 //===----------------------------------------------------------------------===//
1407 // Memory read/write instructions
1408 //===----------------------------------------------------------------------===//
1410 class VTX_READ_eg <string name, bits<8> buffer_id, dag outs, list<dag> pattern>
1411 : InstR600ISA <outs, (ins MEMxi:$ptr), name, pattern>,
1412 VTX_WORD1_GPR, VTX_WORD0 {
1417 let FETCH_WHOLE_QUAD = 0;
1418 let BUFFER_ID = buffer_id;
1420 // XXX: We can infer this field based on the SRC_GPR. This would allow us
1421 // to store vertex addresses in any channel, not just X.
1424 // The docs say that if this bit is set, then DATA_FORMAT, NUM_FORMAT_ALL,
1425 // FORMAT_COMP_ALL, SRF_MODE_ALL, and ENDIAN_SWAP fields will be ignored,
1426 // however, based on my testing if USE_CONST_FIELDS is set, then all
1427 // these fields need to be set to 0.
1428 let USE_CONST_FIELDS = 0;
1429 let NUM_FORMAT_ALL = 1;
1430 let FORMAT_COMP_ALL = 0;
1431 let SRF_MODE_ALL = 0;
1433 let Inst{31-0} = Word0;
1434 let Inst{63-32} = Word1;
1435 // LLVM can only encode 64-bit instructions, so these fields are manually
1436 // encoded in R600CodeEmitter
1439 // bits<2> ENDIAN_SWAP = 0;
1440 // bits<1> CONST_BUF_NO_STRIDE = 0;
1441 // bits<1> MEGA_FETCH = 0;
1442 // bits<1> ALT_CONST = 0;
1443 // bits<2> BUFFER_INDEX_MODE = 0;
1447 // VTX_WORD2 (LLVM can only encode 64-bit instructions, so WORD2 encoding
1448 // is done in R600CodeEmitter
1450 // Inst{79-64} = OFFSET;
1451 // Inst{81-80} = ENDIAN_SWAP;
1452 // Inst{82} = CONST_BUF_NO_STRIDE;
1453 // Inst{83} = MEGA_FETCH;
1454 // Inst{84} = ALT_CONST;
1455 // Inst{86-85} = BUFFER_INDEX_MODE;
1456 // Inst{95-86} = 0; Reserved
1458 // VTX_WORD3 (Padding)
1460 // Inst{127-96} = 0;
1465 class VTX_READ_8_eg <bits<8> buffer_id, list<dag> pattern>
1466 : VTX_READ_eg <"VTX_READ_8 $dst, $ptr", buffer_id, (outs R600_TReg32_X:$dst),
1469 let MEGA_FETCH_COUNT = 1;
1471 let DST_SEL_Y = 7; // Masked
1472 let DST_SEL_Z = 7; // Masked
1473 let DST_SEL_W = 7; // Masked
1474 let DATA_FORMAT = 1; // FMT_8
1477 class VTX_READ_16_eg <bits<8> buffer_id, list<dag> pattern>
1478 : VTX_READ_eg <"VTX_READ_16 $dst, $ptr", buffer_id, (outs R600_TReg32_X:$dst),
1480 let MEGA_FETCH_COUNT = 2;
1482 let DST_SEL_Y = 7; // Masked
1483 let DST_SEL_Z = 7; // Masked
1484 let DST_SEL_W = 7; // Masked
1485 let DATA_FORMAT = 5; // FMT_16
1489 class VTX_READ_32_eg <bits<8> buffer_id, list<dag> pattern>
1490 : VTX_READ_eg <"VTX_READ_32 $dst, $ptr", buffer_id, (outs R600_TReg32_X:$dst),
1493 let MEGA_FETCH_COUNT = 4;
1495 let DST_SEL_Y = 7; // Masked
1496 let DST_SEL_Z = 7; // Masked
1497 let DST_SEL_W = 7; // Masked
1498 let DATA_FORMAT = 0xD; // COLOR_32
1500 // This is not really necessary, but there were some GPU hangs that appeared
1501 // to be caused by ALU instructions in the next instruction group that wrote
1502 // to the $ptr registers of the VTX_READ.
1504 // %T3_X<def> = VTX_READ_PARAM_32_eg %T2_X<kill>, 24
1505 // %T2_X<def> = MOV %ZERO
1506 //Adding this constraint prevents this from happening.
1507 let Constraints = "$ptr.ptr = $dst";
1510 class VTX_READ_128_eg <bits<8> buffer_id, list<dag> pattern>
1511 : VTX_READ_eg <"VTX_READ_128 $dst.XYZW, $ptr", buffer_id, (outs R600_Reg128:$dst),
1514 let MEGA_FETCH_COUNT = 16;
1519 let DATA_FORMAT = 0x22; // COLOR_32_32_32_32
1521 // XXX: Need to force VTX_READ_128 instructions to write to the same register
1522 // that holds its buffer address to avoid potential hangs. We can't use
1523 // the same constraint as VTX_READ_32_eg, because the $ptr.ptr and $dst
1524 // registers are different sizes.
1527 //===----------------------------------------------------------------------===//
1528 // VTX Read from parameter memory space
1529 //===----------------------------------------------------------------------===//
1531 def VTX_READ_PARAM_8_eg : VTX_READ_8_eg <0,
1532 [(set i32:$dst, (load_param_zexti8 ADDRVTX_READ:$ptr))]
1535 def VTX_READ_PARAM_16_eg : VTX_READ_16_eg <0,
1536 [(set i32:$dst, (load_param_zexti16 ADDRVTX_READ:$ptr))]
1539 def VTX_READ_PARAM_32_eg : VTX_READ_32_eg <0,
1540 [(set i32:$dst, (load_param ADDRVTX_READ:$ptr))]
1543 def VTX_READ_PARAM_128_eg : VTX_READ_128_eg <0,
1544 [(set v4i32:$dst, (load_param ADDRVTX_READ:$ptr))]
1547 //===----------------------------------------------------------------------===//
1548 // VTX Read from global memory space
1549 //===----------------------------------------------------------------------===//
1552 def VTX_READ_GLOBAL_8_eg : VTX_READ_8_eg <1,
1553 [(set i32:$dst, (zextloadi8_global ADDRVTX_READ:$ptr))]
1557 def VTX_READ_GLOBAL_32_eg : VTX_READ_32_eg <1,
1558 [(set i32:$dst, (global_load ADDRVTX_READ:$ptr))]
1562 def VTX_READ_GLOBAL_128_eg : VTX_READ_128_eg <1,
1563 [(set v4i32:$dst, (global_load ADDRVTX_READ:$ptr))]
1566 //===----------------------------------------------------------------------===//
1568 // XXX: We are currently storing all constants in the global address space.
1569 //===----------------------------------------------------------------------===//
1571 def CONSTANT_LOAD_eg : VTX_READ_32_eg <1,
1572 [(set i32:$dst, (constant_load ADDRVTX_READ:$ptr))]
1577 //===----------------------------------------------------------------------===//
1578 // Regist loads and stores - for indirect addressing
1579 //===----------------------------------------------------------------------===//
1581 defm R600_ : RegisterLoadStore <R600_Reg32, FRAMEri, ADDRIndirect>;
1583 //===----------------------------------------------------------------------===//
1584 // Cayman Instructions
1585 //===----------------------------------------------------------------------===//
1587 let Predicates = [isCayman] in {
1589 let isVector = 1 in {
1591 def RECIP_IEEE_cm : RECIP_IEEE_Common<0x86>;
1593 def MULLO_INT_cm : MULLO_INT_Common<0x8F>;
1594 def MULHI_INT_cm : MULHI_INT_Common<0x90>;
1595 def MULLO_UINT_cm : MULLO_UINT_Common<0x91>;
1596 def MULHI_UINT_cm : MULHI_UINT_Common<0x92>;
1597 def RECIPSQRT_CLAMPED_cm : RECIPSQRT_CLAMPED_Common<0x87>;
1598 def EXP_IEEE_cm : EXP_IEEE_Common<0x81>;
1599 def LOG_IEEE_cm : LOG_IEEE_Common<0x83>;
1600 def RECIP_CLAMPED_cm : RECIP_CLAMPED_Common<0x84>;
1601 def RECIPSQRT_IEEE_cm : RECIPSQRT_IEEE_Common<0x89>;
1602 def SIN_cm : SIN_Common<0x8D>;
1603 def COS_cm : COS_Common<0x8E>;
1604 } // End isVector = 1
1606 def : POW_Common <LOG_IEEE_cm, EXP_IEEE_cm, MUL>;
1607 def : SIN_PAT <SIN_cm>;
1608 def : COS_PAT <COS_cm>;
1610 defm DIV_cm : DIV_Common<RECIP_IEEE_cm>;
1612 // RECIP_UINT emulation for Cayman
1613 // The multiplication scales from [0,1] to the unsigned integer range
1615 (AMDGPUurecip i32:$src0),
1616 (FLT_TO_UINT_eg (MUL_IEEE (RECIP_IEEE_cm (UINT_TO_FLT_eg $src0)),
1617 (MOV_IMM_I32 CONST.FP_UINT_MAX_PLUS_1)))
1620 def CF_END_CM : CF_CLAUSE_EG<32, (ins), "CF_END"> {
1626 def : Pat<(fsqrt f32:$src), (MUL R600_Reg32:$src, (RECIPSQRT_CLAMPED_cm $src))>;
1629 def RAT_STORE_DWORD_cm : EG_CF_RAT <
1630 0x57, 0x14, 0x1, (outs),
1631 (ins R600_TReg32_X:$rw_gpr, R600_TReg32_X:$index_gpr),
1632 "EXPORT_RAT_INST_STORE_DWORD $rw_gpr, $index_gpr",
1633 [(global_store i32:$rw_gpr, i32:$index_gpr)]
1635 let eop = 0; // This bit is not used on Cayman.
1640 //===----------------------------------------------------------------------===//
1641 // Branch Instructions
1642 //===----------------------------------------------------------------------===//
1645 def IF_PREDICATE_SET : ILFormat<(outs), (ins GPRI32:$src),
1646 "IF_PREDICATE_SET $src", []>;
1648 def PREDICATED_BREAK : ILFormat<(outs), (ins GPRI32:$src),
1649 "PREDICATED_BREAK $src", []>;
1651 //===----------------------------------------------------------------------===//
1652 // Pseudo instructions
1653 //===----------------------------------------------------------------------===//
1655 let isPseudo = 1 in {
1657 def PRED_X : InstR600 <
1658 (outs R600_Predicate_Bit:$dst),
1659 (ins R600_Reg32:$src0, i32imm:$src1, i32imm:$flags),
1661 let FlagOperandIdx = 3;
1664 let isTerminator = 1, isBranch = 1 in {
1665 def JUMP_COND : InstR600 <
1667 (ins brtarget:$target, R600_Predicate_Bit:$p),
1668 "JUMP $target ($p)",
1672 def JUMP : InstR600 <
1674 (ins brtarget:$target),
1679 let isPredicable = 1;
1683 } // End isTerminator = 1, isBranch = 1
1685 let usesCustomInserter = 1 in {
1687 let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in {
1689 def MASK_WRITE : AMDGPUShaderInst <
1691 (ins R600_Reg32:$src),
1696 } // End mayLoad = 0, mayStore = 0, hasSideEffects = 1
1700 (outs R600_Reg128:$dst),
1701 (ins R600_Reg128:$src0, R600_Reg128:$src1, R600_Reg128:$src2,
1702 i32imm:$resourceId, i32imm:$samplerId, i32imm:$textureTarget),
1703 "TXD $dst, $src0, $src1, $src2, $resourceId, $samplerId, $textureTarget",
1704 [(set v4f32:$dst, (int_AMDGPU_txd v4f32:$src0, v4f32:$src1, v4f32:$src2,
1705 imm:$resourceId, imm:$samplerId, imm:$textureTarget))],
1710 def TXD_SHADOW: InstR600 <
1711 (outs R600_Reg128:$dst),
1712 (ins R600_Reg128:$src0, R600_Reg128:$src1, R600_Reg128:$src2,
1713 i32imm:$resourceId, i32imm:$samplerId, i32imm:$textureTarget),
1714 "TXD_SHADOW $dst, $src0, $src1, $src2, $resourceId, $samplerId, $textureTarget",
1715 [(set v4f32:$dst, (int_AMDGPU_txd v4f32:$src0, v4f32:$src1, v4f32:$src2,
1716 imm:$resourceId, imm:$samplerId, TEX_SHADOW:$textureTarget))],
1721 } // End isPseudo = 1
1722 } // End usesCustomInserter = 1
1724 def CLAMP_R600 : CLAMP <R600_Reg32>;
1725 def FABS_R600 : FABS<R600_Reg32>;
1726 def FNEG_R600 : FNEG<R600_Reg32>;
1728 //===---------------------------------------------------------------------===//
1729 // Return instruction
1730 //===---------------------------------------------------------------------===//
1731 let isTerminator = 1, isReturn = 1, hasCtrlDep = 1,
1732 usesCustomInserter = 1 in {
1733 def RETURN : ILFormat<(outs), (ins variable_ops),
1734 "RETURN", [(IL_retflag)]>;
1738 //===----------------------------------------------------------------------===//
1739 // Constant Buffer Addressing Support
1740 //===----------------------------------------------------------------------===//
1742 let usesCustomInserter = 1, isCodeGenOnly = 1, isPseudo = 1, Namespace = "AMDGPU" in {
1743 def CONST_COPY : Instruction {
1744 let OutOperandList = (outs R600_Reg32:$dst);
1745 let InOperandList = (ins i32imm:$src);
1747 [(set R600_Reg32:$dst, (CONST_ADDRESS ADDRGA_CONST_OFFSET:$src))];
1748 let AsmString = "CONST_COPY";
1749 let neverHasSideEffects = 1;
1750 let isAsCheapAsAMove = 1;
1751 let Itinerary = NullALU;
1753 } // end usesCustomInserter = 1, isCodeGenOnly = 1, isPseudo = 1, Namespace = "AMDGPU"
1755 def TEX_VTX_CONSTBUF :
1756 InstR600ISA <(outs R600_Reg128:$dst), (ins MEMxi:$ptr, i32imm:$BUFFER_ID), "VTX_READ_eg $dst, $ptr",
1757 [(set v4i32:$dst, (CONST_ADDRESS ADDRGA_VAR_OFFSET:$ptr, (i32 imm:$BUFFER_ID)))]>,
1758 VTX_WORD1_GPR, VTX_WORD0 {
1762 let FETCH_WHOLE_QUAD = 0;
1766 let USE_CONST_FIELDS = 0;
1767 let NUM_FORMAT_ALL = 2;
1768 let FORMAT_COMP_ALL = 1;
1769 let SRF_MODE_ALL = 1;
1770 let MEGA_FETCH_COUNT = 16;
1775 let DATA_FORMAT = 35;
1777 let Inst{31-0} = Word0;
1778 let Inst{63-32} = Word1;
1780 // LLVM can only encode 64-bit instructions, so these fields are manually
1781 // encoded in R600CodeEmitter
1784 // bits<2> ENDIAN_SWAP = 0;
1785 // bits<1> CONST_BUF_NO_STRIDE = 0;
1786 // bits<1> MEGA_FETCH = 0;
1787 // bits<1> ALT_CONST = 0;
1788 // bits<2> BUFFER_INDEX_MODE = 0;
1792 // VTX_WORD2 (LLVM can only encode 64-bit instructions, so WORD2 encoding
1793 // is done in R600CodeEmitter
1795 // Inst{79-64} = OFFSET;
1796 // Inst{81-80} = ENDIAN_SWAP;
1797 // Inst{82} = CONST_BUF_NO_STRIDE;
1798 // Inst{83} = MEGA_FETCH;
1799 // Inst{84} = ALT_CONST;
1800 // Inst{86-85} = BUFFER_INDEX_MODE;
1801 // Inst{95-86} = 0; Reserved
1803 // VTX_WORD3 (Padding)
1805 // Inst{127-96} = 0;
1810 InstR600ISA <(outs R600_Reg128:$dst), (ins MEMxi:$ptr, i32imm:$BUFFER_ID), "TEX_VTX_EXPLICIT_READ $dst, $ptr",
1811 [(set v4f32:$dst, (int_R600_load_texbuf ADDRGA_VAR_OFFSET:$ptr, imm:$BUFFER_ID))]>,
1812 VTX_WORD1_GPR, VTX_WORD0 {
1816 let FETCH_WHOLE_QUAD = 0;
1820 let USE_CONST_FIELDS = 1;
1821 let NUM_FORMAT_ALL = 0;
1822 let FORMAT_COMP_ALL = 0;
1823 let SRF_MODE_ALL = 1;
1824 let MEGA_FETCH_COUNT = 16;
1829 let DATA_FORMAT = 0;
1831 let Inst{31-0} = Word0;
1832 let Inst{63-32} = Word1;
1834 // LLVM can only encode 64-bit instructions, so these fields are manually
1835 // encoded in R600CodeEmitter
1838 // bits<2> ENDIAN_SWAP = 0;
1839 // bits<1> CONST_BUF_NO_STRIDE = 0;
1840 // bits<1> MEGA_FETCH = 0;
1841 // bits<1> ALT_CONST = 0;
1842 // bits<2> BUFFER_INDEX_MODE = 0;
1846 // VTX_WORD2 (LLVM can only encode 64-bit instructions, so WORD2 encoding
1847 // is done in R600CodeEmitter
1849 // Inst{79-64} = OFFSET;
1850 // Inst{81-80} = ENDIAN_SWAP;
1851 // Inst{82} = CONST_BUF_NO_STRIDE;
1852 // Inst{83} = MEGA_FETCH;
1853 // Inst{84} = ALT_CONST;
1854 // Inst{86-85} = BUFFER_INDEX_MODE;
1855 // Inst{95-86} = 0; Reserved
1857 // VTX_WORD3 (Padding)
1859 // Inst{127-96} = 0;
1865 //===--------------------------------------------------------------------===//
1866 // Instructions support
1867 //===--------------------------------------------------------------------===//
1868 //===---------------------------------------------------------------------===//
1869 // Custom Inserter for Branches and returns, this eventually will be a
1871 //===---------------------------------------------------------------------===//
1872 let isTerminator = 1, usesCustomInserter = 1, isBranch = 1, isBarrier = 1 in {
1873 def BRANCH : ILFormat<(outs), (ins brtarget:$target),
1874 "; Pseudo unconditional branch instruction",
1876 defm BRANCH_COND : BranchConditional<IL_brcond>;
1879 //===---------------------------------------------------------------------===//
1880 // Flow and Program control Instructions
1881 //===---------------------------------------------------------------------===//
1882 let isTerminator=1 in {
1883 def SWITCH : ILFormat< (outs), (ins GPRI32:$src),
1884 !strconcat("SWITCH", " $src"), []>;
1885 def CASE : ILFormat< (outs), (ins GPRI32:$src),
1886 !strconcat("CASE", " $src"), []>;
1887 def BREAK : ILFormat< (outs), (ins),
1889 def CONTINUE : ILFormat< (outs), (ins),
1891 def DEFAULT : ILFormat< (outs), (ins),
1893 def ELSE : ILFormat< (outs), (ins),
1895 def ENDSWITCH : ILFormat< (outs), (ins),
1897 def ENDMAIN : ILFormat< (outs), (ins),
1899 def END : ILFormat< (outs), (ins),
1901 def ENDFUNC : ILFormat< (outs), (ins),
1903 def ENDIF : ILFormat< (outs), (ins),
1905 def WHILELOOP : ILFormat< (outs), (ins),
1907 def ENDLOOP : ILFormat< (outs), (ins),
1909 def FUNC : ILFormat< (outs), (ins),
1911 def RETDYN : ILFormat< (outs), (ins),
1913 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1914 defm IF_LOGICALNZ : BranchInstr<"IF_LOGICALNZ">;
1915 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1916 defm IF_LOGICALZ : BranchInstr<"IF_LOGICALZ">;
1917 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1918 defm BREAK_LOGICALNZ : BranchInstr<"BREAK_LOGICALNZ">;
1919 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1920 defm BREAK_LOGICALZ : BranchInstr<"BREAK_LOGICALZ">;
1921 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1922 defm CONTINUE_LOGICALNZ : BranchInstr<"CONTINUE_LOGICALNZ">;
1923 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
1924 defm CONTINUE_LOGICALZ : BranchInstr<"CONTINUE_LOGICALZ">;
1925 defm IFC : BranchInstr2<"IFC">;
1926 defm BREAKC : BranchInstr2<"BREAKC">;
1927 defm CONTINUEC : BranchInstr2<"CONTINUEC">;
1930 //===----------------------------------------------------------------------===//
1932 //===----------------------------------------------------------------------===//
1934 // CND*_INT Pattterns for f32 True / False values
1936 class CND_INT_f32 <InstR600 cnd, CondCode cc> : Pat <
1937 (selectcc i32:$src0, 0, f32:$src1, f32:$src2, cc),
1938 (cnd $src0, $src1, $src2)
1941 def : CND_INT_f32 <CNDE_INT, SETEQ>;
1942 def : CND_INT_f32 <CNDGT_INT, SETGT>;
1943 def : CND_INT_f32 <CNDGE_INT, SETGE>;
1945 //CNDGE_INT extra pattern
1947 (selectcc i32:$src0, -1, i32:$src1, i32:$src2, COND_GT),
1948 (CNDGE_INT $src0, $src1, $src2)
1954 (MASK_WRITE (KILLGT (f32 ONE), (f32 ZERO)))
1958 (int_AMDGPU_kill f32:$src0),
1959 (MASK_WRITE (KILLGT (f32 ZERO), $src0))
1964 (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_LT),
1970 (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, COND_LE),
1974 // SETGT_DX10 reverse args
1976 (selectcc f32:$src0, f32:$src1, -1, 0, COND_LT),
1977 (SETGT_DX10 $src1, $src0)
1980 // SETGE_DX10 reverse args
1982 (selectcc f32:$src0, f32:$src1, -1, 0, COND_LE),
1983 (SETGE_DX10 $src1, $src0)
1986 // SETGT_INT reverse args
1988 (selectcc i32:$src0, i32:$src1, -1, 0, SETLT),
1989 (SETGT_INT $src1, $src0)
1992 // SETGE_INT reverse args
1994 (selectcc i32:$src0, i32:$src1, -1, 0, SETLE),
1995 (SETGE_INT $src1, $src0)
1998 // SETGT_UINT reverse args
2000 (selectcc i32:$src0, i32:$src1, -1, 0, SETULT),
2001 (SETGT_UINT $src1, $src0)
2004 // SETGE_UINT reverse args
2006 (selectcc i32:$src0, i32:$src1, -1, 0, SETULE),
2007 (SETGE_UINT $src1, $src0)
2010 // The next two patterns are special cases for handling 'true if ordered' and
2011 // 'true if unordered' conditionals. The assumption here is that the behavior of
2012 // SETE and SNE conforms to the Direct3D 10 rules for floating point values
2014 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc308050.aspx#alpha_32_bit
2015 // We assume that SETE returns false when one of the operands is NAN and
2016 // SNE returns true when on of the operands is NAN
2018 //SETE - 'true if ordered'
2020 (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, SETO),
2024 //SETE_DX10 - 'true if ordered'
2026 (selectcc f32:$src0, f32:$src1, -1, 0, SETO),
2027 (SETE_DX10 $src0, $src1)
2030 //SNE - 'true if unordered'
2032 (selectcc f32:$src0, f32:$src1, FP_ONE, FP_ZERO, SETUO),
2036 //SETNE_DX10 - 'true if ordered'
2038 (selectcc f32:$src0, f32:$src1, -1, 0, SETUO),
2039 (SETNE_DX10 $src0, $src1)
2042 def : Extract_Element <f32, v4f32, 0, sub0>;
2043 def : Extract_Element <f32, v4f32, 1, sub1>;
2044 def : Extract_Element <f32, v4f32, 2, sub2>;
2045 def : Extract_Element <f32, v4f32, 3, sub3>;
2047 def : Insert_Element <f32, v4f32, 0, sub0>;
2048 def : Insert_Element <f32, v4f32, 1, sub1>;
2049 def : Insert_Element <f32, v4f32, 2, sub2>;
2050 def : Insert_Element <f32, v4f32, 3, sub3>;
2052 def : Extract_Element <i32, v4i32, 0, sub0>;
2053 def : Extract_Element <i32, v4i32, 1, sub1>;
2054 def : Extract_Element <i32, v4i32, 2, sub2>;
2055 def : Extract_Element <i32, v4i32, 3, sub3>;
2057 def : Insert_Element <i32, v4i32, 0, sub0>;
2058 def : Insert_Element <i32, v4i32, 1, sub1>;
2059 def : Insert_Element <i32, v4i32, 2, sub2>;
2060 def : Insert_Element <i32, v4i32, 3, sub3>;
2062 def : Vector4_Build <v4f32, f32>;
2063 def : Vector4_Build <v4i32, i32>;
2065 // bitconvert patterns
2067 def : BitConvert <i32, f32, R600_Reg32>;
2068 def : BitConvert <f32, i32, R600_Reg32>;
2069 def : BitConvert <v4f32, v4i32, R600_Reg128>;
2070 def : BitConvert <v4i32, v4f32, R600_Reg128>;
2072 // DWORDADDR pattern
2073 def : DwordAddrPat <i32, R600_Reg32>;
2075 } // End isR600toCayman Predicate