Commit 674d8af0 authored by Guy Watson's avatar Guy Watson
Browse files

Rename fresh shortcuts to fresh-<type>

parent c20f5a4b
......@@ -233,9 +233,9 @@
(define f32 (base-type 'f32))
(define f64 (base-type 'f64))
;; Larger groups
(define (number) (fresh-type-variable i32 i64 f32 f64))
(define (int) (fresh-type-variable i32 i64))
(define (float) (fresh-type-variable f32 f64))
(define (fresh-number) (fresh-type-variable i32 i64 f32 f64))
(define (fresh-int) (fresh-type-variable i32 i64))
(define (fresh-float) (fresh-type-variable f32 f64))
(define (no-child-types)
......@@ -253,10 +253,10 @@
[Program [i32
(λ (n t)
(hash 'Func i32
'globals (λ (child-node) (number))))]]
[GlobalDeclaration [(number)
'globals (λ (child-node) (fresh-number))))]]
[GlobalDeclaration [(fresh-number)
(λ (n t) (hash 'initialvalue t))]]
[Func [(number)
[Func [(fresh-number)
(λ (n t)
(hash 'root t))]]
[LiteralIntThirtyTwo [i32
......@@ -267,34 +267,34 @@
(no-child-types)]]
[LiteralFloatSixtyFour [f64
(no-child-types)]]
[Noop [(number) (λ (n t) (hash 'expr t))]] ;;todo This is wierd....
[Noop [(fresh-number) (λ (n t) (hash 'expr t))]] ;;todo This is wierd....
[Binop [(number) binop-rhs]]
[Binop [(fresh-number) binop-rhs]]
;; Restricted binops:
[Remainder [(int) binop-rhs]]
[And [(int) binop-rhs]]
[Or [(int) binop-rhs]]
[Xor [(int) binop-rhs]]
[ShiftLeft [(int) binop-rhs]]
[ShiftRight [(int) binop-rhs]]
[RotateLeft [(int) binop-rhs]]
[RotateRight [(int) binop-rhs]]
[Min [(float) binop-rhs]]
[Max [(float) binop-rhs]]
[CopySign [(float) binop-rhs]]
[Unop [(number) unop-rhs]]
[Remainder [(fresh-int) binop-rhs]]
[And [(fresh-int) binop-rhs]]
[Or [(fresh-int) binop-rhs]]
[Xor [(fresh-int) binop-rhs]]
[ShiftLeft [(fresh-int) binop-rhs]]
[ShiftRight [(fresh-int) binop-rhs]]
[RotateLeft [(fresh-int) binop-rhs]]
[RotateRight [(fresh-int) binop-rhs]]
[Min [(fresh-float) binop-rhs]]
[Max [(fresh-float) binop-rhs]]
[CopySign [(fresh-float) binop-rhs]]
[Unop [(fresh-number) unop-rhs]]
;; Restricted Unops
[CountLeadingZero [(int) unop-rhs]]
[CountTrailingZero [(int) unop-rhs]]
[NonZeroBits [(int) unop-rhs]]
[AbsoluteValue [(float) unop-rhs]]
[Negate [(float) unop-rhs]]
[SquareRoot [(float) unop-rhs]]
[Ceiling [(float) unop-rhs]]
[Floor [(float) unop-rhs]]
[Truncate [(float) unop-rhs]]
[Nearest [(float) unop-rhs]]
[CountLeadingZero [(fresh-int) unop-rhs]]
[CountTrailingZero [(fresh-int) unop-rhs]]
[NonZeroBits [(fresh-int) unop-rhs]]
[AbsoluteValue [(fresh-float) unop-rhs]]
[Negate [(fresh-float) unop-rhs]]
[SquareRoot [(fresh-float) unop-rhs]]
[Ceiling [(fresh-float) unop-rhs]]
[Floor [(fresh-float) unop-rhs]]
[Truncate [(fresh-float) unop-rhs]]
[Nearest [(fresh-float) unop-rhs]]
[Comparison [i32
(λ (n t) ;; The type of the children is unconstrained, they just have to be the same
......@@ -303,45 +303,45 @@
'r child-type))]]
[Testop [i32
(λ (n t) ;; The only testop in wasm 1.1 is integer only
(hash 'expr (int)))]]
[IfElse [(number)
(hash 'expr (fresh-int)))]]
[IfElse [(fresh-number)
(λ (n t)
(hash 'cond i32
'then t
'else t))]]
[If [(number)
[If [(fresh-number)
(λ (n t)
(hash 'cond i32
'then t))]]
[Block [(number) (λ (n t) (hash 'expr t))]]
[Loop [(number) (λ (n t) (hash 'expr t))]]
[ForLoop [(number) (λ (n t) (hash 'initial i32
[Block [(fresh-number) (λ (n t) (hash 'expr t))]]
[Loop [(fresh-number) (λ (n t) (hash 'expr t))]]
[ForLoop [(fresh-number) (λ (n t) (hash 'initial i32
'loopvar i32
'loopbody t))]]
[Branch [(number) (λ (n t) (hash 'val t))]] ;;todo triple check branch interactions here
[BranchIf [(number)
[Branch [(fresh-number) (λ (n t) (hash 'val t))]] ;;todo triple check branch interactions here
[BranchIf [(fresh-number)
(λ (n t) (hash 'cond i32
'val t))]]
[MemStore [(number)
[MemStore [(fresh-number)
(λ (n t) (hash 'address i32
'value t
'expr t))]]
[MemLoad [(number) (λ (n t) (hash 'address i32))]]
[MemLoad [(fresh-number) (λ (n t) (hash 'address i32))]]
[LocalGet [i32 (no-child-types)]] ;;todo change to the new reference binding system
[LocalSet [i32 (λ (n t) (hash 'val i32
'expr i32))]]
[LocalTee [i32 (λ (n t) (hash 'val i32))]]
[GlobalGet [(number) (no-child-types)]]
[GlobalSet [(number) (λ (n t) (hash 'val t))]]
[GlobalGet [(fresh-number) (no-child-types)]]
[GlobalSet [(fresh-number) (λ (n t) (hash 'val t))]]
;;Type conversions
[TruncateFloat [(int)
[TruncateFloat [(fresh-int)
(λ (n t)
(hash 'expr (float)))]]
[ConvertInt [(float)
(hash 'expr (fresh-float)))]]
[ConvertInt [(fresh-float)
(λ (n t)
(hash 'expr (int)))]]
(hash 'expr (fresh-int)))]]
[Wrap [i32 (λ (n t)
(hash 'expr i64))]]
[Extend [i64 (λ (n t)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment