-
Notifications
You must be signed in to change notification settings - Fork 7
Special Forms
This page describes special forms supported by the GPU code translator.
- let
- let*
These forms are fully supported. Types of variables without explicit type declarations are inferred from their initialization forms. The NIL constant is allowed as an initialization form for variables of any type; for types other than boolean it denotes lack of any initialization.
Special variable bindings are implemented by transforming them into normal lexical variables after function inlining. Likewise, referenced specials without local bindings are converted to hidden kernel parameters. This is transparent except for the fact that assignments don’t propagate out of kernel invocations, and are not visible to other GPU threads.
- setq
Supported.
- setf
Supported a as special form; allows some built-in functions as an assignment target.
(setf (values ...) ...)is transformed to multiple-value-setq.
- macrolet
- symbol-macrolet
Fully supported.
- flet
- labels
- lambda
Supported via complete and unconditional inlining. Since hardware GPU threads don’t have stacks, the C compiler works this way too.
Keyword arguments are supported, provided that the keywords are specified directly as constants in the function calls. Recursion is not allowed.
- function
Since funcall and apply are not implemented, it is useless at the moment.
- values
Supported as a special form. Arguments are guaranteed to evaluate in standard order.
- multiple-value-setq
Supported as a special form; only allows simple variables as lvalues.
- multiple-value-bind
Supported as a special form. Since all variables must have a definite type, the value expression must explicitly provide values for all listed variables.
- multiple-value-call
Supported in the simplest form where the function is a lambda and there is only one argument, via transformation to multiple-value-bind.
- multiple-value-prog1
Supported.
- if
Supported. The condition expression must return a boolean value.
- progn
- block
- return-from
- tagbody
- go
Supported.
- catch
- throw
Supported for constant tag argumens via transformation to block & return-from after function inlining.
- locally
Supported.
- the
Supported. Unlike the standard lisp behavior, ‘the’ forces a cast to the resulting type.
- cast
A new special form. Has the same syntax and behavior as the, but makes the intention more explicit (cast also never warns about conversions that might lose precision).
- type
- special
- optimize
- gpu-optimize
Similar to optimize. Guaranteed to override it if specifies at the same level. Allows some gpu-specific properties.
- load-time-value
- eval-when
- unwind-protect
Not implemented due to the lack of obvious use cases in GPU code.
- progv
Cannot be supported because special bindings are statically transformed to lexicals.