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 "llvm/MC/MCContext.h"
20
21namespace llvm {
22class CallBase;
23class MCSymbol;
24
25class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
26private:
27 /// The parameter symbols whose image handles were replaced with image
28 /// references.
29 SmallPtrSet<const MCSymbol *, 8> ImageHandleSymbols;
30
31 using CallProtoTy = std::pair<const CallBase *, MCSymbol *>;
32 /// Stores the call instructions that need an indirect-call prototype emitted.
33 std::vector<CallProtoTy> CallPrototypes;
34
35public:
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 MCSymbol *addCallPrototype(const CallBase *CB, MachineFunction &MF) {
56 MCSymbol *Symbol = MF.getContext().createTempSymbol(Name: "prototype_");
57 CallPrototypes.push_back(x: {CB, Symbol});
58 return Symbol;
59 }
60
61 ArrayRef<CallProtoTy> getCallPrototypes() const { return CallPrototypes; }
62};
63}
64
65#endif
66