(Attempt to) look up the return type of a system function call.
(vl-syscall->returninfo x) → info
Some system calls don't necessarily have a well-defined or sensible
return type, for instance, what is the return type of
Even if certain system calls don't make sense in the context of synthesis, it is generally useful (e.g., for linting) to be able to look up their return types. So, it would be good to extend this function to make it more complete.
Function:
(defun vl-syscall->returninfo (x) (declare (xargs :guard (vl-expr-p x))) (declare (xargs :guard (vl-expr-case x :vl-call x.systemp :otherwise nil))) (let ((__function__ 'vl-syscall->returninfo)) (declare (ignorable __function__)) (cond ((vl-0ary-syscall-p "$time" x) '((:vl-time :vl-kwd-time) (t) t . 64)) ((or (vl-unary-syscall-p "$bits" x) (vl-typearg-syscall-p "$bits" x)) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) ((or (vl-*ary-syscall-p "$left" x) (vl-*ary-syscall-p "$right" x) (vl-*ary-syscall-p "$low" x) (vl-*ary-syscall-p "$high" x) (vl-*ary-syscall-p "$increment" x) (vl-*ary-syscall-p "$size" x)) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) ((or (vl-unary-syscall-p "$dimensions" x) (vl-unary-syscall-p "$unpacked_dimensions" x)) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) ((vl-unary-syscall-p "$clog2" x) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) ((or (vl-unary-syscall-p "$ln" x) (vl-unary-syscall-p "$log10" x)) '((:vl-real :vl-kwd-real))) ((or (vl-*ary-syscall-p "$countbits" x) (vl-unary-syscall-p "$countones" x)) '((:vl-int :vl-kwd-int . t) (t) nil . 32)) ((or (vl-unary-syscall-p "$onehot" x) (vl-unary-syscall-p "$onehot0" x) (vl-unary-syscall-p "$isunknown" x)) '((:vl-bit :vl-kwd-bit) (t . t) nil . 1)) ((vl-$random-expr-p x) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) ((vl-unary-syscall-p "$test$plusargs" x) '((:vl-integer :vl-kwd-integer . t) (t) t . 32)) (t nil))))
Theorem:
(defthm return-type-of-vl-syscall->returninfo (b* ((info (vl-syscall->returninfo x))) (iff (vl-coredatatype-info-p info) info)) :rule-classes :rewrite)
Theorem:
(defthm vl-syscall->returninfo-of-vl-expr-fix-x (equal (vl-syscall->returninfo (vl-expr-fix x)) (vl-syscall->returninfo x)))
Theorem:
(defthm vl-syscall->returninfo-vl-expr-equiv-congruence-on-x (implies (vl-expr-equiv x x-equiv) (equal (vl-syscall->returninfo x) (vl-syscall->returninfo x-equiv))) :rule-classes :congruence)