Commit a6388779 authored by Guy Watson's avatar Guy Watson
Browse files

Change define form used in shorthands.

Getting two children of a node to match the same type isn't quite working
parent 07fae1e5
Here is the error:
!!! Xsmith Error !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Error encountered while generating program!
Options:
Version: xsmith 1.2.0 (b951d0e), in Racket 7.4
Options: --max-depth 4 --s-exp-on-error true -s 883280739
Seed: 883280739
Debug Log:
(Program -i32-
(Func -i32-
(Func -i32-
(root -i32-
(NotEqual -i32-
(l -all-
(Multiplication -all-
(l (LiteralFloatThirtyTwo (v 391.4163827047701)))
(r (LiteralIntSixtyFour (v 34)))))
(r (XsmithAstHoleExpr)))) -all-
(localcount 6)))
(globals ()))
......@@ -48,6 +48,7 @@
(add-to-grammar
wasm-like
[Program #f (Func
;;[main : Func]
[globals : GlobalDeclaration *])]
[Func #f ([root : Expr]
[localcount = (random 1 10)])]
......@@ -76,10 +77,11 @@
#:prop choice-weight 20
#:prop may-be-generated #f]
[Testop Expr ([expr : Expr]) ;;Testops take one operand but return a boolean (i32)
#:prop choice-weight 10
#:prop choice-weight 50
#:prop may-be-generated #f]
[Addition Binop ()]
[Addition Binop ()
#:prop choice-weight 50]
[Subtraction Binop ()]
[Multiplication Binop ()]
[Division Binop ([sign = (choose-random-sign)])] ;;These signs only matter for ints, not floats
......@@ -144,12 +146,15 @@
[offset = (abs (- (random 20000) 10000))]
[alignment = (random 4)])
#:prop choice-weight 3]
[LocalGet Expr ([index])] ;;todo Change these over to the xsmith reference system once random reference increases are implemented by William
[LocalGet Expr ([index])
#:prop choice-weight 0] ;;todo Change these over to the xsmith reference system once random reference increases are implemented by William
[LocalSet Expr ([val : Expr]
[index]
[expr : Expr])]
[expr : Expr])
#:prop choice-weight 0]
[LocalTee Expr ([val : Expr]
[index])]
[index])
#:prop choice-weight 0]
[GlobalDeclaration #f ([name]
[type]
[initialvalue : Literal])
......@@ -226,30 +231,26 @@
(+ 1 depth))))]
[Func (λ (n c) (+ 1 (att-value 'nesting-level (ast-parent n))))])
;; Subtype group - use when all types are valid, but only ONE is wanted
;; Use with (fresh-subtype-of 'value)
(define number (base-type 'number))
;; All the base types of WebAssembly
(define i32 (base-type 'i32 number))
(define i64 (base-type 'i64 number))
(define f32 (base-type 'f32 number))
(define f64 (base-type 'f64 number))
(define i32 (base-type 'i32))
(define i64 (base-type 'i64))
(define f32 (base-type 'f32))
(define f64 (base-type 'f64))
;; Larger groups - use when ALL the contained types are valid
(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)
(λ (n t) (hash)))
(define binop-rhs (λ (n t)
(hash 'l t
'r t)))
(λ (n t)
(hash)))
(define unop-rhs (λ (n t)
(hash 'expr t)))
(define (binop-rhs) (λ (n t)
(define child-type (fresh-number))
(hash 'l child-type
'r child-type)))
(define (unop-rhs) (λ (n t)
(hash 'expr t)))
(add-prop
wasm-like type-info
......@@ -260,50 +261,64 @@
[GlobalDeclaration [(fresh-number)
(λ (n t) (hash 'initialvalue t))]]
[Func [(fresh-number)
(λ (n t)
(hash 'root t))]]
(λ (n t)
(hash 'root t))]]
[LiteralIntThirtyTwo [i32
(no-child-types)]]
(λ (n t)
(unify! (att-value 'xsmith_type (parent-node)) i32)
(hash))]]
[LiteralIntSixtyFour [i64
(no-child-types)]]
(λ (n t)
(unify! (att-value 'xsmith_type (parent-node)) i64)
(hash))]]
[LiteralFloatThirtyTwo [f32
(no-child-types)]]
(λ (n t)
(unify! (att-value 'xsmith_type (parent-node)) f32)
(hash))]]
[LiteralFloatSixtyFour [f64
(no-child-types)]]
(λ (n t)
(unify! (att-value 'xsmith_type (parent-node)) f64)
(hash))]]
[Noop [(fresh-number) (λ (n t) (hash 'expr t))]] ;;todo This is wierd....
[Binop [(fresh-number) binop-rhs]]
[Binop [(fresh-number) (binop-rhs)]]
;; Restricted binops:
[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]]
[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)]]
[Multiplication [(fresh-number)
(λ (n t)
(define child-type (fresh-number))
;;(define child-type (fresh-int))
(hash 'l child-type
'r child-type))]]
[Unop [(fresh-number) (unop-rhs)]]
;; Restricted Unops
[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]]
[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
(define child-type (fresh-subtype-of 'number))
(hash 'l child-type
'r child-type))]]
(λ (n t) ;; The type of the children is unconstrained, they just have to be the same
(define child-type (fresh-number))
(hash 'l child-type
'r child-type))]]
[Testop [i32
(λ (n t) ;; The only testop in wasm 1.1 is integer only
(hash 'expr (fresh-int)))]]
......
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