From 53050a69c0b3cee89aa74bc032992e0d6f1c013e Mon Sep 17 00:00:00 2001 From: Prakalp Srivastava <psrivas2@illinois.edu> Date: Wed, 7 Jun 2017 13:28:59 -0500 Subject: [PATCH] Added parsing support for visc in,out,inout attributes. Commit ef703216 in previous llvm 3.4 based repo --- llvm/lib/AsmParser/LLLexer.cpp | 4 ++++ llvm/lib/AsmParser/LLParser.cpp | 13 +++++++++++++ llvm/lib/AsmParser/LLToken.h | 4 ++++ .../Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp | 12 ++++++------ llvm/lib/Transforms/GenVISC/GenVISC.cpp | 2 -- llvm/lib/Transforms/LocalMem/LocalMem.cpp | 2 +- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 752942fc9f..0d64ef41cc 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -660,6 +660,10 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(uwtable); KEYWORD(writeonly); KEYWORD(zeroext); + // VISC parameter attributes + KEYWORD(in); + KEYWORD(out); + KEYWORD(inout); KEYWORD(type); KEYWORD(opaque); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 4cd986e143..d7189c56ce 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1138,6 +1138,11 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B, case lltok::kw_sret: case lltok::kw_swifterror: case lltok::kw_swiftself: + // VISC Parameter only attributes + case lltok::kw_in: + case lltok::kw_out: + case lltok::kw_inout: + HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute on a function"); @@ -1413,6 +1418,10 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) { case lltok::kw_swiftself: B.addAttribute(Attribute::SwiftSelf); break; case lltok::kw_writeonly: B.addAttribute(Attribute::WriteOnly); break; case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break; + // VISC parameter attributes + case lltok::kw_in: B.addAttribute(Attribute::In); break; + case lltok::kw_out: B.addAttribute(Attribute::Out); break; + case lltok::kw_inout: B.addAttribute(Attribute::InOut); break; case lltok::kw_alignstack: case lltok::kw_alwaysinline: @@ -1501,6 +1510,10 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) { case lltok::kw_sret: case lltok::kw_swifterror: case lltok::kw_swiftself: + // VISC Parameter only attributes + case lltok::kw_in: + case lltok::kw_out: + case lltok::kw_inout: HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute"); break; diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 048aeee90b..0c05d51544 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -209,6 +209,10 @@ enum Kind { kw_uwtable, kw_writeonly, kw_zeroext, + // VISC parameter attributes + kw_in, + kw_out, + kw_inout, kw_type, kw_opaque, diff --git a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp index 2fe2292164..7aeebaef5f 100644 --- a/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp +++ b/llvm/lib/Transforms/DFG2LLVM_NVPTX/DFG2LLVM_NVPTX.cpp @@ -157,7 +157,7 @@ class CGT_NVPTX : public CodeGenTraversal { private: //Member variables Module &KernelM; - DFNode* KernelLaunchNode; + DFNode* KernelLaunchNode = NULL; Kernel* kernel; // VISC Runtime API @@ -255,7 +255,7 @@ void CGT_NVPTX::initRuntimeAPI() { assert(LLVM_SRC_ROOT != NULL && "Define LLVM_SRC_ROOT environment variable!"); Twine llvmSrcRoot = LLVM_SRC_ROOT; - Twine runtimeAPI = llvmSrcRoot+"/projects/visc-rt/visc-rt.ll"; + Twine runtimeAPI = llvmSrcRoot+"/../build/projects/visc-rt/visc-rt.ll"; runtimeModule = parseIRFile(runtimeAPI.str(), Err, M.getContext()); if(runtimeModule == nullptr) @@ -284,7 +284,7 @@ void CGT_NVPTX::initRuntimeAPI() { Function* VI = M.getFunction("llvm.visc.init"); assert(VI->getNumUses() == 1 && "__visc__init should only be used once"); - InitCall = cast<Instruction>(*VI->use_begin()); + InitCall = cast<Instruction>(*VI->user_begin()); initializeTimerSet(InitCall); switchToTimer(visc_TimerID_INIT_CTX, InitCall); CallInst::Create(llvm_visc_ocl_initContext, @@ -298,7 +298,7 @@ void CGT_NVPTX::initRuntimeAPI() { DEBUG(errs() << *VC << "\n"); assert(VC->getNumUses() == 1 && "__visc__clear should only be used once"); - CleanupCall = cast<Instruction>(*VC->use_begin()); + CleanupCall = cast<Instruction>(*VC->user_begin()); printTimerSet(CleanupCall); @@ -1504,7 +1504,7 @@ void CGT_NVPTX::fixValueAddrspace(Value* V, unsigned addrspace) { PointerType* OldTy = cast<PointerType>(V->getType()); PointerType* NewTy = PointerType::get(OldTy->getElementType(), addrspace); V->mutateType(NewTy); - for(Value::use_iterator ui = V->use_begin(), ue = V->use_end(); ui != ue; ui++) { + for(Value::user_iterator ui = V->user_begin(), ue = V->user_end(); ui != ue; ui++) { // Change all uses producing pointer type in same address space to new // addressspace. if(PointerType* PTy = dyn_cast<PointerType>((*ui)->getType())) { @@ -1706,7 +1706,7 @@ static bool findLoadStoreUses(Value* V, std::vector<Value*>*UseList, std::vector return false; } VisitedList->push_back(V); - for(Value::use_iterator ui = V->use_begin(), ue = V->use_end(); + for(Value::user_iterator ui = V->user_begin(), ue = V->user_end(); ui != ue; ++ui) { Instruction* I = dyn_cast<Instruction>(*ui); if(!I) { diff --git a/llvm/lib/Transforms/GenVISC/GenVISC.cpp b/llvm/lib/Transforms/GenVISC/GenVISC.cpp index fa803c9738..7a5d8646e5 100644 --- a/llvm/lib/Transforms/GenVISC/GenVISC.cpp +++ b/llvm/lib/Transforms/GenVISC/GenVISC.cpp @@ -1337,8 +1337,6 @@ bool GenVISC::runOnModule(Module &M) { } } - - return false; //TODO: What does returning "false" mean? } diff --git a/llvm/lib/Transforms/LocalMem/LocalMem.cpp b/llvm/lib/Transforms/LocalMem/LocalMem.cpp index 085a915c37..896c3f382a 100644 --- a/llvm/lib/Transforms/LocalMem/LocalMem.cpp +++ b/llvm/lib/Transforms/LocalMem/LocalMem.cpp @@ -140,7 +140,7 @@ void AT_OCL::codeGen(DFLeafNode* N) { // 2. (TODO:) Whether the allocated pointer escapes the parent node AllocationNodeProperty* isAllocationNode(DFLeafNode* N) { // Allocation node must be free from side-effects - if(!N->hasSideEffects()) + if(N->hasSideEffects()) return NULL; // Allocation node must have some outgoing edges -- GitLab