Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xsmith
WebAssembly Sandbox
Commits
7e76e749
Commit
7e76e749
authored
Jun 01, 2020
by
Guy Watson
Browse files
Add a more concise type prefix function to the renderer
parent
dbc6701c
Changes
1
Hide whitespace changes
Inline
Side-by-side
wasmlike/wasmlike.rkt
View file @
7e76e749
...
...
@@ -383,14 +383,20 @@
(
let
([
type
(
att-value
'xsmith_type
n
)])
(
if
(
concrete-type?
type
)
(
base-type-name
(
concretize-type
type
))
(
eprintf
"Non-concrete type encountered in renderer"
))))
(
begin
(
eprintf
(
format
"Non-concrete type encountered in renderer\n"
))
(
eprintf
(
format
"Node: ~a Types: ~a\n\n"
(
node-type
n
)
(
att-value
'xsmith_type
n
)))
'NON-CONCRETE
))))
;;Combines symbols: useful for printing things like 'i32.add'
(
define
(
combine-symbols
a
b
)
(
let*
([
a-string
(
symbol->string
a
)]
[
b-string
(
symbol->string
b
)])
(
string->symbol
(
format
"~a~a"
a-string
b-string
))))
;; Combines an node's base type and a given string. Returns a symbol.
;; This is useful for constructing symbols like i32.add
;; Usage: (prefix-type <some node> ".add")
;; Return: 'i32.add
(
define
(
prefix-type
node
instruction
)
(
let
([
type
(
get-base-type-name
node
)])
(
string->symbol
(
format
"~a~a"
type
instruction
))))
(
add-prop
wasm-like
...
...
@@ -490,18 +496,14 @@
(
append
(
$xsmith_render-node
(
ast-child
'address
n
))
(
$xsmith_render-node
(
ast-child
'value
n
))
`
(
,
(
combine-symbols
(
get-base-type-name
n
)
'.
store
)
`
(
,
(
prefix-type
n
'.
store
)
,
(
string->symbol
(
format
"offset=~a"
(
ast-child
'offset
n
)))
,
(
string->symbol
(
format
"align=~a"
(
expt
2
(
ast-child
'alignment
n
)))))
(
$xsmith_render-node
(
ast-child
'expr
n
))))]
[
MemLoad
(
λ
(
n
)
(
append
(
$xsmith_render-node
(
ast-child
'address
n
))
`
(
,
(
combine-symbols
(
get-base-type-name
n
)
'.
load
)
`
(
,
(
prefix-type
n
'.
load
)
,
(
string->symbol
(
format
"offset=~a"
(
ast-child
'offset
n
)))
,
(
string->symbol
(
format
"align=~a"
(
expt
2
(
ast-child
'alignment
n
)))))))]
[
LocalGet
(
λ
(
n
)
...
...
@@ -569,35 +571,35 @@
(
add-att-rule
wasm-like
math-op
[
Equal
(
λ
(
n
)
(
combine-symbols
(
get-base-type-name
)
'.
eq
))]
[
NotEqual
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
ne
))]
[
EqualZero
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
eqz
))]
[
Addition
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
add
))]
[
Subtraction
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
sub
))]
[
Multiplication
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
mul
))]
[
DivisionSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
div_s
))]
[
DivisionUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
div_u
))]
[
LessThanSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
lt_s
))]
[
LessThanUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
lt_u
))]
[
GreaterThanSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
gt_s
))]
[
GreaterThanUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
gt_u
))]
[
LessThanOrEqualSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
le_s
))]
[
LessThanOrEqualUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
le_u
))]
[
GreaterThanOrEqualSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
ge_s
))]
[
GreaterThanOrEqualUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
ge_u
))]
[
CountLeadingZero
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
clz
))]
[
CountTrailingZero
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
ctz
))]
[
NonZeroBits
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
popcnt
))]
[
RemainderSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
rem_s
))]
[
RemainderUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
rem_u
))]
[
And
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
and
))]
[
Or
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
or
))]
[
Xor
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
xor
))]
[
ShiftLeft
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
shl
))]
[
ShiftRightSigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
shr_s
))]
[
ShiftRightUnsigned
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
shr_u
))]
[
RotateLeft
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
rotl
))]
[
RotateRight
(
λ
(
n
)
(
combine-symbols
(
get-base-type-nam
e
n
)
'.
rotr
))]
[
Equal
(
λ
(
n
)
(
prefix-type
n
'.
eq
))]
[
NotEqual
(
λ
(
n
)
(
prefix-typ
e
n
'.
ne
))]
[
EqualZero
(
λ
(
n
)
(
prefix-typ
e
n
'.
eqz
))]
[
Addition
(
λ
(
n
)
(
prefix-typ
e
n
'.
add
))]
[
Subtraction
(
λ
(
n
)
(
prefix-typ
e
n
'.
sub
))]
[
Multiplication
(
λ
(
n
)
(
prefix-typ
e
n
'.
mul
))]
[
DivisionSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
div_s
))]
[
DivisionUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
div_u
))]
[
LessThanSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
lt_s
))]
[
LessThanUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
lt_u
))]
[
GreaterThanSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
gt_s
))]
[
GreaterThanUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
gt_u
))]
[
LessThanOrEqualSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
le_s
))]
[
LessThanOrEqualUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
le_u
))]
[
GreaterThanOrEqualSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
ge_s
))]
[
GreaterThanOrEqualUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
ge_u
))]
[
CountLeadingZero
(
λ
(
n
)
(
prefix-typ
e
n
'.
clz
))]
[
CountTrailingZero
(
λ
(
n
)
(
prefix-typ
e
n
'.
ctz
))]
[
NonZeroBits
(
λ
(
n
)
(
prefix-typ
e
n
'.
popcnt
))]
[
RemainderSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
rem_s
))]
[
RemainderUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
rem_u
))]
[
And
(
λ
(
n
)
(
prefix-typ
e
n
'.
and
))]
[
Or
(
λ
(
n
)
(
prefix-typ
e
n
'.
or
))]
[
Xor
(
λ
(
n
)
(
prefix-typ
e
n
'.
xor
))]
[
ShiftLeft
(
λ
(
n
)
(
prefix-typ
e
n
'.
shl
))]
[
ShiftRightSigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
shr_s
))]
[
ShiftRightUnsigned
(
λ
(
n
)
(
prefix-typ
e
n
'.
shr_u
))]
[
RotateLeft
(
λ
(
n
)
(
prefix-typ
e
n
'.
rotl
))]
[
RotateRight
(
λ
(
n
)
(
prefix-typ
e
n
'.
rotr
))]
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment