003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Target/NVPTX
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Target
/
NVPTX
/
📁
..
📁
MCTargetDesc
📄
ManagedStringPool.h
(1.41 KB)
📄
NVPTX.h
(3.22 KB)
📄
NVPTX.td
(4.99 KB)
📄
NVPTXAllocaHoisting.cpp
(2.12 KB)
📄
NVPTXAllocaHoisting.h
(755 B)
📄
NVPTXAsmPrinter.cpp
(71.02 KB)
📄
NVPTXAsmPrinter.h
(11.23 KB)
📄
NVPTXAssignValidGlobalNames.cpp
(2.74 KB)
📄
NVPTXFrameLowering.cpp
(3.41 KB)
📄
NVPTXFrameLowering.h
(1.34 KB)
📄
NVPTXGenericToNVVM.cpp
(11.59 KB)
📄
NVPTXISelDAGToDAG.cpp
(134.03 KB)
📄
NVPTXISelDAGToDAG.h
(3.54 KB)
📄
NVPTXISelLowering.cpp
(198.59 KB)
📄
NVPTXISelLowering.h
(15.65 KB)
📄
NVPTXImageOptimizer.cpp
(5.64 KB)
📄
NVPTXInstrFormats.td
(1.72 KB)
📄
NVPTXInstrInfo.cpp
(7.88 KB)
📄
NVPTXInstrInfo.h
(2.87 KB)
📄
NVPTXInstrInfo.td
(133.35 KB)
📄
NVPTXIntrinsics.td
(329.76 KB)
📄
NVPTXLowerAggrCopies.cpp
(4.85 KB)
📄
NVPTXLowerAggrCopies.h
(744 B)
📄
NVPTXLowerAlloca.cpp
(4.27 KB)
📄
NVPTXLowerArgs.cpp
(9.16 KB)
📄
NVPTXMCExpr.cpp
(2.04 KB)
📄
NVPTXMCExpr.h
(3.92 KB)
📄
NVPTXMachineFunctionInfo.h
(1.71 KB)
📄
NVPTXPeephole.cpp
(4.92 KB)
📄
NVPTXPrologEpilogPass.cpp
(8.91 KB)
📄
NVPTXProxyRegErasure.cpp
(3.81 KB)
📄
NVPTXRegisterInfo.cpp
(4.41 KB)
📄
NVPTXRegisterInfo.h
(2.04 KB)
📄
NVPTXRegisterInfo.td
(3.12 KB)
📄
NVPTXReplaceImageHandles.cpp
(6.27 KB)
📄
NVPTXSubtarget.cpp
(2.15 KB)
📄
NVPTXSubtarget.h
(3.02 KB)
📄
NVPTXTargetMachine.cpp
(14.25 KB)
📄
NVPTXTargetMachine.h
(3.33 KB)
📄
NVPTXTargetObjectFile.h
(1.53 KB)
📄
NVPTXTargetTransformInfo.cpp
(6.18 KB)
📄
NVPTXTargetTransformInfo.h
(4.7 KB)
📄
NVPTXUtilities.cpp
(9.37 KB)
📄
NVPTXUtilities.h
(2.03 KB)
📄
NVVMIntrRange.cpp
(4.88 KB)
📄
NVVMReflect.cpp
(6.8 KB)
📁
TargetInfo
📄
cl_common_defines.h
(3.94 KB)
Editing: NVPTXAssignValidGlobalNames.cpp
//===-- NVPTXAssignValidGlobalNames.cpp - Assign valid names to globals ---===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Clean up the names of global variables in the module to not contain symbols // that are invalid in PTX. // // Currently NVPTX, like other backends, relies on generic symbol name // sanitizing done by MC. However, the ptxas assembler is more stringent and // disallows some additional characters in symbol names. This pass makes sure // such names do not reach MC at all. // //===----------------------------------------------------------------------===// #include "NVPTX.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" #include "llvm/Support/raw_ostream.h" #include <string> using namespace llvm; namespace { /// NVPTXAssignValidGlobalNames class NVPTXAssignValidGlobalNames : public ModulePass { public: static char ID; NVPTXAssignValidGlobalNames() : ModulePass(ID) {} bool runOnModule(Module &M) override; /// Clean up the name to remove symbols invalid in PTX. std::string cleanUpName(StringRef Name); }; } char NVPTXAssignValidGlobalNames::ID = 0; namespace llvm { void initializeNVPTXAssignValidGlobalNamesPass(PassRegistry &); } INITIALIZE_PASS(NVPTXAssignValidGlobalNames, "nvptx-assign-valid-global-names", "Assign valid PTX names to globals", false, false) bool NVPTXAssignValidGlobalNames::runOnModule(Module &M) { for (GlobalVariable &GV : M.globals()) { // We are only allowed to rename local symbols. if (GV.hasLocalLinkage()) { // setName doesn't do extra work if the name does not change. // Note: this does not create collisions - if setName is asked to set the // name to something that already exists, it adds a proper postfix to // avoid collisions. GV.setName(cleanUpName(GV.getName())); } } // Do the same for local functions. for (Function &F : M.functions()) if (F.hasLocalLinkage()) F.setName(cleanUpName(F.getName())); return true; } std::string NVPTXAssignValidGlobalNames::cleanUpName(StringRef Name) { std::string ValidName; raw_string_ostream ValidNameStream(ValidName); for (unsigned I = 0, E = Name.size(); I != E; ++I) { char C = Name[I]; if (C == '.' || C == '@') { ValidNameStream << "_$_"; } else { ValidNameStream << C; } } return ValidNameStream.str(); } ModulePass *llvm::createNVPTXAssignValidGlobalNamesPass() { return new NVPTXAssignValidGlobalNames(); }
Upload File
Create Folder