Skip to content

Commit 3253dfb

Browse files
committed
Allow to synthesize refinements
1 parent 4ce7ab5 commit 3253dfb

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
irdl.dialect @arith {
22
irdl.operation @addi {
33
%integer = irdl.base "!builtin.integer"
4-
%ovf_none = irdl.is #arith.overflow<none>
5-
%ovf_nsw = irdl.is #arith.overflow<nsw>
6-
%ovf_nuw = irdl.is #arith.overflow<nuw>
7-
%ovf_nsw_nuw = irdl.is #arith.overflow<nsw,nuw>
8-
%ovf = irdl.any_of(%ovf_none, %ovf_nsw, %ovf_nuw, %ovf_nsw_nuw)
9-
104
irdl.operands(operand0: %integer, operand1: %integer)
115
irdl.results(result0: %integer)
12-
irdl.attributes {"overflowFlags" = %ovf}
136
}
147
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: superoptimize %s --max-num-ops=1 --dialect=%S/arith.irdl | filecheck %s
2+
3+
func.func @foo(%x: !smt.bv<32>, %y: !smt.bv<32>) -> !smt.bv<32> {
4+
%r = "smt.bv.add"(%x, %y) : (!smt.bv<32>, !smt.bv<32>) -> !smt.bv<32>
5+
func.return %r : !smt.bv<32>
6+
}
7+
8+
// CHECK: func.func @foo(%arg0 : i32) -> i32 {
9+
// CHECK-NEXT: %0 = arith.constant 0 : i32
10+
// CHECK-NEXT: func.return %0 : i32
11+
// CHECK-NEXT: }

xdsl_smt/cli/superoptimize.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def register_all_arguments(arg_parser: argparse.ArgumentParser):
5555
"--dialect",
5656
type=str,
5757
help="The IRDL file defining the dialect we want to use for synthesis",
58+
required=True,
5859
)
5960
arg_parser.add_argument(
6061
"-v",
@@ -63,6 +64,19 @@ def register_all_arguments(arg_parser: argparse.ArgumentParser):
6364
help="Print debugging information in stderr",
6465
action="store_true",
6566
)
67+
arg_parser.add_argument(
68+
"--configuration",
69+
dest="configuration",
70+
type=str,
71+
help="The configuration to use for synthesis",
72+
default="arith",
73+
)
74+
arg_parser.add_argument(
75+
"--optimize",
76+
dest="optimize",
77+
help="Only generate programs with a lower cost than the input program",
78+
action="store_true",
79+
)
6680

6781

6882
def replace_synth_with_constants(
@@ -105,8 +119,9 @@ def main() -> None:
105119
f"--max-num-ops={args.max_num_ops}",
106120
"--pause-between-programs",
107121
"--mlir-print-op-generic",
108-
"--configuration=arith",
122+
f"--configuration={args.configuration}",
109123
f"--use-input-ops={args.use_input_ops}",
124+
# "--optimize" if args.optimize is not None else "",
110125
],
111126
stdin=sp.PIPE,
112127
stdout=sp.PIPE,

0 commit comments

Comments
 (0)