diff --git a/CMakeLists.txt b/CMakeLists.txt index b57c0859d..c3c57def7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(BUILD_PYTHON_MODULE "Build Python Triton bindings" OFF) find_package(LLVM REQUIRED CONFIG) include_directories(${LLVM_INCLUDE_DIRS}) add_definitions(${LLVM_DEFINITIONS}) -#llvm_map_components_to_libnames(llvm_libs all) +llvm_map_components_to_libnames(llvm_libs all) # Default build type if(NOT CMAKE_BUILD_TYPE) @@ -51,7 +51,7 @@ endif() # Triton file(GLOB_RECURSE LIBTRITON_SRC lib/*.cpp lib/*.cc) -add_library(triton SHARED ${LIBTRITON_SRC} ${EIGHTCC_SRC} ${PYTHON_SRC}) +add_library(triton SHARED ${LIBTRITON_SRC} ${PYTHON_SRC}) target_link_libraries(triton LLVM) # Warning level diff --git a/lib/driver/module.cc b/lib/driver/module.cc index 3174eb031..486d7d588 100755 --- a/lib/driver/module.cc +++ b/lib/driver/module.cc @@ -185,29 +185,30 @@ host_module::host_module(driver::context * context, llvm::Module* src): module(c /* ------------------------ */ ocl_module::ocl_module(driver::context * context, llvm::Module* src): module(context, cl_program(), true) { - init_llvm(); - llvm::SmallVector buffer; - module::compile_llvm_module(src, "amdgcn-amd-amdhsa-amdgizcl", "gfx902", "", buffer, "code-object-v3", Object); - std::ofstream output("/tmp/tmp.o", std::ios::binary); - std::copy(buffer.begin(), buffer.end(), std::ostreambuf_iterator(output)); - system("ld.lld-8 /tmp/tmp.o -shared -o /tmp/tmp.o"); - std::ifstream input("/tmp/tmp.o", std::ios::in | std::ios::binary ); - std::vector in_buffer(std::istreambuf_iterator(input), {}); - size_t sizes[] = {in_buffer.size()}; - const unsigned char* data[] = {(unsigned char*)in_buffer.data()}; - cl_int status; - cl_int err; - *cl_ = dispatch::clCreateProgramWithBinary(*context->cl(), 1, &*context->device()->cl(), sizes, data, &status, &err); - check(status); - check(err); - try{ - dispatch::clBuildProgram(*cl_, 1, &*context->device()->cl(), NULL, NULL, NULL); - } - catch(...){ - char log[2048]; - dispatch::clGetProgramBuildInfo(*cl_, *context->device()->cl(), CL_PROGRAM_BUILD_LOG, 1024, log, NULL); - throw; - } + throw std::runtime_error("not supported"); +// init_llvm(); +// llvm::SmallVector buffer; +// module::compile_llvm_module(src, "amdgcn-amd-amdhsa-amdgizcl", "gfx902", "", buffer, "code-object-v3", Object); +// std::ofstream output("/tmp/tmp.o", std::ios::binary); +// std::copy(buffer.begin(), buffer.end(), std::ostreambuf_iterator(output)); +// system("ld.lld-8 /tmp/tmp.o -shared -o /tmp/tmp.o"); +// std::ifstream input("/tmp/tmp.o", std::ios::in | std::ios::binary ); +// std::vector in_buffer(std::istreambuf_iterator(input), {}); +// size_t sizes[] = {in_buffer.size()}; +// const unsigned char* data[] = {(unsigned char*)in_buffer.data()}; +// cl_int status; +// cl_int err; +// *cl_ = dispatch::clCreateProgramWithBinary(*context->cl(), 1, &*context->device()->cl(), sizes, data, &status, &err); +// check(status); +// check(err); +// try{ +// dispatch::clBuildProgram(*cl_, 1, &*context->device()->cl(), NULL, NULL, NULL); +// } +// catch(...){ +// char log[2048]; +// dispatch::clGetProgramBuildInfo(*cl_, *context->device()->cl(), CL_PROGRAM_BUILD_LOG, 1024, log, NULL); +// throw; +// } } diff --git a/lib/lang/code_gen.cc b/lib/lang/code_gen.cc index 17b24d80d..83595d867 100644 --- a/lib/lang/code_gen.cc +++ b/lib/lang/code_gen.cc @@ -333,10 +333,8 @@ void Generator::VisitLabelStmt(LabelStmt* labelStmt) { } void Generator::VisitCompoundStmt(CompoundStmt* compoundStmt) { - if (compoundStmt->scope_){ -// AllocObjects(compoundStmt->scope_); + if (compoundStmt->scope_) pushScope(); - } for (auto stmt: compoundStmt->stmts_) Visit(stmt); if(compoundStmt->scope_)