99#define DEBUG_TYPE "aarch64-srlt-define-superregs"
100#define PASS_NAME "AArch64 SRLT Define Super-Regs Pass"
105 inline static char ID = 0;
141Register AArch64SRLTDefineSuperRegs::getWidestSuperReg(
145 "Expected to be run straight after virtregrewriter!");
148 for (MCRegUnit U :
TRI->regunits(R))
149 Units.set((
unsigned)U);
151 auto IsSuitableSuperReg = [&](
Register SR) {
152 for (MCRegUnit U :
TRI->regunits(SR)) {
157 if (QHiRegUnits.test((
unsigned)U) &&
158 !Subtarget->isSVEorStreamingSVEAvailable())
164 if (!
TRI->isArtificialRegUnit(U) &&
165 (!Units.test((
unsigned)U) || !RequiredBaseRegUnits.test((
unsigned)U)))
171 Register LargestSuperReg = AArch64::NoRegister;
173 if (IsSuitableSuperReg(SR) && (LargestSuperReg == AArch64::NoRegister ||
174 TRI->isSuperRegister(LargestSuperReg, SR)))
175 LargestSuperReg = SR;
177 return LargestSuperReg;
180bool AArch64SRLTDefineSuperRegs::runOnMachineFunction(
MachineFunction &MF) {
186 if (!
MRI->subRegLivenessEnabled())
189 assert(!
MRI->isSSA() &&
"Expected to be run after breaking down SSA form!");
193 constexpr unsigned FixedRegs[] = {AArch64::FP, AArch64::LR, AArch64::SP};
195 BitVector RequiredBaseRegUnits(
TRI->getNumRegUnits());
197 for (MCRegUnit U :
TRI->regunits(R))
198 RequiredBaseRegUnits.set((
unsigned)U);
200 BitVector QHiRegUnits(
TRI->getNumRegUnits());
202 for (MCRegUnit U :
TRI->regunits(R))
203 QHiRegUnits.set((
unsigned)U);
206 for (MachineBasicBlock &
MBB : MF) {
207 for (MachineInstr &
MI :
MBB) {
209 if (
MI.getOpcode() == TargetOpcode::PATCHPOINT)
213 SmallSet<Register, 8> SuperRegs;
214 for (
const MachineOperand &DefOp :
MI.defs())
215 if (
Register R = getWidestSuperReg(DefOp.getReg(), RequiredBaseRegUnits,
217 R != AArch64::NoRegister)
220 if (!SuperRegs.
size())
226 bool IsRenamable =
any_of(
MI.defs(), [&](
const MachineOperand &MO) {
227 return MO.isRenamable() && TRI->regsOverlap(MO.getReg(), R);
230 return MO.isDead() && TRI->regsOverlap(MO.getReg(), R);
233 R,
true,
true,
false,
237 MI.addOperand(DefOp);
247 return new AArch64SRLTDefineSuperRegs();
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallSet class.
const AArch64RegisterInfo * getRegisterInfo() const override
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
Wrapper class representing virtual and physical registers.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
auto seq_inclusive(T Begin, T End)
Iterate over an integral type from Begin to End inclusive.
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
FunctionPass * createAArch64SRLTDefineSuperRegsPass()
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
LLVM_ABI char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.