Skip to content

Commit

Permalink
Move files around
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanradanov committed Jun 14, 2024
1 parent 5bb6194 commit b349b3b
Show file tree
Hide file tree
Showing 65 changed files with 257 additions and 87 deletions.
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(polygeist)
add_subdirectory(mlir)
2 changes: 2 additions & 0 deletions include/mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(Conversion)
add_subdirectory(Dialect)
3 changes: 3 additions & 0 deletions include/mlir/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(LLVM_TARGET_DEFINITIONS PolygeistPasses.td)
mlir_tablegen(PolygeistPasses.h.inc -gen-pass-decls -name Conversion)
add_public_tablegen_target(MLIRPolygeistConversionPassIncGen)
25 changes: 25 additions & 0 deletions include/mlir/Conversion/PolygeistPasses.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef MLIR_CONVERSION_POLYGEISTPASSES_H_
#define MLIR_CONVERSION_POLYGEISTPASSES_H_

#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistDialect.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include <memory>

namespace mlir {
class PatternRewriter;
class RewritePatternSet;
class DominanceInfo;
namespace polygeist {
std::unique_ptr<Pass> createConvertPolygeistToLLVMPass();
std::unique_ptr<Pass>
createConvertPolygeistToLLVMPass(const LowerToLLVMOptions &options,
bool useCStyleMemRef, bool onlyGpuModules,
std::string gpuTarget);
} // namespace polygeist
} // namespace mlir

#endif // POLYGEISTPASSES_H_
64 changes: 64 additions & 0 deletions include/mlir/Conversion/PolygeistPasses.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef MLIR_CONVERSION_POLYGEISTPASSES
#define MLIR_CONVERSION_POLYGEISTPASSES

include "mlir/Pass/PassBase.td"
include "mlir/Rewrite/PassUtil.td"

def ConvertPolygeistToLLVM : Pass<"convert-polygeist-to-llvm", "mlir::ModuleOp"> {
let summary = "Convert scalar and vector operations from the Standard to the "
"LLVM dialect";
let description = [{
Convert standard operations into the LLVM IR dialect operations.

#### Input invariant

- operations including: arithmetic on integers and floats, constants,
direct calls, returns and branches;
- no `tensor` types;
- all `vector` are one-dimensional;
- all blocks are reachable by following the successors of the first basic
block;

If other operations are present and their results are required by the LLVM
IR dialect operations, the pass will fail. Any LLVM IR operations or types
already present in the IR will be kept as is.

#### Output IR

Functions converted to LLVM IR. Function arguments types are converted
one-to-one. Function results are converted one-to-one and, in case more than
1 value is returned, packed into an LLVM IR struct type. Function calls and
returns are updated accordingly. Block argument types are updated to use
LLVM IR types.
}];
let constructor = "mlir::polygeist::createConvertPolygeistToLLVMPass()";
let dependentDialects = [
"polygeist::PolygeistDialect",
"func::FuncDialect",
"LLVM::LLVMDialect",
"memref::MemRefDialect",
"gpu::GPUDialect",
"arith::ArithDialect",
"cf::ControlFlowDialect",
"scf::SCFDialect",
];
let options = [
Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool",
/*default=*/"false",
"Replace FuncOp's MemRef arguments with bare pointers to the MemRef "
"element types">,
Option<"indexBitwidth", "index-bitwidth", "unsigned",
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
"Bitwidth of the index type, 0 to use size of machine word">,
Option<"dataLayout", "data-layout", "std::string",
/*default=*/"\"\"",
"String description (LLVM format) of the data layout that is "
"expected on the produced module">,
Option<"useCStyleMemRef", "use-c-style-memref", "bool",
/*default=*/"true",
"Use C-style nested-array lowering of memref instead of "
"the default MLIR descriptor structure">
];
}

#endif
1 change: 1 addition & 0 deletions include/mlir/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(Polygeist)
2 changes: 2 additions & 0 deletions include/mlir/Dialect/Polygeist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(IR)
add_subdirectory(Transforms)
1 change: 1 addition & 0 deletions include/mlir/Dialect/Polygeist/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_mlir_dialect(PolygeistOps polygeist)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

#include "mlir/IR/Dialect.h"

#include "polygeist/PolygeistOpsDialect.h.inc"
#include "mlir/Dialect/Polygeist/IR/PolygeistOpsDialect.h.inc"

#endif // BFV_BFVDIALECT_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "llvm/Support/CommandLine.h"

#define GET_OP_CLASSES
#include "polygeist/PolygeistOps.h.inc"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h.inc"

#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#ifndef POLYGEIST_OPS
#define POLYGEIST_OPS

include "Dialect.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/ViewLikeInterface.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/IR/SymbolInterfaces.td"

include "mlir/Dialect/Polygeist/IR/PolygeistDialect.td"
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/Dialect/LLVMIR/LLVMInterfaces.td"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name polygeist)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name Polygeist)
add_public_tablegen_target(MLIRPolygeistPassIncGen)

add_mlir_doc(Passes PolygeistPasses ./ -gen-pass-doc)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistDialect.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "polygeist/Dialect.h"
#include <memory>

enum PolygeistAlternativesMode { PAM_Static, PAM_PGO_Profile, PAM_PGO_Opt };
Expand Down Expand Up @@ -128,7 +128,7 @@ class LLVMDialect;
}

#define GEN_PASS_REGISTRATION
#include "polygeist/Passes/Passes.h.inc"
#include "mlir/Dialect/Polygeist/Transforms/Passes.h.inc"

} // end namespace mlir

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Block.h"
#include "polygeist/Ops.h"
#include "llvm/ADT/SetVector.h"

std::pair<mlir::Block *, mlir::Block::iterator>
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions include/polygeist/CMakeLists.txt

This file was deleted.

4 changes: 3 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
add_subdirectory(polygeist)
add_subdirectory(Conversion)
add_subdirectory(ExecutionEngine)
add_subdirectory(Dialect)
1 change: 1 addition & 0 deletions lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(PolygeistToLLVM)
30 changes: 30 additions & 0 deletions lib/Conversion/PolygeistToLLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
add_mlir_conversion_library(MLIRPolygeistToLLVM
PolygeistToLLVM.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/PolygeistToLLVM

DEPENDS
MLIRPolygeistConversionPassIncGen

LINK_COMPONENTS
Core

LINK_LIBS PUBLIC
MLIRAsyncDialect
MLIRFuncTransforms
MLIRMathToLLVM
MLIROpenMPToLLVM
MLIRPass
MLIRPolygeistDialect
MLIRPolygeistTransforms
MLIRSCFToControlFlow
MLIRVectorToLLVM
)

target_compile_definitions(obj.MLIRPolygeistToLLVM
PRIVATE
POLYGEIST_PGO_DEFAULT_DATA_DIR="${POLYGEIST_PGO_DEFAULT_DATA_DIR}"
POLYGEIST_PGO_ALTERNATIVE_ENV_VAR="${POLYGEIST_PGO_ALTERNATIVE_ENV_VAR}"
POLYGEIST_PGO_DATA_DIR_ENV_VAR="${POLYGEIST_PGO_DATA_DIR_ENV_VAR}"
)
39 changes: 39 additions & 0 deletions lib/Conversion/PolygeistToLLVM/PassDetails.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===- PassDetails.h - polygeist pass class details ----------------*- C++
//-*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Stuff shared between the different polygeist passes.
//
//===----------------------------------------------------------------------===//

// clang-tidy seems to expect the absolute path in the header guard on some
// systems, so just disable it.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef CONVERSION_POLYGEIST_PASSDETAILS_H
#define CONVERSION_POLYGEIST_PASSDETAILS_H

#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h"
#include "mlir/Dialect/Polygeist/Transforms/Passes.h"
#include "mlir/Pass/Pass.h"

namespace mlir {
class FunctionOpInterface;
// Forward declaration from Dialect.h
template <typename ConcreteDialect>
void registerDialect(DialectRegistry &registry);
namespace polygeist {

class PolygeistDialect;

#define GEN_PASS_CLASSES
#include "mlir/Dialect/Polygeist/Transforms/Passes.h.inc"

} // namespace polygeist
} // namespace mlir

#endif // DIALECT_POLYGEIST_TRANSFORMS_PASSDETAILS_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// This file implements a pass to lower gpu kernels in NVVM/gpu dialects into
// a generic parallel for representation
//===----------------------------------------------------------------------===//

#include "PassDetails.h"

#include "mlir/../../lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp"
Expand Down Expand Up @@ -39,14 +40,14 @@
#include "mlir/Dialect/LLVMIR/ROCDLDialect.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/Polygeist/Transforms/Passes.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Target/LLVMIR/Import.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/RegionUtils.h"
#include "polygeist/Passes/Passes.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
Expand All @@ -57,7 +58,7 @@
#include <map>
#include <numeric>

#include "RuntimeWrapperUtils.h"
#include "mlir/Dialect/Polygeist/Utils/RuntimeWrapperUtils.h"

extern llvm::cl::opt<bool> EmitROCM;

Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(Polygeist)
4 changes: 4 additions & 0 deletions lib/Dialect/Polygeist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_subdirectory(IR)
add_subdirectory(Transforms)
#add_subdirectory(Analysis)
#add_subdirectory(Utils)
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_mlir_dialect_library(MLIRPolygeist
Dialect.cpp
Ops.cpp
add_mlir_dialect_library(MLIRPolygeistDialect
PolygeistDialect.cpp
PolygeistOps.cpp

ADDITIONAL_HEADER_DIRS
${PROJECT_SOURCE_DIR}/include/polygeist
${PROJECT_SOURCE_DIR}/include/mlir/Dialect/Polygeist

DEPENDS
MLIRPolygeistOpsIncGen
Expand All @@ -17,5 +17,3 @@ MLIRAffineDialect
MLIRSupport
MLIRSCFTransforms
)
add_subdirectory(Passes)
add_subdirectory(ExecutionEngine)
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include "polygeist/Dialect.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistDialect.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h"
#include "mlir/IR/DialectImplementation.h"
#include "polygeist/Ops.h"

using namespace mlir;
using namespace mlir::polygeist;
Expand All @@ -20,8 +20,8 @@ using namespace mlir::polygeist;
void PolygeistDialect::initialize() {
addOperations<
#define GET_OP_LIST
#include "polygeist/PolygeistOps.cpp.inc"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.cpp.inc"
>();
}

#include "polygeist/PolygeistOpsDialect.cpp.inc"
#include "mlir/Dialect/Polygeist/IR/PolygeistOpsDialect.cpp.inc"
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
//
//===----------------------------------------------------------------------===//

#include "polygeist/Ops.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/Dialect/Polygeist/IR/PolygeistDialect.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "polygeist/Dialect.h"

#define GET_OP_CLASSES
#include "polygeist/PolygeistOps.cpp.inc"
#include "mlir/Dialect/Polygeist/IR/PolygeistOps.cpp.inc"

#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "mlir/Dialect/Affine/Passes.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Polygeist/Transforms/Passes.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "polygeist/Passes/Passes.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/Debug.h"
#include <deque>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/Passes.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Polygeist/Transforms/Passes.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "polygeist/Passes/Passes.h"
#include "llvm/Support/Debug.h"

using namespace mlir;
Expand Down
Loading

0 comments on commit b349b3b

Please sign in to comment.