27#define DEBUG_TYPE "loongarch"
40 cl::desc(
"Enable the loop data prefetch pass"),
45 return "e-m:e-p:64:64-i64:64-i128:128-n64-S128";
46 assert(TT.isArch32Bit() &&
"only LA32 and LA64 are currently supported");
47 return "e-m:e-p:32:32-i64:64-n32-S128";
51 std::optional<Reloc::Model> RM) {
70 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
71 Attribute TuneAttr =
F.getFnAttribute(
"tune-cpu");
72 Attribute FSAttr =
F.getFnAttribute(
"target-features");
81 std::string Key = CPU + TuneCPU + FS;
82 auto &
I = SubtargetMap[Key];
89 if (
const MDString *ModuleTargetABI = dyn_cast_or_null<MDString>(
90 F.getParent()->getModuleFlag(
"target-abi"))) {
93 ModuleTargetABI->getString() != ABIName) {
96 ABIName = ModuleTargetABI->getString();
98 I = std::make_unique<LoongArchSubtarget>(
TargetTriple, CPU, TuneCPU, FS,
107 return LoongArchMachineFunctionInfo::create<LoongArchMachineFunctionInfo>(
118 return getTM<LoongArchTargetMachine>();
121 void addIRPasses()
override;
122 bool addInstSelector()
override;
123 void addPreEmitPass()
override;
124 void addPreEmitPass2()
override;
125 void addPreRegAlloc()
override;
131 return new LoongArchPassConfig(*
this, PM);
134void LoongArchPassConfig::addIRPasses() {
146bool LoongArchPassConfig::addInstSelector() {
154void LoongArchPassConfig::addPreEmitPass2() {
161void LoongArchPassConfig::addPreRegAlloc() {
static cl::opt< bool > EnableLoopDataPrefetch("aarch64-enable-loop-data-prefetch", cl::Hidden, cl::desc("Enable the loop data prefetch pass"), cl::init(true))
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static std::string computeDataLayout()
static cl::opt< bool > EnableLoopDataPrefetch("loongarch-enable-loop-data-prefetch", cl::Hidden, cl::desc("Enable the loop data prefetch pass"), cl::init(false))
static Reloc::Model getEffectiveRelocModel(const Triple &TT, std::optional< Reloc::Model > RM)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLoongArchTarget()
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Target-Independent Code Generator Pass Configuration Options pass.
StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Allocate memory in an ever growing pool, as if by bump-pointer.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
~LoongArchTargetMachine() override
const LoongArchSubtarget * getSubtargetImpl() const =delete
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
LoongArchTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
StringRef getABIName() const
getABIName - If this returns a non-empty string this represents the textual name of the ABI that we w...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
std::unique_ptr< const MCSubtargetInfo > STI
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
MCTargetOptions MCOptions
Machine level options.
Target-Independent Code Generator Pass Configuration Options.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Level
Code generation optimization level.
ABI getTargetABI(StringRef ABIName)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheLoongArch64Target()
FunctionPass * createLoongArchExpandAtomicPseudoPass()
void initializeLoongArchDAGToDAGISelPass(PassRegistry &)
FunctionPass * createAtomicExpandPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
void initializeLoongArchPreRAExpandPseudoPass(PassRegistry &)
FunctionPass * createLoongArchISelDag(LoongArchTargetMachine &TM)
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
FunctionPass * createLoopDataPrefetchPass()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Target & getTheLoongArch32Target()
FunctionPass * createLoongArchPreRAExpandPseudoPass()
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
RegisterTargetMachine - Helper template for registering a target machine implementation,...