Skip to content

Commit 7c39670

Browse files
Replace logInfos with trace messages (#1468)
1 parent 3227dc2 commit 7c39670

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

SSA/Experimental/Bits/Generalize/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ open Lean.Meta
55
open Std.Sat
66
open Std.Tactic.BVDecide
77

8+
initialize Lean.registerTraceClass `Generalize
89

910
namespace Generalize
1011
/--

SSA/Experimental/Bits/Generalize/Generalize.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import SSA.Core.Util
77
import SSA.Experimental.Bits.Generalize.Basic
88
import SSA.Experimental.Bits.Generalize.Reflect
99

10-
initialize Lean.registerTraceClass `Generalize
11-
1210
open Lean
1311
open Lean.Meta
1412
open Std.Sat
@@ -269,7 +267,7 @@ elab "#reducewidth" expr:term " : " target:term : command =>
269267
let some targetWidth ← getNatValue? targetExpr | throwError "Invalid width provided"
270268

271269
let hExpr ← Term.elabTerm expr none
272-
logInfo m! "hexpr: {hExpr}"
270+
trace[Generalize] m! "hexpr: {hExpr}"
273271

274272
match_expr hExpr with
275273
| Eq _ lhsExpr rhsExpr =>
@@ -278,7 +276,7 @@ elab "#reducewidth" expr:term " : " target:term : command =>
278276

279277
let bvExpr := parsedBvExpr.bvLogicalExpr
280278
let state := parsedBvExpr.state
281-
logInfo m! "bvExpr: {bvExpr}, state: {state}"
279+
trace[Generalize] m! "bvExpr: {bvExpr}, state: {state}"
282280

283281
let initialGeneralizerState : GeneralizerState :=
284282
{ startTime := 0
@@ -452,7 +450,7 @@ def pruneEquivalentBVExprs (expressions: List (GenBVExpr w)) : GeneralizerStateM
452450
if let some _ ← solve subsumeCheckExpr then
453451
pruned := expr :: pruned
454452

455-
logInfo m! "Removed {expressions.length - pruned.length} expressions after pruning {expressions.length} expressions"
453+
trace[Generalize] m! "Removed {expressions.length - pruned.length} expressions after pruning {expressions.length} expressions"
456454

457455
pure pruned
458456

@@ -906,6 +904,7 @@ def synthesizeWithNoPrecondition (constantAssignments : List (Std.HashMap Nat BV
906904
while currentLevel < lhs.symVars.size do
907905
logInfo m! "Expression Synthesis Processing level {currentLevel}"
908906

907+
--
909908
let bottomUpRes ← constantExprsEnumerationFromCache allLHSVars lhsAssignments rhsAssignments ops
910909
for (var, exprs) in bottomUpRes.toArray do
911910
let existingExprs := exprSynthesisResults.getD var []

SSA/Experimental/Bits/Generalize/Reflect.lean

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import SSA.Experimental.Bits.Generalize.Basic
55

66
namespace Generalize
77

8-
98
open Lean
109
open Lean.Meta
1110
open Std.Sat
1211
open Std.Tactic.BVDecide
1312

14-
1513
structure ParsedBVExprState where
1614
maxFreeVarId : Nat
1715
numSymVars : Nat
@@ -110,13 +108,10 @@ partial def toBVExpr (expr : Expr) (targetWidth: Nat) : ParseBVExprM (Option (BV
110108
| BitVec.rotateRight _ innerExpr distanceExpr =>
111109
rotateReflection innerExpr distanceExpr BVUnOp.rotateRight
112110
| BitVec.zeroExtend _ nExpr vExpr =>
113-
logInfo m! "matched zero extend: {vExpr}"
114111
let some n ← getNatValue? nExpr | return none
115-
logInfo m! "vExpr: {vExpr}"
116112
let some v ← go vExpr | return none
117113
return some {bvExpr := GenBVExpr.zeroExtend n v.bvExpr, width := _}
118114
| BitVec.truncate _ nExpr vExpr =>
119-
logInfo m! "matched truncate: {vExpr}"
120115
let some n ← getNatValue? nExpr | return none
121116
let some v ← go vExpr | return none
122117
return some {bvExpr := GenBVExpr.truncate n v.bvExpr, width := _}
@@ -205,7 +200,6 @@ partial def toBVExpr (expr : Expr) (targetWidth: Nat) : ParseBVExprM (Option (BV
205200
return some {bvExpr := GenBVExpr.const (BitVec.ofNat n v), width := n}
206201

207202
getBitVecValue? (e : Expr) : MetaM (Option ((n : Nat) × BitVec n)) := OptionT.run do
208-
logInfo m! "parsing: {e}"
209203
match_expr e with
210204
| BitVec.ofNat nExpr vExpr =>
211205
let n ← getNatValue? nExpr
@@ -264,11 +258,11 @@ def parseExprs (lhsExpr rhsExpr : Expr) (targetWidth : Nat): ParseBVExprM (Optio
264258

265259
let rhs: ParsedBVExpr := {bvExpr := rhsRes.bvExpr, width := rhsRes.width, symVars := rhsSymVars, inputVars := rhsInputVars}
266260

267-
logInfo m! "lhs width: {lhsRes.width}; rhs width: {rhsRes.width}"
261+
trace[Generalize] m! "lhs width: {lhsRes.width}; rhs width: {rhsRes.width}"
268262
if h : lhsRes.width = rhsRes.width then
269263
let rhsExpr := h ▸ rhsRes.bvExpr
270264
let bvLogicalExpr := BoolExpr.literal (GenBVPred.bin lhsRes.bvExpr BVBinPred.eq rhsExpr)
271-
logInfo m! "BVLogicalExpr: {bvLogicalExpr}"
265+
trace[Generalize] m! "BVLogicalExpr: {bvLogicalExpr}"
272266

273267
return some {lhs := lhs, rhs := rhs, state := state, bvLogicalExpr := bvLogicalExpr}
274268

0 commit comments

Comments
 (0)