LLVM  13.0.0git
LanaiTargetMachine.cpp
Go to the documentation of this file.
1 //===-- LanaiTargetMachine.cpp - Define TargetMachine for Lanai ---------===//
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 // Implements the info about Lanai target spec.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "LanaiTargetMachine.h"
14 
15 #include "Lanai.h"
16 #include "LanaiTargetObjectFile.h"
20 #include "llvm/CodeGen/Passes.h"
26 
27 using namespace llvm;
28 
29 namespace llvm {
31 } // namespace llvm
32 
34  // Register the target.
37 }
38 
39 static std::string computeDataLayout() {
40  // Data layout (keep in sync with clang/lib/Basic/Targets.cpp)
41  return "E" // Big endian
42  "-m:e" // ELF name manging
43  "-p:32:32" // 32-bit pointers, 32 bit aligned
44  "-i64:64" // 64 bit integers, 64 bit aligned
45  "-a:0:32" // 32 bit alignment of objects of aggregate type
46  "-n32" // 32 bit native integer width
47  "-S64"; // 64 bit natural stack alignment
48 }
49 
51  return RM.getValueOr(Reloc::PIC_);
52 }
53 
55  StringRef Cpu, StringRef FeatureString,
56  const TargetOptions &Options,
59  CodeGenOpt::Level OptLevel, bool JIT)
60  : LLVMTargetMachine(T, computeDataLayout(), TT, Cpu, FeatureString, Options,
62  getEffectiveCodeModel(CodeModel, CodeModel::Medium),
63  OptLevel),
64  Subtarget(TT, Cpu, FeatureString, *this, Options, getCodeModel(),
65  OptLevel),
66  TLOF(new LanaiTargetObjectFile()) {
67  initAsmInfo();
68 }
69 
72  return TargetTransformInfo(LanaiTTIImpl(this, F));
73 }
74 
75 namespace {
76 // Lanai Code Generator Pass Configuration Options.
77 class LanaiPassConfig : public TargetPassConfig {
78 public:
81 
82  LanaiTargetMachine &getLanaiTargetMachine() const {
83  return getTM<LanaiTargetMachine>();
84  }
85 
86  bool addInstSelector() override;
87  void addPreSched2() override;
88  void addPreEmitPass() override;
89 };
90 } // namespace
91 
94  return new LanaiPassConfig(*this, &PassManager);
95 }
96 
97 // Install an instruction selector pass.
98 bool LanaiPassConfig::addInstSelector() {
99  addPass(createLanaiISelDag(getLanaiTargetMachine()));
100  return false;
101 }
102 
103 // Implemented by targets that want to run passes immediately before
104 // machine code is emitted.
105 void LanaiPassConfig::addPreEmitPass() {
106  addPass(createLanaiDelaySlotFillerPass(getLanaiTargetMachine()));
107 }
108 
109 // Run passes after prolog-epilog insertion and before the second instruction
110 // scheduling pass.
111 void LanaiPassConfig::addPreSched2() {
113 }
llvm::createLanaiDelaySlotFillerPass
FunctionPass * createLanaiDelaySlotFillerPass(const LanaiTargetMachine &TM)
Definition: LanaiDelaySlotFiller.cpp:85
llvm
Definition: AllocatorList.h:23
llvm::LanaiTargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &pass_manager) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: LanaiTargetMachine.cpp:93
llvm::TargetOptions
Definition: TargetOptions.h:113
llvm::Function
Definition: Function.h:61
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:125
llvm::CodeModel::Medium
@ Medium
Definition: CodeGen.h:28
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:167
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
computeDataLayout
static std::string computeDataLayout()
Definition: LanaiTargetMachine.cpp:39
Lanai.h
llvm::LanaiTTIImpl
Definition: LanaiTargetTransformInfo.h:28
new
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
Definition: README.txt:125
LLVMInitializeLanaiTarget
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTarget()
Definition: LanaiTargetMachine.cpp:33
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
FormattedStream.h
llvm::getTheLanaiTarget
Target & getTheLanaiTarget()
Definition: LanaiTargetInfo.cpp:14
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1199
llvm::PassRegistry
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
Passes.h
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::LanaiTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: LanaiTargetMachine.cpp:71
llvm::createLanaiMemAluCombinerPass
FunctionPass * createLanaiMemAluCombinerPass()
Definition: LanaiMemAluCombiner.cpp:422
LanaiTargetInfo.h
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:525
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
TargetPassConfig.h
LanaiTargetTransformInfo.h
llvm::LanaiTargetMachine::LanaiTargetMachine
LanaiTargetMachine(const Target &TheTarget, const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, const TargetOptions &Options, Optional< Reloc::Model > RelocationModel, Optional< CodeModel::Model > CodeModel, CodeGenOpt::Level OptLevel, bool JIT)
Definition: LanaiTargetMachine.cpp:54
TargetOptions.h
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:469
llvm::Reloc::PIC_
@ PIC_
Definition: CodeGen.h:22
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::initializeLanaiMemAluCombinerPass
void initializeLanaiMemAluCombinerPass(PassRegistry &)
llvm::createLanaiISelDag
FunctionPass * createLanaiISelDag(LanaiTargetMachine &TM)
Definition: LanaiISelDAGToDAG.cpp:331
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::getEffectiveRelocModel
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
Definition: AVRTargetMachine.cpp:39
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:473
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:41
LanaiTargetObjectFile.h
llvm::PassManager
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:466
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:385
llvm::LanaiTargetMachine
Definition: LanaiTargetMachine.h:24
llvm::LanaiTargetObjectFile
Definition: LanaiTargetObjectFile.h:15
TargetTransformInfo.h
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
LanaiTargetMachine.h
TargetRegistry.h
llvm::codegen::getCodeModel
CodeModel::Model getCodeModel()
TargetLoweringObjectFileImpl.h