LLVM: lib/Target/CSKY/CSKYTargetMachine.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
24#include
25
26using namespace llvm;
27
30
34}
35
37 std::string Ret;
38
39
40
41 Ret += "e";
42
43
44
45 Ret += "-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32"
46 "-v128:32:32-a:0:32-Fi32-n32";
47
48 return Ret;
49}
50
54 std::optionalReloc::Model RM,
55 std::optionalCodeModel::Model CM,
58 RM.value_or(Reloc::Static),
62}
63
66 Attribute CPUAttr = F.getFnAttribute("target-cpu");
67 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
68 Attribute FSAttr = F.getFnAttribute("target-features");
69
70 std::string CPU =
72 std::string TuneCPU =
74 std::string FS =
76
77 std::string Key = CPU + TuneCPU + FS;
78 auto &I = SubtargetMap[Key];
79 if () {
80
81
82
84 I = std::make_unique(TargetTriple, CPU, TuneCPU, FS, *this);
85 if (I->useHardFloat() && ->hasAnyFloatExt())
86 errs() << "Hard-float can't be used with current CPU,"
87 " set to Soft-float\n";
88 }
89 return I.get();
90}
91
95 return CSKYMachineFunctionInfo::create(Allocator, F,
97}
98
99namespace {
101public:
104
106 return getTM();
107 }
108
109 void addIRPasses() override;
110 bool addInstSelector() override;
111 void addPreEmitPass() override;
112};
113
114}
115
117 return new CSKYPassConfig(*this, PM);
118}
119
120void CSKYPassConfig::addIRPasses() {
123}
124
125bool CSKYPassConfig::addInstSelector() {
126 addPass(createCSKYISelDag(getCSKYTargetMachine(), getOptLevel()));
127
128 return false;
129}
130
131void CSKYPassConfig::addPreEmitPass() {
133}
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTarget()
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static std::string computeDataLayout()
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.
const CSKYSubtarget * getSubtargetImpl() const =delete
CSKYTargetMachine(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)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
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...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A global registry used in conjunction with static constructors to make pluggable components (like tar...
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.
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 ...
This is an optimization pass for GlobalISel generic memory operations.
void initializeCSKYDAGToDAGISelLegacyPass(PassRegistry &)
void initializeCSKYConstantIslandsPass(PassRegistry &)
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.
CodeGenOptLevel
Code generation optimization level.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Target & getTheCSKYTarget()
FunctionPass * createCSKYConstantIslandPass()
Returns a pass that converts branches to long branches.
FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
FunctionPass * createCSKYISelDag(CSKYTargetMachine &TM, CodeGenOptLevel OptLevel)
Implement std::hash so that hash_code can be used in STL containers.
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,...