LLVM 20.0.0git
NVPTXMachineFunctionInfo.h
Go to the documentation of this file.
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/StringRef.h"
19
20namespace llvm {
22private:
23 /// Stores a mapping from index to symbol name for image handles that are
24 /// replaced with image references
25 SmallVector<std::string, 8> ImageHandleList;
26
27public:
29
33 const override {
34 return DestMF.cloneInfo<NVPTXMachineFunctionInfo>(*this);
35 }
36
37 /// Returns the index for the symbol \p Symbol. If the symbol was previously,
38 /// added, the same index is returned. Otherwise, the symbol is added and the
39 /// new index is returned.
41 // Is the symbol already present?
42 for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
43 if (ImageHandleList[i] == Symbol)
44 return i;
45 // Nope, insert it
46 ImageHandleList.push_back(Symbol.str());
47 return ImageHandleList.size()-1;
48 }
49
50 /// Returns the symbol name at the given index.
52 assert(ImageHandleList.size() > Idx && "Bad index");
53 return ImageHandleList[Idx];
54 }
55
56 /// Check if the symbol has a mapping. Having a mapping means the handle is
57 /// replaced with a reference
58 bool checkImageHandleSymbol(StringRef Symbol) const {
59 return ImageHandleList.end() !=
60 std::find(ImageHandleList.begin(), ImageHandleList.end(), Symbol);
61 }
62};
63}
64
65#endif
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
Basic Register Allocator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Ty * cloneInfo(const Ty &Old)
bool checkImageHandleSymbol(StringRef Symbol) const
Check if the symbol has a mapping.
unsigned getImageHandleSymbolIndex(StringRef Symbol)
Returns the index for the symbol Symbol.
NVPTXMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
StringRef getImageHandleSymbol(unsigned Idx) const
Returns the symbol name at the given index.
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
size_t size() const
Definition: SmallVector.h:78
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...