Mercurial > hg > CbC > CbC_llvm
diff lib/Target/NVPTX/NVVMReflect.cpp @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 803732b1fca8 |
children |
line wrap: on
line diff
--- a/lib/Target/NVPTX/NVVMReflect.cpp Sat Feb 17 09:57:20 2018 +0900 +++ b/lib/Target/NVPTX/NVVMReflect.cpp Wed Aug 14 16:55:33 2019 +0900 @@ -1,9 +1,8 @@ //===- NVVMReflect.cpp - NVVM Emulate conditional compilation -------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -50,7 +49,9 @@ class NVVMReflect : public FunctionPass { public: static char ID; - NVVMReflect() : FunctionPass(ID) { + unsigned int SmVersion; + NVVMReflect() : NVVMReflect(0) {} + explicit NVVMReflect(unsigned int Sm) : FunctionPass(ID), SmVersion(Sm) { initializeNVVMReflectPass(*PassRegistry::getPassRegistry()); } @@ -58,7 +59,9 @@ }; } -FunctionPass *llvm::createNVVMReflectPass() { return new NVVMReflect(); } +FunctionPass *llvm::createNVVMReflectPass(unsigned int SmVersion) { + return new NVVMReflect(SmVersion); +} static cl::opt<bool> NVVMReflectEnabled("nvvm-reflect-enable", cl::init(true), cl::Hidden, @@ -153,7 +156,7 @@ StringRef ReflectArg = cast<ConstantDataSequential>(Operand)->getAsString(); ReflectArg = ReflectArg.substr(0, ReflectArg.size() - 1); - DEBUG(dbgs() << "Arg of _reflect : " << ReflectArg << "\n"); + LLVM_DEBUG(dbgs() << "Arg of _reflect : " << ReflectArg << "\n"); int ReflectVal = 0; // The default value is 0 if (ReflectArg == "__CUDA_FTZ") { @@ -163,6 +166,8 @@ if (auto *Flag = mdconst::extract_or_null<ConstantInt>( F.getParent()->getModuleFlag("nvvm-reflect-ftz"))) ReflectVal = Flag->getSExtValue(); + } else if (ReflectArg == "__CUDA_ARCH") { + ReflectVal = SmVersion * 10; } Call->replaceAllUsesWith(ConstantInt::get(Call->getType(), ReflectVal)); ToRemove.push_back(Call);