36 #define DEBUG_TYPE "r600-expand-special-instrs" 55 return "R600 Expand special instructions pass";
62 "R600 Expand Special Instrs",
false,
false)
66 char R600ExpandSpecialInstrsPass::
ID = 0;
71 return new R600ExpandSpecialInstrsPass();
74 void R600ExpandSpecialInstrsPass::SetFlagInNewMI(
MachineInstr *NewMI,
76 int OpIdx =
TII->getOperandIdx(*OldMI, Op);
79 TII->setImmOperand(*NewMI, Op, Val);
83 bool R600ExpandSpecialInstrsPass::runOnMachineFunction(
MachineFunction &MF) {
93 while (I != MBB.
end()) {
99 int DstIdx = TII->getOperandIdx(MI.
getOpcode(), R600::OpName::dst);
103 DstOp.
getReg(), R600::OQAP);
105 int LDSPredSelIdx = TII->getOperandIdx(MI.
getOpcode(),
106 R600::OpName::pred_sel);
107 int MovPredSelIdx = TII->getOperandIdx(Mov->
getOpcode(),
108 R600::OpName::pred_sel);
121 MachineInstr *PredSet = TII->buildDefaultInstruction(MBB, I,
128 TII->setImmOperand(*PredSet, R600::OpName::update_exec_mask, 1);
130 TII->setImmOperand(*PredSet, R600::OpName::update_pred, 1);
140 unsigned DstBase = TRI.getEncodingValue(DstReg) &
HW_REG_MASK;
142 for (
unsigned Chan = 0; Chan < 4; ++Chan) {
145 R600::R600_TReg32RegClass.getRegister((DstBase * 4) + Chan);
147 TII->buildSlotOfVectorInstruction(MBB, &MI, Chan, SubDstReg);
160 TII->getOperandIdx(Opcode, R600::OpName::src0))
163 TII->getOperandIdx(Opcode, R600::OpName::src1))
167 if ((TRI.getEncodingValue(Src0) & 0xff) < 127 &&
168 (TRI.getEncodingValue(Src1) & 0xff) < 127)
176 bool IsReduction = TII->isReductionOp(MI.
getOpcode());
177 bool IsVector = TII->isVector(MI);
178 bool IsCube = TII->isCubeOp(MI.
getOpcode());
179 if (!IsReduction && !IsVector && !IsCube) {
208 for (
unsigned Chan = 0; Chan < 4; Chan++) {
210 TII->getOperandIdx(MI, R600::OpName::dst)).
getReg();
212 TII->getOperandIdx(MI, R600::OpName::src0)).
getReg();
217 int Src1Idx = TII->getOperandIdx(MI, R600::OpName::src1);
224 Src0 = TRI.getSubReg(Src0, SubRegIndex);
225 Src1 = TRI.getSubReg(Src1, SubRegIndex);
227 static const int CubeSrcSwz[] = {2, 2, 0, 1};
230 Src1 = TRI.getSubReg(Src0, SubRegIndex1);
231 Src0 = TRI.getSubReg(Src0, SubRegIndex0);
239 DstReg = TRI.getSubReg(DstReg, SubRegIndex);
244 unsigned DstBase = TRI.getEncodingValue(DstReg) &
HW_REG_MASK;
245 DstReg = R600::R600_TReg32RegClass.getRegister((DstBase * 4) + Chan);
249 NotLast = (Chan != 3 );
254 case R600::CUBE_r600_pseudo:
255 Opcode = R600::CUBE_r600_real;
257 case R600::CUBE_eg_pseudo:
258 Opcode = R600::CUBE_eg_real;
265 TII->buildDefaultInstruction(MBB, I, Opcode, DstReg, Src0, Src1);
275 SetFlagInNewMI(NewMI, &MI, R600::OpName::clamp);
276 SetFlagInNewMI(NewMI, &MI, R600::OpName::literal);
277 SetFlagInNewMI(NewMI, &MI, R600::OpName::src0_abs);
278 SetFlagInNewMI(NewMI, &MI, R600::OpName::src1_abs);
279 SetFlagInNewMI(NewMI, &MI, R600::OpName::src0_neg);
280 SetFlagInNewMI(NewMI, &MI, R600::OpName::src1_neg);
void bundleWithPred()
Bundle this instruction with its predecessor.
static unsigned getSubRegFromChannel(unsigned Channel)
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Interface definition for R600InstrInfo.
unsigned getReg() const
getReg - Returns the register number.
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()
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.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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.
const MachineOperand & getOperand(unsigned i) const