Skip to content

Commit

Permalink
[gccjit] purge old passes
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Oct 30, 2024
1 parent 0d0c3d4 commit f2bbe63
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 195 deletions.
28 changes: 0 additions & 28 deletions include/mlir-gccjit/IR/GCCJITAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -236,34 +236,6 @@ def FnAttr : GCCJIT_Attr<"Function", "fn_attr"> {
let genVerifyDecl = 0;
}

//===----------------------------------------------------------------------===//
// RegName Attr
//===----------------------------------------------------------------------===//
def RegNameAttr : GCCJIT_Attr<"RegName", "reg_name"> {
let summary = "Register name";
let parameters = (ins "StringAttr":$name);
let description = [{
Represents the register name.
}];
let assemblyFormat = [{
`<` $name `>`
}];
}

//===----------------------------------------------------------------------===//
// Visibility Attr
//===----------------------------------------------------------------------===//
def VisibilityAttr : GCCJIT_Attr<"Visibility", "visibility"> {
let summary = "Visibility";
let parameters = (ins "StringAttr":$visibility);
let description = [{
Represents the visibility.
}];
let assemblyFormat = [{
`<` $visibility `>`
}];
}

//===----------------------------------------------------------------------===//
// ByteArrayInitializer Attr
//===----------------------------------------------------------------------===//
Expand Down
11 changes: 5 additions & 6 deletions include/mlir-gccjit/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@

namespace mlir::gccjit {

std::unique_ptr<Pass> createGCCJITMaterializeRValuePass();

#define GEN_PASS_CLASSES
#define GEN_PASS_REGISTRATION
#define GEN_PASS_DECL
#include "mlir-gccjit/Passes.h.inc"
// TODO: Add pass declarations here.
// #define GEN_PASS_CLASSES
// #define GEN_PASS_REGISTRATION
// #define GEN_PASS_DECL
// #include "mlir-gccjit/Passes.h.inc"

} // namespace mlir::gccjit

Expand Down
41 changes: 1 addition & 40 deletions include/mlir-gccjit/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,6 @@

include "mlir/Pass/PassBase.td"

def GCCJITMaterializeRValue : Pass<"gccjit-materialize-rvalue", "::mlir::gccjit::FuncOp"> {
let summary = "Automatically materialize rvalue expressions in GCCJIT dialect";
let description = [{
RValue expressions are lazy in GCCJIT. If not associated with a local variable,
they will never be emitted inplace. Using a nonmaterialized rvalue expression twice will
result in two separate computations. Using a stateful rvalue across an effectful operation
may result in different results. GCCJIT dialect mimic the low-level behavior of GCCJIT on default,
translating rvalue/lvalue expression plainly. However, if one wants to use this dialect similar to
the traditional SSA semantics, this pass will insert nessary materialization for rvalue expressions.

Definition (Constant RValue): An RValue expression is constant if and only if it is created by
a constant operation.

The automatic materialization criteria are as follows:
- If the RValue expression is a mere constant, then it will not be materialized.
- Otherwise:
- if the RValue has a user that is not local to the block, then the expression is materialized.
- Otherwise, inside a block:
- If the RValue has multiple uses, it shall be materialized.
- If the RValue expression is immediately consumed by terminators, then there is no need to materialize.
- Otherwise:
- If the RValue expression is a call to non-pure/const annotated function, then the expression is immediately
materialized.
- If the RValue expression is a load/dereferece from a volatile lvalue or a dereference of a volatile pointer, then the expression
is immediately materialized.
- If the RValue expression's def-use chain overlap with any other effectful operation such as function call, asm block, or assignment
to variable that is not created by the materialization process, then the expression is materialized.

By materialization, we mean that a local variable will be created and singly assigned by the RValue expression. All
future uses of the RValue expression will be replaced by the local variable.

To obtain a one-to-one mapping between SSA variable and GCCJIT variable, use this pass with option `full=true`. When such option is enabled,
each instruction with result is materialized and each instruction without result is evaluated step-by-step.
}];
let constructor = "::mlir::gccjit::createGCCJITMaterializeRValuePass()";
let dependentDialects = ["::mlir::gccjit::GCCJITDialect"];
let options = [
Option<"full", "full", "bool", /*default=*/"false", "Full Materialization">
];
}
// TODO: Add passes here.

#endif // MLIR_GCCJIT_PASSES
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ add_mlir_dialect_library(MLIRGCCJIT

add_subdirectory(Interfaces)
add_subdirectory(Translation)
add_subdirectory(Passes)
add_subdirectory(Conversion)
10 changes: 0 additions & 10 deletions src/Passes/CMakeLists.txt

This file was deleted.

107 changes: 0 additions & 107 deletions src/Passes/MaterializeRValue.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions tools/gccjit-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ add_mlir_tool(gccjit-opt
DEPENDS
MLIROptLib
MLIRGCCJIT
MLIRGCCJITPasses
${dialect_libs}
${conversion_libs}
${extension_libs}
Expand All @@ -16,7 +15,6 @@ target_link_libraries(gccjit-opt
PRIVATE
MLIROptLib
MLIRGCCJIT
MLIRGCCJITPasses
${dialect_libs}
${conversion_libs}
${extension_libs}
Expand Down
2 changes: 1 addition & 1 deletion tools/gccjit-opt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char **argv) {
registry.insert<mlir::gccjit::GCCJITDialect>();
mlir::registerAllExtensions(registry);
mlir::registerAllPasses();
mlir::gccjit::registerGCCJITPasses();
// mlir::gccjit::registerGCCJITPasses();
return failed(mlir::MlirOptMain(
argc, argv, "GCCJIT analysis and optimization driver\n", registry));
}

0 comments on commit f2bbe63

Please sign in to comment.