| 1 | //===-- NVPTXMachineFunctionInfo.h - NVPTX-specific Function Info --------===// |
| 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 class is attached to a MachineFunction instance and tracks target- |
| 10 | // dependent information |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H |
| 15 | #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H |
| 16 | |
| 17 | #include "llvm/ADT/SmallPtrSet.h" |
| 18 | #include "llvm/CodeGen/MachineFunction.h" |
| 19 | #include <map> |
| 20 | |
| 21 | namespace llvm { |
| 22 | class CallBase; |
| 23 | class MCSymbol; |
| 24 | |
| 25 | class NVPTXMachineFunctionInfo : public MachineFunctionInfo { |
| 26 | private: |
| 27 | /// The parameter symbols whose image handles were replaced with image |
| 28 | /// references. |
| 29 | SmallPtrSet<const MCSymbol *, 8> ImageHandleSymbols; |
| 30 | |
| 31 | /// Stores a mapping from a unique call-site id to the call instruction that |
| 32 | /// needs an indirect-call prototype emitted. |
| 33 | std::map<unsigned, const CallBase *> CallPrototypes; |
| 34 | |
| 35 | public: |
| 36 | NVPTXMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {} |
| 37 | |
| 38 | MachineFunctionInfo * |
| 39 | clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, |
| 40 | const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB) |
| 41 | const override { |
| 42 | return DestMF.cloneInfo<NVPTXMachineFunctionInfo>(Old: *this); |
| 43 | } |
| 44 | |
| 45 | /// Record that \p Symbol's handle was replaced with an image reference. |
| 46 | void addImageHandleSymbol(const MCSymbol *Symbol) { |
| 47 | ImageHandleSymbols.insert(Ptr: Symbol); |
| 48 | } |
| 49 | |
| 50 | /// Check whether \p Symbol's handle was replaced with an image reference. |
| 51 | bool checkImageHandleSymbol(const MCSymbol *Symbol) const { |
| 52 | return ImageHandleSymbols.contains(Ptr: Symbol); |
| 53 | } |
| 54 | |
| 55 | void addCallPrototype(unsigned Id, const CallBase *CB) { |
| 56 | CallPrototypes.try_emplace(k: Id, args&: CB); |
| 57 | } |
| 58 | |
| 59 | const std::map<unsigned, const CallBase *> &getCallPrototypes() const { |
| 60 | return CallPrototypes; |
| 61 | } |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | #endif |
| 66 | |