[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Target / ARC / ARCTargetMachine.cpp
blobb8c8949e18dd692cfdc5aafee0ca5e13d9f04fec
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 //===----------------------------------------------------------------------===//
12 #include "ARCTargetMachine.h"
13 #include "ARC.h"
14 #include "ARCTargetTransformInfo.h"
15 #include "TargetInfo/ARCTargetInfo.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
18 #include "llvm/CodeGen/TargetPassConfig.h"
19 #include "llvm/Support/TargetRegistry.h"
21 using namespace llvm;
23 static Reloc::Model getRelocModel(Optional<Reloc::Model> RM) {
24 return RM.getValueOr(Reloc::Static);
27 /// ARCTargetMachine ctor - Create an ILP32 architecture model
28 ARCTargetMachine::ARCTargetMachine(const Target &T, const Triple &TT,
29 StringRef CPU, StringRef FS,
30 const TargetOptions &Options,
31 Optional<Reloc::Model> RM,
32 Optional<CodeModel::Model> CM,
33 CodeGenOpt::Level OL, bool JIT)
34 : LLVMTargetMachine(T,
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();
44 ARCTargetMachine::~ARCTargetMachine() = default;
46 namespace {
48 /// ARC Code Generator Pass Configuration Options.
49 class ARCPassConfig : public TargetPassConfig {
50 public:
51 ARCPassConfig(ARCTargetMachine &TM, PassManagerBase &PM)
52 : TargetPassConfig(TM, PM) {}
54 ARCTargetMachine &getARCTargetMachine() const {
55 return getTM<ARCTargetMachine>();
58 bool addInstSelector() override;
59 void addPreEmitPass() override;
60 void addPreRegAlloc() override;
63 } // end anonymous namespace
65 TargetPassConfig *ARCTargetMachine::createPassConfig(PassManagerBase &PM) {
66 return new ARCPassConfig(*this, PM);
69 bool ARCPassConfig::addInstSelector() {
70 addPass(createARCISelDag(getARCTargetMachine(), getOptLevel()));
71 return false;
74 void ARCPassConfig::addPreEmitPass() { addPass(createARCBranchFinalizePass()); }
76 void ARCPassConfig::addPreRegAlloc() {
77 addPass(createARCExpandPseudosPass());
78 addPass(createARCOptAddrMode());
81 // Force static initialization.
82 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget() {
83 RegisterTargetMachine<ARCTargetMachine> X(getTheARCTarget());
86 TargetTransformInfo
87 ARCTargetMachine::getTargetTransformInfo(const Function &F) {
88 return TargetTransformInfo(ARCTTIImpl(this, F));