1 //=- LoongArchTargetMachine.h - Define TargetMachine for LoongArch -*- 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 LoongArch specific subclass of TargetMachine.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETMACHINE_H
14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETMACHINE_H
15 
16 #include "LoongArchSubtarget.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include <optional>
19 
20 namespace llvm {
21 
22 class LoongArchTargetMachine : public LLVMTargetMachine {
23   std::unique_ptr<TargetLoweringObjectFile> TLOF;
24   mutable StringMap<std::unique_ptr<LoongArchSubtarget>> SubtargetMap;
25 
26 public:
27   LoongArchTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
28                          StringRef FS, const TargetOptions &Options,
29                          std::optional<Reloc::Model> RM,
30                          std::optional<CodeModel::Model> CM,
31                          CodeGenOpt::Level OL, bool JIT);
32   ~LoongArchTargetMachine() override;
33 
34   TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
35   const LoongArchSubtarget *getSubtargetImpl(const Function &F) const override;
36   const LoongArchSubtarget *getSubtargetImpl() const = delete;
37 
38   // Pass Pipeline Configuration
39   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
40 
41   TargetLoweringObjectFile *getObjFileLowering() const override {
42     return TLOF.get();
43   }
44 
45   MachineFunctionInfo *
46   createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
47                             const TargetSubtargetInfo *STI) const override;
48 };
49 
50 } // end namespace llvm
51 
52 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETMACHINE_H
53