Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
62c2e97
chore: import changes to framework
luisacicolini Aug 22, 2025
c9c6ad5
chore: minimal changes
luisacicolini Aug 22, 2025
3f64de6
chore: minimal changes
luisacicolini Aug 22, 2025
6150a40
chore: minimize diff
luisacicolini Aug 22, 2025
1c7e0fc
chore: all printing in the same section
luisacicolini Aug 22, 2025
2823e27
chore: minimize diff
luisacicolini Aug 22, 2025
f7f3597
chore: printing infra in base file
luisacicolini Aug 22, 2025
53f98b9
chore: update opt
luisacicolini Aug 22, 2025
b096d79
chore: remove unsafe
luisacicolini Aug 22, 2025
fdaace8
chore: address comments
luisacicolini Aug 22, 2025
4c99d40
chore: address comments
luisacicolini Aug 22, 2025
7edf12d
add evaluation
luisacicolini Aug 23, 2025
52dd04c
chore: add gitignore, update generation of scripts
luisacicolini Aug 23, 2025
221526b
chore: changes to Pipeline
luisacicolini Aug 23, 2025
beb47ef
chore: add RISCV64 changes from prototypeEval branch
luisacicolini Aug 23, 2025
31de012
chore: changes to Pipeline only
luisacicolini Aug 23, 2025
50d6942
changes to LLVMRIscV
luisacicolini Aug 23, 2025
dd29e2b
feat: add evaluation
luisacicolini Aug 23, 2025
161e939
chore: remove old evaluation
luisacicolini Aug 23, 2025
a00f63f
chore: more tests from prototypeEval
luisacicolini Aug 23, 2025
be12ac8
chore: gitignore
luisacicolini Aug 23, 2025
a323087
chore: remove riscv updates
luisacicolini Aug 23, 2025
dcade9d
chore: riscv changes needed for the evaluation
luisacicolini Aug 23, 2025
ae8ad0e
chore: necessary updates to riscv64?
luisacicolini Aug 23, 2025
1915e8f
IT BUILDS
luisacicolini Aug 23, 2025
036a2fd
chore: removal of casts does not work :(
luisacicolini Aug 23, 2025
0b16349
chore: pipeline works
luisacicolini Aug 23, 2025
1aafa2b
chore: dont push results
luisacicolini Aug 23, 2025
7086ad6
never push results or logs
luisacicolini Aug 23, 2025
35b8928
chore: no pushing results either
luisacicolini Aug 23, 2025
09a0716
chore: no pushing results either
luisacicolini Aug 23, 2025
6c64097
chore: readme
luisacicolini Aug 24, 2025
bce4a3c
chore: analysis tool
luisacicolini Aug 24, 2025
f80ff95
chore: ignore results
luisacicolini Aug 24, 2025
0f9a5d5
chore: make readme md
luisacicolini Aug 24, 2025
bc6650f
chore: fix error
luisacicolini Aug 24, 2025
1a3bafa
chore: reduce code dupplication
luisacicolini Aug 24, 2025
53758f8
chore: make generation of benchmarks less brittle
luisacicolini Aug 24, 2025
d95218d
chore: fix generation
luisacicolini Aug 25, 2025
3c92311
add globalisel workflow
Aug 25, 2025
909fd6f
add basic table logic, needs sorting
Aug 26, 2025
9db313c
Merge remote-tracking branch 'origin/main' into sarah-eval
Aug 26, 2025
3df4afb
confusion
Aug 26, 2025
6161633
Merge remote-tracking branch 'origin/main' into sarah-eval
Aug 26, 2025
faa6cc5
first eval run
Aug 27, 2025
b899aac
Merge remote-tracking branch 'origin/main' into sarah-eval
luisacicolini Aug 27, 2025
0a72a2b
chore: remove proof automation folder
luisacicolini Aug 27, 2025
850921a
chore: do not push benchmarks
luisacicolini Aug 27, 2025
815a645
chore: add gitignore
luisacicolini Aug 27, 2025
960a137
chore: clean build before testing
luisacicolini Aug 27, 2025
70fcb51
chore: undo unwanted change
luisacicolini Aug 27, 2025
1d703bc
chore: undo unwanted change
luisacicolini Aug 27, 2025
b676218
chore: undo unwanted change
luisacicolini Aug 27, 2025
adfbed0
chore: undo unwanted change
luisacicolini Aug 27, 2025
57b7783
chore: do not lower empty blocks
luisacicolini Aug 27, 2025
4fb817d
chore: just to be safe
Aug 27, 2025
0816a57
Merge branch 'sarah-eval' into HEAD
Aug 27, 2025
cdddf8e
data and script
salinhkuhn Aug 28, 2025
8fe7c68
chore: more plots
luisacicolini Aug 28, 2025
a7d6866
extend parsing logic for generic flag attributes
salinhkuhn Aug 29, 2025
dcc39c4
done
salinhkuhn Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 3 additions & 2 deletions SSA/Core/Framework/Print.lean
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,13 @@ section ToPrint
open Std (Format)
variable {d} [ToPrint d] [DialectSignature d] [Repr d.Op] [Repr d.Ty] [ToString d.Ty] [ToString d.Op]

/-- Format a list of formal arguments as `(%0 : t₀, %1 : t₁, ... %n : tₙ)` -/
/-- Format a list of formal arguments as `(%0 : t₀, %1 : t₁, ... %n : tₙ)` -/ --here
partial def formatFormalArgListTuplePrint [ToString d.Ty] (ts : List d.Ty) : String :=
let args := (List.range ts.length).zip ts |>.map
let args := (List.range ts.length).zip ts.reverse |>.map
(fun (i, t) => s!"%{i} : {ToPrint.printTy t}")
"(" ++ String.intercalate ", " args ++ ")"


-- Format a sequence of types as `(t₁, ..., tₙ)` using toString instances -/
private def formatTypeTuplePrint [ToString d.Ty] (xs : List d.Ty) : String :=
"(" ++ String.intercalate ", " (xs.map ToPrint.printTy) ++ ")"
Expand Down
35 changes: 21 additions & 14 deletions SSA/Projects/InstCombine/LLVM/EDSL.lean
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,27 @@ In future, this might start throwing errors, if the type is not a bitvec.
def getVarWidth {Γ : Ctxt (MetaLLVM φ).Ty} : (Σ t, Γ.Var t) → Width φ
| ⟨.bitvec w, _⟩ => w

def parseOverflowFlags (op : AST.Op φ) : ReaderM φ LLVM.NoWrapFlags :=
match op.getAttr? "overflowFlags" with
| .none => return {}
| .some y => match y with
| .opaque_ "llvm.overflow" "nsw" => return ⟨true, false⟩
| .opaque_ "llvm.overflow" "nuw" => return ⟨false, true⟩
| .opaque_ "llvm.overflow" "none" => return ⟨false, false⟩
| .list [.opaque_ "llvm.overflow" "nuw", .opaque_ "llvm.overflow" "nsw"]
| .list [.opaque_ "llvm.overflow" "nsw", .opaque_ "llvm.overflow" "nuw"] =>
return ⟨true, true⟩
| .opaque_ "llvm.overflow" s => throw <| .generic s!"The overflow flag {s} not allowed. \
We currently support nsw (no signed wrap) and nuw (no unsigned wrap)"
| _ => throw <| .generic s!"Unrecognised overflow flag found: {MLIR.AST.docAttrVal y}. \
We currently support nsw (no signed wrap) and nuw (no unsigned wrap)"
def parseOverflowFlags (op : AST.Op φ) : ReaderM φ LLVM.NoWrapFlags := do
match op.getAttr? "overflowFlags" with
| .none => return {}
| .some y =>
match y with
| .opaque_ "llvm.overflow" "nsw" => return (⟨true, false⟩)
| .opaque_ "llvm.overflow" "nuw" => return (⟨false, true⟩)
| .opaque_ "llvm.overflow" "none" => return (⟨false, false⟩)
| .list [.opaque_ "llvm.overflow" "nuw", .opaque_ "llvm.overflow" "nsw"]
| .list [.opaque_ "llvm.overflow" "nsw", .opaque_ "llvm.overflow" "nuw"] =>
return (⟨true, true⟩)
| _ => /- This case covers generic MLIR syntax for operations with attributes as
MLIR encodes them using integer attributes. -/
let ⟨n, _ ⟩ ← op.getIntAttr "overflowFlags"
match n with
| 0 => return (⟨false, false⟩)
| 1 => return (⟨true, false⟩)
| 2 => return (⟨false, true⟩)
| 3 => return (⟨true, true⟩)
| s => throw <| .generic s!"The overflow flag with prediacte {s} not allowed. \
We currently support nsw (no signed wrap) and nuw (no unsigned wrap)"
/--
Maps integer predicate codes (as defined in the MLIR LLVM dialect) to their corresponding
`LLVM.IntPred` constructors.
Expand Down
10 changes: 10 additions & 0 deletions SSA/Projects/LLVMRiscV/Evaluation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
benchmarks/MLIR_single
benchmarks/MLIR_bb0
benchmarks/LEANMLIR_ASM
benchmarks/LLC_ASM
benchmarks/LLVM
benchmarks/LLVMIR
benchmarks/logs
benchmarks/XDSL_ASM
benchmarks/XDSL_no_casts
benchmarks/XDSL_reg_alloc
191 changes: 191 additions & 0 deletions SSA/Projects/LLVMRiscV/Evaluation/LLVM-tests/add-imm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,27 @@ def add_positive_low_bound_reject_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (.
lhs := add_positive_low_bound_reject_llvm
rhs := add_positive_low_bound_reject_riscv

<<<<<<< HEAD
<<<<<<< HEAD

/-- ### add_positive_low_bound_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 2 -/
/-
define i32 @add_positive_low_bound_accept(i32 %a) nounwind {
; RV64I-LABEL: add_positive_low_bound_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, 2047
; RV64I-NEXT: addiw a0, a0, 1
; RV64I-NEXT: ret
%1 = add i32 %a, 2048
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_positive_low_bound_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (2048) : i32
Expand All @@ -56,8 +74,26 @@ def add_positive_low_bound_accept_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (.
lhs := add_positive_low_bound_accept_llvm
rhs := add_positive_low_bound_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD
/-- ### add_positive_high_bound_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 3 -/
/--
define i32 @add_positive_high_bound_accept(i32 %a) nounwind {
; RV64I-LABEL: add_positive_high_bound_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, 2047
; RV64I-NEXT: addiw a0, a0, 2047
; RV64I-NEXT: ret
%1 = add i32 %a, 4094
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_positive_high_bound_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (4094) : i32
Expand All @@ -80,9 +116,28 @@ def add_positive_high_bound_accept_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_positive_high_bound_accept_llvm
rhs := add_positive_high_bound_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD

/-- ### add_positive_high_bound_reject -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 4 -/
/-
define i32 @add_positive_high_bound_reject(i32 %a) nounwind {
; RV64I-LABEL: add_positive_high_bound_reject:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a1, 1
; RV64I-NEXT: addi a1, a1, -1
; RV64I-NEXT: addw a0, a0, a1
; RV64I-NEXT: ret
%1 = add i32 %a, 4095
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_positive_high_bound_reject_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (4095) : i32
Expand All @@ -107,9 +162,31 @@ def add_positive_high_bound_reject_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_positive_high_bound_reject_llvm
rhs := add_positive_high_bound_reject_riscv

<<<<<<< HEAD
<<<<<<< HEAD

/-- ### add_negative_high_bound_reject -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 5 -/
/-
define i32 @add_negative_high_bound_reject(i32 %a) nounwind {
; RV32I-LABEL: add_negative_high_bound_reject:
; RV32I: # %bb.0:
; RV32I-NEXT: addi a0, a0, -2048
; RV32I-NEXT: ret
;
; RV64I-LABEL: add_negative_high_bound_reject:
; RV64I: # %bb.0:
; RV64I-NEXT: addiw a0, a0, -2048
; RV64I-NEXT: ret
%1 = add i32 %a, -2048
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_negative_high_bound_reject_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (-2048) : i32
Expand All @@ -131,9 +208,33 @@ def add_negative_high_bound_reject_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_negative_high_bound_reject_llvm
rhs := add_negative_high_bound_reject_riscv

<<<<<<< HEAD
<<<<<<< HEAD

/-- ### add_negative_high_bound_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 6 -/
/-
define i32 @add_negative_high_bound_accept(i32 %a) nounwind {
; RV32I-LABEL: add_negative_high_bound_accept:
; RV32I: # %bb.0:
; RV32I-NEXT: addi a0, a0, -2048
; RV32I-NEXT: addi a0, a0, -1
; RV32I-NEXT: ret
;
; RV64I-LABEL: add_negative_high_bound_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, -2048
; RV64I-NEXT: addiw a0, a0, -1
; RV64I-NEXT: ret
%1 = add i32 %a, -2049
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_negative_high_bound_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (-2049) : i32
Expand All @@ -155,8 +256,26 @@ def add_negative_high_bound_accept_test: LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_negative_high_bound_accept_llvm
rhs := add_negative_high_bound_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD
/-- ### add_negative_low_bound_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 7 -/
/-
define i32 @add_negative_low_bound_accept(i32 %a) nounwind {
; RV64I-LABEL: add_negative_low_bound_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, -2048
; RV64I-NEXT: addiw a0, a0, -2048
; RV64I-NEXT: ret
%1 = add i32 %a, -4096
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_negative_low_bound_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (-4096) : i32
Expand All @@ -178,8 +297,27 @@ def add_negative_low_bound_accept_test : LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_negative_low_bound_accept_llvm
rhs := add_negative_low_bound_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD
/-- ### add_negative_low_bound_reject -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 8 -/
/-
define i32 @add_negative_low_bound_reject(i32 %a) nounwind {
; RV64I-LABEL: add_negative_low_bound_reject:
; RV64I: # %bb.0:
; RV64I-NEXT: lui a1, 1048575
; RV64I-NEXT: addi a1, a1, -1
; RV64I-NEXT: addw a0, a0, a1
; RV64I-NEXT: ret
%1 = add i32 %a, -4097
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add_negative_low_bound_reject_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (-4097) : i32
Expand All @@ -203,8 +341,26 @@ def add_negative_low_bound_reject_test : LLVMPeepholeRewriteRefine 32 [Ty.llvm (
lhs := add_negative_low_bound_reject_llvm
rhs := add_negative_low_bound_reject_riscv

<<<<<<< HEAD
<<<<<<< HEAD
/-- ### add32_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 9 -/
/-
define i32 @add32_accept(i32 %a) nounwind {
; RV64I-LABEL: add32_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, 2047
; RV64I-NEXT: addiw a0, a0, 952
; RV64I-NEXT: ret
%1 = add i32 %a, 2999
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add32_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (2999) : i32
Expand All @@ -226,8 +382,26 @@ def add32_accept_test : LLVMPeepholeRewriteRefine 32 [Ty.llvm (.bitvec 32)] wher
lhs := add32_accept_llvm
rhs := add32_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD
/-- ### add32_sext_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 10 -/
/-
define signext i32 @add32_sext_accept(i32 signext %a) nounwind {
; RV64I-LABEL: add32_sext_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, 2047
; RV64I-NEXT: addiw a0, a0, 952
; RV64I-NEXT: ret
%1 = add i32 %a, 2999
ret i32 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add32_sext_accept_llvm := [LV| {
^entry (%a: i32):
%0 = llvm.mlir.constant (2999) : i32
Expand All @@ -249,9 +423,26 @@ def add32_sext_accept_test : LLVMPeepholeRewriteRefine 32 [Ty.llvm (.bitvec 32)]
lhs := add32_sext_accept_llvm
rhs := add32_sext_accept_riscv

<<<<<<< HEAD
<<<<<<< HEAD

/-- ### add64_accept -/
@[simp_denote]
=======
=======
>>>>>>> sarah-eval
/-# 11 -/
/-define i64 @add64_accept(i64 %a) nounwind {
; RV64I-LABEL: add64_accept:
; RV64I: # %bb.0:
; RV64I-NEXT: addi a0, a0, 2047
; RV64I-NEXT: addi a0, a0, 952
; RV64I-NEXT: ret
%1 = add i64 %a, 2999
ret i64 %1
}
-/
>>>>>>> faa6cc524 (first eval run)
def add64_accept_llvm := [LV| {
^entry (%a: i64):
%0 = llvm.mlir.constant (2999) : i64
Expand Down
Loading
Loading