LLVM  4.0.0
XCoreTargetMachine.cpp
Go to the documentation of this file.
1 //===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "XCoreTargetMachine.h"
14 #include "XCoreTargetObjectFile.h"
16 #include "XCore.h"
17 #include "llvm/CodeGen/Passes.h"
19 #include "llvm/IR/Module.h"
22 using namespace llvm;
23 
25  if (!RM.hasValue())
26  return Reloc::Static;
27  return *RM;
28 }
29 
30 /// Create an ILP32 architecture model
31 ///
33  StringRef CPU, StringRef FS,
34  const TargetOptions &Options,
39  T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
40  TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM, OL),
42  Subtarget(TT, CPU, FS, *this) {
43  initAsmInfo();
44 }
45 
47 
48 namespace {
49 /// XCore Code Generator Pass Configuration Options.
50 class XCorePassConfig : public TargetPassConfig {
51 public:
52  XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
53  : TargetPassConfig(TM, PM) {}
54 
55  XCoreTargetMachine &getXCoreTargetMachine() const {
56  return getTM<XCoreTargetMachine>();
57  }
58 
59  void addIRPasses() override;
60  bool addPreISel() override;
61  bool addInstSelector() override;
62  void addPreEmitPass() override;
63 };
64 } // namespace
65 
67  return new XCorePassConfig(this, PM);
68 }
69 
70 void XCorePassConfig::addIRPasses() {
71  addPass(createAtomicExpandPass(&getXCoreTargetMachine()));
72 
74 }
75 
76 bool XCorePassConfig::addPreISel() {
78  return false;
79 }
80 
81 bool XCorePassConfig::addInstSelector() {
82  addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
83  return false;
84 }
85 
86 void XCorePassConfig::addPreEmitPass() {
88 }
89 
90 // Force static initialization.
91 extern "C" void LLVMInitializeXCoreTarget() {
93 }
94 
96  return TargetIRAnalysis([this](const Function &F) {
97  return TargetTransformInfo(XCoreTTIImpl(this, F));
98  });
99 }
void LLVMInitializeXCoreTarget()
bool hasValue() const
Definition: Optional.h:125
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
TargetIRAnalysis getTargetIRAnalysis() override
Get a TargetIRAnalysis implementation for the target.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Analysis pass providing the TargetTransformInfo.
ModulePass * createXCoreLowerThreadLocalPass()
FunctionPass * createAtomicExpandPass(const TargetMachine *TM)
Target-Independent Code Generator Pass Configuration Options.
#define F(x, y, z)
Definition: MD5.cpp:51
FunctionPass * createXCoreFrameToArgsOffsetEliminationPass()
createXCoreFrameToArgsOffsetEliminationPass - returns an instance of the Frame to args offset elimina...
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
Definition: STLExtras.h:845
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
FunctionPass * createXCoreISelDag(XCoreTargetMachine &TM, CodeGenOpt::Level OptLevel)
createXCoreISelDag - This pass converts a legalized DAG into a XCore-specific DAG, ready for instruction scheduling.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
This class describes a target machine that is implemented with the LLVM target-independent code gener...
XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Create an ILP32 architecture model.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Target & getTheXCoreTarget()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Module.h This file contains the declarations for the Module class.
Target - Wrapper for Target specific information.
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
This file a TargetTransformInfo::Concept conforming object specific to the XCore target machine...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47