You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/NNNN-inline-spirv-function-attributes.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,8 +67,33 @@ HLSL Attribute | Applicab
67
67
`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`.
68
68
`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.)
69
69
70
+
TODO: Discuss optimizations.
71
+
70
72
## Detailed design
71
73
72
74
## Alternatives considered (Optional)
73
75
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.
0 commit comments