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/CodeGen/CodeGenTargetMachineImpl.h"
20#include <optional>
21
22namespace llvm {
23
24enum class QFloatMode { StrictIEEE, IEEE, Lossy, Legacy };
25
26class HexagonTargetMachine : public CodeGenTargetMachineImpl {
27 std::unique_ptr<TargetLoweringObjectFile> TLOF;
28 HexagonSubtarget Subtarget;
29 mutable StringMap<std::unique_ptr<HexagonSubtarget>> SubtargetMap;
30
31public:
32 HexagonTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
33 StringRef FS, const TargetOptions &Options,
34 std::optional<Reloc::Model> RM,
35 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
36 bool JIT);
37 ~HexagonTargetMachine() override;
38 const HexagonSubtarget *getHexagonSubtarget() const { return &Subtarget; }
39 const HexagonSubtarget *getSubtargetImpl(const Function &F) const override;
40
41 void registerPassBuilderCallbacks(PassBuilder &PB) override;
42 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
43 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
44
45 HexagonTargetObjectFile *getObjFileLowering() const override {
46 return static_cast<HexagonTargetObjectFile*>(TLOF.get());
47 }
48
49 MachineFunctionInfo *
50 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
51 const TargetSubtargetInfo *STI) const override;
52
53 yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;
54 yaml::MachineFunctionInfo *
55 convertFuncInfoToYAML(const MachineFunction &MF) const override;
56 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,
57 PerFunctionMIParsingState &PFS,
58 SMDiagnostic &Error,
59 SMRange &SourceRange) const override;
60
61 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
62 return true;
63 }
64 ScheduleDAGInstrs *
65 createMachineScheduler(MachineSchedContext *C) const override;
66};
67
68} // end namespace llvm
69
70#endif
71