Skip to content

Commit

Permalink
Vamp-IR List Primitive Addition
Browse files Browse the repository at this point in the history
Adds a list Vamp-IR primitive operation and changes corresponding
range functions.
  • Loading branch information
agureev committed Jun 26, 2023
1 parent 89cf93f commit e5d5bfd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/vampir/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
;; vampir api functions
:*bool*
:bool
:*base-range*
:*next-range*
:next-range
:*range-n*
:range-n
:*range32*
:range32

Expand Down
2 changes: 1 addition & 1 deletion src/vampir/spec.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
`(or wire constant))

(deftype primitive ()
`(or (eql :+) (eql :-) (eql :*) (eql :^) (eql :\\) (eql :%) (eql :/)))
`(or (eql :+) (eql :-) (eql :*) (eql :^) (eql :\\) (eql :%) (eql :/) (eql :|:|)))

(deftype constraint-list ()
`(satisfies constraint-list))
Expand Down
37 changes: 26 additions & 11 deletions src/vampir/vampir.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@
:func :negative31
:arguments (list a)))


(defparameter *base-range*
(make-alias
:name :base_range
:inputs (list (make-constant :const 0))
:body
(list (make-wire :var :[]))))

(defparameter *next-range*
(let ((a-wire (make-wire :var :a)))
(make-alias
Expand Down Expand Up @@ -149,18 +157,25 @@
(make-infix :op :\\
:lhs a-wire
:rhs (make-constant :const 2)))))
(make-equality :lhs a-wire
:rhs
(make-infix :op :+
:lhs (make-wire :var :a0)
:rhs (make-infix :op :*
:lhs (make-constant :const 2)
:rhs (make-wire :var :a1))))
(make-tuples :wires (list
(make-wire :var :a0)
(make-application :func :range
(make-infix :op :|:|
:lhs (make-wire :var :a0)
:rhs (make-application :func :range
:arguments
(list (make-wire :var :a1)))))))))
(list (make-wire :var :a1))))))))
(defparameter *range-n*
(make-alias
:name :range-n
:inputs (list :n)
:body
(list (make-application :func :iter
:arguments (list (make-wire :var :n)
(make-wire :var :next_range)
(make-wire :var :base_range))))))

(defun range-n (n a)
(make-application :func :range-n
:arguments (list n
a)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Range
Expand Down

0 comments on commit e5d5bfd

Please sign in to comment.