Skip to content

Commit 58f8f7d

Browse files
committed
Add alternatives
1 parent ec46355 commit 58f8f7d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

proposals/NNNN-inline-spirv-function-attributes.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,33 @@ HLSL Attribute | Applicab
6767
`vk::ext_literal` | Parameters of functions with `vk::ext_instruction` | `"spv.literal"` | The parameter is encoded as a literal in the SPIR-V instruction instead of generating an `OpConstant`.
6868
`vk::ext_reference` | Parameters of functions with `vk::ext_instruction` | N/A (handled in Clang) | The parameter's type is modified to a reference type in the Clang AST. (Address space handling needs further investigation.)
6969

70+
TODO: Discuss optimizations.
71+
7072
## Detailed design
7173

7274
## Alternatives considered (Optional)
7375

76+
When implementing the extension and capability attributes, they could be
77+
represented as a target type: `target("spv.capability", <capability>)` and
78+
`target("spv.extension.<name>")`. We could then have some way of add these as
79+
extra parameter to the function. This is not a desirable solution for functions
80+
because it is less straight forward. The llvm-ir will be harder to read, and the
81+
code to generate the function will contain code that does not follow common code
82+
patterns.
83+
84+
Another alternative is to add metadata nodes that contain this information. The
85+
OpenCL FE uses metadata to pass information to the SPIR-V backend. One example
86+
is the `spirv.Decorations` metadata nodes to adding decorations to values. We
87+
chose not to use metadata because metadata is supposed to "convey extra
88+
information about the code to the optimizers and code generator." However, these
89+
attributes do not represent extra information. Instead, they are information
90+
necessary for the code-generator to generate correct code. The information
91+
cannot be dropped.
92+
93+
Extensions and capabilities are module level information. It would be possible
94+
to encode them as named metadata attached to the module, which cannot be
95+
dropped. That could work, but we want to retain the connection between the
96+
extensions and capabilities with the function or type so that the backend can
97+
avoid generating them if the function or type is unused.
98+
7499
<!-- {% endraw %} -->

0 commit comments

Comments
 (0)