44 #define DEBUG_TYPE "ppc-vsx-fma-mutate"
46 namespace llvm {
namespace PPC {
102 SlotIndex FMAIdx = LIS->getInstructionIndex(MI);
106 MachineInstr *AddendMI = LIS->getInstructionFromIndex(AddendValNo->
def);
149 bool OtherUsers =
false, KillsAddendSrc =
false;
156 if (J->modifiesRegister(AddendSrcReg, TRI) ||
157 J->killsRegister(AddendSrcReg, TRI)) {
158 KillsAddendSrc =
true;
163 if (OtherUsers || KillsAddendSrc)
168 unsigned KilledProdOp = 0, OtherProdOp = 0;
170 .Query(FMAIdx).isKill()) {
174 .Query(FMAIdx).isKill()) {
187 LIS->getInterval(AddendSrcReg).liveAt(FMAIdx)) &&
188 "Addend source register is not live!");
213 if (OldFMAReg == KilledProdReg)
217 "Addend copy not tied to old FMA output!");
219 DEBUG(
dbgs() <<
"VSX FMA Mutation:\n " << *MI;);
255 if (UseMI == AddendMI)
258 UseMO.
setReg(KilledProdReg);
265 LiveInterval &NewFMAInt = LIS->getInterval(KilledProdReg);
269 if (AI->valno == AddendValNo)
274 LIS->getVNInfoAllocator());
276 NewFMAInt.
addSegment(LiveInterval::Segment(AI->start, AI->end,
279 DEBUG(
dbgs() <<
" extended: " << NewFMAInt <<
'\n');
282 DEBUG(
dbgs() <<
" trimmed: " << FMAInt <<
'\n');
286 DEBUG(
dbgs() <<
" removing: " << *AddendMI <<
'\n');
287 LIS->RemoveMachineInstrFromMaps(AddendMI);
304 LIS = &getAnalysis<LiveIntervals>();
308 bool Changed =
false;
333 "PowerPC VSX FMA Mutation",
false,
false)
341 char PPCVSXFMAMutate::ID = 0;
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Segments::iterator iterator
SlotIndex def
The index of the defining instruction.
FunctionPass * createPPCVSXFMAMutatePass()
LiveInterval - This class represents the liveness of a register, or stack slot.
void setIsUndef(bool Val=true)
static bool isVirtualRegister(unsigned Reg)
isVirtualRegister - Return true if the specified register number is in the virtual register namespace...
VNInfo - Value Number Information.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const TargetRegisterClass * getRegClass(unsigned Reg) const
getRegClass - Return the register class of the specified virtual register.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
const HexagonRegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
bundle_iterator< MachineInstr, instr_iterator > iterator
void removeValNo(VNInfo *ValNo)
removeValNo - Remove all the segments defined by the specified value#.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
int getAltVSXFMAOpcode(uint16_t Opcode)
const MachineOperand & getOperand(unsigned i) const
void initializePPCVSXFMAMutatePass(PassRegistry &)
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
unsigned getSubReg() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void setIsKill(bool Val=true)
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
const PPCInstrInfo * getInstrInfo() const override
MachineOperand class - Representation of each machine instruction operand.
static cl::opt< bool > DisableVSXFMAMutate("disable-ppc-vsx-fma-mutation", cl::desc("Disable VSX FMA instruction mutation"), cl::Hidden)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
INITIALIZE_PASS_BEGIN(PPCVSXFMAMutate, DEBUG_TYPE,"PowerPC VSX FMA Mutation", false, false) INITIALIZE_PASS_END(PPCVSXFMAMutate
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
void setSubReg(unsigned subReg)
static reg_nodbg_iterator reg_nodbg_end()
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
unsigned getReg() const
getReg - Returns the register number.
VNInfo * getNextValue(SlotIndex def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
FMA - Perform a * b + c with no intermediate rounding step.
BasicBlockListType::iterator iterator
reg_nodbg_iterator reg_nodbg_begin(unsigned RegNo) const
SlotIndex - An opaque wrapper around machine indexes.