#include "GCNSubtarget.h"
#include "AMDGPUCallLowering.h"
#include "AMDGPUInstructionSelector.h"
#include "AMDGPULegalizerInfo.h"
#include "AMDGPURegisterBankInfo.h"
#include "AMDGPUTargetMachine.h"
#include "R600Subtarget.h"
#include "SIMachineFunctionInfo.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/CodeGen/GlobalISel/InlineAsmLowering.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/IntrinsicsR600.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include <algorithm>
usingnamespacellvm;
#define DEBUG_TYPE …
#define GET_SUBTARGETINFO_TARGET_DESC
#define GET_SUBTARGETINFO_CTOR
#define AMDGPUSubtarget …
#include "AMDGPUGenSubtargetInfo.inc"
#undef AMDGPUSubtarget
static cl::opt<bool>
EnablePowerSched("amdgpu-enable-power-sched",
cl::desc("Enable scheduling to minimize mAI power bursts"),
cl::init(false));
static cl::opt<bool> EnableVGPRIndexMode(
"amdgpu-vgpr-index-mode",
cl::desc("Use GPR indexing mode instead of movrel for vector indexing"),
cl::init(false));
static cl::opt<bool> UseAA("amdgpu-use-aa-in-codegen",
cl::desc("Enable the use of AA during codegen."),
cl::init(true));
static cl::opt<unsigned>
NSAThreshold("amdgpu-nsa-threshold",
cl::desc("Number of addresses from which to enable MIMG NSA."),
cl::init(3), cl::Hidden);
GCNSubtarget::~GCNSubtarget() = default;
GCNSubtarget &GCNSubtarget::initializeSubtargetDependencies(const Triple &TT,
StringRef GPU,
StringRef FS) { … }
void GCNSubtarget::checkSubtargetFeatures(const Function &F) const { … }
GCNSubtarget::GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
const GCNTargetMachine &TM)
: … { … }
unsigned GCNSubtarget::getConstantBusLimit(unsigned Opcode) const { … }
bool GCNSubtarget::zeroesHigh16BitsOfDest(unsigned Opcode) const { … }
void GCNSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const { … }
void GCNSubtarget::mirFileLoaded(MachineFunction &MF) const { … }
bool GCNSubtarget::hasMadF16() const { … }
bool GCNSubtarget::useVGPRIndexMode() const { … }
bool GCNSubtarget::useAA() const { … }
unsigned GCNSubtarget::getOccupancyWithNumSGPRs(unsigned SGPRs) const { … }
unsigned GCNSubtarget::getOccupancyWithNumVGPRs(unsigned NumVGPRs) const { … }
unsigned
GCNSubtarget::getBaseReservedNumSGPRs(const bool HasFlatScratch) const { … }
unsigned GCNSubtarget::getReservedNumSGPRs(const MachineFunction &MF) const { … }
unsigned GCNSubtarget::getReservedNumSGPRs(const Function &F) const { … }
unsigned GCNSubtarget::computeOccupancy(const Function &F, unsigned LDSSize,
unsigned NumSGPRs,
unsigned NumVGPRs) const { … }
unsigned GCNSubtarget::getBaseMaxNumSGPRs(
const Function &F, std::pair<unsigned, unsigned> WavesPerEU,
unsigned PreloadedSGPRs, unsigned ReservedNumSGPRs) const { … }
unsigned GCNSubtarget::getMaxNumSGPRs(const MachineFunction &MF) const { … }
static unsigned getMaxNumPreloadedSGPRs() { … }
unsigned GCNSubtarget::getMaxNumSGPRs(const Function &F) const { … }
unsigned GCNSubtarget::getBaseMaxNumVGPRs(
const Function &F, std::pair<unsigned, unsigned> WavesPerEU) const { … }
unsigned GCNSubtarget::getMaxNumVGPRs(const Function &F) const { … }
unsigned GCNSubtarget::getMaxNumVGPRs(const MachineFunction &MF) const { … }
void GCNSubtarget::adjustSchedDependency(
SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx, SDep &Dep,
const TargetSchedModel *SchedModel) const { … }
namespace {
struct FillMFMAShadowMutation : ScheduleDAGMutation { … };
}
void GCNSubtarget::getPostRAMutations(
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const { … }
std::unique_ptr<ScheduleDAGMutation>
GCNSubtarget::createFillMFMAShadowMutation(const TargetInstrInfo *TII) const { … }
unsigned GCNSubtarget::getNSAThreshold(const MachineFunction &MF) const { … }
GCNUserSGPRUsageInfo::GCNUserSGPRUsageInfo(const Function &F,
const GCNSubtarget &ST)
: … { … }
void GCNUserSGPRUsageInfo::allocKernargPreloadSGPRs(unsigned NumSGPRs) { … }
unsigned GCNUserSGPRUsageInfo::getNumFreeUserSGPRs() { … }