| 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/TargetMachine.h" |
| 20 | #include <optional> |
| 21 | |
| 22 | namespace llvm { |
| 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | // R600 Target Machine (R600 -> Cayman) |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
| 28 | class R600TargetMachine final : public AMDGPUTargetMachine { |
| 29 | private: |
| 30 | mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap; |
| 31 | |
| 32 | public: |
| 33 | R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
| 34 | StringRef FS, const TargetOptions &Options, |
| 35 | std::optional<Reloc::Model> RM, |
| 36 | std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, |
| 37 | bool JIT); |
| 38 | |
| 39 | TargetPassConfig *createPassConfig(PassManagerBase &PM) override; |
| 40 | |
| 41 | Error buildCodeGenPipeline(ModulePassManager &MPM, raw_pwrite_stream &Out, |
| 42 | raw_pwrite_stream *DwoOut, |
| 43 | CodeGenFileType FileType, |
| 44 | const CGPassBuilderOption &Opt, |
| 45 | PassInstrumentationCallbacks *PIC) override; |
| 46 | |
| 47 | const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override; |
| 48 | |
| 49 | TargetTransformInfo getTargetTransformInfo(const Function &F) const override; |
| 50 | |
| 51 | bool isMachineVerifierClean() const override { return false; } |
| 52 | |
| 53 | MachineFunctionInfo * |
| 54 | createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, |
| 55 | const TargetSubtargetInfo *STI) const override; |
| 56 | ScheduleDAGInstrs * |
| 57 | createMachineScheduler(MachineSchedContext *C) const override; |
| 58 | }; |
| 59 | |
| 60 | //===----------------------------------------------------------------------===// |
| 61 | // R600 CodeGen Pass Builder interface. |
| 62 | //===----------------------------------------------------------------------===// |
| 63 | |
| 64 | class R600CodeGenPassBuilder |
| 65 | : public CodeGenPassBuilder<R600CodeGenPassBuilder, R600TargetMachine> { |
| 66 | public: |
| 67 | R600CodeGenPassBuilder(R600TargetMachine &TM, const CGPassBuilderOption &Opts, |
| 68 | PassInstrumentationCallbacks *PIC); |
| 69 | |
| 70 | void addPreISel(AddIRPass &addPass) const; |
| 71 | void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const; |
| 72 | Error addInstSelector(AddMachinePass &) const; |
| 73 | }; |
| 74 | |
| 75 | } // end namespace llvm |
| 76 | |
| 77 | #endif // LLVM_LIB_TARGET_AMDGPU_R600TARGETMACHINE_H |
| 78 | |