LLVM  3.7.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"
18 #include "llvm/IR/Module.h"
21 using namespace llvm;
22 
23 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
24 ///
26  StringRef CPU, StringRef FS,
27  const TargetOptions &Options,
31  T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
32  TT, CPU, FS, Options, RM, CM, OL),
34  Subtarget(TT, CPU, FS, *this) {
35  initAsmInfo();
36 }
37 
39 
40 namespace {
41 /// XCore Code Generator Pass Configuration Options.
42 class XCorePassConfig : public TargetPassConfig {
43 public:
44  XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
45  : TargetPassConfig(TM, PM) {}
46 
47  XCoreTargetMachine &getXCoreTargetMachine() const {
48  return getTM<XCoreTargetMachine>();
49  }
50 
51  void addIRPasses() override;
52  bool addPreISel() override;
53  bool addInstSelector() override;
54  void addPreEmitPass() override;
55 };
56 } // namespace
57 
59  return new XCorePassConfig(this, PM);
60 }
61 
62 void XCorePassConfig::addIRPasses() {
63  addPass(createAtomicExpandPass(&getXCoreTargetMachine()));
64 
66 }
67 
68 bool XCorePassConfig::addPreISel() {
70  return false;
71 }
72 
73 bool XCorePassConfig::addInstSelector() {
74  addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
75  return false;
76 }
77 
78 void XCorePassConfig::addPreEmitPass() {
80 }
81 
82 // Force static initialization.
83 extern "C" void LLVMInitializeXCoreTarget() {
85 }
86 
88  return TargetIRAnalysis([this](Function &F) {
89  return TargetTransformInfo(XCoreTTIImpl(this, F));
90  });
91 }
void LLVMInitializeXCoreTarget()
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
Definition: Passes.cpp:377
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.
F(f)
ModulePass * createXCoreLowerThreadLocalPass()
FunctionPass * createAtomicExpandPass(const TargetMachine *TM)
Target-Independent Code Generator Pass Configuration Options.
XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
XCoreTargetMachine ctor - Create an ILP32 architecture model.
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:354
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...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
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.
Target TheXCoreTarget
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:40