LLVM  14.0.0git
MSP430TargetMachine.cpp
Go to the documentation of this file.
1 //===-- MSP430TargetMachine.cpp - Define TargetMachine for MSP430 ---------===//
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 // Top-level implementation for the MSP430 target.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "MSP430TargetMachine.h"
14 #include "MSP430.h"
16 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/MC/MCAsmInfo.h"
22 using namespace llvm;
23 
25  // Register the target.
27 }
28 
30  if (!RM.hasValue())
31  return Reloc::Static;
32  return *RM;
33 }
34 
35 static std::string computeDataLayout(const Triple &TT, StringRef CPU,
36  const TargetOptions &Options) {
37  return "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16";
38 }
39 
41  StringRef CPU, StringRef FS,
42  const TargetOptions &Options,
45  CodeGenOpt::Level OL, bool JIT)
46  : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS,
48  getEffectiveCodeModel(CM, CodeModel::Small), OL),
49  TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
50  Subtarget(TT, std::string(CPU), std::string(FS), *this) {
51  initAsmInfo();
52 }
53 
55 
56 namespace {
57 /// MSP430 Code Generator Pass Configuration Options.
58 class MSP430PassConfig : public TargetPassConfig {
59 public:
60  MSP430PassConfig(MSP430TargetMachine &TM, PassManagerBase &PM)
61  : TargetPassConfig(TM, PM) {}
62 
63  MSP430TargetMachine &getMSP430TargetMachine() const {
64  return getTM<MSP430TargetMachine>();
65  }
66 
67  bool addInstSelector() override;
68  void addPreEmitPass() override;
69 };
70 } // namespace
71 
73  return new MSP430PassConfig(*this, PM);
74 }
75 
76 bool MSP430PassConfig::addInstSelector() {
77  // Install an instruction selector.
78  addPass(createMSP430ISelDag(getMSP430TargetMachine(), getOptLevel()));
79  return false;
80 }
81 
82 void MSP430PassConfig::addPreEmitPass() {
83  // Must run branch selection immediately preceding the asm printer.
84  addPass(createMSP430BranchSelectionPass(), false);
85 }
MSP430TargetInfo.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
MSP430TargetMachine.h
llvm::TargetOptions
Definition: TargetOptions.h:124
LLVMInitializeMSP430Target
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Target()
Definition: MSP430TargetMachine.cpp:24
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::TargetLoweringObjectFileELF
Definition: TargetLoweringObjectFileImpl.h:33
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
LegacyPassManager.h
llvm::MSP430TargetMachine::MSP430TargetMachine
MSP430TargetMachine(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)
Definition: MSP430TargetMachine.cpp:40
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
llvm::MSP430TargetMachine
MSP430TargetMachine.
Definition: MSP430TargetMachine.h:25
llvm::MSP430TargetMachine::~MSP430TargetMachine
~MSP430TargetMachine() override
Definition: MSP430TargetMachine.cpp:54
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1275
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
computeDataLayout
static std::string computeDataLayout(const Triple &TT, StringRef CPU, const TargetOptions &Options)
Definition: MSP430TargetMachine.cpp:35
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
TargetPassConfig.h
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:472
MCAsmInfo.h
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::Reloc::Static
@ Static
Definition: CodeGen.h:22
MSP430.h
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::getEffectiveRelocModel
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
Definition: AVRTargetMachine.cpp:40
llvm::getEffectiveCodeModel
CodeModel::Model getEffectiveCodeModel(Optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
Definition: TargetMachine.h:481
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:41
std
Definition: BitVector.h:838
llvm::createMSP430BranchSelectionPass
FunctionPass * createMSP430BranchSelectionPass()
Returns an instance of the Branch Selection Pass.
Definition: MSP430BranchSelector.cpp:255
llvm::getTheMSP430Target
Target & getTheMSP430Target()
Definition: MSP430TargetInfo.cpp:13
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:393
llvm::createMSP430ISelDag
FunctionPass * createMSP430ISelDag(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel)
createMSP430ISelDag - This pass converts a legalized DAG into a MSP430-specific DAG,...
Definition: MSP430ISelDAGToDAG.cpp:126
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::MSP430TargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: MSP430TargetMachine.cpp:72
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
TargetRegistry.h
SpecialSubKind::string
@ string
TargetLoweringObjectFileImpl.h