LLVM  13.0.0git
VETargetMachine.cpp
Go to the documentation of this file.
1 //===-- VETargetMachine.cpp - Define TargetMachine for VE -----------------===//
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 "VETargetMachine.h"
14 #include "VE.h"
15 #include "VETargetTransformInfo.h"
16 #include "llvm/CodeGen/Passes.h"
21 
22 using namespace llvm;
23 
24 #define DEBUG_TYPE "ve"
25 
27  // Register the target.
29 }
30 
31 static std::string computeDataLayout(const Triple &T) {
32  // Aurora VE is little endian
33  std::string Ret = "e";
34 
35  // Use ELF mangling
36  Ret += "-m:e";
37 
38  // Alignments for 64 bit integers.
39  Ret += "-i64:64";
40 
41  // VE supports 32 bit and 64 bits integer on registers
42  Ret += "-n32:64";
43 
44  // Stack alignment is 128 bits
45  Ret += "-S128";
46 
47  // Vector alignments are 64 bits
48  // Need to define all of them. Otherwise, each alignment becomes
49  // the size of each data by default.
50  Ret += "-v64:64:64"; // for v2f32
51  Ret += "-v128:64:64";
52  Ret += "-v256:64:64";
53  Ret += "-v512:64:64";
54  Ret += "-v1024:64:64";
55  Ret += "-v2048:64:64";
56  Ret += "-v4096:64:64";
57  Ret += "-v8192:64:64";
58  Ret += "-v16384:64:64"; // for v256f64
59 
60  return Ret;
61 }
62 
64  return RM.getValueOr(Reloc::Static);
65 }
66 
68  void Initialize(MCContext &Ctx, const TargetMachine &TM) override {
70  InitializeELF(TM.Options.UseInitArray);
71  }
72 };
73 
74 static std::unique_ptr<TargetLoweringObjectFile> createTLOF() {
75  return std::make_unique<VEELFTargetObjectFile>();
76 }
77 
78 /// Create an Aurora VE architecture model
80  StringRef CPU, StringRef FS,
81  const TargetOptions &Options,
84  CodeGenOpt::Level OL, bool JIT)
85  : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
87  getEffectiveCodeModel(CM, CodeModel::Small), OL),
88  TLOF(createTLOF()),
89  Subtarget(TT, std::string(CPU), std::string(FS), *this) {
90  initAsmInfo();
91 }
92 
94 
96  return TargetTransformInfo(VETTIImpl(this, F));
97 }
98 
99 namespace {
100 /// VE Code Generator Pass Configuration Options.
101 class VEPassConfig : public TargetPassConfig {
102 public:
103  VEPassConfig(VETargetMachine &TM, PassManagerBase &PM)
104  : TargetPassConfig(TM, PM) {}
105 
106  VETargetMachine &getVETargetMachine() const {
107  return getTM<VETargetMachine>();
108  }
109 
110  void addIRPasses() override;
111  bool addInstSelector() override;
112  void addPreEmitPass() override;
113 };
114 } // namespace
115 
117  return new VEPassConfig(*this, PM);
118 }
119 
120 void VEPassConfig::addIRPasses() {
121  // VE requires atomic expand pass.
122  addPass(createAtomicExpandPass());
124 }
125 
126 bool VEPassConfig::addInstSelector() {
127  addPass(createVEISelDag(getVETargetMachine()));
128  return false;
129 }
130 
131 void VEPassConfig::addPreEmitPass() {
132  // LVLGen should be called after scheduling and register allocation
133  addPass(createLVLGenPass());
134 }
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::TargetOptions
Definition: TargetOptions.h:122
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:71
llvm::Function
Definition: Function.h:61
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:124
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::TargetLoweringObjectFileELF
Definition: TargetLoweringObjectFileImpl.h:33
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::VETTIImpl
Definition: VETargetTransformInfo.h:26
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::X86AS::FS
@ FS
Definition: X86.h:182
LegacyPassManager.h
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
VEELFTargetObjectFile
Definition: VETargetMachine.cpp:67
llvm::getTheVETarget
Target & getTheVETarget()
Definition: VETargetInfo.cpp:14
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::createAtomicExpandPass
FunctionPass * createAtomicExpandPass()
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1113
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
LLVMInitializeVETarget
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeVETarget()
Definition: VETargetMachine.cpp:26
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:525
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:131
llvm::VETargetMachine::VETargetMachine
VETargetMachine(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 Aurora VE architecture model.
Definition: VETargetMachine.cpp:79
llvm::createLVLGenPass
FunctionPass * createLVLGenPass()
Definition: LVLGen.cpp:38
llvm::TargetPassConfig::addIRPasses
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
Definition: TargetPassConfig.cpp:800
TargetPassConfig.h
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:463
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:22
llvm::createVEISelDag
FunctionPass * createVEISelDag(VETargetMachine &TM)
createVEISelDag - This pass converts a legalized DAG into a VE-specific DAG, ready for instruction sc...
Definition: VEISelDAGToDAG.cpp:356
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
VETargetTransformInfo.h
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:474
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:41
llvm::VETargetMachine
Definition: VETargetMachine.h:22
VETargetInfo.h
llvm::VETargetMachine::~VETargetMachine
~VETargetMachine() override
Definition: VETargetMachine.cpp:93
std
Definition: BitVector.h:941
llvm::VETargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: VETargetMachine.cpp:95
llvm::TargetLoweringObjectFileELF::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:114
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:386
VE.h
llvm::VETargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: VETargetMachine.cpp:116
computeDataLayout
static std::string computeDataLayout(const Triple &T)
Definition: VETargetMachine.cpp:31
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
VETargetMachine.h
TargetRegistry.h
createTLOF
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
Definition: VETargetMachine.cpp:74
SpecialSubKind::string
@ string
TargetLoweringObjectFileImpl.h