LLVM  14.0.0git
ARCTargetMachine.cpp
Go to the documentation of this file.
1 //===- ARCTargetMachine.cpp - Define TargetMachine for ARC ------*- C++ -*-===//
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 "ARCTargetMachine.h"
13 #include "ARC.h"
14 #include "ARCTargetTransformInfo.h"
16 #include "llvm/CodeGen/Passes.h"
20 
21 using namespace llvm;
22 
24  return RM.getValueOr(Reloc::Static);
25 }
26 
27 /// ARCTargetMachine ctor - Create an ILP32 architecture model
29  StringRef CPU, StringRef FS,
30  const TargetOptions &Options,
33  CodeGenOpt::Level OL, bool JIT)
35  "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
36  "f32:32:32-i64:32-f64:32-a:0:32-n32",
37  TT, CPU, FS, Options, getRelocModel(RM),
38  getEffectiveCodeModel(CM, CodeModel::Small), OL),
39  TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
40  Subtarget(TT, std::string(CPU), std::string(FS), *this) {
41  initAsmInfo();
42 }
43 
45 
46 namespace {
47 
48 /// ARC Code Generator Pass Configuration Options.
49 class ARCPassConfig : public TargetPassConfig {
50 public:
51  ARCPassConfig(ARCTargetMachine &TM, PassManagerBase &PM)
52  : TargetPassConfig(TM, PM) {}
53 
54  ARCTargetMachine &getARCTargetMachine() const {
55  return getTM<ARCTargetMachine>();
56  }
57 
58  bool addInstSelector() override;
59  void addPreEmitPass() override;
60  void addPreRegAlloc() override;
61 };
62 
63 } // end anonymous namespace
64 
66  return new ARCPassConfig(*this, PM);
67 }
68 
69 bool ARCPassConfig::addInstSelector() {
70  addPass(createARCISelDag(getARCTargetMachine(), getOptLevel()));
71  return false;
72 }
73 
74 void ARCPassConfig::addPreEmitPass() { addPass(createARCBranchFinalizePass()); }
75 
76 void ARCPassConfig::addPreRegAlloc() {
77  addPass(createARCExpandPseudosPass());
78  addPass(createARCOptAddrMode());
79 }
80 
81 // Force static initialization.
84 }
85 
88  return TargetTransformInfo(ARCTTIImpl(this, F));
89 }
llvm::createARCISelDag
FunctionPass * createARCISelDag(ARCTargetMachine &TM, CodeGenOpt::Level OptLevel)
This pass converts a legalized DAG into a ARC-specific DAG, ready for instruction scheduling.
Definition: ARCISelDAGToDAG.cpp:70
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::createARCExpandPseudosPass
FunctionPass * createARCExpandPseudosPass()
Definition: ARCExpandPseudos.cpp:163
llvm::TargetOptions
Definition: TargetOptions.h:124
llvm::Function
Definition: Function.h:61
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:168
llvm::ARCTargetMachine
Definition: ARCTargetMachine.h:23
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
ARCTargetTransformInfo.h
llvm::TargetLoweringObjectFileELF
Definition: TargetLoweringObjectFileImpl.h:33
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::createARCOptAddrMode
FunctionPass * createARCOptAddrMode()
Definition: ARCOptAddrMode.cpp:506
llvm::ARCTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: ARCTargetMachine.cpp:87
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
LLVMInitializeARCTarget
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget()
Definition: ARCTargetMachine.cpp:82
llvm::ARCTargetMachine::~ARCTargetMachine
~ARCTargetMachine() override
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::getTheARCTarget
Target & getTheARCTarget()
Definition: ARCTargetInfo.cpp:14
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
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
ARCTargetInfo.h
llvm::ARCTargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: ARCTargetMachine.cpp:65
TargetPassConfig.h
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:472
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
ARCTargetMachine.h
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
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::ARCTargetMachine::ARCTargetMachine
ARCTargetMachine(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)
ARCTargetMachine ctor - Create an ILP32 architecture model.
Definition: ARCTargetMachine.cpp:28
getRelocModel
static Reloc::Model getRelocModel(Optional< Reloc::Model > RM)
Definition: ARCTargetMachine.cpp:23
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:393
ARC.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
llvm::createARCBranchFinalizePass
FunctionPass * createARCBranchFinalizePass()
Definition: ARCBranchFinalize.cpp:181
TargetRegistry.h
llvm::ARCTTIImpl
Definition: ARCTargetTransformInfo.h:29
SpecialSubKind::string
@ string
TargetLoweringObjectFileImpl.h