From b4a67d8b5a3e4b32e863869b992a70a890af1f8f Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 4 Oct 2023 14:17:37 +0200 Subject: [PATCH 1/2] LLVM Submodule update Changes needed: * FunctionInterfaces.h has moved to the mlir/Interfaces/ directory. * FunctionOpInterface is now a subclass to CallableOpInterface, so getCallableRegion() has to be implemented for RustFuncOp and RustExtFuncOp. * The binop folder now supports poison, so we explicitly have to disable the poison support for our integer operations. * FlatSymbolRefAttr are now printed as template <...> arguments, so the test for rust.spawn has to be updated. --- arc-mlir/llvm-project | 2 +- arc-mlir/src/include/Arc/Arc.h | 2 +- arc-mlir/src/include/Rust/Rust.h | 2 +- arc-mlir/src/include/Rust/Rust.td | 6 +++++- arc-mlir/src/lib/Arc/Dialect.cpp | 20 ++++++++++---------- arc-mlir/src/tests/arc-to-rust/spawn.mlir | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arc-mlir/llvm-project b/arc-mlir/llvm-project index a23d65ac8..8823e961f 160000 --- a/arc-mlir/llvm-project +++ b/arc-mlir/llvm-project @@ -1 +1 @@ -Subproject commit a23d65ac89ce1263b58690fa051e81d7cd0b139d +Subproject commit 8823e961f6a41854668d2dc1a1fc787cfa85ca43 diff --git a/arc-mlir/src/include/Arc/Arc.h b/arc-mlir/src/include/Arc/Arc.h index d64a3760f..2145dc332 100644 --- a/arc-mlir/src/include/Arc/Arc.h +++ b/arc-mlir/src/include/Arc/Arc.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arc-mlir/src/include/Rust/Rust.h b/arc-mlir/src/include/Rust/Rust.h index 236deacc8..bd15c950f 100644 --- a/arc-mlir/src/include/Rust/Rust.h +++ b/arc-mlir/src/include/Rust/Rust.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arc-mlir/src/include/Rust/Rust.td b/arc-mlir/src/include/Rust/Rust.td index 4fcf0f703..2f33e617c 100644 --- a/arc-mlir/src/include/Rust/Rust.td +++ b/arc-mlir/src/include/Rust/Rust.td @@ -25,7 +25,7 @@ #ifndef OP_BASE include "../../mlir/include/mlir/IR/OpBase.td" -include "../../mlir/include/mlir/IR/FunctionInterfaces.td" +include "../../mlir/include/mlir/Interfaces/FunctionInterfaces.td" include "../../mlir/include/mlir/Interfaces/CallInterfaces.td" include "../../mlir/include/mlir/Interfaces/InferTypeOpInterface.td" include "../../mlir/include/mlir/Interfaces/SideEffectInterfaces.td" @@ -221,6 +221,8 @@ def Rust_RustFuncOp : Rust_Op<"func", return getFunctionType().cast().getResults(); } + Region *getCallableRegion() { return &getBody(); } + /// Hook for FunctionOpInterface verifier. LogicalResult verifyType(); @@ -257,6 +259,8 @@ def Rust_RustExtFuncOp : Rust_Op<"extfunc", return getFunctionType().cast().getResults(); } + Region *getCallableRegion() { return &getEmptyBody(); } + /// Hook for FunctionOpInterface verifier. LogicalResult verifyType(); diff --git a/arc-mlir/src/lib/Arc/Dialect.cpp b/arc-mlir/src/lib/Arc/Dialect.cpp index ce0dd05c9..8794ac83b 100644 --- a/arc-mlir/src/lib/Arc/Dialect.cpp +++ b/arc-mlir/src/lib/Arc/Dialect.cpp @@ -119,8 +119,8 @@ OpFoldResult arc::AndOp::fold(FoldAdaptor operands) { if (getLhs() == getRhs()) return getRhs(); - return constFoldBinaryOp(operands.getOperands(), - [](APInt a, APInt b) { return a & b; }); + return constFoldBinaryOp( + operands.getOperands(), [](APInt a, APInt b) { return a & b; }); } //===----------------------------------------------------------------------===// @@ -234,7 +234,7 @@ OpFoldResult DivIOp::fold(FoldAdaptor operands) { bool isUnsigned = getType().isUnsignedInteger(); // Don't fold if it would overflow or if it requires a division by zero. bool overflowOrDiv0 = false; - auto result = constFoldBinaryOp( + auto result = constFoldBinaryOp( operands.getOperands(), [&](APInt a, APInt b) { if (overflowOrDiv0 || !b) { overflowOrDiv0 = true; @@ -439,7 +439,7 @@ OpFoldResult AddIOp::fold(FoldAdaptor operands) { bool isUnsigned = getType().isUnsignedInteger(); bool overflowDetected = false; - auto result = constFoldBinaryOp( + auto result = constFoldBinaryOp( operands.getOperands(), [&](APInt a, APInt b) { if (overflowDetected) return a; @@ -466,7 +466,7 @@ OpFoldResult MulIOp::fold(FoldAdaptor operands) { // Don't fold if it would overflow bool overflow = false; - auto result = constFoldBinaryOp( + auto result = constFoldBinaryOp( operands.getOperands(), [&](APInt a, APInt b) { if (overflow || !b) { overflow = true; @@ -491,8 +491,8 @@ OpFoldResult arc::OrOp::fold(FoldAdaptor operands) { if (getLhs() == getRhs()) return getRhs(); - return constFoldBinaryOp(operands.getOperands(), - [](APInt a, APInt b) { return a | b; }); + return constFoldBinaryOp( + operands.getOperands(), [](APInt a, APInt b) { return a | b; }); } //===----------------------------------------------------------------------===// @@ -665,7 +665,7 @@ OpFoldResult SubIOp::fold(FoldAdaptor operands) { bool isUnsigned = getType().isUnsignedInteger(); bool overflowDetected = false; - auto result = constFoldBinaryOp( + auto result = constFoldBinaryOp( operands.getOperands(), [&](APInt a, APInt b) { if (overflowDetected) return a; @@ -689,8 +689,8 @@ OpFoldResult arc::XOrOp::fold(FoldAdaptor operands) { if (getLhs() == getRhs()) return Builder(getContext()).getZeroAttr(getType()); - return constFoldBinaryOp(operands.getOperands(), - [](APInt a, APInt b) { return a ^ b; }); + return constFoldBinaryOp( + operands.getOperands(), [](APInt a, APInt b) { return a ^ b; }); } //===----------------------------------------------------------------------===// diff --git a/arc-mlir/src/tests/arc-to-rust/spawn.mlir b/arc-mlir/src/tests/arc-to-rust/spawn.mlir index ca40a398d..7e13e4d36 100644 --- a/arc-mlir/src/tests/arc-to-rust/spawn.mlir +++ b/arc-mlir/src/tests/arc-to-rust/spawn.mlir @@ -26,7 +26,7 @@ module @arctorustspawn { %out : !arc.stream.sink) { arc.spawn @id(%in, %out) : (!arc.stream.source, !arc.stream.sink) -> () -// CHECK: "rust.spawn"(%arg0, %arg1) {callee = @id} : (!rust<>, !rust<>) -> () +// CHECK: "rust.spawn"(%arg0, %arg1) <{callee = @id}> : (!rust<>, !rust<>) -> () return } } From 75d169eaf58fa2225af553c4a01e339b5778c103 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Thu, 5 Oct 2023 09:50:25 +0200 Subject: [PATCH 2/2] arc-runtime: Support rustc >= 1.72 In rustc 1.72 identifier attributes inside macros are now methods and not plain values. --- arc-runtime/macros/src/proc_macros.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arc-runtime/macros/src/proc_macros.rs b/arc-runtime/macros/src/proc_macros.rs index 32e939c1a..8516fcba3 100644 --- a/arc-runtime/macros/src/proc_macros.rs +++ b/arc-runtime/macros/src/proc_macros.rs @@ -194,8 +194,8 @@ pub fn wait(input: TokenStream) -> TokenStream { fn generate_wrapper(id: &syn::Ident) -> (pm2::TokenStream, impl Fn(syn::Expr) -> pm2::TokenStream) { let span = id.span().unwrap().start(); - let line = span.line; - let column = span.column; + let line = span.line(); + let column = span.column(); let abstract_id: syn::Ident = new_id(format!("Wrapper_{}_{}", line, column)); let concrete_id: syn::Ident = new_id(format!("ConcreteWrapper_{}_{}", line, column)); let sharable_wrapper_mod_id = new_id(format!("sharable_{}", abstract_id));