mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 03:30:22 +00:00
R600/SI: Use a ComplexPattern for MUBUF stores
Now that non-leaf ComplexPatterns are allowed we can fold all the MUBUF store patterns into the instruction definition. We will also be able to reuse this new ComplexPattern for MUBUF loads and atomic operations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211644 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
78d1e95201
commit
11580ee62d
@ -84,6 +84,8 @@ private:
|
||||
SDValue& Offset);
|
||||
bool SelectADDRVTX_READ(SDValue Addr, SDValue &Base, SDValue &Offset);
|
||||
bool SelectADDRIndirect(SDValue Addr, SDValue &Base, SDValue &Offset);
|
||||
bool SelectMUBUFAddr64(SDValue Addr, SDValue &Ptr, SDValue &Offset,
|
||||
SDValue &ImmOffset) const;
|
||||
|
||||
SDNode *SelectADD_SUB_I64(SDNode *N);
|
||||
SDNode *SelectDIV_SCALE(SDNode *N);
|
||||
@ -723,6 +725,57 @@ SDNode *AMDGPUDAGToDAGISel::SelectDIV_SCALE(SDNode *N) {
|
||||
return CurDAG->SelectNodeTo(N, Opc, VT, MVT::i1, Ops);
|
||||
}
|
||||
|
||||
static SDValue wrapAddr64Rsrc(SelectionDAG *DAG, SDLoc DL, SDValue Ptr) {
|
||||
return SDValue(DAG->getMachineNode(AMDGPU::SI_ADDR64_RSRC, DL, MVT::v4i32,
|
||||
Ptr), 0);
|
||||
}
|
||||
|
||||
bool AMDGPUDAGToDAGISel::SelectMUBUFAddr64(SDValue Addr, SDValue &Ptr,
|
||||
SDValue &Offset,
|
||||
SDValue &ImmOffset) const {
|
||||
SDLoc DL(Addr);
|
||||
|
||||
if (CurDAG->isBaseWithConstantOffset(Addr)) {
|
||||
SDValue N0 = Addr.getOperand(0);
|
||||
SDValue N1 = Addr.getOperand(1);
|
||||
ConstantSDNode *C1 = cast<ConstantSDNode>(N1);
|
||||
|
||||
if (isUInt<12>(C1->getZExtValue())) {
|
||||
|
||||
if (N0.getOpcode() == ISD::ADD) {
|
||||
// (add (add N2, N3), C1)
|
||||
SDValue N2 = N0.getOperand(0);
|
||||
SDValue N3 = N0.getOperand(1);
|
||||
Ptr = wrapAddr64Rsrc(CurDAG, DL, N2);
|
||||
Offset = N3;
|
||||
ImmOffset = CurDAG->getTargetConstant(C1->getZExtValue(), MVT::i16);
|
||||
return true;
|
||||
}
|
||||
|
||||
// (add N0, C1)
|
||||
Ptr = wrapAddr64Rsrc(CurDAG, DL, CurDAG->getTargetConstant(0, MVT::i64));;
|
||||
Offset = N0;
|
||||
ImmOffset = CurDAG->getTargetConstant(C1->getZExtValue(), MVT::i16);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Addr.getOpcode() == ISD::ADD) {
|
||||
// (add N0, N1)
|
||||
SDValue N0 = Addr.getOperand(0);
|
||||
SDValue N1 = Addr.getOperand(1);
|
||||
Ptr = wrapAddr64Rsrc(CurDAG, DL, N0);
|
||||
Offset = N1;
|
||||
ImmOffset = CurDAG->getTargetConstant(0, MVT::i16);
|
||||
return true;
|
||||
}
|
||||
|
||||
// default case
|
||||
Ptr = wrapAddr64Rsrc(CurDAG, DL, CurDAG->getConstant(0, MVT::i64));
|
||||
Offset = Addr;
|
||||
ImmOffset = CurDAG->getTargetConstant(0, MVT::i16);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AMDGPUDAGToDAGISel::PostprocessISelDAG() {
|
||||
const AMDGPUTargetLowering& Lowering =
|
||||
*static_cast<const AMDGPUTargetLowering*>(getTargetLowering());
|
||||
|
@ -146,6 +146,12 @@ def FRAMEri32 : Operand<iPTR> {
|
||||
let MIOperandInfo = (ops i32:$ptr, i32imm:$index);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Complex patterns
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def MUBUFAddr64 : ComplexPattern<i64, 3, "SelectMUBUFAddr64">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// SI assembler operands
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -617,11 +623,12 @@ multiclass MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> {
|
||||
}
|
||||
}
|
||||
|
||||
class MUBUF_Store_Helper <bits<7> op, string name, RegisterClass vdataClass> :
|
||||
class MUBUF_Store_Helper <bits<7> op, string name, RegisterClass vdataClass,
|
||||
ValueType store_vt, SDPatternOperator st> :
|
||||
MUBUF <op, (outs), (ins vdataClass:$vdata, SReg_128:$srsrc, VReg_64:$vaddr,
|
||||
u16imm:$offset),
|
||||
name#" $vdata, $srsrc + $vaddr + $offset",
|
||||
[]> {
|
||||
[(st store_vt:$vdata, (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, u16imm:$offset))]> {
|
||||
|
||||
let mayLoad = 0;
|
||||
let mayStore = 1;
|
||||
|
@ -855,23 +855,23 @@ defm BUFFER_LOAD_DWORDX2 : MUBUF_Load_Helper <0x0000000d, "BUFFER_LOAD_DWORDX2",
|
||||
defm BUFFER_LOAD_DWORDX4 : MUBUF_Load_Helper <0x0000000e, "BUFFER_LOAD_DWORDX4", VReg_128>;
|
||||
|
||||
def BUFFER_STORE_BYTE : MUBUF_Store_Helper <
|
||||
0x00000018, "BUFFER_STORE_BYTE", VReg_32
|
||||
0x00000018, "BUFFER_STORE_BYTE", VReg_32, i32, truncstorei8_global
|
||||
>;
|
||||
|
||||
def BUFFER_STORE_SHORT : MUBUF_Store_Helper <
|
||||
0x0000001a, "BUFFER_STORE_SHORT", VReg_32
|
||||
0x0000001a, "BUFFER_STORE_SHORT", VReg_32, i32, truncstorei16_global
|
||||
>;
|
||||
|
||||
def BUFFER_STORE_DWORD : MUBUF_Store_Helper <
|
||||
0x0000001c, "BUFFER_STORE_DWORD", VReg_32
|
||||
0x0000001c, "BUFFER_STORE_DWORD", VReg_32, i32, global_store
|
||||
>;
|
||||
|
||||
def BUFFER_STORE_DWORDX2 : MUBUF_Store_Helper <
|
||||
0x0000001d, "BUFFER_STORE_DWORDX2", VReg_64
|
||||
0x0000001d, "BUFFER_STORE_DWORDX2", VReg_64, v2i32, global_store
|
||||
>;
|
||||
|
||||
def BUFFER_STORE_DWORDX4 : MUBUF_Store_Helper <
|
||||
0x0000001e, "BUFFER_STORE_DWORDX4", VReg_128
|
||||
0x0000001e, "BUFFER_STORE_DWORDX4", VReg_128, v4i32, global_store
|
||||
>;
|
||||
//def BUFFER_ATOMIC_SWAP : MUBUF_ <0x00000030, "BUFFER_ATOMIC_SWAP", []>;
|
||||
//def BUFFER_ATOMIC_CMPSWAP : MUBUF_ <0x00000031, "BUFFER_ATOMIC_CMPSWAP", []>;
|
||||
@ -2529,35 +2529,6 @@ defm : MUBUFLoad_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, v2i32,
|
||||
defm : MUBUFLoad_Pattern <BUFFER_LOAD_DWORDX4_ADDR64, v4i32,
|
||||
global_load, constant_load>;
|
||||
|
||||
multiclass MUBUFStore_Pattern <MUBUF Instr, ValueType vt, PatFrag st> {
|
||||
|
||||
def : Pat <
|
||||
(st vt:$value, (mubuf_vaddr_offset i64:$ptr, i64:$offset, IMM12bit:$imm_offset)),
|
||||
(Instr $value, (SI_ADDR64_RSRC $ptr), $offset, (as_i16imm $imm_offset))
|
||||
>;
|
||||
|
||||
def : Pat <
|
||||
(st vt:$value, (add i64:$ptr, IMM12bit:$offset)),
|
||||
(Instr $value, (SI_ADDR64_RSRC (i64 0)), $ptr, (as_i16imm $offset))
|
||||
>;
|
||||
|
||||
def : Pat <
|
||||
(st vt:$value, i64:$ptr),
|
||||
(Instr $value, (SI_ADDR64_RSRC (i64 0)), $ptr, 0)
|
||||
>;
|
||||
|
||||
def : Pat <
|
||||
(st vt:$value, (add i64:$ptr, i64:$offset)),
|
||||
(Instr $value, (SI_ADDR64_RSRC $ptr), $offset, 0)
|
||||
>;
|
||||
}
|
||||
|
||||
defm : MUBUFStore_Pattern <BUFFER_STORE_BYTE, i32, truncstorei8_global>;
|
||||
defm : MUBUFStore_Pattern <BUFFER_STORE_SHORT, i32, truncstorei16_global>;
|
||||
defm : MUBUFStore_Pattern <BUFFER_STORE_DWORD, i32, global_store>;
|
||||
defm : MUBUFStore_Pattern <BUFFER_STORE_DWORDX2, v2i32, global_store>;
|
||||
defm : MUBUFStore_Pattern <BUFFER_STORE_DWORDX4, v4i32, global_store>;
|
||||
|
||||
// BUFFER_LOAD_DWORD*, addr64=0
|
||||
multiclass MUBUF_Load_Dword <ValueType vt, MUBUF offset, MUBUF offen, MUBUF idxen,
|
||||
MUBUF bothen> {
|
||||
|
Loading…
Reference in New Issue
Block a user