-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from spcl/backward-conversion
Backward Conversion
- Loading branch information
Showing
204 changed files
with
4,619 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
add_subdirectory(SDFG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
add_subdirectory(GenericToSDFG) | ||
add_subdirectory(LinalgToSDFG) | ||
|
||
add_subdirectory(SDFGToGeneric) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
set(LLVM_TARGET_DEFINITIONS Passes.td) | ||
mlir_tablegen(Passes.h.inc -gen-pass-decls -name SDFGToGeneric) | ||
add_public_tablegen_target(MLIRSDFGToGenericPassIncGen) | ||
|
||
target_sources(SOURCE_FILES_H PRIVATE PassDetail.h Passes.h SymbolicParser.h | ||
OpCreators.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
/// Header for convenience functions, creating various operations. | ||
|
||
#ifndef SDFG_Conversion_SDFGToGeneric_Op_Creators_H | ||
#define SDFG_Conversion_SDFGToGeneric_Op_Creators_H | ||
|
||
#include "mlir/Dialect/Arith/IR/Arith.h" | ||
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" | ||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
#include "mlir/Dialect/MemRef/IR/MemRef.h" | ||
#include "mlir/Dialect/SCF/IR/SCF.h" | ||
#include "mlir/Transforms/DialectConversion.h" | ||
|
||
using namespace mlir; | ||
|
||
namespace mlir::sdfg::conversion { | ||
|
||
/// Builds, creates and inserts a func::FuncOp. | ||
func::FuncOp createFunc(PatternRewriter &rewriter, Location loc, StringRef name, | ||
TypeRange inputTypes, TypeRange resultTypes, | ||
StringRef visibility); | ||
|
||
/// Builds, creates and inserts a func::CallOp. | ||
func::CallOp createCall(PatternRewriter &rewriter, Location loc, | ||
TypeRange resultTypes, StringRef callee, | ||
ValueRange operands); | ||
|
||
/// Builds, creates and inserts a func::ReturnOp. | ||
func::ReturnOp createReturn(PatternRewriter &rewriter, Location loc, | ||
ValueRange operands); | ||
|
||
/// Builds, creates and inserts a cf::BranchOp. | ||
cf::BranchOp createBranch(PatternRewriter &rewriter, Location loc, | ||
ValueRange operands, Block *dest); | ||
|
||
/// Builds, creates and inserts a cf::CondBranchOp. | ||
cf::CondBranchOp createCondBranch(PatternRewriter &rewriter, Location loc, | ||
Value condition, Block *trueDest, | ||
Block *falseDest); | ||
|
||
/// Builds, creates and inserts a memref::AllocOp. | ||
memref::AllocOp createAlloc(PatternRewriter &rewriter, Location loc, | ||
MemRefType memrefType, ValueRange dynamicSizes); | ||
|
||
/// Builds, creates and inserts a memref::LoadOp. | ||
memref::LoadOp createLoad(PatternRewriter &rewriter, Location loc, Value memref, | ||
ValueRange indices); | ||
|
||
/// Builds, creates and inserts a memref::StoreOp. | ||
memref::StoreOp createStore(PatternRewriter &rewriter, Location loc, | ||
Value value, Value memref, ValueRange indices); | ||
|
||
/// Builds, creates and inserts a memref::CopyOp. | ||
memref::CopyOp createCopy(PatternRewriter &rewriter, Location loc, Value source, | ||
Value target); | ||
|
||
/// Allocates a symbol as a memref<i64> if it's not already allocated and | ||
/// populates the symbol map. | ||
void allocSymbol(PatternRewriter &rewriter, Location loc, StringRef symName, | ||
llvm::StringMap<Value> &symbolMap); | ||
|
||
/// Builds, creates and inserts an arith::ConstantIntOp. | ||
arith::ConstantIntOp createConstantInt(PatternRewriter &rewriter, Location loc, | ||
int val, int width); | ||
|
||
/// Builds, creates and inserts an arith::AddIOp. | ||
arith::AddIOp createAddI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::SubIOp. | ||
arith::SubIOp createSubI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::MulIOp. | ||
arith::MulIOp createMulI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::DivSIOp. | ||
arith::DivSIOp createDivSI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::FloorDivSIOp. | ||
arith::FloorDivSIOp createFloorDivSI(PatternRewriter &rewriter, Location loc, | ||
Value a, Value b); | ||
|
||
/// Builds, creates and inserts an arith::RemSIOp. | ||
arith::RemSIOp createRemSI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::OrIOp. | ||
arith::OrIOp createOrI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::AndIOp. | ||
arith::AndIOp createAndI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::XOrIOp. | ||
arith::XOrIOp createXOrI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::ShLIOp. | ||
arith::ShLIOp createShLI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::ShRSIOp. | ||
arith::ShRSIOp createShRSI(PatternRewriter &rewriter, Location loc, Value a, | ||
Value b); | ||
|
||
/// Builds, creates and inserts an arith::CmpIOp. | ||
arith::CmpIOp createCmpI(PatternRewriter &rewriter, Location loc, | ||
arith::CmpIPredicate predicate, Value lhs, Value rhs); | ||
|
||
/// Builds, creates and inserts an arith::ExtSIOp. | ||
arith::ExtSIOp createExtSI(PatternRewriter &rewriter, Location loc, Type out, | ||
Value in); | ||
|
||
/// Builds, creates and inserts an arith::TruncIOp. | ||
arith::TruncIOp createTruncI(PatternRewriter &rewriter, Location loc, Type out, | ||
Value in); | ||
|
||
/// Builds, creates and inserts an arith::IndexCastOp. | ||
arith::IndexCastOp createIndexCast(PatternRewriter &rewriter, Location loc, | ||
Type out, Value in); | ||
|
||
/// Builds, creates and inserts a scf::ParallelOp. | ||
scf::ParallelOp createParallel(PatternRewriter &rewriter, Location loc, | ||
ValueRange lowerBounds, ValueRange upperBounds, | ||
ValueRange steps); | ||
|
||
/// Builds, creates and inserts a scf::YieldOp. | ||
scf::YieldOp createYield(PatternRewriter &rewriter, Location loc); | ||
|
||
} // namespace mlir::sdfg::conversion | ||
|
||
#endif // SDFG_Conversion_SDFGToGeneric_Op_Creators_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
/// Header for SDFG to Generic conversion pass details. | ||
|
||
#ifndef SDFG_Conversion_SDFGToGeneric_PassDetail_H | ||
#define SDFG_Conversion_SDFGToGeneric_PassDetail_H | ||
|
||
#include "SDFG/Dialect/Dialect.h" | ||
#include "mlir/Pass/Pass.h" | ||
|
||
namespace mlir { | ||
namespace sdfg { | ||
namespace conversion { | ||
|
||
/// Generate the code for base classes. | ||
#define GEN_PASS_CLASSES | ||
#include "SDFG/Conversion/SDFGToGeneric/Passes.h.inc" | ||
|
||
} // namespace conversion | ||
} // namespace sdfg | ||
} // end namespace mlir | ||
|
||
#endif // SDFG_Conversion_SDFGToGeneric_PassDetail_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
/// Header for SDFG to Generic conversion passes. | ||
|
||
#ifndef SDFG_Conversion_SDFGToGeneric_H | ||
#define SDFG_Conversion_SDFGToGeneric_H | ||
|
||
#include "mlir/Pass/Pass.h" | ||
|
||
namespace mlir::sdfg::conversion { | ||
|
||
/// Creates a sdfg to generic converting pass | ||
std::unique_ptr<Pass> createSDFGToGenericPass(); | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Registration | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// Generate the code for registering passes. | ||
#define GEN_PASS_REGISTRATION | ||
#include "SDFG/Conversion/SDFGToGeneric/Passes.h.inc" | ||
|
||
} // namespace mlir::sdfg::conversion | ||
|
||
#endif // SDFG_Conversion_SDFGToGeneric_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2021-2023, Scalable Parallel Computing Lab, ETH Zurich | ||
|
||
/// Table-driven file for SDFG to Generic conversion passes. | ||
|
||
#ifndef SDFG_Conversion_SDFGToGeneric | ||
#define SDFG_Conversion_SDFGToGeneric | ||
|
||
include "mlir/Pass/PassBase.td" | ||
include "SDFG/Dialect/Dialect.td" | ||
|
||
/// Define SDFG to generic pass. | ||
def SDFGToGenericPass : Pass<"lower-sdfg", "ModuleOp"> { | ||
let summary = "Convert SDFG dialect to Func, CF, Memref and SCF dialects"; | ||
let constructor = "mlir::sdfg::conversion::createSDFGToGenericPass()"; | ||
let dependentDialects = [ | ||
"mlir::func::FuncDialect", | ||
"mlir::cf::ControlFlowDialect", | ||
"mlir::memref::MemRefDialect", | ||
"mlir::scf::SCFDialect" | ||
]; | ||
} | ||
|
||
#endif // SDFG_Conversion_SDFGToGeneric |
Oops, something went wrong.