LLVM 22.0.0git
XCoreTargetMachine.cpp
Go to the documentation of this file.
1//===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//
10//===----------------------------------------------------------------------===//
11
12#include "XCoreTargetMachine.h"
14#include "XCore.h"
19#include "llvm/CodeGen/Passes.h"
24#include <optional>
25
26using namespace llvm;
27
28static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) {
29 return RM.value_or(Reloc::Static);
30}
31
33getEffectiveXCoreCodeModel(std::optional<CodeModel::Model> CM) {
34 if (CM) {
35 if (*CM != CodeModel::Small && *CM != CodeModel::Large)
36 report_fatal_error("Target only supports CodeModel Small or Large");
37 return *CM;
38 }
39 return CodeModel::Small;
40}
41
42/// Create an ILP32 architecture model
43///
45 StringRef CPU, StringRef FS,
47 std::optional<Reloc::Model> RM,
48 std::optional<CodeModel::Model> CM,
49 CodeGenOptLevel OL, bool JIT)
51 T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
52 TT, CPU, FS, Options, getEffectiveRelocModel(RM),
54 TLOF(std::make_unique<XCoreTargetObjectFile>()),
55 Subtarget(TT, std::string(CPU), std::string(FS), *this) {
57}
58
60
61namespace {
62
63/// XCore Code Generator Pass Configuration Options.
64class XCorePassConfig : public TargetPassConfig {
65public:
66 XCorePassConfig(XCoreTargetMachine &TM, PassManagerBase &PM)
67 : TargetPassConfig(TM, PM) {}
68
69 XCoreTargetMachine &getXCoreTargetMachine() const {
70 return getTM<XCoreTargetMachine>();
71 }
72
73 void addIRPasses() override;
74 bool addPreISel() override;
75 bool addInstSelector() override;
76 void addPreEmitPass() override;
77};
78
79} // end anonymous namespace
80
82 return new XCorePassConfig(*this, PM);
83}
84
85void XCorePassConfig::addIRPasses() {
87
89}
90
91bool XCorePassConfig::addPreISel() {
93 return false;
94}
95
96bool XCorePassConfig::addInstSelector() {
97 addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
98 return false;
99}
100
101void XCorePassConfig::addPreEmitPass() {
103}
104
105// Force static initialization.
112}
113
116 return TargetTransformInfo(std::make_unique<XCoreTTIImpl>(this, F));
117}
118
120 BumpPtrAllocator &Allocator, const Function &F,
121 const TargetSubtargetInfo *STI) const {
122 return XCoreFunctionInfo::create<XCoreFunctionInfo>(Allocator, F, STI);
123}
#define LLVM_ABI
Definition: Compiler.h:213
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static LVOptions Options
Definition: LVOptions.cpp:25
#define F(x, y, z)
Definition: MD5.cpp:55
Basic Register Allocator
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTarget()
static CodeModel::Model getEffectiveXCoreCodeModel(std::optional< CodeModel::Model > CM)
This file a TargetTransformInfoImplBase conforming object specific to the XCore target machine.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
implements a set of functionality in the TargetMachine class for targets that make use of the indepen...
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::unique_ptr< const MCSubtargetInfo > STI
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.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
XCoreTargetMachine(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)
Create an ILP32 architecture model.
~XCoreTargetMachine() override
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FunctionPass * createXCoreFrameToArgsOffsetEliminationPass()
createXCoreFrameToArgsOffsetEliminationPass - returns an instance of the Frame to args offset elimina...
Target & getTheXCoreTarget()
void initializeXCoreDAGToDAGISelLegacyPass(PassRegistry &)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition: Error.cpp:167
void initializeXCoreLowerThreadLocalPass(PassRegistry &p)
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:82
void initializeXCoreAsmPrinterPass(PassRegistry &)
ModulePass * createXCoreLowerThreadLocalPass()
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
FunctionPass * createXCoreISelDag(XCoreTargetMachine &TM, CodeGenOptLevel OptLevel)
createXCoreISelDag - This pass converts a legalized DAG into a XCore-specific DAG,...
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
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,...