Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / lib / Target / NVPTX / NVPTXMachineFunctionInfo.h
blob77426f7f6da71e83139be41ab3b7d4ca86962ee2
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
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H
17 #include "llvm/CodeGen/MachineFunction.h"
19 namespace llvm {
20 class NVPTXMachineFunctionInfo : public MachineFunctionInfo {
21 private:
22 /// Stores a mapping from index to symbol name for removing image handles
23 /// on Fermi.
24 SmallVector<std::string, 8> ImageHandleList;
26 public:
27 NVPTXMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {}
29 MachineFunctionInfo *
30 clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
31 const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
32 const override {
33 return DestMF.cloneInfo<NVPTXMachineFunctionInfo>(*this);
36 /// Returns the index for the symbol \p Symbol. If the symbol was previously,
37 /// added, the same index is returned. Otherwise, the symbol is added and the
38 /// new index is returned.
39 unsigned getImageHandleSymbolIndex(const char *Symbol) {
40 // Is the symbol already present?
41 for (unsigned i = 0, e = ImageHandleList.size(); i != e; ++i)
42 if (ImageHandleList[i] == std::string(Symbol))
43 return i;
44 // Nope, insert it
45 ImageHandleList.push_back(Symbol);
46 return ImageHandleList.size()-1;
49 /// Returns the symbol name at the given index.
50 const char *getImageHandleSymbol(unsigned Idx) const {
51 assert(ImageHandleList.size() > Idx && "Bad index");
52 return ImageHandleList[Idx].c_str();
57 #endif