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