Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change lookup to deflookup #354

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion pkg/hir/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (p *hirParser) parseDeclaration(s sexp.SExp) error {
return p.parseAssertionDeclaration(e.Elements)
} else if e.Len() == 3 && e.MatchSymbols(1, "permute") {
return p.parseSortedPermutationDeclaration(e)
} else if e.Len() == 4 && e.MatchSymbols(1, "lookup") {
} else if e.Len() == 4 && e.MatchSymbols(1, "deflookup") {
return p.parseLookupDeclaration(e)
} else if e.Len() == 3 && e.MatchSymbols(1, "interleave") {
return p.parseInterleavingDeclaration(e)
Expand Down
7 changes: 6 additions & 1 deletion pkg/schema/constraint/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,10 @@ func (p *LookupConstraint[E]) Lisp(schema sc.Schema) sexp.SExp {
targets.Append(p.targets[i].Lisp(schema))
}
// Done
return sexp.NewList([]sexp.SExp{sexp.NewSymbol(p.handle)})
return sexp.NewList([]sexp.SExp{
sexp.NewSymbol("deflookup"),
sexp.NewSymbol(p.handle),
targets,
sources,
})
}
2 changes: 1 addition & 1 deletion testdata/bin-dynamic.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

(defconstraint bin:is-byte-result () (ifnot bin:IS_BYTE (if bin:CT_MAX (begin bin:RESULT_HI bin:RESULT_LO) (begin bin:RESULT_HI (- bin:RESULT_LO (* bin:SMALL bin:PIVOT))))))

(defconstraint bin:result-via-lookup () (ifnot (+ bin:IS_AND bin:IS_OR bin:IS_XOR bin:IS_NOT) (begin (- bin:BYTE_5 bin:XXX_BYTE_HI) (- bin:BYTE_6 bin:XXX_BYTE_LO))))
(defconstraint bin:result-via-deflookup () (ifnot (+ bin:IS_AND bin:IS_OR bin:IS_XOR bin:IS_NOT) (begin (- bin:BYTE_5 bin:XXX_BYTE_HI) (- bin:BYTE_6 bin:XXX_BYTE_LO))))

(defconstraint bin:isnot-ctmax () (if (- bin:IS_NOT 1) (- bin:CT_MAX 15)))

Expand Down
2 changes: 1 addition & 1 deletion testdata/bin-static.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

(defconstraint bin:set-oli-mli () (if (+ bin:IS_BYTE bin:IS_SIGNEXTEND) bin:ONE_LINE_INSTRUCTION (if bin:ARGUMENT_1_HI bin:ONE_LINE_INSTRUCTION (- bin:ONE_LINE_INSTRUCTION 1))))

(defconstraint bin:result-via-lookup () (ifnot (+ bin:IS_AND bin:IS_OR bin:IS_XOR bin:IS_NOT) (begin (- bin:BYTE_5 bin:XXX_BYTE_HI) (- bin:BYTE_6 bin:XXX_BYTE_LO))))
(defconstraint bin:result-via-deflookup () (ifnot (+ bin:IS_AND bin:IS_OR bin:IS_XOR bin:IS_NOT) (begin (- bin:BYTE_5 bin:XXX_BYTE_HI) (- bin:BYTE_6 bin:XXX_BYTE_LO))))

(defconstraint bin:oli-incrementation () (ifnot bin:ONE_LINE_INSTRUCTION (- (shift bin:STAMP 1) (+ bin:STAMP 1))))

Expand Down
2 changes: 1 addition & 1 deletion testdata/interleave_04.lisp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(defcolumns X Y Z)
(interleave A (X Y))
(lookup l1 (A) (Z))
(deflookup l1 (A) (Z))
2 changes: 1 addition & 1 deletion testdata/lookup_01.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns X Y)
(lookup test (Y) (X))
(deflookup test (Y) (X))
2 changes: 1 addition & 1 deletion testdata/lookup_02.lisp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(defcolumns A B X Y)
;; Inclusion A,B into X,Y
(lookup test (X Y) (A B))
(deflookup test (X Y) (A B))
2 changes: 1 addition & 1 deletion testdata/lookup_03.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns X Y)
(lookup test (Y) ((* X 2)))
(deflookup test (Y) ((* X 2)))
2 changes: 1 addition & 1 deletion testdata/lookup_04.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns ST X Y)
(lookup test (Y) ((* ST (+ 1 X))))
(deflookup test (Y) ((* ST (+ 1 X))))
2 changes: 1 addition & 1 deletion testdata/lookup_05.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns A B X Y)
(lookup test (X Y) (A (* B 3)))
(deflookup test (X Y) (A (* B 3)))
2 changes: 1 addition & 1 deletion testdata/lookup_06.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
(module m2)
(defcolumns Y)
;;
(lookup test (Y) (m1.X))
(deflookup test (Y) (m1.X))
2 changes: 1 addition & 1 deletion testdata/lookup_07.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns A B X)
(lookup test (A B) (X 0))
(deflookup test (A B) (X 0))
2 changes: 1 addition & 1 deletion testdata/lookup_08.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defcolumns A B X)
(lookup test (A B) (0 X))
(deflookup test (A B) (0 X))