Commit 992fc8f9 authored by Guy Watson's avatar Guy Watson
Browse files

Add rendering info for type conversion instructions

parent 82895506
......@@ -168,11 +168,11 @@
#:prop choice-weight 20
#:prop may-be-generated #f]
[TruncateFloat TypeConversion ([sign = (choose-random-sign)])] ;; float -> int
[ConvertInt TypeConversion ([sign = (choose-random-sign)])] ;; int -> float
[Wrap TypeConversion ()] ;; i64 -> i32
[Extend TypeConversion ([sign = (choose-random-sign)])] ;; i32 -> i64
[Demote TypeConversion ()] ;; f64 -> f32
[Promote TypeConversion ()] ;; f32 -> f64
[ConvertInt TypeConversion ([sign = (choose-random-sign)])] ;; int -> float
[Wrap TypeConversion ()] ;; i64 -> i32
[Extend TypeConversion ([sign = (choose-random-sign)])] ;; i32 -> i64
[Demote TypeConversion ()] ;; f64 -> f32
[Promote TypeConversion ()] ;; f32 -> f64
[ReinterpretIntThirtyTwo TypeConversion ()]
[ReinterpretIntSixtyFour TypeConversion ()]
[ReinterpretFloatThirtyTwo TypeConversion ()]
......@@ -586,35 +586,57 @@
`(global.set ,(string->symbol (format "$~a" (ast-child 'name n))))
($xsmith_render-node (ast-child 'expr n))))]
[TruncateFloat (λ (n)
(append
'(FIXME)))]
(append
($xsmith_render-node (ast-child 'expr n))
`(,(let* ([prefix-type (get-base-type-name n)]
[suffix-type (get-base-type-name (ast-child 'expr n))]
[instruction (format "~a.~a_~a" prefix-type 'trunc suffix-type)])
(if (ast-child 'sign n)
(string->symbol (format "~a~a" instruction '_s))
(string->symbol (format "~a~a" instruction '_u)))))))]
[ConvertInt (λ (n)
(append
'(FIXME)))]
(append
($xsmith_render-node (ast-child 'expr n))
`(,(let* ([prefix-type (get-base-type-name n)]
[suffix-type (get-base-type-name (ast-child 'expr n))]
[instruction (format "~a.~a_~a" prefix-type 'convert suffix-type)])
(if (ast-child 'sign n)
(string->symbol (format "~a~a" instruction '_s))
(string->symbol (format "~a~a" instruction '_u)))))))]
[Wrap (λ (n)
(append
'(FIXME)))]
[Extend (λ (n)
($xsmith_render-node (ast-child 'expr n))
'(i32.wrap_i64)))]
[Extend (λ (n) ;;todo: add support for different extension widths: Section 5.4.5, v1.1
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
`(,(if (ast-child 'sign n)
'i64.extend_i32_s
'i64.extend_i32_u))))]
[Demote (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(f32.demote_f64)))]
[Promote (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(f64.promote_f32)))]
[ReinterpretIntThirtyTwo (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(f32.reinterpret_i32)))]
[ReinterpretIntSixtyFour (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(f64.reinterpret_i32)))]
[ReinterpretFloatThirtyTwo (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(i32.reinterpret_f32)))]
[ReinterpretFloatSixtyFour (λ (n)
(append
'(FIXME)))]
($xsmith_render-node (ast-child 'expr n))
'(i64.reinterpret_i64)))]
)
;; Convenience function to get the type of the node
......@@ -673,8 +695,8 @@
(let ([node-type (get-base-type-name)])
(cond [(or (eq? node-type 'i32) (eq? node-type 'i64))
(if (ast-child 'sign node)
(format "~a~a" instruction '_s)
(format "~a~a" instruction '_u))]
(string->symbol (format "~a~a" instruction '_s))
(string->symbol (format "~a~a" instruction '_u)))]
[(or (eq? node-type 'f32) (eq? node-type 'f64))
instruction] ;; floats don't need any suffixes
[else
......
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