mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-24 07:01:35 +00:00
AMDGPU/SI: Remove source uses of VCCReg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
18f2a33eba
commit
f456aa53d9
@ -1136,7 +1136,7 @@ def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>;
|
|||||||
def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
|
def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
|
||||||
def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
|
def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
|
||||||
def VOP_CNDMASK : VOPProfile <[i32, i32, i32, untyped]> {
|
def VOP_CNDMASK : VOPProfile <[i32, i32, i32, untyped]> {
|
||||||
let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, VCCReg:$src2);
|
let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1);
|
||||||
let Ins64 = (ins Src0RC64:$src0, Src1RC64:$src1, SSrc_64:$src2);
|
let Ins64 = (ins Src0RC64:$src0, Src1RC64:$src1, SSrc_64:$src2);
|
||||||
let Asm64 = "$dst, $src0, $src1, $src2";
|
let Asm64 = "$dst, $src0, $src1, $src2";
|
||||||
}
|
}
|
||||||
|
@ -449,14 +449,16 @@ def S_CBRANCH_SCC1 : SOPP <
|
|||||||
>;
|
>;
|
||||||
} // End Uses = [SCC]
|
} // End Uses = [SCC]
|
||||||
|
|
||||||
|
let Uses = [VCC] in {
|
||||||
def S_CBRANCH_VCCZ : SOPP <
|
def S_CBRANCH_VCCZ : SOPP <
|
||||||
0x00000006, (ins sopp_brtarget:$simm16, VCCReg:$vcc),
|
0x00000006, (ins sopp_brtarget:$simm16),
|
||||||
"s_cbranch_vccz $simm16"
|
"s_cbranch_vccz $simm16"
|
||||||
>;
|
>;
|
||||||
def S_CBRANCH_VCCNZ : SOPP <
|
def S_CBRANCH_VCCNZ : SOPP <
|
||||||
0x00000007, (ins sopp_brtarget:$simm16, VCCReg:$vcc),
|
0x00000007, (ins sopp_brtarget:$simm16),
|
||||||
"s_cbranch_vccnz $simm16"
|
"s_cbranch_vccnz $simm16"
|
||||||
>;
|
>;
|
||||||
|
} // End Uses = [VCC]
|
||||||
|
|
||||||
let Uses = [EXEC] in {
|
let Uses = [EXEC] in {
|
||||||
def S_CBRANCH_EXECZ : SOPP <
|
def S_CBRANCH_EXECZ : SOPP <
|
||||||
|
@ -192,7 +192,7 @@ def SReg_32 : RegisterClass<"AMDGPU", [i32, f32], 32,
|
|||||||
def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64], 64, (add SGPR_64Regs)>;
|
def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64], 64, (add SGPR_64Regs)>;
|
||||||
|
|
||||||
def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, i1], 64,
|
def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, i1], 64,
|
||||||
(add SGPR_64, VCCReg, EXEC, FLAT_SCR)
|
(add SGPR_64, VCC, EXEC, FLAT_SCR)
|
||||||
>;
|
>;
|
||||||
|
|
||||||
def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v16i8], 128, (add SGPR_128)>;
|
def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v16i8], 128, (add SGPR_128)>;
|
||||||
|
@ -187,6 +187,21 @@ static void foldImmediates(MachineInstr &MI, const SIInstrInfo *TII,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy MachineOperand with all flags except setting it as implicit.
|
||||||
|
static MachineOperand copyRegOperandAsImplicit(const MachineOperand &Orig) {
|
||||||
|
assert(!Orig.isImplicit());
|
||||||
|
return MachineOperand::CreateReg(Orig.getReg(),
|
||||||
|
Orig.isDef(),
|
||||||
|
true,
|
||||||
|
Orig.isKill(),
|
||||||
|
Orig.isDead(),
|
||||||
|
Orig.isUndef(),
|
||||||
|
Orig.isEarlyClobber(),
|
||||||
|
Orig.getSubReg(),
|
||||||
|
Orig.isDebug(),
|
||||||
|
Orig.isInternalRead());
|
||||||
|
}
|
||||||
|
|
||||||
bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
|
bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
|
||||||
MachineRegisterInfo &MRI = MF.getRegInfo();
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||||
const SIInstrInfo *TII =
|
const SIInstrInfo *TII =
|
||||||
@ -236,14 +251,10 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
if (TII->isVOPC(Op32)) {
|
if (TII->isVOPC(Op32)) {
|
||||||
unsigned DstReg = MI.getOperand(0).getReg();
|
unsigned DstReg = MI.getOperand(0).getReg();
|
||||||
if (TargetRegisterInfo::isVirtualRegister(DstReg)) {
|
if (TargetRegisterInfo::isVirtualRegister(DstReg)) {
|
||||||
// VOPC instructions can only write to the VCC register. We can't
|
// VOPC instructions can only write to the VCC register. We can't
|
||||||
// force them to use VCC here, because the register allocator has
|
// force them to use VCC here, because this is only one register and
|
||||||
// trouble with sequences like this, which cause the allocator to run
|
// cannot deal with sequences which would require multiple copies of
|
||||||
// out of registers if vreg0 and vreg1 belong to the VCCReg register
|
// VCC, e.g. S_AND_B64 (vcc = V_CMP_...), (vcc = V_CMP_...)
|
||||||
// class:
|
|
||||||
// vreg0 = VOPC;
|
|
||||||
// vreg1 = VOPC;
|
|
||||||
// S_AND_B64 vreg0, vreg1
|
|
||||||
//
|
//
|
||||||
// So, instead of forcing the instruction to write to VCC, we provide
|
// So, instead of forcing the instruction to write to VCC, we provide
|
||||||
// a hint to the register allocator to use VCC and then we we will run
|
// a hint to the register allocator to use VCC and then we we will run
|
||||||
@ -288,9 +299,19 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
Inst32.addOperand(*Src1);
|
Inst32.addOperand(*Src1);
|
||||||
|
|
||||||
const MachineOperand *Src2 =
|
const MachineOperand *Src2 =
|
||||||
TII->getNamedOperand(MI, AMDGPU::OpName::src2);
|
TII->getNamedOperand(MI, AMDGPU::OpName::src2);
|
||||||
if (Src2)
|
if (Src2) {
|
||||||
Inst32.addOperand(*Src2);
|
int Op32Src2Idx = AMDGPU::getNamedOperandIdx(Op32, AMDGPU::OpName::src2);
|
||||||
|
if (Op32Src2Idx != -1) {
|
||||||
|
Inst32.addOperand(*Src2);
|
||||||
|
} else {
|
||||||
|
// In the case of V_CNDMASK_B32_e32, the explicit operand src2 is
|
||||||
|
// replaced with an implicit read of vcc.
|
||||||
|
assert(Src2->getReg() == AMDGPU::VCC &&
|
||||||
|
"Unexpected missing register operand");
|
||||||
|
Inst32.addOperand(copyRegOperandAsImplicit(*Src2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++NumInstructionsShrunk;
|
++NumInstructionsShrunk;
|
||||||
MI.eraseFromParent();
|
MI.eraseFromParent();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user