LLVM  9.0.0svn
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"
15 #include "XCoreTargetObjectFile.h"
17 #include "llvm/ADT/Optional.h"
18 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/CodeGen/Passes.h"
22 #include "llvm/Support/CodeGen.h"
24 
25 using namespace llvm;
26 
28  if (!RM.hasValue())
29  return Reloc::Static;
30  return *RM;
31 }
32 
33 static CodeModel::Model
35  if (CM) {
36  if (*CM != CodeModel::Small && *CM != CodeModel::Large)
37  report_fatal_error("Target only supports CodeModel Small or Large");
38  return *CM;
39  }
40  return CodeModel::Small;
41 }
42 
43 /// Create an ILP32 architecture model
44 ///
46  StringRef CPU, StringRef FS,
47  const TargetOptions &Options,
50  CodeGenOpt::Level OL, bool JIT)
52  T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
53  TT, CPU, FS, Options, getEffectiveRelocModel(RM),
56  Subtarget(TT, CPU, FS, *this) {
57  initAsmInfo();
58 }
59 
61 
62 namespace {
63 
64 /// XCore Code Generator Pass Configuration Options.
65 class XCorePassConfig : public TargetPassConfig {
66 public:
67  XCorePassConfig(XCoreTargetMachine &TM, PassManagerBase &PM)
68  : TargetPassConfig(TM, PM) {}
69 
70  XCoreTargetMachine &getXCoreTargetMachine() const {
71  return getTM<XCoreTargetMachine>();
72  }
73 
74  void addIRPasses() override;
75  bool addPreISel() override;
76  bool addInstSelector() override;
77  void addPreEmitPass() override;
78 };
79 
80 } // end anonymous namespace
81 
83  return new XCorePassConfig(*this, PM);
84 }
85 
86 void XCorePassConfig::addIRPasses() {
87  addPass(createAtomicExpandPass());
88 
90 }
91 
92 bool XCorePassConfig::addPreISel() {
94  return false;
95 }
96 
97 bool XCorePassConfig::addInstSelector() {
98  addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
99  return false;
100 }
101 
102 void XCorePassConfig::addPreEmitPass() {
104 }
105 
106 // Force static initialization.
107 extern "C" void LLVMInitializeXCoreTarget() {
109 }
110 
113  return TargetTransformInfo(XCoreTTIImpl(this, F));
114 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void LLVMInitializeXCoreTarget()
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
static CodeModel::Model getEffectiveXCoreCodeModel(Optional< CodeModel::Model > CM)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
F(f)
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:1393
ModulePass * createXCoreLowerThreadLocalPass()
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.
Target-Independent Code Generator Pass Configuration Options.
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
FunctionPass * createXCoreFrameToArgsOffsetEliminationPass()
createXCoreFrameToArgsOffsetEliminationPass - returns an instance of the Frame to args offset elimina...
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
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.
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:43
Target & getTheXCoreTarget()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Target - Wrapper for Target specific information.
bool hasValue() const
Definition: Optional.h:259
~XCoreTargetMachine() override
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:48
This pass exposes codegen information to IR-level passes.
FunctionPass * createAtomicExpandPass()