class raw_ostream;
class MachineFunction;
class ModuleSlotTracker;
+class TargetInstrInfo;
/// This class contains a discriminated union of information about pointers in
/// memory operands, relating them back to LLVM IR or to virtual locations (such
class MIRFormatter;
class PseudoSourceValue;
class raw_ostream;
-class TargetInstrInfo;
+class TargetMachine;
raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue* PSV);
virtual void printCustom(raw_ostream &O) const;
public:
- explicit PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII);
+ explicit PseudoSourceValue(unsigned Kind, const TargetMachine &TM);
virtual ~PseudoSourceValue();
const int FI;
public:
- explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII)
- : PseudoSourceValue(FixedStack, TII), FI(FI) {}
+ explicit FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
+ : PseudoSourceValue(FixedStack, TM), FI(FI) {}
static bool classof(const PseudoSourceValue *V) {
return V->kind() == FixedStack;
class CallEntryPseudoSourceValue : public PseudoSourceValue {
protected:
- CallEntryPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII);
+ CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM);
public:
bool isConstant(const MachineFrameInfo *) const override;
const GlobalValue *GV;
public:
- GlobalValuePseudoSourceValue(const GlobalValue *GV,
- const TargetInstrInfo &TII);
+ GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetMachine &TM);
static bool classof(const PseudoSourceValue *V) {
return V->kind() == GlobalValueCallEntry;
const char *ES;
public:
- ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII);
+ ExternalSymbolPseudoSourceValue(const char *ES, const TargetMachine &TM);
static bool classof(const PseudoSourceValue *V) {
return V->kind() == ExternalSymbolCallEntry;
/// Manages creation of pseudo source values.
class PseudoSourceValueManager {
- const TargetInstrInfo &TII;
+ const TargetMachine &TM;
const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
std::map<int, std::unique_ptr<FixedStackPseudoSourceValue>> FSValues;
StringMap<std::unique_ptr<const ExternalSymbolPseudoSourceValue>>
GlobalCallEntries;
public:
- PseudoSourceValueManager(const TargetInstrInfo &TII);
+ PseudoSourceValueManager(const TargetMachine &TM);
/// Return a pseudo source value referencing the area below the stack frame of
/// a function, e.g., the argument space.
}
public:
- /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
- /// (e.g. stack) the target returns the corresponding address space.
- virtual unsigned
- getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
- return 0;
- }
-
/// unfoldMemoryOperand - Separate a single instruction which folded a load or
/// a store or a load and a store into two or more instruction. If this is
/// possible, returns true as well as the new instructions by reference.
virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
static std::pair<int, int> parseBinutilsVersion(StringRef Version);
+
+ /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
+ /// (e.g. stack) the target returns the corresponding address space.
+ virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
+ return 0;
+ }
};
/// This class describes a target machine that is implemented with the LLVM
"Can't create a MachineFunction using a Module with a "
"Target-incompatible DataLayout attached\n");
- PSVManager =
- std::make_unique<PseudoSourceValueManager>(*(getSubtarget().
- getInstrInfo()));
+ PSVManager = std::make_unique<PseudoSourceValueManager>(getTarget());
}
MachineFunction::~MachineFunction() {
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetMachine.h"
+
using namespace llvm;
static const char *const PSVNames[] = {
"Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
"GlobalValueCallEntry", "ExternalSymbolCallEntry"};
-PseudoSourceValue::PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
+PseudoSourceValue::PseudoSourceValue(unsigned Kind, const TargetMachine &TM)
: Kind(Kind) {
- AddressSpace = TII.getAddressSpaceForPseudoSourceKind(Kind);
+ AddressSpace = TM.getAddressSpaceForPseudoSourceKind(Kind);
}
PseudoSourceValue::~PseudoSourceValue() = default;
OS << "FixedStack" << FI;
}
-CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(
- unsigned Kind, const TargetInstrInfo &TII)
- : PseudoSourceValue(Kind, TII) {}
+CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(unsigned Kind,
+ const TargetMachine &TM)
+ : PseudoSourceValue(Kind, TM) {}
bool CallEntryPseudoSourceValue::isConstant(const MachineFrameInfo *) const {
return false;
}
GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue(
- const GlobalValue *GV,
- const TargetInstrInfo &TII)
- : CallEntryPseudoSourceValue(GlobalValueCallEntry, TII), GV(GV) {}
+ const GlobalValue *GV, const TargetMachine &TM)
+ : CallEntryPseudoSourceValue(GlobalValueCallEntry, TM), GV(GV) {}
ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(
- const char *ES, const TargetInstrInfo &TII)
- : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TII), ES(ES) {}
+ const char *ES, const TargetMachine &TM)
+ : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TM), ES(ES) {}
-PseudoSourceValueManager::PseudoSourceValueManager(
- const TargetInstrInfo &TIInfo)
- : TII(TIInfo),
- StackPSV(PseudoSourceValue::Stack, TII),
- GOTPSV(PseudoSourceValue::GOT, TII),
- JumpTablePSV(PseudoSourceValue::JumpTable, TII),
- ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
+PseudoSourceValueManager::PseudoSourceValueManager(const TargetMachine &TMInfo)
+ : TM(TMInfo), StackPSV(PseudoSourceValue::Stack, TM),
+ GOTPSV(PseudoSourceValue::GOT, TM),
+ JumpTablePSV(PseudoSourceValue::JumpTable, TM),
+ ConstantPoolPSV(PseudoSourceValue::ConstantPool, TM) {}
const PseudoSourceValue *PseudoSourceValueManager::getStack() {
return &StackPSV;
PseudoSourceValueManager::getFixedStack(int FI) {
std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
if (!V)
- V = std::make_unique<FixedStackPseudoSourceValue>(FI, TII);
+ V = std::make_unique<FixedStackPseudoSourceValue>(FI, TM);
return V.get();
}
std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
GlobalCallEntries[GV];
if (!E)
- E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
+ E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TM);
return E.get();
}
std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
ExternalCallEntries[ES];
if (!E)
- E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
+ E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TM);
return E.get();
}
StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS,
const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const {
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
- const SIInstrInfo &TII = *MF.getSubtarget<GCNSubtarget>().getInstrInfo();
+ const AMDGPUTargetMachine &TM =
+ static_cast<const AMDGPUTargetMachine &>(MF.getTarget());
if (Src == "BufferResource") {
- PSV = MFI->getBufferPSV(TII);
+ PSV = MFI->getBufferPSV(TM);
return false;
}
if (Src == "ImageResource") {
- PSV = MFI->getImagePSV(TII);
+ PSV = MFI->getImagePSV(TM);
return false;
}
if (Src == "GWSResource") {
- PSV = MFI->getGWSPSV(TII);
+ PSV = MFI->getGWSPSV(TM);
return false;
}
llvm_unreachable("unknown MIR custom pseudo source value");
return std::make_pair(nullptr, -1);
}
+unsigned
+AMDGPUTargetMachine::getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
+ switch (Kind) {
+ case PseudoSourceValue::Stack:
+ case PseudoSourceValue::FixedStack:
+ return AMDGPUAS::PRIVATE_ADDRESS;
+ case PseudoSourceValue::ConstantPool:
+ case PseudoSourceValue::GOT:
+ case PseudoSourceValue::JumpTable:
+ case PseudoSourceValue::GlobalValueCallEntry:
+ case PseudoSourceValue::ExternalSymbolCallEntry:
+ case PseudoSourceValue::TargetCustom:
+ return AMDGPUAS::CONSTANT_ADDRESS;
+ }
+ return AMDGPUAS::FLAT_ADDRESS;
+}
+
//===----------------------------------------------------------------------===//
// GCN Target Machine (SI+)
//===----------------------------------------------------------------------===//
std::pair<const Value *, unsigned>
getPredicatedAddrSpace(const Value *V) const override;
+
+ unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const override;
};
//===----------------------------------------------------------------------===//
FlagOp.setImm(InstFlags);
}
}
-
-unsigned R600InstrInfo::getAddressSpaceForPseudoSourceKind(
- unsigned Kind) const {
- switch (Kind) {
- case PseudoSourceValue::Stack:
- case PseudoSourceValue::FixedStack:
- return AMDGPUAS::PRIVATE_ADDRESS;
- case PseudoSourceValue::ConstantPool:
- case PseudoSourceValue::GOT:
- case PseudoSourceValue::JumpTable:
- case PseudoSourceValue::GlobalValueCallEntry:
- case PseudoSourceValue::ExternalSymbolCallEntry:
- case PseudoSourceValue::TargetCustom:
- return AMDGPUAS::CONSTANT_ADDRESS;
- }
-
- llvm_unreachable("Invalid pseudo source kind");
-}
bool isRegisterLoad(const MachineInstr &MI) const {
return get(MI.getOpcode()).TSFlags & R600InstrFlags::REGISTER_LOAD;
}
-
- unsigned getAddressSpaceForPseudoSourceKind(
- unsigned Kind) const override;
};
namespace R600 {
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
+ const GCNTargetMachine &TM =
+ static_cast<const GCNTargetMachine &>(getTargetMachine());
+
if (RsrcIntr->IsImage) {
- Info.ptrVal =
- MFI->getImagePSV(*MF.getSubtarget<GCNSubtarget>().getInstrInfo());
+ Info.ptrVal = MFI->getImagePSV(TM);
Info.align.reset();
} else {
- Info.ptrVal =
- MFI->getBufferPSV(*MF.getSubtarget<GCNSubtarget>().getInstrInfo());
+ Info.ptrVal = MFI->getBufferPSV(TM);
}
Info.flags |= MachineMemOperand::MODereferenceable;
case Intrinsic::amdgcn_buffer_atomic_fadd: {
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
+ const GCNTargetMachine &TM =
+ static_cast<const GCNTargetMachine &>(getTargetMachine());
+
Info.opc = ISD::INTRINSIC_W_CHAIN;
Info.memVT = MVT::getVT(CI.getOperand(0)->getType());
- Info.ptrVal =
- MFI->getBufferPSV(*MF.getSubtarget<GCNSubtarget>().getInstrInfo());
+ Info.ptrVal = MFI->getBufferPSV(TM);
Info.align.reset();
Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
Info.opc = ISD::INTRINSIC_W_CHAIN;
Info.memVT = MVT::getVT(CI.getType()); // XXX: what is correct VT?
- Info.ptrVal =
- MFI->getImagePSV(*MF.getSubtarget<GCNSubtarget>().getInstrInfo());
+
+ const GCNTargetMachine &TM =
+ static_cast<const GCNTargetMachine &>(getTargetMachine());
+
+ Info.ptrVal = MFI->getImagePSV(TM);
Info.align.reset();
Info.flags |= MachineMemOperand::MOLoad |
MachineMemOperand::MODereferenceable;
case Intrinsic::amdgcn_ds_gws_sema_release_all: {
Info.opc = ISD::INTRINSIC_VOID;
+ const GCNTargetMachine &TM =
+ static_cast<const GCNTargetMachine &>(getTargetMachine());
+
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
- Info.ptrVal =
- MFI->getGWSPSV(*MF.getSubtarget<GCNSubtarget>().getInstrInfo());
+ Info.ptrVal = MFI->getGWSPSV(TM);
// This is an abstract access, but we need to specify a type and size.
Info.memVT = MVT::i32;
}
}
-unsigned SIInstrInfo::getAddressSpaceForPseudoSourceKind(
- unsigned Kind) const {
- switch(Kind) {
- case PseudoSourceValue::Stack:
- case PseudoSourceValue::FixedStack:
- return AMDGPUAS::PRIVATE_ADDRESS;
- case PseudoSourceValue::ConstantPool:
- case PseudoSourceValue::GOT:
- case PseudoSourceValue::JumpTable:
- case PseudoSourceValue::GlobalValueCallEntry:
- case PseudoSourceValue::ExternalSymbolCallEntry:
- case PseudoSourceValue::TargetCustom:
- return AMDGPUAS::CONSTANT_ADDRESS;
- }
- return AMDGPUAS::FLAT_ADDRESS;
-}
-
static constexpr unsigned ModifierOpNames[] = {
AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src1_modifiers,
AMDGPU::OpName::src2_modifiers, AMDGPU::OpName::clamp,
Register SrcReg2, int64_t CmpMask, int64_t CmpValue,
const MachineRegisterInfo *MRI) const override;
- unsigned getAddressSpaceForPseudoSourceKind(
- unsigned Kind) const override;
-
bool
areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,
const MachineInstr &MIb) const override;
#include "AMDGPUArgumentUsageInfo.h"
#include "AMDGPUMachineFunction.h"
+#include "AMDGPUTargetMachine.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIInstrInfo.h"
#include "llvm/ADT/SetVector.h"
};
protected:
- AMDGPUPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
- : PseudoSourceValue(Kind, TII) {}
+ AMDGPUPseudoSourceValue(unsigned Kind, const AMDGPUTargetMachine &TM)
+ : PseudoSourceValue(Kind, TM) {}
public:
bool isConstant(const MachineFrameInfo *) const override {
class AMDGPUBufferPseudoSourceValue final : public AMDGPUPseudoSourceValue {
public:
- explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII)
- : AMDGPUPseudoSourceValue(PSVBuffer, TII) {}
+ explicit AMDGPUBufferPseudoSourceValue(const AMDGPUTargetMachine &TM)
+ : AMDGPUPseudoSourceValue(PSVBuffer, TM) {}
static bool classof(const PseudoSourceValue *V) {
return V->kind() == PSVBuffer;
class AMDGPUImagePseudoSourceValue final : public AMDGPUPseudoSourceValue {
public:
// TODO: Is the img rsrc useful?
- explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII)
- : AMDGPUPseudoSourceValue(PSVImage, TII) {}
+ explicit AMDGPUImagePseudoSourceValue(const AMDGPUTargetMachine &TM)
+ : AMDGPUPseudoSourceValue(PSVImage, TM) {}
static bool classof(const PseudoSourceValue *V) {
return V->kind() == PSVImage;
class AMDGPUGWSResourcePseudoSourceValue final : public AMDGPUPseudoSourceValue {
public:
- explicit AMDGPUGWSResourcePseudoSourceValue(const TargetInstrInfo &TII)
- : AMDGPUPseudoSourceValue(GWSResource, TII) {}
+ explicit AMDGPUGWSResourcePseudoSourceValue(const AMDGPUTargetMachine &TM)
+ : AMDGPUPseudoSourceValue(GWSResource, TM) {}
static bool classof(const PseudoSourceValue *V) {
return V->kind() == GWSResource;
llvm_unreachable("unexpected dimension");
}
- const AMDGPUBufferPseudoSourceValue *getBufferPSV(const SIInstrInfo &TII) {
+ const AMDGPUBufferPseudoSourceValue *
+ getBufferPSV(const AMDGPUTargetMachine &TM) {
if (!BufferPSV)
- BufferPSV = std::make_unique<AMDGPUBufferPseudoSourceValue>(TII);
+ BufferPSV = std::make_unique<AMDGPUBufferPseudoSourceValue>(TM);
return BufferPSV.get();
}
- const AMDGPUImagePseudoSourceValue *getImagePSV(const SIInstrInfo &TII) {
+ const AMDGPUImagePseudoSourceValue *
+ getImagePSV(const AMDGPUTargetMachine &TM) {
if (!ImagePSV)
- ImagePSV = std::make_unique<AMDGPUImagePseudoSourceValue>(TII);
+ ImagePSV = std::make_unique<AMDGPUImagePseudoSourceValue>(TM);
return ImagePSV.get();
}
- const AMDGPUGWSResourcePseudoSourceValue *getGWSPSV(const SIInstrInfo &TII) {
+ const AMDGPUGWSResourcePseudoSourceValue *
+ getGWSPSV(const AMDGPUTargetMachine &TM) {
if (!GWSResourcePSV) {
- GWSResourcePSV =
- std::make_unique<AMDGPUGWSResourcePseudoSourceValue>(TII);
+ GWSResourcePSV = std::make_unique<AMDGPUGWSResourcePseudoSourceValue>(TM);
}
return GWSResourcePSV.get();
// Generate a misaligned load that is guaranteed to cause a crash.
class CrashPseudoSourceValue : public PseudoSourceValue {
public:
- CrashPseudoSourceValue(const TargetInstrInfo &TII)
- : PseudoSourceValue(TargetCustom, TII) {}
+ CrashPseudoSourceValue(const TargetMachine &TM)
+ : PseudoSourceValue(TargetCustom, TM) {}
bool isConstant(const MachineFrameInfo *) const override {
return false;
}
};
- static const CrashPseudoSourceValue CrashPSV(*this);
+ static const CrashPseudoSourceValue CrashPSV(MF.getTarget());
MachineMemOperand *MMO = MF.getMachineMemOperand(
MachinePointerInfo(&CrashPSV),
MachineMemOperand::MOLoad | MachineMemOperand::MOVolatile, 8,