brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 8feae34 Raw
59 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This class is attached to a MachineFunction instance and tracks target-10// dependent information11//12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H15#define LLVM_LIB_TARGET_NVPTX_NVPTXMACHINEFUNCTIONINFO_H16 17#include "llvm/ADT/StringRef.h"18#include "llvm/CodeGen/MachineFunction.h"19 20namespace llvm {21class NVPTXMachineFunctionInfo : public MachineFunctionInfo {22private:23  /// Stores a mapping from index to symbol name for image handles that are24  /// replaced with image references25  SmallVector<std::string, 8> ImageHandleList;26 27public:28  NVPTXMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {}29 30  MachineFunctionInfo *31  clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,32        const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)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 the39  /// new index is returned.40  unsigned getImageHandleSymbolIndex(StringRef Symbol) {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 it46    ImageHandleList.push_back(Symbol.str());47    return ImageHandleList.size()-1;48  }49 50  /// Check if the symbol has a mapping. Having a mapping means the handle is51  /// replaced with a reference52  bool checkImageHandleSymbol(StringRef Symbol) const {53    return llvm::is_contained(ImageHandleList, Symbol);54  }55};56}57 58#endif59