}
def CONST : Constants;
+def FP_ZERO : PatLeaf <
+ (fpimm),
+ [{return N->getValueAPF().isZero();}]
+>;
+
+def FP_ONE : PatLeaf <
+ (fpimm),
+ [{return N->isExactlyValue(1.0);}]
+>;
+
let isCodeGenOnly = 1 in {
def MASK_WRITE : AMDGPUShaderInst <
let isPseudo = 1, usesCustomInserter = 1 in {
+class CLAMP <RegisterClass rc> : AMDGPUShaderInst <
+ (outs rc:$dst),
+ (ins rc:$src0),
+ "CLAMP $dst, $src0",
+ [(set rc:$dst, (int_AMDIL_clamp rc:$src0, (f32 FP_ZERO), (f32 FP_ONE)))]
+>;
+
class FABS <RegisterClass rc> : AMDGPUShaderInst <
(outs rc:$dst),
(ins rc:$src0),
}
}
let mayLoad = 0, mayStore=0 in {
-defm CLAMP : TernaryIntrinsicFloat<IL_OP_CLAMP, int_AMDIL_clamp>;
defm FMA : TernaryIntrinsicFloat<IL_OP_FMA, int_AMDIL_fma>;
defm LERP : TernaryIntrinsicFloat<IL_OP_LERP, int_AMDIL_lerp>;
}
lowerImplicitParameter(MI, *BB, MRI, 8);
break;
+ case AMDIL::CLAMP_R600:
+ MI->getOperand(0).addTargetFlag(MO_FLAG_CLAMP);
+ BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDIL::MOV))
+ .addOperand(MI->getOperand(0))
+ .addOperand(MI->getOperand(1));
+ break;
+
case AMDIL::FABS_R600:
MI->getOperand(1).addTargetFlag(MO_FLAG_ABS);
BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDIL::MOV))
}]
>;
-def FP_ZERO : PatLeaf <
- (fpimm),
- [{return N->getValueAPF().isZero();}]
->;
-
-def FP_ONE : PatLeaf <
- (fpimm),
- [{return N->isExactlyValue(1.0);}]
->;
-
def COND_EQ : PatLeaf <
(cond),
[{switch(N->get()){{default: return false;
} // End isCodeGenOnly = 1
+def CLAMP_R600 : CLAMP <R600_Reg32>;
def FABS_R600 : FABS<R600_Reg32>;
let isPseudo = 1 in {
.addOperand(MI.getOperand(1));
break;
- case AMDIL::CLAMP_f32:
- {
- MachineOperand lowOp = MI.getOperand(2);
- MachineOperand highOp = MI.getOperand(3);
- if (lowOp.isReg() && highOp.isReg()
- && lowOp.getReg() == AMDIL::ZERO && highOp.getReg() == AMDIL::ONE) {
- MI.getOperand(0).addTargetFlag(MO_FLAG_CLAMP);
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::MOV))
- .addOperand(MI.getOperand(0))
- .addOperand(MI.getOperand(1));
- } else {
- /* XXX: Handle other cases */
- abort();
- }
- break;
- }
-
/* XXX: Figure out the semantics of DIV_INF_f32 and make sure this is OK */
/* case AMDIL::DIV_INF_f32:
{
}
if (canInline) {
- MachineOperand * use = dstOp.getNextOperandForReg();
- /* The lowering operation for CLAMP needs to have the immediates
- * as operands, so we must propagate them. */
- while (use) {
- MachineOperand * next = use->getNextOperandForReg();
- if (use->getParent()->getOpcode() == AMDIL::CLAMP_f32) {
- use->setReg(inlineReg);
- }
- use = next;
- }
BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::COPY))
.addOperand(dstOp)
.addReg(inlineReg);
default:
return AMDGPUTargetLowering::EmitInstrWithCustomInserter(MI, BB);
+ case AMDIL::CLAMP_SI:
+ BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDIL::V_MOV_B32_e64))
+ .addOperand(MI->getOperand(0))
+ .addOperand(MI->getOperand(1))
+ /* VSRC1-2 are unused, but we still need to fill all the
+ * operand slots, so we just reuse the VSRC0 operand */
+ .addOperand(MI->getOperand(1))
+ .addOperand(MI->getOperand(1))
+ .addImm(0) // ABS
+ .addImm(1) // CLAMP
+ .addImm(0) // OMOD
+ .addImm(0); // NEG
+ MI->eraseFromParent();
+ break;
+
case AMDIL::FABS_SI:
BuildMI(*BB, I, BB->findDebugLoc(I), TII->get(AMDIL::V_MOV_B32_e64))
.addOperand(MI->getOperand(0))
MachineInstr * SIInstrInfo::convertToISA(MachineInstr & MI, MachineFunction &MF,
DebugLoc DL) const
{
-
- switch (MI.getOpcode()) {
- default: break;
- case AMDIL::CLAMP_f32: return convertCLAMP_f32(MI, MF, DL);
- }
-
MachineInstr * newMI = AMDGPUInstrInfo::convertToISA(MI, MF, DL);
const MCInstrDesc &newDesc = get(newMI->getOpcode());
default: return AMDILopcode;
}
}
-
-MachineInstr * SIInstrInfo::convertCLAMP_f32(MachineInstr & clampInstr,
- MachineFunction &MF, DebugLoc DL) const
-{
- MachineRegisterInfo &MRI = MF.getRegInfo();
- /* XXX: HACK assume that low == zero and high == one for now until
- * we have a way to propogate the immediates. */
-
-/*
- uint32_t zero = (uint32_t)APFloat(0.0f).bitcastToAPInt().getZExtValue();
- uint32_t one = (uint32_t)APFloat(1.0f).bitcastToAPInt().getZExtValue();
- uint32_t low = clampInstr.getOperand(2).getImm();
- uint32_t high = clampInstr.getOperand(3).getImm();
-*/
-// if (low == zero && high == one) {
-
- /* Convert the desination register to the VReg_32 class */
- if (TargetRegisterInfo::isVirtualRegister(clampInstr.getOperand(0).getReg())) {
- MRI.setRegClass(clampInstr.getOperand(0).getReg(),
- AMDIL::VReg_32RegisterClass);
- }
- return BuildMI(MF, DL, get(AMDIL::V_MOV_B32_e64))
- .addOperand(clampInstr.getOperand(0))
- .addOperand(clampInstr.getOperand(1))
- /* VSRC1-2 are unused, but we still need to fill all the
- * operand slots, so we just reuse the VSRC0 operand */
- .addOperand(clampInstr.getOperand(1))
- .addOperand(clampInstr.getOperand(1))
- .addImm(0) // ABS
- .addImm(1) // CLAMP
- .addImm(0) // OMOD
- .addImm(0); // NEG
-// } else {
- /* XXX: Handle other cases */
-// abort();
-// }
-}
const SIRegisterInfo RI;
AMDGPUTargetMachine &TM;
- MachineInstr * convertCLAMP_f32(MachineInstr & clampInstr,
- MachineFunction &MF, DebugLoc DL) const;
-
public:
explicit SIInstrInfo(AMDGPUTargetMachine &tm);
(S_LOAD_DWORDX4_IMM imm:$sampler_offset, SReg_64:$sampler)) /* Sampler */
>;
+def CLAMP_SI : CLAMP<VReg_32>;
def FABS_SI : FABS<VReg_32>;
def : Extract_Element <f32, v4f32, VReg_128, 0, sel_x>;