radeon/llvm: Remove the last uses of MachineOperand flags

This commit is contained in:
Tom Stellard 2012-08-23 13:55:22 +00:00
parent 67a47a445b
commit ead72204f1
2 changed files with 27 additions and 8 deletions

View file

@ -316,7 +316,7 @@ R600InstrInfo::InsertBranch(MachineBasicBlock &MBB,
} else {
MachineInstr *PredSet = findFirstPredicateSetterFrom(MBB, MBB.end());
assert(PredSet && "No previous predicate !");
PredSet->getOperand(1).addTargetFlag(1<<4);
AddFlag(PredSet, 1, MO_FLAG_PUSH);
PredSet->getOperand(2).setImm(Cond[1].getImm());
BuildMI(&MBB, DL, get(AMDGPU::JUMP))
@ -327,7 +327,7 @@ R600InstrInfo::InsertBranch(MachineBasicBlock &MBB,
} else {
MachineInstr *PredSet = findFirstPredicateSetterFrom(MBB, MBB.end());
assert(PredSet && "No previous predicate !");
PredSet->getOperand(1).addTargetFlag(1<<4);
AddFlag(PredSet, 1, MO_FLAG_PUSH);
PredSet->getOperand(2).setImm(Cond[1].getImm());
BuildMI(&MBB, DL, get(AMDGPU::JUMP))
.addMBB(TBB)
@ -356,8 +356,7 @@ R600InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const
case AMDGPU::JUMP:
if (isPredicated(I)) {
MachineInstr *predSet = findFirstPredicateSetterFrom(MBB, I);
char flag = predSet->getOperand(1).getTargetFlags() & (~(1<<4));
predSet->getOperand(1).setTargetFlags(flag);
ClearFlag(predSet, 1, MO_FLAG_PUSH);
}
I->eraseFromParent();
break;
@ -375,8 +374,7 @@ R600InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const
case AMDGPU::JUMP:
if (isPredicated(I)) {
MachineInstr *predSet = findFirstPredicateSetterFrom(MBB, I);
char flag = predSet->getOperand(1).getTargetFlags() & (~(1<<4));
predSet->getOperand(1).setTargetFlags(flag);
ClearFlag(predSet, 1, MO_FLAG_PUSH);
}
I->eraseFromParent();
break;
@ -532,14 +530,20 @@ bool R600InstrInfo::HasFlagOperand(const MachineInstr &MI) const
return GET_FLAG_OPERAND_IDX(MI) != 0;
}
void R600InstrInfo::AddFlag(MachineInstr *MI, unsigned Operand,
unsigned Flag) const
MachineOperand &R600InstrInfo::GetFlagOp(MachineInstr *MI) const
{
unsigned FlagIndex = GET_FLAG_OPERAND_IDX(*MI);
assert(FlagIndex != 0 &&
"Instruction flags not supported for this instruction");
MachineOperand &FlagOp = MI->getOperand(FlagIndex);
assert(FlagOp.isImm());
return FlagOp;
}
void R600InstrInfo::AddFlag(MachineInstr *MI, unsigned Operand,
unsigned Flag) const
{
MachineOperand &FlagOp = GetFlagOp(MI);
FlagOp.setImm(FlagOp.getImm() | (Flag << (NUM_MO_FLAGS * Operand)));
}
@ -554,3 +558,12 @@ bool R600InstrInfo::IsFlagSet(const MachineInstr &MI, unsigned Operand,
return !!((MI.getOperand(FlagIndex).getImm() >>
(NUM_MO_FLAGS * Operand)) & Flag);
}
void R600InstrInfo::ClearFlag(MachineInstr *MI, unsigned Operand,
unsigned Flag) const
{
MachineOperand &FlagOp = GetFlagOp(MI);
unsigned InstFlags = FlagOp.getImm();
InstFlags &= ~(Flag << (NUM_MO_FLAGS * Operand));
FlagOp.setImm(InstFlags);
}

View file

@ -119,6 +119,12 @@ namespace llvm {
///IsFlagSet - Determine if the specified flag is set on this Operand.
bool IsFlagSet(const MachineInstr &MI, unsigned Operand, unsigned Flag) const;
///GetFlagOp - Return the operand containing the flags for this instruction.
MachineOperand &GetFlagOp(MachineInstr *MI) const;
///ClearFlag - Clear the specified flag on the instruction.
void ClearFlag(MachineInstr *MI, unsigned Operand, unsigned Flag) const;
};
} // End llvm namespace