From 69ef101ba56b5746293f3178533ca5f4af999985 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Thu, 10 Mar 2022 19:15:10 +0100 Subject: [PATCH 1/3] RV integration as an LLVM component --- .gitmodules | 4 ++++ llvm/CMakeLists.txt | 2 ++ llvm/lib/CMakeLists.txt | 2 ++ llvm/lib/Passes/CMakeLists.txt | 1 + llvm/lib/Passes/PassBuilder.cpp | 3 +++ llvm/lib/rv | 1 + 6 files changed, 13 insertions(+) create mode 100644 .gitmodules create mode 160000 llvm/lib/rv diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..740eb9cd5b06 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "llvm/lib/rv"] + path = llvm/lib/rv + url = https://github.com/sx-aurora-dev/rv.git + branch = hpce/develop diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 91410659a0be..0ceac08c04cf 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1033,6 +1033,8 @@ if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) # (this is a variable that CrossCompile sets on recursive invocations) endif() +include_directories("${CMAKE_SOURCE_DIR}/lib/rv/include") + if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) # special hack for Solaris to handle crazy system sys/regset.h include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris") diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 5ecdf5af956a..491517c670fa 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -38,6 +38,8 @@ add_subdirectory(Passes) add_subdirectory(TextAPI) add_subdirectory(ToolDrivers) add_subdirectory(XRay) +add_subdirectory(rv) + if (LLVM_INCLUDE_TESTS) add_subdirectory(Testing) endif() diff --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt index 703969f8b5f4..43b48a15d0e9 100644 --- a/llvm/lib/Passes/CMakeLists.txt +++ b/llvm/lib/Passes/CMakeLists.txt @@ -27,4 +27,5 @@ add_llvm_component_library(LLVMPasses TransformUtils Vectorize Instrumentation + RV ) diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 090477c3dffb..954723e79700 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -250,6 +250,8 @@ #include "llvm/Transforms/Vectorize/SLPVectorizer.h" #include "llvm/Transforms/Vectorize/VectorCombine.h" +#include "rv/registerPasses.h" + using namespace llvm; static const Regex DefaultAliasRegex( @@ -413,6 +415,7 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO, PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); #include "PassRegistry.def" } + rv::addConfiguredRVPasses(*this); } void PassBuilder::registerModuleAnalyses(ModuleAnalysisManager &MAM) { diff --git a/llvm/lib/rv b/llvm/lib/rv new file mode 160000 index 000000000000..def8c8d3863e --- /dev/null +++ b/llvm/lib/rv @@ -0,0 +1 @@ +Subproject commit def8c8d3863edf3bf8226876855cc0093165d148 From e1fa3befc20ffbd20ecef2d439a12769f12c1f68 Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Wed, 12 May 2021 16:03:52 +0200 Subject: [PATCH 2/3] [omp] drop parallel loop md (even if there is no clause) --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index a5ee7abc655b..7d1cdcef652b 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3300,6 +3300,9 @@ bool CodeGenFunction::EmitOMPWorksharingLoop( } else if (const auto *C = S.getSingleClause()) { if (C->getKind() == OMPC_ORDER_concurrent) CGF.LoopStack.setParallel(/*Enable=*/true); + } else { + // TODO: This may not be legal + CGF.LoopStack.setParallel(/*Enable=*/true); } }, [IVSize, IVSigned, Ordered, IL, LB, UB, ST, StaticChunkedOne, Chunk, From d345c9744cf7fdfc85fc808f244b72634943cbfa Mon Sep 17 00:00:00 2001 From: Simon Moll Date: Fri, 18 Mar 2022 15:12:39 +0100 Subject: [PATCH 3/3] VBBuilder::createSelect --- llvm/include/llvm/IR/VPBuilder.h | 2 ++ llvm/lib/IR/VPBuilder.cpp | 9 +++++++++ llvm/lib/rv | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/IR/VPBuilder.h b/llvm/include/llvm/IR/VPBuilder.h index 6de1317f7934..98ede35b2a5a 100644 --- a/llvm/include/llvm/IR/VPBuilder.h +++ b/llvm/include/llvm/IR/VPBuilder.h @@ -69,6 +69,8 @@ class VPBuilder { Value& CreateContiguousLoad(Type *ReturnTy, Value & Pointer, MaybeAlign Alignment); Value& CreateScatter(Value & Val, Value & PointerVec, MaybeAlign Alignment); Value& CreateGather(Type *ReturnTy, Value & PointerVec, MaybeAlign Alignment); + Value &createSelect(Value &OnTrue, Value &OnFalse, Value &Mask, Value &Pivot, + Twine Name = ""); }; } // namespace llvm diff --git a/llvm/lib/IR/VPBuilder.cpp b/llvm/lib/IR/VPBuilder.cpp index 728132fada9a..e8b7765e6d7d 100644 --- a/llvm/lib/IR/VPBuilder.cpp +++ b/llvm/lib/IR/VPBuilder.cpp @@ -209,4 +209,13 @@ Value *VPBuilder::CreateVectorShift(Value *SrcVal, Value *Amount, Twine Name) { Name); } +Value &VPBuilder::createSelect(Value &OnTrue, Value &OnFalse, Value &Mask, + Value &Pivot, Twine Name) { + auto D = VPIntrinsic::getDeclarationForParams( + &getModule(), Intrinsic::vp_select, OnTrue.getType(), + {&OnTrue, &OnFalse, &Mask, &Pivot}); + return *Builder.CreateCall( + D, {&OnTrue, &OnFalse, &Mask, &Pivot, &RequestEVL()}, Name); +} + } // namespace llvm diff --git a/llvm/lib/rv b/llvm/lib/rv index def8c8d3863e..da1bb9e4e29f 160000 --- a/llvm/lib/rv +++ b/llvm/lib/rv @@ -1 +1 @@ -Subproject commit def8c8d3863edf3bf8226876855cc0093165d148 +Subproject commit da1bb9e4e29f1fb00ecf8dc5153899b119e99463