32 cl::desc(
"Threshold for triggering vextract replacement"));
46 return "Hexagon optimize vextract";
65 "Hexagon optimize vextract",
false,
false)
71 unsigned ElemR = MRI.createVirtualRegister(&Hexagon::IntRegsRegClass);
73 unsigned ExtIdxR = ExtI->
getOperand(2).getReg();
74 unsigned ExtIdxS = ExtI->getOperand(2).getSubReg();
79 if (DI->
getOpcode() == Hexagon::A2_tfrsi) {
81 V &= (HST->getVectorLength()-1) & -4u;
83 BuildMI(ExtB, ExtI, DL, HII->
get(Hexagon::L2_loadri_io), ElemR)
90 unsigned IdxR = MRI.createVirtualRegister(&Hexagon::IntRegsRegClass);
91 BuildMI(ExtB, ExtI, DL, HII->
get(Hexagon::A2_andir), IdxR)
92 .
add(ExtI->getOperand(2))
94 BuildMI(ExtB, ExtI, DL, HII->
get(Hexagon::L4_loadri_rr), ElemR)
104 const auto &HRI = *HST->getRegisterInfo();
107 std::map<unsigned, SmallVector<MachineInstr*,4>> VExtractMap;
108 bool Changed =
false;
112 unsigned Opc =
MI.getOpcode();
113 if (Opc != Hexagon::V6_extractw)
115 unsigned VecR =
MI.getOperand(1).getReg();
116 VExtractMap[VecR].push_back(&
MI);
120 for (
auto &
P : VExtractMap) {
121 unsigned VecR =
P.first;
127 HRI.getSpillAlignment(VecRC));
131 unsigned StoreOpc = VecRC.getID() == Hexagon::HvxVRRegClassID
132 ? Hexagon::V6_vS32b_ai
133 : Hexagon::PS_vstorerw_ai;
139 unsigned VecSize = HRI.getRegSizeInBits(VecRC) / 8;
149 BuildMI(ExtB, ExtI, DL, HII->get(Hexagon::PS_fi), BaseR)
151 .
addImm(SR == 0 ? 0 : VecSize/2);
153 unsigned ElemR = genElemLoad(ExtI, BaseR, MRI);
165 return new HexagonVExtract();
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
This class represents lattice values for constants.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned getReg() const
getReg - Returns the register number.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
unsigned getSubReg() const
const MDOperand & getOperand(unsigned I) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
void initializeHexagonVExtractPass(PassRegistry &)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
initializer< Ty > init(const Ty &Val)
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
int CreateSpillStackObject(uint64_t Size, unsigned Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
FunctionPass * createHexagonVExtract()
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const HexagonInstrInfo * getInstrInfo() const override
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
const MachineOperand & getOperand(unsigned i) const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...