38#define DEBUG_TYPE "x86-lower-tile-copy"
49 bool SrcKill,
int TileSS,
Register ScratchZMM) {
68 unsigned MemIdx,
unsigned Row) {
107 TRI->getAllocatableSet(MF,
TRI->getRegClass(X86::VR512RegClassID));
108 for (
auto RegT : VR512Regs.
set_bits())
111 return X86::NoRegister;
120 X86LowerTileCopyLegacy() : MachineFunctionPass(ID) {}
122 void getAnalysisUsage(AnalysisUsage &AU)
const override;
126 StringRef getPassName()
const override {
return "X86 Lower Tile Copy"; }
131char X86LowerTileCopyLegacy::ID = 0;
138void X86LowerTileCopyLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
139 AU.setPreservesAll();
144 return new X86LowerTileCopyLegacy();
154 assert((ST.hasAMXTILE() || ST.hasACEV1()) &&
155 "Only supported on AMX-TILE or ACE v1 targets");
160 TRI->getAllocatableSet(MF,
TRI->getRegClass(X86::GR64RegClassID));
167 if (
MI.isDebugInstr())
174 unsigned Opcode =
MI.getOpcode();
175 if (Opcode == X86::ACE_TILESPILL || Opcode == X86::ACE_TILERELOAD ||
176 Opcode == X86::ACE_TILERELOADV) {
178 "ACE tile spill pseudo outside an ACE function");
179 bool IsSpill = Opcode == X86::ACE_TILESPILL;
184 if (Opcode == X86::ACE_TILERELOAD)
186 else if (Opcode == X86::ACE_TILERELOADV)
194 ScratchZMM = X86::ZMM0;
208 addACETileRowAddr(MIB, MI, MemIdx, Row);
216 MI.eraseFromParent();
227 if (!X86::TILERegClass.
contains(DstReg, SrcReg))
231 unsigned Size =
TRI->getSpillSize(X86::TILERegClass);
232 Align Alignment =
TRI->getSpillAlign(X86::TILERegClass);
244 ScratchZMM = X86::ZMM0;
268 Register GR64Cand = X86::NoRegister;
269 for (
auto RegT : GR64Regs.set_bits()) {
283 Size =
TRI->getSpillSize(X86::GR64RegClass);
284 Alignment =
TRI->getSpillAlign(X86::GR64RegClass);
295#define GET_EGPR_IF_ENABLED(OPC) (ST.hasEGPR() ? OPC##_EVEX : OPC)
301 MO->
setReg(GR64Cand ? GR64Cand : X86::RAX);
304#undef GET_EGPR_IF_ENABLED
308 MO->
setReg(GR64Cand ? GR64Cand : X86::RAX);
318 MI.eraseFromParent();
325bool X86LowerTileCopyLegacy::runOnMachineFunction(
MachineFunction &MF) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static constexpr unsigned ACENumTileRows
static Register findScratchZMM(MachineFunction &MF, const TargetRegisterInfo *TRI, const LiveRegUnits &UsedRegs)
Pick a ZMM that is dead here, or NoRegister if none is available.
#define GET_EGPR_IF_ENABLED(OPC)
static bool lowerTileCopy(MachineFunction &MF)
static void addACETileRowAddr(MachineInstrBuilder &MIB, MachineInstr &MI, unsigned MemIdx, unsigned Row)
Add tile row Row's address to MIB from MI's operands at MemIdx.
static const unsigned ACETileRowSize
static void emitACETileReload(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const X86InstrInfo *TII, Register DstReg, Register ScratchZMM, function_ref< void(MachineInstrBuilder &, unsigned)> AddRowAddr)
Reload DstReg through ScratchZMM, a row at a time from AddRowAddr.
static void emitACETileSpill(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const X86InstrInfo *TII, Register SrcReg, bool SrcKill, int TileSS, Register ScratchZMM)
Emit the ACE tile spill sequence, storing SrcReg to TileSS.
Represent the analysis usage information of a pass.
iterator_range< const_set_bits_iterator > set_bits() const
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
A set of register units used to track register liveness.
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
LLVM_ABI void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI int CreateSpillStackObject(uint64_t Size, Align Alignment, TargetStackID::Value StackID=TargetStackID::Default)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
Representation of each machine instruction.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
void setIsKill(bool Val=true)
Register getReg() const
getReg - Returns the register number.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
ACEProgModelEnum getACEProgModel() const
AMXProgModelEnum getAMXProgModel() const
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ NoFlags
No Specific Flags.
constexpr RegState getKillRegState(bool B)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
addFrameReference - This function is used to add a reference to the base of an abstract object on the...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
FunctionPass * createX86LowerTileCopyLegacyPass()
auto reverse(ContainerTy &&C)
This struct is a compact representation of a valid (non-zero power of two) alignment.