Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# actionlint.yaml

self-hosted-runner:
labels:
- zkir
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ concurrency:

jobs:
build-and-test:
runs-on: self-hosted
runs-on: [self-hosted, zkir]
steps:
- name: Checkout ZKIR
uses: actions/checkout@v4

- name: Run `bazel build`
run: |
bazel build --remote_cache=grpc://127.0.0.1:9092 --test_output=errors //...
bazel build --remote_cache=grpc://127.0.0.1:9092 --remote_download_outputs=all --test_output=errors //...

- name: Run `bazel test`
run: |
bazel test --config ci --remote_cache=grpc://127.0.0.1:9092 --test_output=errors //...

pre-commit-style:
runs-on: self-hosted
runs-on: [self-hosted, zkir]
steps:
- name: Checkout ZKIR
uses: actions/checkout@v4
Expand All @@ -47,7 +47,7 @@ jobs:

- name: Refresh compile commands
run: |
bazel run @hedron_compile_commands//:refresh_all
bazel run --remote_cache=grpc://127.0.0.1:9092 --remote_download_outputs=all @hedron_compile_commands//:refresh_all

- name: Run pre-commit github action
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # pin@v3
36 changes: 23 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ repos:
- id: check-added-large-files
args: ["--maxkb=500000"] # 500MB

# clang-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
args: ["--style=file"]

# cpplint + clang-tidy
# cpplint
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
Expand All @@ -27,11 +20,27 @@ repos:
[
"--filter=-whitespace/indent_namespace, -legal/copyright, -build/namespaces, -runtime/references",
]

# clang-tidy
# This hook now relies on a local shell script.
- repo: local
hooks:
- id: clang-tidy
args:
[
"--checks=readability-static-definition-in-anonymous-namespace,modernize-concat-nested-namespaces",
]
name: clang-tidy
entry: ./run_clang_tidy.sh
language: script
files: '\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$'
exclude: |
(?x)
(^|/)(bazel-.*|bazel-out/|build/|out/|third_party/|external/)
pass_filenames: true

# clang-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
args: ["--style=file"]

# Starlark
- repo: https://github.com/keith/pre-commit-buildifier
Expand Down Expand Up @@ -60,6 +69,7 @@ repos:
hooks:
- id: actionlint
additional_dependencies: [pyflakes>=3.0.1, shellcheck-py>=0.9.0.5]
args: ["--config-file=.github/actionlint.yaml"]

# mdformat
- repo: https://github.com/executablebooks/mdformat
Expand All @@ -78,4 +88,4 @@ repos:
- id: pyink
language_version: python3

exclude: patches/.*\.patch$
exclude: third_party/llvm-project/.*\.patch$
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ zkir_deps()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

LLVM_COMMIT = "9ae3bce17543f92ce0237597cc66503d58cce317"
LLVM_COMMIT = "5ed852f7f72855710eeff53179e6a6f2271a3c2a"

LLVM_SHA256 = "19a170bb0931bcf3e698f37fef24b2c52871525987731b5d56be6a4afc705b22"
LLVM_SHA256 = "95792e50d5f84847721545b645a6ca2c2b3b7610d02e3de07d65a6148e68508c"

http_archive(
name = "llvm-raw",
Expand Down
43 changes: 43 additions & 0 deletions run_clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -euo pipefail

# This script runs clang-tidy with OS-specific arguments.

# Get the path to the directory containing this script.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT_ROOT="$SCRIPT_DIR"

# Define the base clang-tidy command.
CLANG_TIDY_BIN=$(command -v clang-tidy)
if [ -z "$CLANG_TIDY_BIN" ]; then
echo "Error: clang-tidy not found in PATH." >&2
exit 1
fi

# Define the common arguments.
CLANG_TIDY_ARGS=(
"--checks=readability-static-definition-in-anonymous-namespace,modernize-concat-nested-namespaces"
"-fix"
)

# Add macOS-specific arguments.
if [ "$(uname)" == "Darwin" ]; then
echo "Running clang-tidy with macOS toolchain."
CLANG_TIDY_ARGS+=(
"--extra-arg=-isysroot"
"--extra-arg=$(xcrun --show-sdk-path)"
)
else
# This branch would be for Linux, Windows, etc.
echo "Running clang-tidy with default toolchain."
fi

# Pass the compile_commands.json directory.
# This assumes the file is in the project root.
if [ -f "$PROJECT_ROOT/compile_commands.json" ]; then
CLANG_TIDY_ARGS+=("-p=$PROJECT_ROOT")
fi

# Run clang-tidy on the files passed by pre-commit.
# $@ is the array of all arguments passed to this script (i.e., the filenames).
$CLANG_TIDY_BIN "${CLANG_TIDY_ARGS[@]}" "$@"
8 changes: 4 additions & 4 deletions tests/Dialect/EllipticCurve/bufferization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func.func @test_bufferization_materialize_in_destination(%tensor : tensor<2x!aff
return
}

// CHECK-LABEL: @test_bufferization_to_memref
// CHECK-LABEL: @test_bufferization_to_buffer
// CHECK-SAME: (%[[TENSOR:.*]]: [[TENSOR_TYPE:.*]]) -> [[T:.*]] {
func.func @test_bufferization_to_memref(%tensor : tensor<2x!affine>) -> memref<2x!affine> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_memref %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_memref %tensor : tensor<2x!affine> to memref<2x!affine>
func.func @test_bufferization_to_buffer(%tensor : tensor<2x!affine>) -> memref<2x!affine> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_buffer %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_buffer %tensor : tensor<2x!affine> to memref<2x!affine>
// CHECK: return %[[MEMREF]] : [[T]]
return %memref : memref<2x!affine>
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Dialect/EllipticCurve/elliptic_curve_msm_runner.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func.func @test_msm() {
%extract_point_reduced = field.from_mont %extract_point : tensor<2x!PF>
%extract = field.extract %extract_point_reduced : tensor<2x!PF> -> tensor<2xi256>
%trunc = arith.trunci %extract : tensor<2xi256> to tensor<2xi32>
%mem = bufferization.to_memref %trunc : tensor<2xi32> to memref<2xi32>
%mem = bufferization.to_buffer %trunc : tensor<2xi32> to memref<2xi32>
%U = memref.cast %mem : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U) : (memref<*xi32>) -> ()

Expand All @@ -73,7 +73,7 @@ func.func @test_msm() {
%extract_point1_reduced = field.from_mont %extract_point1 : tensor<2x!PF>
%extract1 = field.extract %extract_point1_reduced : tensor<2x!PF> -> tensor<2xi256>
%trunc1 = arith.trunci %extract1 : tensor<2xi256> to tensor<2xi32>
%mem1 = bufferization.to_memref %trunc1 : tensor<2xi32> to memref<2xi32>
%mem1 = bufferization.to_buffer %trunc1 : tensor<2xi32> to memref<2xi32>
%U1 = memref.cast %mem1 : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U1) : (memref<*xi32>) -> ()
return
Expand Down
18 changes: 9 additions & 9 deletions tests/Dialect/EllipticCurve/elliptic_curve_to_field_runner.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func.func @test_ops_in_order() {
%from_mont1 = field.from_mont %extract_point1 : tensor<3x!PF>
%extract1 = field.extract %from_mont1 : tensor<3x!PF> -> tensor<3xi256>
%trunc1 = arith.trunci %extract1 : tensor<3xi256> to tensor<3xi32>
%1 = bufferization.to_memref %trunc1 : tensor<3xi32> to memref<3xi32>
%1 = bufferization.to_buffer %trunc1 : tensor<3xi32> to memref<3xi32>
%U1 = memref.cast %1 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U1) : (memref<*xi32>) -> ()

Expand All @@ -59,7 +59,7 @@ func.func @test_ops_in_order() {
%from_mont2 = field.from_mont %extract_point2 : tensor<3x!PF>
%extract2 = field.extract %from_mont2 : tensor<3x!PF> -> tensor<3xi256>
%trunc2 = arith.trunci %extract2 : tensor<3xi256> to tensor<3xi32>
%2 = bufferization.to_memref %trunc2 : tensor<3xi32> to memref<3xi32>
%2 = bufferization.to_buffer %trunc2 : tensor<3xi32> to memref<3xi32>
%U2 = memref.cast %2 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U2) : (memref<*xi32>) -> ()

Expand All @@ -69,7 +69,7 @@ func.func @test_ops_in_order() {
%from_mont3 = field.from_mont %extract_point3 : tensor<3x!PF>
%extract3 = field.extract %from_mont3 : tensor<3x!PF> -> tensor<3xi256>
%trunc3 = arith.trunci %extract3 : tensor<3xi256> to tensor<3xi32>
%3 = bufferization.to_memref %trunc3 : tensor<3xi32> to memref<3xi32>
%3 = bufferization.to_buffer %trunc3 : tensor<3xi32> to memref<3xi32>
%U3 = memref.cast %3 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U3) : (memref<*xi32>) -> ()

Expand All @@ -79,7 +79,7 @@ func.func @test_ops_in_order() {
%from_mont4 = field.from_mont %extract_point4 : tensor<3x!PF>
%extract4 = field.extract %from_mont4 : tensor<3x!PF> -> tensor<3xi256>
%trunc4 = arith.trunci %extract4 : tensor<3xi256> to tensor<3xi32>
%4 = bufferization.to_memref %trunc4 : tensor<3xi32> to memref<3xi32>
%4 = bufferization.to_buffer %trunc4 : tensor<3xi32> to memref<3xi32>
%U4 = memref.cast %4 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U4) : (memref<*xi32>) -> ()

Expand All @@ -89,7 +89,7 @@ func.func @test_ops_in_order() {
%from_mont5 = field.from_mont %extract_point5 : tensor<4x!PF>
%extract5 = field.extract %from_mont5 : tensor<4x!PF> -> tensor<4xi256>
%trunc5 = arith.trunci %extract5 : tensor<4xi256> to tensor<4xi32>
%5 = bufferization.to_memref %trunc5 : tensor<4xi32> to memref<4xi32>
%5 = bufferization.to_buffer %trunc5 : tensor<4xi32> to memref<4xi32>
%U5 = memref.cast %5 : memref<4xi32> to memref<*xi32>
func.call @printMemrefI32(%U5) : (memref<*xi32>) -> ()

Expand All @@ -99,7 +99,7 @@ func.func @test_ops_in_order() {
%from_mont6 = field.from_mont %extract_point6 : tensor<2x!PF>
%extract6 = field.extract %from_mont6 : tensor<2x!PF> -> tensor<2xi256>
%trunc6 = arith.trunci %extract6 : tensor<2xi256> to tensor<2xi32>
%6 = bufferization.to_memref %trunc6 : tensor<2xi32> to memref<2xi32>
%6 = bufferization.to_buffer %trunc6 : tensor<2xi32> to memref<2xi32>
%U6 = memref.cast %6 : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U6) : (memref<*xi32>) -> ()

Expand All @@ -111,7 +111,7 @@ func.func @test_ops_in_order() {
%from_mont7 = field.from_mont %extract_point7 : tensor<3x!PF>
%extract7 = field.extract %from_mont7 : tensor<3x!PF> -> tensor<3xi256>
%trunc7 = arith.trunci %extract7 : tensor<3xi256> to tensor<3xi32>
%7 = bufferization.to_memref %trunc7 : tensor<3xi32> to memref<3xi32>
%7 = bufferization.to_buffer %trunc7 : tensor<3xi32> to memref<3xi32>
%U7 = memref.cast %7 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U7) : (memref<*xi32>) -> ()

Expand All @@ -121,7 +121,7 @@ func.func @test_ops_in_order() {
%from_mont8 = field.from_mont %extract_point8 : tensor<2x!PF>
%extract8 = field.extract %from_mont8 : tensor<2x!PF> -> tensor<2xi256>
%trunc8 = arith.trunci %extract8 : tensor<2xi256> to tensor<2xi32>
%8 = bufferization.to_memref %trunc8 : tensor<2xi32> to memref<2xi32>
%8 = bufferization.to_buffer %trunc8 : tensor<2xi32> to memref<2xi32>
%U8 = memref.cast %8 : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U8) : (memref<*xi32>) -> ()

Expand All @@ -133,7 +133,7 @@ func.func @test_ops_in_order() {
%from_mont9 = field.from_mont %extract_point9 : tensor<4x!PF>
%extract9 = field.extract %from_mont9 : tensor<4x!PF> -> tensor<4xi256>
%trunc9 = arith.trunci %extract9 : tensor<4xi256> to tensor<4xi32>
%9 = bufferization.to_memref %trunc9 : tensor<4xi32> to memref<4xi32>
%9 = bufferization.to_buffer %trunc9 : tensor<4xi32> to memref<4xi32>
%U9 = memref.cast %9 : memref<4xi32> to memref<*xi32>
func.call @printMemrefI32(%U9) : (memref<*xi32>) -> ()

Expand Down
8 changes: 4 additions & 4 deletions tests/Dialect/Field/bufferization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func.func @test_bufferization_materialize_in_destination(%tensor : tensor<2x!PF>
return
}

// CHECK-LABEL: @test_bufferization_to_memref
// CHECK-LABEL: @test_bufferization_to_buffer
// CHECK-SAME: (%[[TENSOR:.*]]: [[TENSOR_TYPE:.*]]) -> [[T:.*]] {
func.func @test_bufferization_to_memref(%tensor : tensor<2x!PF>) -> memref<2x!PF> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_memref %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_memref %tensor : tensor<2x!PF> to memref<2x!PF>
func.func @test_bufferization_to_buffer(%tensor : tensor<2x!PF>) -> memref<2x!PF> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_buffer %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_buffer %tensor : tensor<2x!PF> to memref<2x!PF>
// CHECK: return %[[MEMREF]] : [[T]]
return %memref : memref<2x!PF>
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Dialect/Field/field_runner.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func.func @test_power() {
%res1 = field.pow %base_pf, %exp : !PF, i64
%1 = field.extract %res1 : !PF -> i32
%2 = tensor.from_elements %1 : tensor<1xi32>
%3 = bufferization.to_memref %2 : tensor<1xi32> to memref<1xi32>
%3 = bufferization.to_buffer %2 : tensor<1xi32> to memref<1xi32>
%U1 = memref.cast %3 : memref<1xi32> to memref<*xi32>
func.call @printMemrefI32(%U1) : (memref<*xi32>) -> ()

Expand All @@ -32,15 +32,15 @@ func.func @test_power() {
%res1_standard = field.from_mont %res1_mont : !PF
%4 = field.extract %res1_standard : !PF -> i32
%5 = tensor.from_elements %4 : tensor<1xi32>
%6 = bufferization.to_memref %5 : tensor<1xi32> to memref<1xi32>
%6 = bufferization.to_buffer %5 : tensor<1xi32> to memref<1xi32>
%U2 = memref.cast %6 : memref<1xi32> to memref<*xi32>
func.call @printMemrefI32(%U2) : (memref<*xi32>) -> ()

%base_f2 = field.encapsulate %base, %base : i32, i32 -> !QF
%res2 = field.pow %base_f2, %exp : !QF, i64
%9, %10 = field.extract %res2 : !QF -> i32, i32
%11 = tensor.from_elements %9, %10 : tensor<2xi32>
%12 = bufferization.to_memref %11 : tensor<2xi32> to memref<2xi32>
%12 = bufferization.to_buffer %11 : tensor<2xi32> to memref<2xi32>
%U3 = memref.cast %12 : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U3) : (memref<*xi32>) -> ()

Expand All @@ -49,7 +49,7 @@ func.func @test_power() {
%res2_standard = field.from_mont %res2_mont : !QF
%13, %14 = field.extract %res2_standard : !QF -> i32, i32
%15 = tensor.from_elements %13, %14 : tensor<2xi32>
%16 = bufferization.to_memref %15 : tensor<2xi32> to memref<2xi32>
%16 = bufferization.to_buffer %15 : tensor<2xi32> to memref<2xi32>
%U4 = memref.cast %16 : memref<2xi32> to memref<*xi32>
func.call @printMemrefI32(%U4) : (memref<*xi32>) -> ()

Expand Down
8 changes: 4 additions & 4 deletions tests/Dialect/ModArith/bufferization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func.func @test_bufferization_materialize_in_destination(%tensor : tensor<2x!Zp>
return
}

// CHECK-LABEL: @test_bufferization_to_memref
// CHECK-LABEL: @test_bufferization_to_buffer
// CHECK-SAME: (%[[TENSOR:.*]]: [[TENSOR_TYPE:.*]]) -> [[T:.*]] {
func.func @test_bufferization_to_memref(%tensor : tensor<2x!Zp>) -> memref<2x!Zp> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_memref %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_memref %tensor : tensor<2x!Zp> to memref<2x!Zp>
func.func @test_bufferization_to_buffer(%tensor : tensor<2x!Zp>) -> memref<2x!Zp> {
// CHECK: %[[MEMREF:.*]] = bufferization.to_buffer %[[TENSOR]] : [[TENSOR_TYPE]] to [[T]]
%memref = bufferization.to_buffer %tensor : tensor<2x!Zp> to memref<2x!Zp>
// CHECK: return %[[MEMREF]] : [[T]]
return %memref : memref<2x!Zp>
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Dialect/ModArith/mod_arith_runner.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func.func @test_lower_inverse() {
%2 = mod_arith.extract %from_mont : !Fq -> i256
%3 = arith.trunci %2 : i256 to i32
%4 = tensor.from_elements %3 : tensor<1xi32>
%5 = bufferization.to_memref %4 : tensor<1xi32> to memref<1xi32>
%5 = bufferization.to_buffer %4 : tensor<1xi32> to memref<1xi32>
%U = memref.cast %5 : memref<1xi32> to memref<*xi32>
func.call @printMemrefI32(%U) : (memref<*xi32>) -> ()

Expand All @@ -50,7 +50,7 @@ func.func @test_lower_inverse() {
%6 = mod_arith.extract %mul2 : !Fq -> i256
%7 = arith.trunci %6 : i256 to i32
%8 = tensor.from_elements %7 : tensor<1xi32>
%9 = bufferization.to_memref %8 : tensor<1xi32> to memref<1xi32>
%9 = bufferization.to_buffer %8 : tensor<1xi32> to memref<1xi32>
%10 = memref.cast %9 : memref<1xi32> to memref<*xi32>
func.call @printMemrefI32(%10) : (memref<*xi32>) -> ()

Expand All @@ -61,7 +61,7 @@ func.func @test_lower_inverse() {
%from_mont_r = mod_arith.from_mont %mul_r : !Fr
%r_ext = mod_arith.extract %from_mont_r : !Fr -> i32
%r_tensor = tensor.from_elements %r_ext : tensor<1xi32>
%r_mem = bufferization.to_memref %r_tensor : tensor<1xi32> to memref<1xi32>
%r_mem = bufferization.to_buffer %r_tensor : tensor<1xi32> to memref<1xi32>
%r_mem_cast = memref.cast %r_mem : memref<1xi32> to memref<*xi32>
func.call @printMemrefI32(%r_mem_cast) : (memref<*xi32>) -> ()
return
Expand All @@ -84,7 +84,7 @@ func.func @test_lower_inverse_tensor() {
%mul = mod_arith.mul %inv, %tensor2 : tensor<3x!Fq>
%ext = mod_arith.extract %mul : tensor<3x!Fq> -> tensor<3xi256>
%trunc = arith.trunci %ext : tensor<3xi256> to tensor<3xi32>
%1 = bufferization.to_memref %trunc : tensor<3xi32> to memref<3xi32>
%1 = bufferization.to_buffer %trunc : tensor<3xi32> to memref<3xi32>
%U1 = memref.cast %1 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U1) : (memref<*xi32>) -> ()

Expand All @@ -94,7 +94,7 @@ func.func @test_lower_inverse_tensor() {
%from_mont = mod_arith.from_mont %mul_mont : tensor<3x!Fq>
%ext2 = mod_arith.extract %from_mont : tensor<3x!Fq> -> tensor<3xi256>
%trunc2 = arith.trunci %ext2 : tensor<3xi256> to tensor<3xi32>
%2 = bufferization.to_memref %trunc2 : tensor<3xi32> to memref<3xi32>
%2 = bufferization.to_buffer %trunc2 : tensor<3xi32> to memref<3xi32>
%U2 = memref.cast %2 : memref<3xi32> to memref<*xi32>
func.call @printMemrefI32(%U2) : (memref<*xi32>) -> ()
return
Expand Down
Loading
Loading