1//===-- LanaiTargetMachine.h - Define TargetMachine for Lanai --- 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// This file declares the Lanai specific subclass of TargetMachine.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_LANAI_LANAITARGETMACHINE_H
14#define LLVM_LIB_TARGET_LANAI_LANAITARGETMACHINE_H
15
16#include "LanaiISelLowering.h"
17#include "LanaiInstrInfo.h"
18#include "LanaiSelectionDAGInfo.h"
19#include "LanaiSubtarget.h"
20#include "llvm/CodeGen/CodeGenTargetMachineImpl.h"
21#include <optional>
22
23namespace llvm {
24
25class LanaiTargetMachine : public CodeGenTargetMachineImpl {
26 const LanaiOptions &CLOpts;
27 LanaiSubtarget Subtarget;
28 std::unique_ptr<TargetLoweringObjectFile> TLOF;
29
30public:
31 LanaiTargetMachine(const Target &TheTarget, const Triple &TargetTriple,
32 StringRef Cpu, StringRef FeatureString,
33 const TargetOptions &Options,
34 std::optional<Reloc::Model> RM,
35 std::optional<CodeModel::Model> CodeModel,
36 CodeGenOptLevel OptLevel, bool JIT);
37
38 const LanaiOptions &getCLOpts() const { return CLOpts; }
39
40 const LanaiSubtarget *
41 getSubtargetImpl(const llvm::Function & /*Fn*/) const override {
42 return &Subtarget;
43 }
44
45 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
46
47 // Pass Pipeline Configuration
48 TargetPassConfig *createPassConfig(PassManagerBase &pass_manager) override;
49
50 TargetLoweringObjectFile *getObjFileLowering() const override {
51 return TLOF.get();
52 }
53
54 MachineFunctionInfo *
55 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
56 const TargetSubtargetInfo *STI) const override;
57
58 void registerPassBuilderCallbacks(PassBuilder &PB) override;
59
60 Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM,
61 raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
62 CodeGenFileType FileType,
63 const CGPassBuilderOption &Opt, MCContext &Ctx,
64 PassInstrumentationCallbacks *PIC) override;
65
66 bool shouldDefaultToNewPM() const override { return true; }
67};
68} // namespace llvm
69
70#endif // LLVM_LIB_TARGET_LANAI_LANAITARGETMACHINE_H
71