binary.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) 2015-2016 The Khronos Group Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef SOURCE_BINARY_H_
  15. #define SOURCE_BINARY_H_
  16. #include <string>
  17. #include "source/spirv_definition.h"
  18. #include "spirv-tools/libspirv.h"
  19. // Functions
  20. // Grabs the header from the SPIR-V module given in the binary parameter. The
  21. // endian parameter specifies the endianness of the binary module. On success,
  22. // returns SPV_SUCCESS and writes the parsed header into *header.
  23. spv_result_t spvBinaryHeaderGet(const spv_const_binary binary,
  24. const spv_endianness_t endian,
  25. spv_header_t* header);
  26. // Returns the number of non-null characters in str before the first null
  27. // character, or strsz if there is no null character. Examines at most the
  28. // first strsz characters in str. Returns 0 if str is nullptr. This is a
  29. // replacement for C11's strnlen_s which might not exist in all environments.
  30. size_t spv_strnlen_s(const char* str, size_t strsz);
  31. // Decode the string literal operand with index operand_index from instruction
  32. // inst.
  33. std::string spvDecodeLiteralStringOperand(const spv_parsed_instruction_t& inst,
  34. const uint16_t operand_index);
  35. #endif // SOURCE_BINARY_H_