45 assert(Addr.
isReg() &&
"Expected an address register");
49 if (!Mov || (Mov->
getOpcode() != NVPTX::MOV_B32_sym &&
58 const int AddrSpaceIdx =
59 NVPTX::getNamedOperandIdx(
MI.getOpcode(), NVPTX::OpName::addsp);
62 const auto AddrSpace =
MI.getOperand(AddrSpaceIdx).getImm();
85 if (
MI.mayLoadOrStore()) {
87 NVPTX::getNamedOperandIdx(
MI.getOpcode(), NVPTX::OpName::addr);
88 if (AddrIdx >= 0 &&
MI.getOperand(AddrIdx).isReg())
102 NVPTXAddressFolderPass() : MachineFunctionPass(ID) {}
104 bool runOnMachineFunction(MachineFunction &MF)
override;
106 void getAnalysisUsage(AnalysisUsage &AU)
const override {
112char NVPTXAddressFolderPass::ID = 0;
115 "NVPTX Address Folder",
false,
false)
122 return new NVPTXAddressFolderPass();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool foldAddresses(MachineFunction &MF)
static bool foldAddress(MachineInstr &MI, MachineOperand &Addr, MachineRegisterInfo &MRI)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
LLVM_ABI void ChangeToES(const char *SymName, unsigned TargetFlags=0)
ChangeToES - Replace this operand with a new external symbol operand.
LLVM_ABI void ChangeToGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
ChangeToGA - Replace this operand with a new global address operand.
unsigned getTargetFlags() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
This is an optimization pass for GlobalISel generic memory operations.
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...
MachineFunctionPass * createNVPTXAddressFolderPass()