2013-02-21 15:16:44 +00:00
|
|
|
//===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===//
|
2012-12-11 21:25:42 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SI DAG Nodes
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-02-07 19:39:40 +00:00
|
|
|
// SMRD takes a 64bit memory address and can only add an 32bit offset
|
|
|
|
def SIadd64bit32bit : SDNode<"ISD::ADD",
|
|
|
|
SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisVT<0, i64>, SDTCisVT<2, i32>]>
|
|
|
|
>;
|
|
|
|
|
2013-08-14 23:24:45 +00:00
|
|
|
def SIload_constant : SDNode<"AMDGPUISD::LOAD_CONSTANT",
|
|
|
|
SDTypeProfile<1, 2, [SDTCisVT<0, f32>, SDTCisVT<1, i128>, SDTCisVT<2, i32>]>,
|
|
|
|
[SDNPMayLoad, SDNPMemOperand]
|
|
|
|
>;
|
|
|
|
|
2013-09-12 02:55:14 +00:00
|
|
|
def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT",
|
|
|
|
SDTypeProfile<0, 13,
|
|
|
|
[SDTCisVT<0, i128>, // rsrc(SGPR)
|
|
|
|
SDTCisVT<1, iAny>, // vdata(VGPR)
|
|
|
|
SDTCisVT<2, i32>, // num_channels(imm)
|
|
|
|
SDTCisVT<3, i32>, // vaddr(VGPR)
|
|
|
|
SDTCisVT<4, i32>, // soffset(SGPR)
|
|
|
|
SDTCisVT<5, i32>, // inst_offset(imm)
|
|
|
|
SDTCisVT<6, i32>, // dfmt(imm)
|
|
|
|
SDTCisVT<7, i32>, // nfmt(imm)
|
|
|
|
SDTCisVT<8, i32>, // offen(imm)
|
|
|
|
SDTCisVT<9, i32>, // idxen(imm)
|
|
|
|
SDTCisVT<10, i32>, // glc(imm)
|
|
|
|
SDTCisVT<11, i32>, // slc(imm)
|
|
|
|
SDTCisVT<12, i32> // tfe(imm)
|
|
|
|
]>,
|
|
|
|
[SDNPMayStore, SDNPMemOperand, SDNPHasChain]
|
|
|
|
>;
|
|
|
|
|
2013-08-14 23:24:45 +00:00
|
|
|
def SIload_input : SDNode<"AMDGPUISD::LOAD_INPUT",
|
|
|
|
SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisVT<1, i128>, SDTCisVT<2, i16>,
|
|
|
|
SDTCisVT<3, i32>]>
|
|
|
|
>;
|
|
|
|
|
|
|
|
class SDSample<string opcode> : SDNode <opcode,
|
2013-08-14 23:24:53 +00:00
|
|
|
SDTypeProfile<1, 4, [SDTCisVT<0, v4f32>, SDTCisVT<2, v32i8>,
|
2013-08-14 23:24:45 +00:00
|
|
|
SDTCisVT<3, i128>, SDTCisVT<4, i32>]>
|
|
|
|
>;
|
|
|
|
|
|
|
|
def SIsample : SDSample<"AMDGPUISD::SAMPLE">;
|
|
|
|
def SIsampleb : SDSample<"AMDGPUISD::SAMPLEB">;
|
|
|
|
def SIsampled : SDSample<"AMDGPUISD::SAMPLED">;
|
|
|
|
def SIsamplel : SDSample<"AMDGPUISD::SAMPLEL">;
|
|
|
|
|
2013-02-07 19:39:38 +00:00
|
|
|
// Transformation function, extract the lower 32bit of a 64bit immediate
|
|
|
|
def LO32 : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getZExtValue() & 0xffffffff, MVT::i32);
|
|
|
|
}]>;
|
|
|
|
|
2013-07-12 18:15:02 +00:00
|
|
|
def LO32f : SDNodeXForm<fpimm, [{
|
2013-07-12 20:18:05 +00:00
|
|
|
APInt V = N->getValueAPF().bitcastToAPInt().trunc(32);
|
|
|
|
return CurDAG->getTargetConstantFP(APFloat(APFloat::IEEEsingle, V), MVT::f32);
|
2013-07-12 18:15:02 +00:00
|
|
|
}]>;
|
|
|
|
|
2013-02-07 19:39:38 +00:00
|
|
|
// Transformation function, extract the upper 32bit of a 64bit immediate
|
|
|
|
def HI32 : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getZExtValue() >> 32, MVT::i32);
|
|
|
|
}]>;
|
|
|
|
|
2013-07-12 18:15:02 +00:00
|
|
|
def HI32f : SDNodeXForm<fpimm, [{
|
2013-07-12 20:18:05 +00:00
|
|
|
APInt V = N->getValueAPF().bitcastToAPInt().lshr(32).trunc(32);
|
|
|
|
return CurDAG->getTargetConstantFP(APFloat(APFloat::IEEEsingle, V), MVT::f32);
|
2013-07-12 18:15:02 +00:00
|
|
|
}]>;
|
|
|
|
|
2014-02-06 18:36:34 +00:00
|
|
|
def IMM8bitDWORD : PatLeaf <(imm),
|
|
|
|
[{return (N->getZExtValue() & ~0x3FC) == 0;}]
|
2013-02-07 19:39:40 +00:00
|
|
|
>;
|
|
|
|
|
2014-02-06 18:36:34 +00:00
|
|
|
def as_dword_i32imm : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getZExtValue() >> 2, MVT::i32);
|
|
|
|
}]>;
|
|
|
|
|
2013-09-12 02:55:14 +00:00
|
|
|
def as_i1imm : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getZExtValue(), MVT::i1);
|
|
|
|
}]>;
|
|
|
|
|
|
|
|
def as_i8imm : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getZExtValue(), MVT::i8);
|
|
|
|
}]>;
|
|
|
|
|
2013-06-03 17:39:43 +00:00
|
|
|
def as_i16imm : SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getSExtValue(), MVT::i16);
|
|
|
|
}]>;
|
|
|
|
|
2014-02-06 18:36:34 +00:00
|
|
|
def as_i32imm: SDNodeXForm<imm, [{
|
|
|
|
return CurDAG->getTargetConstant(N->getSExtValue(), MVT::i32);
|
|
|
|
}]>;
|
|
|
|
|
2013-06-03 17:39:43 +00:00
|
|
|
def IMM12bit : PatLeaf <(imm),
|
|
|
|
[{return isUInt<12>(N->getZExtValue());}]
|
2013-02-07 19:39:40 +00:00
|
|
|
>;
|
|
|
|
|
2014-02-06 18:36:41 +00:00
|
|
|
def mubuf_vaddr_offset : PatFrag<
|
|
|
|
(ops node:$ptr, node:$offset, node:$imm_offset),
|
|
|
|
(add (add node:$ptr, node:$offset), node:$imm_offset)
|
|
|
|
>;
|
|
|
|
|
2013-02-26 17:52:23 +00:00
|
|
|
class InlineImm <ValueType vt> : PatLeaf <(vt imm), [{
|
2013-06-19 21:36:55 +00:00
|
|
|
return
|
|
|
|
(*(const SITargetLowering *)getTargetLowering()).analyzeImmediate(N) == 0;
|
2013-02-16 11:28:36 +00:00
|
|
|
}]>;
|
|
|
|
|
2013-08-14 23:24:24 +00:00
|
|
|
class SGPRImm <dag frag> : PatLeaf<frag, [{
|
|
|
|
if (TM.getSubtarget<AMDGPUSubtarget>().getGeneration() <
|
|
|
|
AMDGPUSubtarget::SOUTHERN_ISLANDS) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const SIRegisterInfo *SIRI =
|
|
|
|
static_cast<const SIRegisterInfo*>(TM.getRegisterInfo());
|
|
|
|
for (SDNode::use_iterator U = N->use_begin(), E = SDNode::use_end();
|
|
|
|
U != E; ++U) {
|
|
|
|
if (SIRI->isSGPRClass(getOperandRegClass(*U, U.getOperandNo()))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}]>;
|
|
|
|
|
2013-12-19 05:32:55 +00:00
|
|
|
def FRAMEri32 : Operand<iPTR> {
|
2013-11-13 23:36:50 +00:00
|
|
|
let MIOperandInfo = (ops SReg_32:$ptr, i32imm:$index);
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SI assembler operands
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:49 +00:00
|
|
|
def SIOperand {
|
|
|
|
int ZERO = 0x80;
|
2013-02-26 17:52:09 +00:00
|
|
|
int VCC = 0x6A;
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
include "SIInstrFormats.td"
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// SI Instruction multiclass helpers.
|
|
|
|
//
|
|
|
|
// Instructions with _32 take 32-bit operands.
|
|
|
|
// Instructions with _64 take 64-bit operands.
|
|
|
|
//
|
|
|
|
// VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit
|
|
|
|
// encoding is the standard encoding, but instruction that make use of
|
|
|
|
// any of the instruction modifiers must use the 64-bit encoding.
|
|
|
|
//
|
|
|
|
// Instructions with _e32 use the 32-bit encoding.
|
|
|
|
// Instructions with _e64 use the 64-bit encoding.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Scalar classes
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOP1_32 <bits<8> op, string opName, list<dag> pattern> : SOP1 <
|
|
|
|
op, (outs SReg_32:$dst), (ins SSrc_32:$src0),
|
|
|
|
opName#" $dst, $src0", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOP1_64 <bits<8> op, string opName, list<dag> pattern> : SOP1 <
|
|
|
|
op, (outs SReg_64:$dst), (ins SSrc_64:$src0),
|
|
|
|
opName#" $dst, $src0", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOP2_32 <bits<7> op, string opName, list<dag> pattern> : SOP2 <
|
|
|
|
op, (outs SReg_32:$dst), (ins SSrc_32:$src0, SSrc_32:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOP2_64 <bits<7> op, string opName, list<dag> pattern> : SOP2 <
|
|
|
|
op, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_64:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
class SOP2_SHIFT_64 <bits<7> op, string opName, list<dag> pattern> : SOP2 <
|
|
|
|
op, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_32:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>;
|
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOPC_32 <bits<7> op, string opName, list<dag> pattern> : SOPC <
|
|
|
|
op, (outs SCCReg:$dst), (ins SSrc_32:$src0, SSrc_32:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOPC_64 <bits<7> op, string opName, list<dag> pattern> : SOPC <
|
|
|
|
op, (outs SCCReg:$dst), (ins SSrc_64:$src0, SSrc_64:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOPK_32 <bits<5> op, string opName, list<dag> pattern> : SOPK <
|
|
|
|
op, (outs SReg_32:$dst), (ins i16imm:$src0),
|
|
|
|
opName#" $dst, $src0", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:17:13 +00:00
|
|
|
class SOPK_64 <bits<5> op, string opName, list<dag> pattern> : SOPK <
|
|
|
|
op, (outs SReg_64:$dst), (ins i16imm:$src0),
|
|
|
|
opName#" $dst, $src0", pattern
|
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-03-18 11:33:50 +00:00
|
|
|
multiclass SMRD_Helper <bits<5> op, string asm, RegisterClass baseClass,
|
|
|
|
RegisterClass dstClass> {
|
2013-02-21 15:16:44 +00:00
|
|
|
def _IMM : SMRD <
|
|
|
|
op, 1, (outs dstClass:$dst),
|
2013-03-18 11:33:50 +00:00
|
|
|
(ins baseClass:$sbase, i32imm:$offset),
|
2013-02-21 15:17:13 +00:00
|
|
|
asm#" $dst, $sbase, $offset", []
|
2013-02-21 15:16:44 +00:00
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
def _SGPR : SMRD <
|
|
|
|
op, 0, (outs dstClass:$dst),
|
2013-03-18 11:33:50 +00:00
|
|
|
(ins baseClass:$sbase, SReg_32:$soff),
|
2013-02-21 15:17:13 +00:00
|
|
|
asm#" $dst, $sbase, $soff", []
|
2013-02-21 15:16:44 +00:00
|
|
|
>;
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Vector ALU classes
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-26 17:52:42 +00:00
|
|
|
class VOP <string opName> {
|
|
|
|
string OpName = opName;
|
|
|
|
}
|
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
class VOP2_REV <string revOp, bit isOrig> {
|
|
|
|
string RevOp = revOp;
|
|
|
|
bit IsOrig = isOrig;
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:53 +00:00
|
|
|
multiclass VOP1_Helper <bits<8> op, RegisterClass drc, RegisterClass src,
|
|
|
|
string opName, list<dag> pattern> {
|
2013-02-21 15:16:44 +00:00
|
|
|
|
2013-02-26 17:52:42 +00:00
|
|
|
def _e32 : VOP1 <
|
2013-02-21 15:16:53 +00:00
|
|
|
op, (outs drc:$dst), (ins src:$src0),
|
|
|
|
opName#"_e32 $dst, $src0", pattern
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:53 +00:00
|
|
|
def _e64 : VOP3 <
|
2013-02-21 15:16:44 +00:00
|
|
|
{1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
|
2013-02-21 15:16:53 +00:00
|
|
|
(outs drc:$dst),
|
|
|
|
(ins src:$src0,
|
|
|
|
i32imm:$abs, i32imm:$clamp,
|
|
|
|
i32imm:$omod, i32imm:$neg),
|
|
|
|
opName#"_e64 $dst, $src0, $abs, $clamp, $omod, $neg", []
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName> {
|
2013-05-20 15:02:08 +00:00
|
|
|
let src1 = SIOperand.ZERO;
|
|
|
|
let src2 = SIOperand.ZERO;
|
2013-02-21 15:16:53 +00:00
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:53 +00:00
|
|
|
multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern>
|
|
|
|
: VOP1_Helper <op, VReg_32, VSrc_32, opName, pattern>;
|
|
|
|
|
|
|
|
multiclass VOP1_64 <bits<8> op, string opName, list<dag> pattern>
|
|
|
|
: VOP1_Helper <op, VReg_64, VSrc_64, opName, pattern>;
|
|
|
|
|
2013-08-08 16:06:08 +00:00
|
|
|
multiclass VOP1_32_64 <bits<8> op, string opName, list<dag> pattern>
|
|
|
|
: VOP1_Helper <op, VReg_32, VSrc_64, opName, pattern>;
|
|
|
|
|
|
|
|
multiclass VOP1_64_32 <bits<8> op, string opName, list<dag> pattern>
|
|
|
|
: VOP1_Helper <op, VReg_64, VSrc_32, opName, pattern>;
|
|
|
|
|
2013-02-21 15:16:58 +00:00
|
|
|
multiclass VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc,
|
2013-03-27 09:12:59 +00:00
|
|
|
string opName, list<dag> pattern, string revOp> {
|
2013-02-21 15:16:58 +00:00
|
|
|
def _e32 : VOP2 <
|
|
|
|
op, (outs vrc:$dst), (ins arc:$src0, vrc:$src1),
|
|
|
|
opName#"_e32 $dst, $src0, $src1", pattern
|
2013-03-27 09:12:59 +00:00
|
|
|
>, VOP <opName>, VOP2_REV<revOp#"_e32", !eq(revOp, opName)>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-02-21 15:16:58 +00:00
|
|
|
def _e64 : VOP3 <
|
|
|
|
{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
|
|
|
|
(outs vrc:$dst),
|
2013-02-26 17:52:23 +00:00
|
|
|
(ins arc:$src0, arc:$src1,
|
2013-02-21 15:16:58 +00:00
|
|
|
i32imm:$abs, i32imm:$clamp,
|
|
|
|
i32imm:$omod, i32imm:$neg),
|
|
|
|
opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg", []
|
2013-03-27 09:12:59 +00:00
|
|
|
>, VOP <opName>, VOP2_REV<revOp#"_e64", !eq(revOp, opName)> {
|
2013-05-20 15:02:08 +00:00
|
|
|
let src2 = SIOperand.ZERO;
|
2013-02-21 15:16:58 +00:00
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern,
|
|
|
|
string revOp = opName>
|
|
|
|
: VOP2_Helper <op, VReg_32, VSrc_32, opName, pattern, revOp>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
multiclass VOP2_64 <bits<6> op, string opName, list<dag> pattern,
|
|
|
|
string revOp = opName>
|
|
|
|
: VOP2_Helper <op, VReg_64, VSrc_64, opName, pattern, revOp>;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
multiclass VOP2b_32 <bits<6> op, string opName, list<dag> pattern,
|
|
|
|
string revOp = opName> {
|
2013-02-26 17:52:09 +00:00
|
|
|
|
|
|
|
def _e32 : VOP2 <
|
|
|
|
op, (outs VReg_32:$dst), (ins VSrc_32:$src0, VReg_32:$src1),
|
|
|
|
opName#"_e32 $dst, $src0, $src1", pattern
|
2013-03-27 09:12:59 +00:00
|
|
|
>, VOP <opName>, VOP2_REV<revOp#"_e32", !eq(revOp, opName)>;
|
2013-02-26 17:52:09 +00:00
|
|
|
|
|
|
|
def _e64 : VOP3b <
|
|
|
|
{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
|
|
|
|
(outs VReg_32:$dst),
|
2013-02-26 17:52:23 +00:00
|
|
|
(ins VSrc_32:$src0, VSrc_32:$src1,
|
2013-02-26 17:52:09 +00:00
|
|
|
i32imm:$abs, i32imm:$clamp,
|
|
|
|
i32imm:$omod, i32imm:$neg),
|
|
|
|
opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg", []
|
2013-03-27 09:12:59 +00:00
|
|
|
>, VOP <opName>, VOP2_REV<revOp#"_e64", !eq(revOp, opName)> {
|
2013-05-20 15:02:08 +00:00
|
|
|
let src2 = SIOperand.ZERO;
|
2013-02-26 17:52:09 +00:00
|
|
|
/* the VOP2 variant puts the carry out into VCC, the VOP3 variant
|
|
|
|
can write it into any SGPR. We currently don't use the carry out,
|
|
|
|
so for now hardcode it to VCC as well */
|
2013-05-20 15:02:08 +00:00
|
|
|
let sdst = SIOperand.VCC;
|
2013-02-26 17:52:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
multiclass VOPC_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
|
2013-02-21 15:17:04 +00:00
|
|
|
string opName, ValueType vt, PatLeaf cond> {
|
|
|
|
|
|
|
|
def _e32 : VOPC <
|
|
|
|
op, (ins arc:$src0, vrc:$src1),
|
|
|
|
opName#"_e32 $dst, $src0, $src1", []
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName>;
|
2013-02-21 15:16:44 +00:00
|
|
|
|
|
|
|
def _e64 : VOP3 <
|
|
|
|
{0, op{7}, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
|
|
|
|
(outs SReg_64:$dst),
|
2013-02-26 17:52:23 +00:00
|
|
|
(ins arc:$src0, arc:$src1,
|
2013-02-21 15:16:44 +00:00
|
|
|
InstFlag:$abs, InstFlag:$clamp,
|
|
|
|
InstFlag:$omod, InstFlag:$neg),
|
2013-02-21 15:17:04 +00:00
|
|
|
opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg",
|
|
|
|
!if(!eq(!cast<string>(cond), "COND_NULL"), []<dag>,
|
2013-02-26 17:52:23 +00:00
|
|
|
[(set SReg_64:$dst, (i1 (setcc (vt arc:$src0), arc:$src1, cond)))]
|
2013-02-21 15:17:04 +00:00
|
|
|
)
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName> {
|
2013-05-20 15:02:08 +00:00
|
|
|
let src2 = SIOperand.ZERO;
|
2013-02-21 15:16:44 +00:00
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-21 15:17:04 +00:00
|
|
|
multiclass VOPC_32 <bits<8> op, string opName,
|
|
|
|
ValueType vt = untyped, PatLeaf cond = COND_NULL>
|
|
|
|
: VOPC_Helper <op, VReg_32, VSrc_32, opName, vt, cond>;
|
2013-02-21 15:16:44 +00:00
|
|
|
|
2013-02-21 15:17:04 +00:00
|
|
|
multiclass VOPC_64 <bits<8> op, string opName,
|
|
|
|
ValueType vt = untyped, PatLeaf cond = COND_NULL>
|
|
|
|
: VOPC_Helper <op, VReg_64, VSrc_64, opName, vt, cond>;
|
2013-02-21 15:16:44 +00:00
|
|
|
|
2013-02-21 15:17:09 +00:00
|
|
|
class VOP3_32 <bits<9> op, string opName, list<dag> pattern> : VOP3 <
|
|
|
|
op, (outs VReg_32:$dst),
|
2013-02-26 17:52:23 +00:00
|
|
|
(ins VSrc_32:$src0, VSrc_32:$src1, VSrc_32:$src2,
|
2013-04-19 02:11:00 +00:00
|
|
|
InstFlag:$abs, InstFlag:$clamp, InstFlag:$omod, InstFlag:$neg),
|
2013-02-21 15:17:09 +00:00
|
|
|
opName#" $dst, $src0, $src1, $src2, $abs, $clamp, $omod, $neg", pattern
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName>;
|
2013-02-21 15:17:09 +00:00
|
|
|
|
2013-05-20 15:02:12 +00:00
|
|
|
class VOP3_64_Shift <bits <9> op, string opName, list<dag> pattern> : VOP3 <
|
|
|
|
op, (outs VReg_64:$dst),
|
|
|
|
(ins VSrc_64:$src0, VSrc_32:$src1),
|
|
|
|
opName#" $dst, $src0, $src1", pattern
|
|
|
|
>, VOP <opName> {
|
|
|
|
|
|
|
|
let src2 = SIOperand.ZERO;
|
|
|
|
let abs = 0;
|
|
|
|
let clamp = 0;
|
|
|
|
let omod = 0;
|
|
|
|
let neg = 0;
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:17:09 +00:00
|
|
|
class VOP3_64 <bits<9> op, string opName, list<dag> pattern> : VOP3 <
|
|
|
|
op, (outs VReg_64:$dst),
|
2013-02-26 17:52:23 +00:00
|
|
|
(ins VSrc_64:$src0, VSrc_64:$src1, VSrc_64:$src2,
|
2013-04-19 02:11:00 +00:00
|
|
|
InstFlag:$abs, InstFlag:$clamp, InstFlag:$omod, InstFlag:$neg),
|
2013-02-21 15:17:09 +00:00
|
|
|
opName#" $dst, $src0, $src1, $src2, $abs, $clamp, $omod, $neg", pattern
|
2013-02-26 17:52:42 +00:00
|
|
|
>, VOP <opName>;
|
2013-02-21 15:17:09 +00:00
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Vector I/O classes
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-07-10 16:36:43 +00:00
|
|
|
class DS_Load_Helper <bits<8> op, string asm, RegisterClass regClass> : DS <
|
|
|
|
op,
|
|
|
|
(outs regClass:$vdst),
|
2013-08-16 01:18:43 +00:00
|
|
|
(ins i1imm:$gds, VReg_32:$addr, VReg_32:$data0, VReg_32:$data1,
|
|
|
|
i8imm:$offset0, i8imm:$offset1),
|
2013-07-10 16:36:43 +00:00
|
|
|
asm#" $vdst, $gds, $addr, $data0, $data1, $offset0, $offset1, [M0]",
|
|
|
|
[]> {
|
|
|
|
let mayLoad = 1;
|
|
|
|
let mayStore = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DS_Store_Helper <bits<8> op, string asm, RegisterClass regClass> : DS <
|
|
|
|
op,
|
|
|
|
(outs),
|
2013-08-16 01:18:43 +00:00
|
|
|
(ins i1imm:$gds, VReg_32:$addr, VReg_32:$data0, VReg_32:$data1,
|
|
|
|
i8imm:$offset0, i8imm:$offset1),
|
2013-07-10 16:36:43 +00:00
|
|
|
asm#" $gds, $addr, $data0, $data1, $offset0, $offset1, [M0]",
|
|
|
|
[]> {
|
|
|
|
let mayStore = 1;
|
|
|
|
let mayLoad = 0;
|
|
|
|
let vdst = 0;
|
|
|
|
}
|
|
|
|
|
2013-09-05 18:38:09 +00:00
|
|
|
class DS_1A1D_RET <bits<8> op, string asm, RegisterClass rc> : DS <
|
|
|
|
op,
|
|
|
|
(outs rc:$vdst),
|
|
|
|
(ins i1imm:$gds, VReg_32:$addr, VReg_32:$data0, i8imm:$offset0,
|
|
|
|
i8imm:$offset1),
|
|
|
|
asm#" $gds, $vdst, $addr, $data0, $offset0, $offset1, [M0]",
|
|
|
|
[]> {
|
|
|
|
let mayStore = 1;
|
|
|
|
let mayLoad = 1;
|
|
|
|
let data1 = 0;
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
class MTBUF_Store_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
|
|
|
|
op,
|
|
|
|
(outs),
|
|
|
|
(ins regClass:$vdata, i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc,
|
|
|
|
i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr,
|
2013-03-01 09:46:17 +00:00
|
|
|
SReg_128:$srsrc, i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
|
2013-02-21 15:17:17 +00:00
|
|
|
asm#" $vdata, $offset, $offen, $idxen, $glc, $addr64, $dfmt,"
|
|
|
|
#" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset",
|
2013-02-21 15:16:44 +00:00
|
|
|
[]> {
|
|
|
|
let mayStore = 1;
|
2012-12-11 21:25:42 +00:00
|
|
|
let mayLoad = 0;
|
|
|
|
}
|
|
|
|
|
2013-05-20 15:02:31 +00:00
|
|
|
multiclass MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> {
|
|
|
|
|
2014-01-27 07:20:51 +00:00
|
|
|
let lds = 0, mayLoad = 1 in {
|
|
|
|
|
|
|
|
let addr64 = 0 in {
|
|
|
|
|
|
|
|
let offen = 0, idxen = 0 in {
|
|
|
|
def _OFFSET : MUBUF <op, (outs regClass:$vdata),
|
|
|
|
(ins SReg_128:$srsrc, VReg_32:$vaddr,
|
|
|
|
i16imm:$offset, SSrc_32:$soffset, i1imm:$glc,
|
|
|
|
i1imm:$slc, i1imm:$tfe),
|
|
|
|
asm#" $vdata, $srsrc + $offset + $soffset, glc=$glc, slc=$slc, tfe=$tfe", []>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let offen = 1, idxen = 0, offset = 0 in {
|
|
|
|
def _OFFEN : MUBUF <op, (outs regClass:$vdata),
|
|
|
|
(ins SReg_128:$srsrc, VReg_32:$vaddr,
|
|
|
|
SSrc_32:$soffset, i1imm:$glc, i1imm:$slc,
|
|
|
|
i1imm:$tfe),
|
|
|
|
asm#" $vdata, $srsrc + $vaddr + $soffset, glc=$glc, slc=$slc, tfe=$tfe", []>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let offen = 0, idxen = 1 in {
|
|
|
|
def _IDXEN : MUBUF <op, (outs regClass:$vdata),
|
|
|
|
(ins SReg_128:$srsrc, VReg_32:$vaddr,
|
|
|
|
i16imm:$offset, SSrc_32:$soffset, i1imm:$glc,
|
|
|
|
i1imm:$slc, i1imm:$tfe),
|
|
|
|
asm#" $vdata, $srsrc[$vaddr] + $offset + $soffset, glc=$glc, slc=$slc, tfe=$tfe", []>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let offen = 1, idxen = 1 in {
|
|
|
|
def _BOTHEN : MUBUF <op, (outs regClass:$vdata),
|
|
|
|
(ins SReg_128:$srsrc, VReg_64:$vaddr,
|
|
|
|
SSrc_32:$soffset, i1imm:$glc,
|
|
|
|
i1imm:$slc, i1imm:$tfe),
|
|
|
|
asm#" $vdata, $srsrc[$vaddr[0]] + $vaddr[1] + $soffset, glc=$glc, slc=$slc, tfe=$tfe", []>;
|
|
|
|
}
|
|
|
|
}
|
2013-05-20 15:02:31 +00:00
|
|
|
|
2014-01-27 07:20:51 +00:00
|
|
|
let offen = 0, idxen = 0, addr64 = 1, glc = 0, slc = 0, tfe = 0, soffset = 128 /* ZERO */ in {
|
|
|
|
def _ADDR64 : MUBUF <op, (outs regClass:$vdata),
|
|
|
|
(ins SReg_128:$srsrc, VReg_64:$vaddr, i16imm:$offset),
|
|
|
|
asm#" $vdata, $srsrc + $vaddr + $offset", []>;
|
|
|
|
}
|
2013-05-20 15:02:31 +00:00
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-16 01:12:06 +00:00
|
|
|
class MUBUF_Store_Helper <bits<7> op, string name, RegisterClass vdataClass> :
|
|
|
|
MUBUF <op, (outs), (ins vdataClass:$vdata, SReg_128:$srsrc, VReg_64:$vaddr,
|
|
|
|
i16imm:$offset),
|
2013-06-03 17:39:37 +00:00
|
|
|
name#" $vdata, $srsrc + $vaddr + $offset",
|
|
|
|
[]> {
|
2013-04-05 23:31:51 +00:00
|
|
|
|
|
|
|
let mayLoad = 0;
|
|
|
|
let mayStore = 1;
|
|
|
|
|
|
|
|
// Encoding
|
|
|
|
let offen = 0;
|
|
|
|
let idxen = 0;
|
|
|
|
let glc = 0;
|
|
|
|
let addr64 = 1;
|
|
|
|
let lds = 0;
|
|
|
|
let slc = 0;
|
|
|
|
let tfe = 0;
|
|
|
|
let soffset = 128; // ZERO
|
|
|
|
}
|
|
|
|
|
2013-02-21 15:16:44 +00:00
|
|
|
class MTBUF_Load_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
|
|
|
|
op,
|
|
|
|
(outs regClass:$dst),
|
|
|
|
(ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
|
2013-03-01 09:46:17 +00:00
|
|
|
i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, SReg_128:$srsrc,
|
2013-02-21 15:16:44 +00:00
|
|
|
i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
|
2013-02-21 15:17:17 +00:00
|
|
|
asm#" $dst, $offset, $offen, $idxen, $glc, $addr64, $dfmt,"
|
|
|
|
#" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset",
|
2013-02-21 15:16:44 +00:00
|
|
|
[]> {
|
|
|
|
let mayLoad = 1;
|
2012-12-11 21:25:42 +00:00
|
|
|
let mayStore = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:24 +00:00
|
|
|
class MIMG_Mask <string op, int channels> {
|
|
|
|
string Op = op;
|
|
|
|
int Channels = channels;
|
|
|
|
}
|
|
|
|
|
2013-08-14 23:24:17 +00:00
|
|
|
class MIMG_NoSampler_Helper <bits<7> op, string asm,
|
2013-10-10 17:11:24 +00:00
|
|
|
RegisterClass dst_rc,
|
2013-08-14 23:24:17 +00:00
|
|
|
RegisterClass src_rc> : MIMG <
|
2013-05-06 23:02:12 +00:00
|
|
|
op,
|
2013-10-10 17:11:24 +00:00
|
|
|
(outs dst_rc:$vdata),
|
2013-05-06 23:02:12 +00:00
|
|
|
(ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128,
|
2013-08-14 23:24:17 +00:00
|
|
|
i1imm:$tfe, i1imm:$lwe, i1imm:$slc, src_rc:$vaddr,
|
2013-05-06 23:02:12 +00:00
|
|
|
SReg_256:$srsrc),
|
|
|
|
asm#" $vdata, $dmask, $unorm, $glc, $da, $r128,"
|
|
|
|
#" $tfe, $lwe, $slc, $vaddr, $srsrc",
|
|
|
|
[]> {
|
|
|
|
let SSAMP = 0;
|
|
|
|
let mayLoad = 1;
|
|
|
|
let mayStore = 0;
|
|
|
|
let hasPostISelHook = 1;
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:24 +00:00
|
|
|
multiclass MIMG_NoSampler_Src_Helper <bits<7> op, string asm,
|
|
|
|
RegisterClass dst_rc,
|
|
|
|
int channels> {
|
|
|
|
def _V1 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_32>,
|
|
|
|
MIMG_Mask<asm#"_V1", channels>;
|
|
|
|
def _V2 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_64>,
|
|
|
|
MIMG_Mask<asm#"_V2", channels>;
|
|
|
|
def _V4 : MIMG_NoSampler_Helper <op, asm, dst_rc, VReg_128>,
|
|
|
|
MIMG_Mask<asm#"_V4", channels>;
|
|
|
|
}
|
|
|
|
|
2013-08-14 23:24:17 +00:00
|
|
|
multiclass MIMG_NoSampler <bits<7> op, string asm> {
|
2013-10-10 17:11:24 +00:00
|
|
|
defm _V1 : MIMG_NoSampler_Src_Helper <op, asm, VReg_32, 1>;
|
|
|
|
defm _V2 : MIMG_NoSampler_Src_Helper <op, asm, VReg_64, 2>;
|
|
|
|
defm _V3 : MIMG_NoSampler_Src_Helper <op, asm, VReg_96, 3>;
|
|
|
|
defm _V4 : MIMG_NoSampler_Src_Helper <op, asm, VReg_128, 4>;
|
2013-08-14 23:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class MIMG_Sampler_Helper <bits<7> op, string asm,
|
2013-10-10 17:11:24 +00:00
|
|
|
RegisterClass dst_rc,
|
2013-08-14 23:24:17 +00:00
|
|
|
RegisterClass src_rc> : MIMG <
|
2013-02-21 15:16:44 +00:00
|
|
|
op,
|
2013-10-10 17:11:24 +00:00
|
|
|
(outs dst_rc:$vdata),
|
2013-02-21 15:16:44 +00:00
|
|
|
(ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128,
|
2013-08-14 23:24:17 +00:00
|
|
|
i1imm:$tfe, i1imm:$lwe, i1imm:$slc, src_rc:$vaddr,
|
2013-03-01 09:46:17 +00:00
|
|
|
SReg_256:$srsrc, SReg_128:$ssamp),
|
2013-02-21 15:17:17 +00:00
|
|
|
asm#" $vdata, $dmask, $unorm, $glc, $da, $r128,"
|
|
|
|
#" $tfe, $lwe, $slc, $vaddr, $srsrc, $ssamp",
|
2013-02-21 15:16:44 +00:00
|
|
|
[]> {
|
|
|
|
let mayLoad = 1;
|
2012-12-11 21:25:42 +00:00
|
|
|
let mayStore = 0;
|
2013-04-10 08:39:16 +00:00
|
|
|
let hasPostISelHook = 1;
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:24 +00:00
|
|
|
multiclass MIMG_Sampler_Src_Helper <bits<7> op, string asm,
|
|
|
|
RegisterClass dst_rc,
|
|
|
|
int channels> {
|
|
|
|
def _V1 : MIMG_Sampler_Helper <op, asm, dst_rc, VReg_32>,
|
|
|
|
MIMG_Mask<asm#"_V1", channels>;
|
|
|
|
def _V2 : MIMG_Sampler_Helper <op, asm, dst_rc, VReg_64>,
|
|
|
|
MIMG_Mask<asm#"_V2", channels>;
|
|
|
|
def _V4 : MIMG_Sampler_Helper <op, asm, dst_rc, VReg_128>,
|
|
|
|
MIMG_Mask<asm#"_V4", channels>;
|
|
|
|
def _V8 : MIMG_Sampler_Helper <op, asm, dst_rc, VReg_256>,
|
|
|
|
MIMG_Mask<asm#"_V8", channels>;
|
|
|
|
def _V16 : MIMG_Sampler_Helper <op, asm, dst_rc, VReg_512>,
|
|
|
|
MIMG_Mask<asm#"_V16", channels>;
|
|
|
|
}
|
|
|
|
|
2013-08-14 23:24:17 +00:00
|
|
|
multiclass MIMG_Sampler <bits<7> op, string asm> {
|
2013-10-10 17:11:24 +00:00
|
|
|
defm _V1 : MIMG_Sampler_Src_Helper<op, asm, VReg_32, 1>;
|
|
|
|
defm _V2 : MIMG_Sampler_Src_Helper<op, asm, VReg_64, 2>;
|
|
|
|
defm _V3 : MIMG_Sampler_Src_Helper<op, asm, VReg_96, 3>;
|
|
|
|
defm _V4 : MIMG_Sampler_Src_Helper<op, asm, VReg_128, 4>;
|
2013-08-14 23:24:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 17:52:42 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Vector instruction mappings
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Maps an opcode in e32 form to its e64 equivalent
|
|
|
|
def getVOPe64 : InstrMapping {
|
|
|
|
let FilterClass = "VOP";
|
|
|
|
let RowFields = ["OpName"];
|
|
|
|
let ColFields = ["Size"];
|
|
|
|
let KeyCol = ["4"];
|
|
|
|
let ValueCols = [["8"]];
|
|
|
|
}
|
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
// Maps an original opcode to its commuted version
|
|
|
|
def getCommuteRev : InstrMapping {
|
|
|
|
let FilterClass = "VOP2_REV";
|
|
|
|
let RowFields = ["RevOp"];
|
|
|
|
let ColFields = ["IsOrig"];
|
|
|
|
let KeyCol = ["1"];
|
|
|
|
let ValueCols = [["0"]];
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:24 +00:00
|
|
|
def getMaskedMIMGOp : InstrMapping {
|
|
|
|
let FilterClass = "MIMG_Mask";
|
|
|
|
let RowFields = ["Op"];
|
|
|
|
let ColFields = ["Channels"];
|
|
|
|
let KeyCol = ["4"];
|
|
|
|
let ValueCols = [["1"], ["2"], ["3"] ];
|
|
|
|
}
|
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
// Maps an commuted opcode to its original version
|
|
|
|
def getCommuteOrig : InstrMapping {
|
|
|
|
let FilterClass = "VOP2_REV";
|
|
|
|
let RowFields = ["RevOp"];
|
|
|
|
let ColFields = ["IsOrig"];
|
|
|
|
let KeyCol = ["0"];
|
|
|
|
let ValueCols = [["1"]];
|
|
|
|
}
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
include "SIInstructions.td"
|