35 #define DEBUG_TYPE "r600-expand-special-instrs" 54 return "R600 Expand special instructions pass";
61 "R600 Expand Special Instrs",
false,
false)
65 char R600ExpandSpecialInstrsPass::
ID = 0;
70 return new R600ExpandSpecialInstrsPass();
73 void R600ExpandSpecialInstrsPass::SetFlagInNewMI(
MachineInstr *NewMI,
75 int OpIdx =
TII->getOperandIdx(*OldMI, Op);
78 TII->setImmOperand(*NewMI, Op, Val);
82 bool R600ExpandSpecialInstrsPass::runOnMachineFunction(
MachineFunction &MF) {
92 while (I != MBB.
end()) {
98 int DstIdx = TII->getOperandIdx(MI.
getOpcode(), R600::OpName::dst);
102 DstOp.
getReg(), R600::OQAP);
104 int LDSPredSelIdx = TII->getOperandIdx(MI.
getOpcode(),
105 R600::OpName::pred_sel);
106 int MovPredSelIdx = TII->getOperandIdx(Mov->
getOpcode(),
107 R600::OpName::pred_sel);
120 MachineInstr *PredSet = TII->buildDefaultInstruction(MBB, I,
127 TII->setImmOperand(*PredSet, R600::OpName::update_exec_mask, 1);
129 TII->setImmOperand(*PredSet, R600::OpName::update_pred, 1);
139 unsigned DstBase = TRI.getEncodingValue(DstReg) &
HW_REG_MASK;
141 for (
unsigned Chan = 0; Chan < 4; ++Chan) {
144 R600::R600_TReg32RegClass.getRegister((DstBase * 4) + Chan);
146 TII->buildSlotOfVectorInstruction(MBB, &MI, Chan, SubDstReg);
159 BMI->
getOperand(TII->getOperandIdx(Opcode, R600::OpName::src0))
162 BMI->
getOperand(TII->getOperandIdx(Opcode, R600::OpName::src1))
166 if ((TRI.getEncodingValue(Src0) & 0xff) < 127 &&
167 (TRI.getEncodingValue(Src1) & 0xff) < 127)
175 bool IsReduction = TII->isReductionOp(MI.
getOpcode());
176 bool IsVector = TII->isVector(MI);
177 bool IsCube = TII->isCubeOp(MI.
getOpcode());
178 if (!IsReduction && !IsVector && !IsCube) {
207 for (
unsigned Chan = 0; Chan < 4; Chan++) {
216 int Src1Idx = TII->getOperandIdx(MI, R600::OpName::src1);
223 Src0 = TRI.getSubReg(Src0, SubRegIndex);
224 Src1 = TRI.getSubReg(Src1, SubRegIndex);
226 static const int CubeSrcSwz[] = {2, 2, 0, 1};
229 Src1 = TRI.getSubReg(Src0, SubRegIndex1);
230 Src0 = TRI.getSubReg(Src0, SubRegIndex0);
238 DstReg = TRI.getSubReg(DstReg, SubRegIndex);
243 unsigned DstBase = TRI.getEncodingValue(DstReg) &
HW_REG_MASK;
244 DstReg = R600::R600_TReg32RegClass.getRegister((DstBase * 4) + Chan);
248 NotLast = (Chan != 3 );
253 case R600::CUBE_r600_pseudo:
254 Opcode = R600::CUBE_r600_real;
256 case R600::CUBE_eg_pseudo:
257 Opcode = R600::CUBE_eg_real;
264 TII->buildDefaultInstruction(MBB, I, Opcode, DstReg, Src0, Src1);
274 SetFlagInNewMI(NewMI, &MI, R600::OpName::clamp);
275 SetFlagInNewMI(NewMI, &MI, R600::OpName::literal);
276 SetFlagInNewMI(NewMI, &MI, R600::OpName::src0_abs);
277 SetFlagInNewMI(NewMI, &MI, R600::OpName::src1_abs);
278 SetFlagInNewMI(NewMI, &MI, R600::OpName::src0_neg);
279 SetFlagInNewMI(NewMI, &MI, R600::OpName::src1_neg);
void bundleWithPred()
Bundle this instruction with its predecessor.
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Interface definition for R600InstrInfo.
unsigned const TargetRegisterInfo * TRI
Interface definition for R600RegisterInfo.
INITIALIZE_PASS_BEGIN(R600ExpandSpecialInstrsPass, DEBUG_TYPE, "R600 Expand Special Instrs", false, false) INITIALIZE_PASS_END(R600ExpandSpecialInstrsPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
FunctionPass * createR600ExpandSpecialInstrsPass()
void setReg(Register Reg)
Change the register this operand corresponds to.
static unsigned getSubRegFromChannel(unsigned Channel, unsigned NumRegs=1)
char & R600ExpandSpecialInstrsPassID
#define HW_REG_MASK
Defines for extracting register information from register encoding.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const R600InstrInfo * getInstrInfo() const override
FunctionPass class - This class is used to implement most global optimizations.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
const R600RegisterInfo * getRegisterInfo() const override
Iterator for intrusive lists based on ilist_node.
MachineOperand class - Representation of each machine instruction operand.
unsigned getHWRegChan(unsigned reg) const
get the HW encoding for a register's channel.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Wrapper class representing virtual and physical registers.