-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to preserve all function metadata and attributes from LLV…
…M-IR Initial implementation of function metadata and attribute preservation In Intel's SYCL compiler, we have a use case where we need to convert to SPIR-V and then back to LLVM-IR and preserve all function metadata and attributes. The metadata and attributes we need to preserve have no value outside an internal stage of Intel's SYCL compiler and are not good fits for SPIR-V extensions. The list of what is needed is very volatile as well. To implement generic support in the translator, the general approach is to use SPV_KHR_non_semantic_info to add a new nonsemantic EIS, named NonSemantic.AuxData This new instruction set has two instructions: NonSemanticAuxDataFunctionMetadata and NonSemanticAuxDataFunctionAttribute Both instructions will be placed outside of the function CFG and take in what function to target as an operand, similar to debuginfo. We do this to support function declarations. The operands after the function to target are either strings or values describing the metadata or attribute. Specific information can be found in the SPIRVWriter.cpp changes. I also added a new option, --spirv-preserve-auxdata to preserve these. If a flag is passed for translation to SPIR-V the respective information will be preserved as described above. The flag is also required for reverse translation. If it not provided, it will be dropped as allowed in the spec. In order to handle the case of some metadata/attributes being handled manually (maybe we have metadata "foo=bar" in LLVM-IR, but we translate to "foo=oof" for some reason in SPIR-V (and thus reverse translation)), we process these new instructions very late in reverse translation, and if the metadata or attribute already exists, we skip it. Signed-off-by: Sarnie, Nick <[email protected]>
- Loading branch information
Showing
16 changed files
with
339 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
** Copyright (c) 2023 The Khronos Group Inc. | ||
** | ||
** Permission is hereby granted, free of charge, to any person obtaining a copy | ||
** of this software and/or associated documentation files (the "Materials"), | ||
** to deal in the Materials without restriction, including without limitation | ||
** the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
** and/or sell copies of the Materials, and to permit persons to whom the | ||
** Materials are furnished to do so, subject to the following conditions: | ||
** | ||
** The above copyright notice and this permission notice shall be included in | ||
** all copies or substantial portions of the Materials. | ||
** | ||
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS | ||
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND | ||
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ | ||
** | ||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS | ||
** IN THE MATERIALS. | ||
*/ | ||
|
||
namespace NonSemanticAuxData { | ||
enum Instruction { | ||
FunctionMetadata = 0, | ||
FunctionAttribute = 1, | ||
PreserveCount = 2 | ||
}; | ||
} // namespace NonSemanticAuxData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.