LLVM  16.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"
21 #include "llvm/MC/TargetRegistry.h"
22 using namespace llvm;
23 
25  // Register the target.
27 }
28 
30  return RM.value_or(Reloc::Static);
31 }
32 
33 static std::string computeDataLayout(const Triple &TT, StringRef CPU,
34  const TargetOptions &Options) {
35  return "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16";
36 }
37 
39  StringRef CPU, StringRef FS,
40  const TargetOptions &Options,
43  CodeGenOpt::Level OL, bool JIT)
44  : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS,
47  TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
48  Subtarget(TT, std::string(CPU), std::string(FS), *this) {
49  initAsmInfo();
50 }
51 
53 
54 namespace {
55 /// MSP430 Code Generator Pass Configuration Options.
56 class MSP430PassConfig : public TargetPassConfig {
57 public:
58  MSP430PassConfig(MSP430TargetMachine &TM, PassManagerBase &PM)
59  : TargetPassConfig(TM, PM) {}
60 
61  MSP430TargetMachine &getMSP430TargetMachine() const {
62  return getTM<MSP430TargetMachine>();
63  }
64 
65  bool addInstSelector() override;
66  void addPreEmitPass() override;
67 };
68 } // namespace
69 
71  return new MSP430PassConfig(*this, PM);
72 }
73 
74 bool MSP430PassConfig::addInstSelector() {
75  // Install an instruction selector.
76  addPass(createMSP430ISelDag(getMSP430TargetMachine(), getOptLevel()));
77  return false;
78 }
79 
80 void MSP430PassConfig::addPreEmitPass() {
81  // Must run branch selection immediately preceding the asm printer.
83 }
MSP430TargetInfo.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MSP430TargetMachine.h
llvm::TargetOptions
Definition: TargetOptions.h:124
T
LLVMInitializeMSP430Target
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Target()
Definition: MSP430TargetMachine.cpp:24
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::TargetLoweringObjectFileELF
Definition: TargetLoweringObjectFileImpl.h:34
llvm::Optional< Reloc::Model >
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:38
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
llvm::MSP430Attrs::CodeModel
CodeModel
Definition: MSP430Attributes.h:37
llvm::MSP430TargetMachine
MSP430TargetMachine.
Definition: MSP430TargetMachine.h:25
llvm::MSP430TargetMachine::~MSP430TargetMachine
~MSP430TargetMachine() override
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1318
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:33
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:127
TargetPassConfig.h
llvm::X86AS::FS
@ FS
Definition: X86.h:200
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:479
MCAsmInfo.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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:506
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:40
std
Definition: BitVector.h:851
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:414
llvm::createMSP430ISelDag
FunctionPass * createMSP430ISelDag(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel)
createMSP430ISelDag - This pass converts a legalized DAG into a MSP430-specific DAG,...
Definition: MSP430ISelDAGToDAG.cpp:125
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:70
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
TargetRegistry.h
SpecialSubKind::string
@ string
TargetLoweringObjectFileImpl.h