#include "LoongArchTargetMachine.h"
#include "LoongArch.h"
#include "LoongArchMachineFunctionInfo.h"
#include "LoongArchTargetTransformInfo.h"
#include "MCTargetDesc/LoongArchBaseInfo.h"
#include "TargetInfo/LoongArchTargetInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Transforms/Scalar.h"
#include <optional>
usingnamespacellvm;
#define DEBUG_TYPE …
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLoongArchTarget() { … }
static cl::opt<bool> EnableLoongArchDeadRegisterElimination(
"loongarch-enable-dead-defs", cl::Hidden,
cl::desc("Enable the pass that removes dead"
" definitons and replaces stores to"
" them with stores to r0"),
cl::init(true));
static cl::opt<bool>
EnableLoopDataPrefetch("loongarch-enable-loop-data-prefetch", cl::Hidden,
cl::desc("Enable the loop data prefetch pass"),
cl::init(false));
static std::string computeDataLayout(const Triple &TT) { … }
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
std::optional<Reloc::Model> RM) { … }
static CodeModel::Model
getEffectiveLoongArchCodeModel(const Triple &TT,
std::optional<CodeModel::Model> CM) { … }
LoongArchTargetMachine::LoongArchTargetMachine(
const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
const TargetOptions &Options, std::optional<Reloc::Model> RM,
std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT)
: … { … }
LoongArchTargetMachine::~LoongArchTargetMachine() = default;
const LoongArchSubtarget *
LoongArchTargetMachine::getSubtargetImpl(const Function &F) const { … }
MachineFunctionInfo *LoongArchTargetMachine::createMachineFunctionInfo(
BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const { … }
namespace {
class LoongArchPassConfig : public TargetPassConfig { … };
}
TargetPassConfig *
LoongArchTargetMachine::createPassConfig(PassManagerBase &PM) { … }
void LoongArchPassConfig::addIRPasses() { … }
void LoongArchPassConfig::addCodeGenPrepare() { … }
bool LoongArchPassConfig::addInstSelector() { … }
TargetTransformInfo
LoongArchTargetMachine::getTargetTransformInfo(const Function &F) const { … }
void LoongArchPassConfig::addPreEmitPass() { … }
void LoongArchPassConfig::addPreEmitPass2() { … }
void LoongArchPassConfig::addMachineSSAOptimization() { … }
void LoongArchPassConfig::addPreRegAlloc() { … }
bool LoongArchPassConfig::addRegAssignAndRewriteFast() { … }
bool LoongArchPassConfig::addRegAssignAndRewriteOptimized() { … }