LLVM  14.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"
15 #include "XCore.h"
16 #include "XCoreTargetObjectFile.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/CodeGen/Passes.h"
23 #include "llvm/MC/TargetRegistry.h"
24 #include "llvm/Support/CodeGen.h"
25 
26 using namespace llvm;
27 
29  return RM.getValueOr(Reloc::Static);
30 }
31 
32 static CodeModel::Model
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,
46  const TargetOptions &Options,
49  CodeGenOpt::Level 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) {
56  initAsmInfo();
57 }
58 
60 
61 namespace {
62 
63 /// XCore Code Generator Pass Configuration Options.
64 class XCorePassConfig : public TargetPassConfig {
65 public:
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 
85 void XCorePassConfig::addIRPasses() {
86  addPass(createAtomicExpandPass());
87 
89 }
90 
91 bool XCorePassConfig::addPreISel() {
93  return false;
94 }
95 
96 bool XCorePassConfig::addInstSelector() {
97  addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
98  return false;
99 }
100 
101 void XCorePassConfig::addPreEmitPass() {
103 }
104 
105 // Force static initialization.
108 }
109 
112  return TargetTransformInfo(XCoreTTIImpl(this, F));
113 }
LLVMInitializeXCoreTarget
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTarget()
Definition: XCoreTargetMachine.cpp:106
llvm::createXCoreISelDag
FunctionPass * createXCoreISelDag(XCoreTargetMachine &TM, CodeGenOpt::Level OptLevel)
createXCoreISelDag - This pass converts a legalized DAG into a XCore-specific DAG,...
Definition: XCoreISelDAGToDAG.cpp:82
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
Optional.h
llvm::createXCoreFrameToArgsOffsetEliminationPass
FunctionPass * createXCoreFrameToArgsOffsetEliminationPass()
createXCoreFrameToArgsOffsetEliminationPass - returns an instance of the Frame to args offset elimina...
Definition: XCoreFrameToArgsOffsetElim.cpp:43
llvm::TargetOptions
Definition: TargetOptions.h:124
T
llvm::Function
Definition: Function.h:62
XCore.h
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:168
llvm::XCoreTargetMachine::~XCoreTargetMachine
~XCoreTargetMachine() override
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::Optional< Reloc::Model >
XCoreTargetObjectFile.h
STLExtras.h
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
getEffectiveXCoreCodeModel
static CodeModel::Model getEffectiveXCoreCodeModel(Optional< CodeModel::Model > CM)
Definition: XCoreTargetMachine.cpp:33
llvm::XCoreTargetMachine
Definition: XCoreTargetMachine.h:26
llvm::XCoreTargetMachine::XCoreTargetMachine
XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Create an ILP32 architecture model.
Definition: XCoreTargetMachine.cpp:44
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::createAtomicExpandPass
FunctionPass * createAtomicExpandPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1275
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
XCoreMCTargetDesc.h
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::getTheXCoreTarget
Target & getTheXCoreTarget()
Definition: XCoreTargetInfo.cpp:13
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
llvm::TargetPassConfig::addIRPasses
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
Definition: TargetPassConfig.cpp:844
TargetPassConfig.h
llvm::XCoreTTIImpl
Definition: XCoreTargetTransformInfo.h:27
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:476
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::XCoreTargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: XCoreTargetMachine.cpp:81
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:22
XCoreTargetTransformInfo.h
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::getEffectiveRelocModel
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
Definition: AVRTargetMachine.cpp:40
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:41
std
Definition: BitVector.h:838
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:393
llvm::createXCoreLowerThreadLocalPass
ModulePass * createXCoreLowerThreadLocalPass()
XCoreTargetMachine.h
CodeGen.h
llvm::CodeModel::Large
@ Large
Definition: CodeGen.h:28
llvm::XCoreTargetObjectFile
Definition: XCoreTargetObjectFile.h:18
TargetTransformInfo.h
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::XCoreTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: XCoreTargetMachine.cpp:111
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
XCoreTargetInfo.h
TargetRegistry.h
SpecialSubKind::string
@ string