diff --git a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/CMakeLists.txt b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/CMakeLists.txt index 6421b528d766db0efc16e083c70d1d9328fcba84..bb943f9100e628c87c865dfbdce80fc094ebb23e 100644 --- a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/CMakeLists.txt +++ b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/CMakeLists.txt @@ -2,7 +2,8 @@ if(WIN32 OR CYGWIN) set(LLVM_LINK_COMPONENTS Core Support) endif() -add_llvm_loadable_module( ExtractHPVMLeafNodes +add_llvm_library( ExtractHPVMLeafNodes + MODULE ExtractHPVMLeafNodes.cpp DEPENDS diff --git a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.cpp b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.cpp index cd7ead9f6cda5048d03d1b56b0684dcfba368c73..031503adeddd6c070ca06f3012fa0c2e5362f92c 100644 --- a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.cpp +++ b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.cpp @@ -12,10 +12,11 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Pass.h" -#include "llvm/SupportVISC/DFGTreeTraversal.h" -#include "llvm/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h" -#include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "SupportHPVM/DFGTreeTraversal.h" +#include "ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.h" + +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/Support/ToolOutputFile.h" @@ -53,10 +54,10 @@ void PrintLeafNodes::process(DFLeafNode* N) { } // Find function generated for node - Function *F = N->getGenFuncForTarget(visc::CPU_TARGET); + Function *F = N->getGenFuncForTarget(hpvm::CPU_TARGET); assert(F != NULL && "This pass is invoked after code generation for x86 is completed.\nFound leaf node for which code generation has not happened!\n"); - assert(N->hasX86GenFuncForTarget(visc::CPU_TARGET) && + assert(N->hasCPUGenFuncForTarget(hpvm::CPU_TARGET) && "The generated function from x86 pass is not an x86 function\n"); std::string module_name = std::string("./build/") + std::string(F->getName().str().c_str()) + std::string("_module.ll"); @@ -85,8 +86,8 @@ void PrintLeafNodes::process(DFLeafNode* N) { StringRef CallName = CalledF->getName(); errs() << "CallName: " << CallName << "\n"; -// if (CallName.startswith("llvm_visc")) { //TODO - if ((CallName.startswith("llvm_visc")) || (CallName.startswith("tensor"))) { //TODO +// if (CallName.startswith("llvm_hpvm")) { //TODO + if ((CallName.startswith("llvm_hpvm")) || (CallName.startswith("tensor"))) { //TODO // errs() << "This is an HPVM runtime call. Include its declaration.\n"; errs() << "This is an HPVM runtime call or tensor. Include its declaration.\n"; @@ -96,7 +97,7 @@ void PrintLeafNodes::process(DFLeafNode* N) { for (unsigned argno = 0; argno < CI->getNumArgOperands(); argno++) { Fargs.push_back(CI->getArgOperand(argno)); } - Function *FDecl = cast<Function>(m->getOrInsertFunction(CallName, CalledFType)); + Function *FDecl = dyn_cast<Function>((m->getOrInsertFunction(CallName, CalledFType)).getCallee()); CallInst *NewCI = CallInst::Create(CalledFType, FDecl, Fargs, CallName, CI); errs() << "NewCI: " << *NewCI << "\n"; CI->replaceAllUsesWith(NewCI); @@ -116,7 +117,7 @@ void PrintLeafNodes::process(DFLeafNode* N) { errs() << "Writing to File --- " << tw.str() << "\n"; std::error_code EC; - tool_output_file Out(tw.str(), EC, sys::fs::F_None); + ToolOutputFile Out(tw.str(), EC, sys::fs::F_None); if (EC) { errs() << EC.message() << '\n'; } @@ -145,10 +146,10 @@ void PrintLeafNodes::process(DFLeafNode* N) { // Get the parent node's generated x86 function DFInternalNode *ParentNode = N->getParent(); - Function *PGenF = ParentNode->getGenFuncForTarget(visc::CPU_TARGET); + Function *PGenF = ParentNode->getGenFuncForTarget(hpvm::CPU_TARGET); assert(PGenF != NULL && "This pass is invoked after code generation for x86 is completed.\nFound node for which code generation has not happened!\n"); - assert(ParentNode->hasX86GenFuncForTarget(visc::CPU_TARGET) && + assert(ParentNode->hasCPUGenFuncForTarget(hpvm::CPU_TARGET) && "The generated function from x86 pass is not an x86 function\n"); for (inst_iterator i = inst_begin(PGenF), e = inst_end(PGenF); i != e; ++i) { @@ -169,7 +170,7 @@ void PrintLeafNodes::process(DFLeafNode* N) { for (unsigned argno = 0; argno < CI->getNumArgOperands(); argno++) { Fargs.push_back(CI->getArgOperand(argno)); } - Function *FDecl = cast<Function>(M.getOrInsertFunction(FName, FType)); + Function *FDecl = dyn_cast<Function>(M.getOrInsertFunction(FName, FType).getCallee()); CallInst *NewCI = CallInst::Create(FType, FDecl, Fargs, FName, CI); errs() << "NewCI: " << *NewCI << "\n"; CI->replaceAllUsesWith(NewCI); @@ -244,3 +245,4 @@ static RegisterPass<ExtractHPVMLeafNodeGenFunctionsWrapper> X( "Pass to extract leaf nodes to modules in HPVM", false /* does not modify the CFG */, true /* transformation, not just analysis */); + diff --git a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.exports b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.exports index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..139597f9cb07c5d48bed18984ec4747f4b4f3438 100644 --- a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.exports +++ b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/ExtractHPVMLeafNodes.exports @@ -0,0 +1,2 @@ + + diff --git a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/LLVMBuild.txt b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/LLVMBuild.txt index 9862f559e5d9e0ec6d47aa7eb3b8b811a79d8d79..73ac540f06e86e9e7f0201b993d2c1e11270158e 100644 --- a/hpvm/lib/Transforms/ExtractHPVMLeafNodes/LLVMBuild.txt +++ b/hpvm/lib/Transforms/ExtractHPVMLeafNodes/LLVMBuild.txt @@ -1,4 +1,4 @@ -;===- ./lib/Transforms/DFG2LLVM_NVPTX/LLVMBuild.txt ------------*- Conf -*--===; +;===- ./lib/Transforms/DFG2LLVM_WrapperAPI/LLVMBuild.txt -------*- Conf -*--===; ; ; The LLVM Compiler Infrastructure ; @@ -19,4 +19,3 @@ type = Library name = ExtractHPVMLeafNodes parent = Transforms -