blob: 05443953e0f1140befe6406abb07210cacb2b1dc [file] [log] [blame]
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001// Copyright (c) 2015 The Khronos Group Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and/or associated documentation files (the
5// "Materials"), to deal in the Materials without restriction, including
6// without limitation the rights to use, copy, modify, merge, publish,
7// distribute, sublicense, and/or sell copies of the Materials, and to
8// permit persons to whom the Materials are furnished to do so, subject to
9// the following conditions:
10//
11// The above copyright notice and this permission notice shall be included
12// in all copies or substantial portions of the Materials.
13//
14// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
16// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
17// https://www.khronos.org/registry/
18//
19// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
26
27#ifndef _LIBSPIRV_UTIL_BINARY_H_
28#define _LIBSPIRV_UTIL_BINARY_H_
29
30#include <libspirv/libspirv.h>
David Netob5dc8fc2015-10-06 16:22:00 -040031#include "instruction.h"
David Neto78c3b432015-08-27 13:03:52 -040032#include "operand.h"
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010033#include "print.h"
34
35// Functions
36
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010037/// @brief Grab the header from the SPV module
38///
39/// @param[in] binary the binary module
40/// @param[in] endian the endianness of the module
41/// @param[out] pHeader the returned header
42///
43/// @return result code
44spv_result_t spvBinaryHeaderGet(const spv_binary binary,
45 const spv_endianness_t endian,
46 spv_header_t *pHeader);
47
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010048/// @brief Determine the type of the desired operand
49///
50/// @param[in] word the operand value
51/// @param[in] index the word index in the instruction
52/// @param[in] opcodeEntry table of specified Opcodes
53/// @param[in] operandTable table of specified operands
54/// @param[in,out] pOperandEntry the entry in the operand table
55///
56/// @return type returned
57spv_operand_type_t spvBinaryOperandInfo(const uint32_t word,
58 const uint16_t index,
59 const spv_opcode_desc opcodeEntry,
60 const spv_operand_table operandTable,
61 spv_operand_desc *pOperandEntry);
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010062#endif