mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-08 19:06:39 +00:00
ecc571f063
This is a candidate for the stable branch. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Tom Stellard <thomas.stellard@amd.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175356 91177308-0d34-0410-b5e6-96231b3b80d8
466 lines
9.9 KiB
TableGen
466 lines
9.9 KiB
TableGen
//===-- SIInstrInfo.td - SI Instruction Encodings ---------*- tablegen -*--===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// SI DAG Nodes
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// 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>]>
|
|
>;
|
|
|
|
// Transformation function, extract the lower 32bit of a 64bit immediate
|
|
def LO32 : SDNodeXForm<imm, [{
|
|
return CurDAG->getTargetConstant(N->getZExtValue() & 0xffffffff, MVT::i32);
|
|
}]>;
|
|
|
|
// Transformation function, extract the upper 32bit of a 64bit immediate
|
|
def HI32 : SDNodeXForm<imm, [{
|
|
return CurDAG->getTargetConstant(N->getZExtValue() >> 32, MVT::i32);
|
|
}]>;
|
|
|
|
def IMM8bitDWORD : ImmLeaf <
|
|
i32, [{
|
|
return (Imm & ~0x3FC) == 0;
|
|
}], SDNodeXForm<imm, [{
|
|
return CurDAG->getTargetConstant(
|
|
N->getZExtValue() >> 2, MVT::i32);
|
|
}]>
|
|
>;
|
|
|
|
def IMM12bit : ImmLeaf <
|
|
i16,
|
|
[{return isUInt<12>(Imm);}]
|
|
>;
|
|
|
|
class InlineImm <ValueType vt> : ImmLeaf <vt, [{
|
|
return -16 <= Imm && Imm <= 64;
|
|
}]>;
|
|
|
|
class InstSI <dag outs, dag ins, string asm, list<dag> pattern> :
|
|
AMDGPUInst<outs, ins, asm, pattern> {
|
|
|
|
field bits<1> VM_CNT = 0;
|
|
field bits<1> EXP_CNT = 0;
|
|
field bits<1> LGKM_CNT = 0;
|
|
|
|
let TSFlags{0} = VM_CNT;
|
|
let TSFlags{1} = EXP_CNT;
|
|
let TSFlags{2} = LGKM_CNT;
|
|
}
|
|
|
|
class Enc32 <dag outs, dag ins, string asm, list<dag> pattern> :
|
|
InstSI <outs, ins, asm, pattern> {
|
|
|
|
field bits<32> Inst;
|
|
let Size = 4;
|
|
}
|
|
|
|
class Enc64 <dag outs, dag ins, string asm, list<dag> pattern> :
|
|
InstSI <outs, ins, asm, pattern> {
|
|
|
|
field bits<64> Inst;
|
|
let Size = 8;
|
|
}
|
|
|
|
class SIOperand <ValueType vt, dag opInfo>: Operand <vt> {
|
|
let EncoderMethod = "encodeOperand";
|
|
let MIOperandInfo = opInfo;
|
|
}
|
|
|
|
class GPR4Align <RegisterClass rc> : Operand <vAny> {
|
|
let EncoderMethod = "GPR4AlignEncode";
|
|
let MIOperandInfo = (ops rc:$reg);
|
|
}
|
|
|
|
class GPR2Align <RegisterClass rc> : Operand <iPTR> {
|
|
let EncoderMethod = "GPR2AlignEncode";
|
|
let MIOperandInfo = (ops rc:$reg);
|
|
}
|
|
|
|
let Uses = [EXEC] in {
|
|
|
|
def EXP : Enc64<
|
|
(outs),
|
|
(ins i32imm:$en, i32imm:$tgt, i32imm:$compr, i32imm:$done, i32imm:$vm,
|
|
VReg_32:$src0, VReg_32:$src1, VReg_32:$src2, VReg_32:$src3),
|
|
"EXP $en, $tgt, $compr, $done, $vm, $src0, $src1, $src2, $src3",
|
|
[] > {
|
|
|
|
bits<4> EN;
|
|
bits<6> TGT;
|
|
bits<1> COMPR;
|
|
bits<1> DONE;
|
|
bits<1> VM;
|
|
bits<8> VSRC0;
|
|
bits<8> VSRC1;
|
|
bits<8> VSRC2;
|
|
bits<8> VSRC3;
|
|
|
|
let Inst{3-0} = EN;
|
|
let Inst{9-4} = TGT;
|
|
let Inst{10} = COMPR;
|
|
let Inst{11} = DONE;
|
|
let Inst{12} = VM;
|
|
let Inst{31-26} = 0x3e;
|
|
let Inst{39-32} = VSRC0;
|
|
let Inst{47-40} = VSRC1;
|
|
let Inst{55-48} = VSRC2;
|
|
let Inst{63-56} = VSRC3;
|
|
|
|
let EXP_CNT = 1;
|
|
}
|
|
|
|
class MIMG <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc64 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDATA;
|
|
bits<4> DMASK;
|
|
bits<1> UNORM;
|
|
bits<1> GLC;
|
|
bits<1> DA;
|
|
bits<1> R128;
|
|
bits<1> TFE;
|
|
bits<1> LWE;
|
|
bits<1> SLC;
|
|
bits<8> VADDR;
|
|
bits<5> SRSRC;
|
|
bits<5> SSAMP;
|
|
|
|
let Inst{11-8} = DMASK;
|
|
let Inst{12} = UNORM;
|
|
let Inst{13} = GLC;
|
|
let Inst{14} = DA;
|
|
let Inst{15} = R128;
|
|
let Inst{16} = TFE;
|
|
let Inst{17} = LWE;
|
|
let Inst{24-18} = op;
|
|
let Inst{25} = SLC;
|
|
let Inst{31-26} = 0x3c;
|
|
let Inst{39-32} = VADDR;
|
|
let Inst{47-40} = VDATA;
|
|
let Inst{52-48} = SRSRC;
|
|
let Inst{57-53} = SSAMP;
|
|
|
|
let VM_CNT = 1;
|
|
let EXP_CNT = 1;
|
|
}
|
|
|
|
class MTBUF <bits<3> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc64<outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDATA;
|
|
bits<12> OFFSET;
|
|
bits<1> OFFEN;
|
|
bits<1> IDXEN;
|
|
bits<1> GLC;
|
|
bits<1> ADDR64;
|
|
bits<4> DFMT;
|
|
bits<3> NFMT;
|
|
bits<8> VADDR;
|
|
bits<5> SRSRC;
|
|
bits<1> SLC;
|
|
bits<1> TFE;
|
|
bits<8> SOFFSET;
|
|
|
|
let Inst{11-0} = OFFSET;
|
|
let Inst{12} = OFFEN;
|
|
let Inst{13} = IDXEN;
|
|
let Inst{14} = GLC;
|
|
let Inst{15} = ADDR64;
|
|
let Inst{18-16} = op;
|
|
let Inst{22-19} = DFMT;
|
|
let Inst{25-23} = NFMT;
|
|
let Inst{31-26} = 0x3a; //encoding
|
|
let Inst{39-32} = VADDR;
|
|
let Inst{47-40} = VDATA;
|
|
let Inst{52-48} = SRSRC;
|
|
let Inst{54} = SLC;
|
|
let Inst{55} = TFE;
|
|
let Inst{63-56} = SOFFSET;
|
|
|
|
let VM_CNT = 1;
|
|
let EXP_CNT = 1;
|
|
|
|
let neverHasSideEffects = 1;
|
|
}
|
|
|
|
class MUBUF <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc64<outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDATA;
|
|
bits<12> OFFSET;
|
|
bits<1> OFFEN;
|
|
bits<1> IDXEN;
|
|
bits<1> GLC;
|
|
bits<1> ADDR64;
|
|
bits<1> LDS;
|
|
bits<8> VADDR;
|
|
bits<5> SRSRC;
|
|
bits<1> SLC;
|
|
bits<1> TFE;
|
|
bits<8> SOFFSET;
|
|
|
|
let Inst{11-0} = OFFSET;
|
|
let Inst{12} = OFFEN;
|
|
let Inst{13} = IDXEN;
|
|
let Inst{14} = GLC;
|
|
let Inst{15} = ADDR64;
|
|
let Inst{16} = LDS;
|
|
let Inst{24-18} = op;
|
|
let Inst{31-26} = 0x38; //encoding
|
|
let Inst{39-32} = VADDR;
|
|
let Inst{47-40} = VDATA;
|
|
let Inst{52-48} = SRSRC;
|
|
let Inst{54} = SLC;
|
|
let Inst{55} = TFE;
|
|
let Inst{63-56} = SOFFSET;
|
|
|
|
let VM_CNT = 1;
|
|
let EXP_CNT = 1;
|
|
|
|
let neverHasSideEffects = 1;
|
|
}
|
|
|
|
} // End Uses = [EXEC]
|
|
|
|
class SMRD <bits<5> op, bits<1> imm, dag outs, dag ins, string asm,
|
|
list<dag> pattern> : Enc32<outs, ins, asm, pattern> {
|
|
|
|
bits<7> SDST;
|
|
bits<6> SBASE;
|
|
bits<8> OFFSET;
|
|
|
|
let Inst{7-0} = OFFSET;
|
|
let Inst{8} = imm;
|
|
let Inst{14-9} = SBASE;
|
|
let Inst{21-15} = SDST;
|
|
let Inst{26-22} = op;
|
|
let Inst{31-27} = 0x18; //encoding
|
|
|
|
let LGKM_CNT = 1;
|
|
}
|
|
|
|
class SOP1 <bits<8> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32<outs, ins, asm, pattern> {
|
|
|
|
bits<7> SDST;
|
|
bits<8> SSRC0;
|
|
|
|
let Inst{7-0} = SSRC0;
|
|
let Inst{15-8} = op;
|
|
let Inst{22-16} = SDST;
|
|
let Inst{31-23} = 0x17d; //encoding;
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class SOP2 <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <outs, ins, asm, pattern> {
|
|
|
|
bits<7> SDST;
|
|
bits<8> SSRC0;
|
|
bits<8> SSRC1;
|
|
|
|
let Inst{7-0} = SSRC0;
|
|
let Inst{15-8} = SSRC1;
|
|
let Inst{22-16} = SDST;
|
|
let Inst{29-23} = op;
|
|
let Inst{31-30} = 0x2; // encoding
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class SOPC <bits<7> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32<outs, ins, asm, pattern> {
|
|
|
|
bits<8> SSRC0;
|
|
bits<8> SSRC1;
|
|
|
|
let Inst{7-0} = SSRC0;
|
|
let Inst{15-8} = SSRC1;
|
|
let Inst{22-16} = op;
|
|
let Inst{31-23} = 0x17e;
|
|
|
|
let DisableEncoding = "$dst";
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class SOPK <bits<5> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <outs, ins , asm, pattern> {
|
|
|
|
bits <7> SDST;
|
|
bits <16> SIMM16;
|
|
|
|
let Inst{15-0} = SIMM16;
|
|
let Inst{22-16} = SDST;
|
|
let Inst{27-23} = op;
|
|
let Inst{31-28} = 0xb; //encoding
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class SOPP <bits<7> op, dag ins, string asm, list<dag> pattern> : Enc32 <
|
|
(outs),
|
|
ins,
|
|
asm,
|
|
pattern > {
|
|
|
|
bits <16> SIMM16;
|
|
|
|
let Inst{15-0} = SIMM16;
|
|
let Inst{22-16} = op;
|
|
let Inst{31-23} = 0x17f; // encoding
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
let Uses = [EXEC] in {
|
|
|
|
class VINTRP <bits <2> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDST;
|
|
bits<8> VSRC;
|
|
bits<2> ATTRCHAN;
|
|
bits<6> ATTR;
|
|
|
|
let Inst{7-0} = VSRC;
|
|
let Inst{9-8} = ATTRCHAN;
|
|
let Inst{15-10} = ATTR;
|
|
let Inst{17-16} = op;
|
|
let Inst{25-18} = VDST;
|
|
let Inst{31-26} = 0x32; // encoding
|
|
|
|
let neverHasSideEffects = 1;
|
|
let mayLoad = 1;
|
|
let mayStore = 0;
|
|
}
|
|
|
|
class VOP1 <bits<8> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDST;
|
|
bits<9> SRC0;
|
|
|
|
let Inst{8-0} = SRC0;
|
|
let Inst{16-9} = op;
|
|
let Inst{24-17} = VDST;
|
|
let Inst{31-25} = 0x3f; //encoding
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class VOP2 <bits<6> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDST;
|
|
bits<9> SRC0;
|
|
bits<8> VSRC1;
|
|
|
|
let Inst{8-0} = SRC0;
|
|
let Inst{16-9} = VSRC1;
|
|
let Inst{24-17} = VDST;
|
|
let Inst{30-25} = op;
|
|
let Inst{31} = 0x0; //encoding
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class VOP3 <bits<9> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc64 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDST;
|
|
bits<9> SRC0;
|
|
bits<9> SRC1;
|
|
bits<9> SRC2;
|
|
bits<3> ABS;
|
|
bits<1> CLAMP;
|
|
bits<2> OMOD;
|
|
bits<3> NEG;
|
|
|
|
let Inst{7-0} = VDST;
|
|
let Inst{10-8} = ABS;
|
|
let Inst{11} = CLAMP;
|
|
let Inst{25-17} = op;
|
|
let Inst{31-26} = 0x34; //encoding
|
|
let Inst{40-32} = SRC0;
|
|
let Inst{49-41} = SRC1;
|
|
let Inst{58-50} = SRC2;
|
|
let Inst{60-59} = OMOD;
|
|
let Inst{63-61} = NEG;
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class VOP3b <bits<9> op, dag outs, dag ins, string asm, list<dag> pattern> :
|
|
Enc64 <outs, ins, asm, pattern> {
|
|
|
|
bits<8> VDST;
|
|
bits<9> SRC0;
|
|
bits<9> SRC1;
|
|
bits<9> SRC2;
|
|
bits<7> SDST;
|
|
bits<2> OMOD;
|
|
bits<3> NEG;
|
|
|
|
let Inst{7-0} = VDST;
|
|
let Inst{14-8} = SDST;
|
|
let Inst{25-17} = op;
|
|
let Inst{31-26} = 0x34; //encoding
|
|
let Inst{40-32} = SRC0;
|
|
let Inst{49-41} = SRC1;
|
|
let Inst{58-50} = SRC2;
|
|
let Inst{60-59} = OMOD;
|
|
let Inst{63-61} = NEG;
|
|
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
class VOPC <bits<8> op, dag ins, string asm, list<dag> pattern> :
|
|
Enc32 <(outs VCCReg:$dst), ins, asm, pattern> {
|
|
|
|
bits<9> SRC0;
|
|
bits<8> VSRC1;
|
|
|
|
let Inst{8-0} = SRC0;
|
|
let Inst{16-9} = VSRC1;
|
|
let Inst{24-17} = op;
|
|
let Inst{31-25} = 0x3e;
|
|
|
|
let DisableEncoding = "$dst";
|
|
let mayLoad = 0;
|
|
let mayStore = 0;
|
|
let hasSideEffects = 0;
|
|
}
|
|
|
|
} // End Uses = [EXEC]
|
|
|
|
include "SIInstrFormats.td"
|
|
include "SIInstructions.td"
|