1//===-- R600TargetMachine.h - AMDGPU TargetMachine Interface ----*- 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/// \file
10/// The AMDGPU TargetMachine interface definition for hw codegen targets.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_AMDGPU_R600TARGETMACHINE_H
15#define LLVM_LIB_TARGET_AMDGPU_R600TARGETMACHINE_H
16
17#include "AMDGPUTargetMachine.h"
18#include "R600Subtarget.h"
19#include "llvm/Target/LastSubtargetCache.h"
20#include "llvm/Target/TargetMachine.h"
21#include <optional>
22
23namespace llvm {
24
25//===----------------------------------------------------------------------===//
26// R600 Target Machine (R600 -> Cayman)
27//===----------------------------------------------------------------------===//
28
29class R600TargetMachine final : public AMDGPUTargetMachine {
30private:
31 mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
32
33 /// The attributes that select a subtarget.
34 struct SubtargetAttrs {
35 Attribute GPU, FS;
36
37 bool operator==(const SubtargetAttrs &RHS) const {
38 return GPU == RHS.GPU && FS == RHS.FS;
39 }
40
41 bool operator!=(const SubtargetAttrs &RHS) const { return !(*this == RHS); }
42 };
43 mutable LastSubtargetCache<R600Subtarget, SubtargetAttrs> LastSubtarget;
44
45public:
46 R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
47 StringRef FS, const TargetOptions &Options,
48 std::optional<Reloc::Model> RM,
49 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
50 bool JIT);
51
52 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
53
54 Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM,
55 raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
56 CodeGenFileType FileType,
57 const CGPassBuilderOption &Opt, MCContext &Ctx,
58 PassInstrumentationCallbacks *PIC) override;
59
60 const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override;
61
62 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
63
64 bool isMachineVerifierClean() const override { return false; }
65
66 MachineFunctionInfo *
67 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
68 const TargetSubtargetInfo *STI) const override;
69 ScheduleDAGInstrs *
70 createMachineScheduler(MachineSchedContext *C) const override;
71};
72
73} // end namespace llvm
74
75#endif // LLVM_LIB_TARGET_AMDGPU_R600TARGETMACHINE_H
76