LLVM  10.0.0
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"
13 #include "VE.h"
14 #include "VETargetTransformInfo.h"
15 #include "llvm/CodeGen/Passes.h"
20 
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "ve"
24 
25 extern "C" void LLVMInitializeVETarget() {
26  // Register the target.
28 }
29 
30 static std::string computeDataLayout(const Triple &T) {
31  // Aurora VE is little endian
32  std::string Ret = "e";
33 
34  // Use ELF mangling
35  Ret += "-m:e";
36 
37  // Alignments for 64 bit integers.
38  Ret += "-i64:64";
39 
40  // VE supports 32 bit and 64 bits integer on registers
41  Ret += "-n32:64";
42 
43  // Stack alignment is 64 bits
44  Ret += "-S64";
45 
46  return Ret;
47 }
48 
50  if (!RM.hasValue())
51  return Reloc::Static;
52  return *RM;
53 }
54 
56  void Initialize(MCContext &Ctx, const TargetMachine &TM) override {
58  InitializeELF(TM.Options.UseInitArray);
59  }
60 };
61 
62 static std::unique_ptr<TargetLoweringObjectFile> createTLOF() {
63  return std::make_unique<VEELFTargetObjectFile>();
64 }
65 
66 /// Create an Aurora VE architecture model
68  StringRef CPU, StringRef FS,
69  const TargetOptions &Options,
72  CodeGenOpt::Level OL, bool JIT)
73  : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
75  getEffectiveCodeModel(CM, CodeModel::Small), OL),
76  TLOF(createTLOF()), Subtarget(TT, CPU, FS, *this) {
77  initAsmInfo();
78 }
79 
81 
83  return TargetTransformInfo(VETTIImpl(this, F));
84 }
85 
86 namespace {
87 /// VE Code Generator Pass Configuration Options.
88 class VEPassConfig : public TargetPassConfig {
89 public:
90  VEPassConfig(VETargetMachine &TM, PassManagerBase &PM)
91  : TargetPassConfig(TM, PM) {}
92 
93  VETargetMachine &getVETargetMachine() const {
94  return getTM<VETargetMachine>();
95  }
96 
97  bool addInstSelector() override;
98 };
99 } // namespace
100 
102  return new VEPassConfig(*this, PM);
103 }
104 
105 bool VEPassConfig::addInstSelector() {
106  addPass(createVEISelDag(getVETargetMachine()));
107  return false;
108 }
void LLVMInitializeVETarget()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
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.
F(f)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Target-Independent Code Generator Pass Configuration Options.
Context object for machine code objects.
Definition: MCContext.h:65
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
This class describes a target machine that is implemented with the LLVM target-independent code gener...
FunctionPass * createVEISelDag(VETargetMachine &TM)
createVEISelDag - This pass converts a legalized DAG into a VE-specific DAG, ready for instruction sc...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
Target & getTheVETarget()
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
static std::string computeDataLayout(const Triple &T)
Target - Wrapper for Target specific information.
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
bool hasValue() const
Definition: Optional.h:259
This file a TargetTransformInfo::Concept conforming object specific to the VE target machine...
TargetOptions Options
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.