class MachineFrameInfo;
class MachineMemOperand;
class raw_ostream;
+class TargetInstrInfo;
raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
class PseudoSourceValue;
private:
PSVKind Kind;
+ unsigned AddressSpace;
friend raw_ostream &llvm::operator<<(raw_ostream &OS,
const PseudoSourceValue* PSV);
virtual void printCustom(raw_ostream &O) const;
public:
- explicit PseudoSourceValue(PSVKind Kind);
+ explicit PseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII);
virtual ~PseudoSourceValue();
bool isGOT() const { return Kind == GOT; }
bool isConstantPool() const { return Kind == ConstantPool; }
bool isJumpTable() const { return Kind == JumpTable; }
+
+ unsigned getAddressSpace() const { return AddressSpace; }
+
unsigned getTargetCustom() const {
return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0;
}
const int FI;
public:
- explicit FixedStackPseudoSourceValue(int FI)
- : PseudoSourceValue(FixedStack), FI(FI) {}
+ explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII)
+ : PseudoSourceValue(FixedStack, TII), FI(FI) {}
static bool classof(const PseudoSourceValue *V) {
return V->kind() == FixedStack;
class CallEntryPseudoSourceValue : public PseudoSourceValue {
protected:
- CallEntryPseudoSourceValue(PSVKind Kind);
+ CallEntryPseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII);
public:
bool isConstant(const MachineFrameInfo *) const override;
const GlobalValue *GV;
public:
- GlobalValuePseudoSourceValue(const GlobalValue *GV);
+ GlobalValuePseudoSourceValue(const GlobalValue *GV,
+ const TargetInstrInfo &TII);
static bool classof(const PseudoSourceValue *V) {
return V->kind() == GlobalValueCallEntry;
const char *ES;
public:
- ExternalSymbolPseudoSourceValue(const char *ES);
+ ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII);
static bool classof(const PseudoSourceValue *V) {
return V->kind() == ExternalSymbolCallEntry;
/// Manages creation of pseudo source values.
class PseudoSourceValueManager {
+ const TargetInstrInfo &TII;
const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
std::map<int, std::unique_ptr<FixedStackPseudoSourceValue>> FSValues;
StringMap<std::unique_ptr<const ExternalSymbolPseudoSourceValue>>
GlobalCallEntries;
public:
- PseudoSourceValueManager();
+ PseudoSourceValueManager(const TargetInstrInfo &TII);
/// Return a pseudo source value referencing the area below the stack frame of
/// a function, e.g., the argument space.
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/ErrorHandling.h"
}
public:
+ /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
+ /// (e.g. stack) the target returns the corresponding address space.
+ virtual unsigned
+ getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind 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.
"Can't create a MachineFunction using a Module with a "
"Target-incompatible DataLayout attached\n");
- PSVManager = llvm::make_unique<PseudoSourceValueManager>();
+ PSVManager =
+ llvm::make_unique<PseudoSourceValueManager>(*(getSubtarget().
+ getInstrInfo()));
}
MachineFunction::~MachineFunction() {
/// getAddrSpace - Return the LLVM IR address space number that this pointer
/// points into.
unsigned MachinePointerInfo::getAddrSpace() const {
- if (V.isNull() || V.is<const PseudoSourceValue*>()) return 0;
+ if (V.isNull()) return 0;
+
+ if (V.is<const PseudoSourceValue*>())
+ return V.get<const PseudoSourceValue*>()->getAddressSpace();
+
return cast<PointerType>(V.get<const Value*>()->getType())->getAddressSpace();
}
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/ErrorHandling.h"
"Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
"GlobalValueCallEntry", "ExternalSymbolCallEntry"};
-PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {}
+PseudoSourceValue::PseudoSourceValue(PSVKind Kind, const TargetInstrInfo &TII)
+ : Kind(Kind) {
+ AddressSpace = TII.getAddressSpaceForPseudoSourceKind(Kind);
+}
+
PseudoSourceValue::~PseudoSourceValue() {}
OS << "FixedStack" << FI;
}
-CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(PSVKind Kind)
- : PseudoSourceValue(Kind) {}
+CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(
+ PSVKind Kind, const TargetInstrInfo &TII)
+ : PseudoSourceValue(Kind, TII) {}
bool CallEntryPseudoSourceValue::isConstant(const MachineFrameInfo *) const {
return false;
}
GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue(
- const GlobalValue *GV)
- : CallEntryPseudoSourceValue(GlobalValueCallEntry), GV(GV) {}
-
-ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(const char *ES)
- : CallEntryPseudoSourceValue(ExternalSymbolCallEntry), ES(ES) {}
-
-PseudoSourceValueManager::PseudoSourceValueManager()
- : StackPSV(PseudoSourceValue::Stack), GOTPSV(PseudoSourceValue::GOT),
- JumpTablePSV(PseudoSourceValue::JumpTable),
- ConstantPoolPSV(PseudoSourceValue::ConstantPool) {}
+ const GlobalValue *GV,
+ const TargetInstrInfo &TII)
+ : CallEntryPseudoSourceValue(GlobalValueCallEntry, TII), GV(GV) {}
+ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(
+ const char *ES, const TargetInstrInfo &TII)
+ : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TII), 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) {}
const PseudoSourceValue *PseudoSourceValueManager::getStack() {
return &StackPSV;
return &JumpTablePSV;
}
-const PseudoSourceValue *PseudoSourceValueManager::getFixedStack(int FI) {
+const PseudoSourceValue *
+PseudoSourceValueManager::getFixedStack(int FI) {
std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
if (!V)
- V = llvm::make_unique<FixedStackPseudoSourceValue>(FI);
+ V = llvm::make_unique<FixedStackPseudoSourceValue>(FI, TII);
return V.get();
}
std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
GlobalCallEntries[GV];
if (!E)
- E = llvm::make_unique<GlobalValuePseudoSourceValue>(GV);
+ E = llvm::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
return E.get();
}
std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
ExternalCallEntries[ES];
if (!E)
- E = llvm::make_unique<ExternalSymbolPseudoSourceValue>(ES);
+ E = llvm::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
return E.get();
}
}
}
+unsigned SIInstrInfo::getAddressSpaceForPseudoSourceKind(
+ PseudoSourceValue::PSVKind Kind) const {
+ switch(Kind) {
+ case PseudoSourceValue::Stack:
+ case PseudoSourceValue::FixedStack:
+ return AMDGPUASI.PRIVATE_ADDRESS;
+ case PseudoSourceValue::ConstantPool:
+ case PseudoSourceValue::GOT:
+ case PseudoSourceValue::JumpTable:
+ case PseudoSourceValue::GlobalValueCallEntry:
+ case PseudoSourceValue::ExternalSymbolCallEntry:
+ case PseudoSourceValue::TargetCustom:
+ return AMDGPUASI.CONSTANT_ADDRESS;
+ default:
+ return AMDGPUASI.FLAT_ADDRESS;
+ }
+}
+
+
static void removeModOperands(MachineInstr &MI) {
unsigned Opc = MI.getOpcode();
int Src0ModIdx = AMDGPU::getNamedOperandIdx(Opc,
unsigned DstReg, ArrayRef<MachineOperand> Cond,
unsigned TrueReg, unsigned FalseReg) const;
+ unsigned
+ getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind Kind) const;
+
bool
areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb,
AliasAnalysis *AA = nullptr) const override;
SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF)
: AMDGPUMachineFunction(MF),
+ BufferPSV(*(MF.getSubtarget().getInstrInfo())),
+ ImagePSV(*(MF.getSubtarget().getInstrInfo())),
PrivateSegmentBuffer(false),
DispatchPtr(false),
QueuePtr(false),
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/ErrorHandling.h"
#include <array>
class AMDGPUImagePseudoSourceValue : public PseudoSourceValue {
public:
- explicit AMDGPUImagePseudoSourceValue() :
- PseudoSourceValue(PseudoSourceValue::TargetCustom) {}
+ explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII) :
+ PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
bool isConstant(const MachineFrameInfo *) const override {
// This should probably be true for most images, but we will start by being
class AMDGPUBufferPseudoSourceValue : public PseudoSourceValue {
public:
- explicit AMDGPUBufferPseudoSourceValue() :
- PseudoSourceValue(PseudoSourceValue::TargetCustom) {}
+ explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII) :
+ PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
bool isConstant(const MachineFrameInfo *) const override {
// This should probably be true for most images, but we will start by being