Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1 | // 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 | #include <libspirv/libspirv.h> |
David Neto | db901b6 | 2015-10-27 16:14:40 -0400 | [diff] [blame] | 28 | #include "endian.h" |
David Neto | b5dc8fc | 2015-10-06 16:22:00 -0400 | [diff] [blame] | 29 | #include "instruction.h" |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 30 | #include "opcode.h" |
| 31 | |
| 32 | #include <assert.h> |
| 33 | #include <string.h> |
| 34 | |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 35 | namespace { |
| 36 | |
| 37 | // Descriptions of each opcode. Each entry describes the format of the |
| 38 | // instruction that follows a particular opcode. |
| 39 | // |
| 40 | // Most fields are initialized statically by including an automatically |
| 41 | // generated file. |
| 42 | // The operandTypes fields are initialized during spvOpcodeInitialize(). |
| 43 | // |
| 44 | // TODO(dneto): Some of the macros are quite unreadable. We could make |
| 45 | // good use of constexpr functions, but some compilers don't support that yet. |
| 46 | spv_opcode_desc_t opcodeTableEntries[] = { |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 47 | #define EmptyList \ |
| 48 | {} |
| 49 | #define List(...) \ |
| 50 | { __VA_ARGS__ } |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 51 | #define Capability(X) SPV_CAPABILITY_AS_MASK(SpvCapability##X) |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 52 | #define Capability2(X, Y) Capability(X) | Capability(Y) |
| 53 | #define SpvCapabilityNone \ |
| 54 | 0 // Needed so Capability(None) still expands to valid syntax. |
David Neto | 201caf7 | 2015-11-04 17:38:17 -0500 | [diff] [blame^] | 55 | #define Instruction(Name, HasResult, HasType, NumLogicalOperands, \ |
| 56 | NumCapabilities, CapabilityRequired, IsVariable, \ |
| 57 | LogicalArgsList) \ |
| 58 | {#Name, SpvOp##Name, (NumCapabilities) ? (CapabilityRequired) : 0, \ |
| 59 | 0, {}, /* Filled in later. Operand list, including \ |
| 60 | result id and type id, if needed */ \ |
| 61 | HasResult, HasType, LogicalArgsList}, |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 62 | #include "opcode.inc" |
| 63 | #undef EmptyList |
| 64 | #undef List |
| 65 | #undef Capability |
Dejan Mircevski | 205408b | 2015-09-30 16:42:34 -0400 | [diff] [blame] | 66 | #undef Capability2 |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 67 | #undef CapabilityNone |
| 68 | #undef Instruction |
| 69 | }; |
| 70 | |
| 71 | // Has the opcodeTableEntries table been fully elaborated? |
| 72 | // That is, are the operandTypes fields initialized? |
| 73 | bool opcodeTableInitialized = false; |
| 74 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 75 | // Opcode API |
| 76 | |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 77 | // Converts the given operand class enum (from the SPIR-V document generation |
| 78 | // logic) to the operand type required by the parser. |
| 79 | // This only applies to logical operands. |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 80 | spv_operand_type_t convertOperandClassToType(SpvOp opcode, |
| 81 | OperandClass operandClass) { |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 82 | // The spec document generator uses OptionalOperandLiteral for several kinds |
| 83 | // of repeating values. Our parser needs more specific information about |
| 84 | // what is being repeated. |
| 85 | if (operandClass == OperandOptionalLiteral) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 86 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 87 | case SpvOpLoad: |
| 88 | case SpvOpStore: |
| 89 | case SpvOpCopyMemory: |
| 90 | case SpvOpCopyMemorySized: |
David Neto | 3fca4cd | 2015-09-17 17:39:45 -0400 | [diff] [blame] | 91 | // Expect an optional mask. When the Aligned bit is set in the mask, |
| 92 | // we will later add the expectation of a literal number operand. |
| 93 | return SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS; |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 94 | case SpvOpExecutionMode: |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 95 | return SPV_OPERAND_TYPE_VARIABLE_EXECUTION_MODE; |
| 96 | default: |
| 97 | break; |
| 98 | } |
Lei Zhang | b41d150 | 2015-09-14 15:22:23 -0400 | [diff] [blame] | 99 | } else if (operandClass == OperandVariableLiterals) { |
David Neto | 201caf7 | 2015-11-04 17:38:17 -0500 | [diff] [blame^] | 100 | if (opcode == SpvOpConstant || opcode == SpvOpSpecConstant) { |
| 101 | // The number type is determined by the type Id operand. |
| 102 | return SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER; |
| 103 | } |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 104 | } |
| 105 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 106 | switch (operandClass) { |
| 107 | case OperandNone: |
| 108 | return SPV_OPERAND_TYPE_NONE; |
| 109 | case OperandId: |
| 110 | return SPV_OPERAND_TYPE_ID; |
| 111 | case OperandOptionalId: |
| 112 | return SPV_OPERAND_TYPE_OPTIONAL_ID; |
| 113 | case OperandOptionalImage: |
| 114 | return SPV_OPERAND_TYPE_OPTIONAL_IMAGE; |
| 115 | case OperandVariableIds: |
| 116 | return SPV_OPERAND_TYPE_VARIABLE_ID; |
David Neto | 561dc4e | 2015-09-25 14:23:29 -0400 | [diff] [blame] | 117 | // The spec only uses OptionalLiteral for an optional literal number. |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 118 | case OperandOptionalLiteral: |
| 119 | return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER; |
| 120 | case OperandOptionalLiteralString: |
| 121 | return SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING; |
David Neto | 561dc4e | 2015-09-25 14:23:29 -0400 | [diff] [blame] | 122 | // This is only used for sequences of literal numbers. |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 123 | case OperandVariableLiterals: |
| 124 | return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER; |
David Neto | 445ce44 | 2015-10-15 15:22:06 -0400 | [diff] [blame] | 125 | case OperandLiteralNumber: |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 126 | if (opcode == SpvOpExtInst) { |
David Neto | 445ce44 | 2015-10-15 15:22:06 -0400 | [diff] [blame] | 127 | // We use a special operand type for the extension instruction number. |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 128 | // For now, we assume there is only one LiteraNumber argument to |
| 129 | // OpExtInst, and it is the extension instruction argument. |
David Neto | 445ce44 | 2015-10-15 15:22:06 -0400 | [diff] [blame] | 130 | // See the ExtInst entry in opcode.inc |
| 131 | // TODO(dneto): Use a function to confirm the assumption, and to verify |
| 132 | // that the index into the operandClass is 1, as expected. |
| 133 | return SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER; |
| 134 | } |
| 135 | return SPV_OPERAND_TYPE_LITERAL_INTEGER; |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 136 | case OperandLiteralString: |
| 137 | return SPV_OPERAND_TYPE_LITERAL_STRING; |
| 138 | case OperandSource: |
| 139 | return SPV_OPERAND_TYPE_SOURCE_LANGUAGE; |
| 140 | case OperandExecutionModel: |
| 141 | return SPV_OPERAND_TYPE_EXECUTION_MODEL; |
| 142 | case OperandAddressing: |
| 143 | return SPV_OPERAND_TYPE_ADDRESSING_MODEL; |
| 144 | case OperandMemory: |
| 145 | return SPV_OPERAND_TYPE_MEMORY_MODEL; |
| 146 | case OperandExecutionMode: |
| 147 | return SPV_OPERAND_TYPE_EXECUTION_MODE; |
| 148 | case OperandStorage: |
| 149 | return SPV_OPERAND_TYPE_STORAGE_CLASS; |
| 150 | case OperandDimensionality: |
| 151 | return SPV_OPERAND_TYPE_DIMENSIONALITY; |
| 152 | case OperandSamplerAddressingMode: |
| 153 | return SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE; |
| 154 | case OperandSamplerFilterMode: |
| 155 | return SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE; |
| 156 | case OperandSamplerImageFormat: |
| 157 | return SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT; |
David Neto | 7cefb23 | 2015-09-28 15:33:49 -0400 | [diff] [blame] | 158 | case OperandImageChannelOrder: |
| 159 | // This is only used to describe the value generated by OpImageQueryOrder. |
| 160 | // It is not used as an operand. |
| 161 | break; |
| 162 | case OperandImageChannelDataType: |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 163 | // This is only used to describe the value generated by |
| 164 | // OpImageQueryFormat. It is not used as an operand. |
David Neto | 7cefb23 | 2015-09-28 15:33:49 -0400 | [diff] [blame] | 165 | break; |
| 166 | case OperandImageOperands: |
Dejan Mircevski | f8e091a | 2015-10-13 14:41:31 -0400 | [diff] [blame] | 167 | // This is not used in opcode.inc. It only exists to generate the |
| 168 | // corresponding spec section. In parsing, image operands meld into the |
| 169 | // OperandOptionalImage case. |
David Neto | 7cefb23 | 2015-09-28 15:33:49 -0400 | [diff] [blame] | 170 | break; |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 171 | case OperandFPFastMath: |
| 172 | return SPV_OPERAND_TYPE_FP_FAST_MATH_MODE; |
| 173 | case OperandFPRoundingMode: |
| 174 | return SPV_OPERAND_TYPE_FP_ROUNDING_MODE; |
| 175 | case OperandLinkageType: |
| 176 | return SPV_OPERAND_TYPE_LINKAGE_TYPE; |
| 177 | case OperandAccessQualifier: |
| 178 | return SPV_OPERAND_TYPE_ACCESS_QUALIFIER; |
| 179 | case OperandFuncParamAttr: |
| 180 | return SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE; |
| 181 | case OperandDecoration: |
| 182 | return SPV_OPERAND_TYPE_DECORATION; |
| 183 | case OperandBuiltIn: |
| 184 | return SPV_OPERAND_TYPE_BUILT_IN; |
| 185 | case OperandSelect: |
| 186 | return SPV_OPERAND_TYPE_SELECTION_CONTROL; |
| 187 | case OperandLoop: |
| 188 | return SPV_OPERAND_TYPE_LOOP_CONTROL; |
| 189 | case OperandFunction: |
| 190 | return SPV_OPERAND_TYPE_FUNCTION_CONTROL; |
| 191 | case OperandMemorySemantics: |
| 192 | return SPV_OPERAND_TYPE_MEMORY_SEMANTICS; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 193 | case OperandMemoryAccess: |
David Neto | 7cefb23 | 2015-09-28 15:33:49 -0400 | [diff] [blame] | 194 | // This case does not occur in the table for SPIR-V 0.99 Rev 32. |
David Neto | 3fca4cd | 2015-09-17 17:39:45 -0400 | [diff] [blame] | 195 | // We expect that it will become SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS, |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 196 | // and we can remove the special casing above for memory operation |
| 197 | // instructions. |
| 198 | break; |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 199 | case OperandScope: |
| 200 | return SPV_OPERAND_TYPE_EXECUTION_SCOPE; |
| 201 | case OperandGroupOperation: |
| 202 | return SPV_OPERAND_TYPE_GROUP_OPERATION; |
| 203 | case OperandKernelEnqueueFlags: |
| 204 | return SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS; |
| 205 | case OperandKernelProfilingInfo: |
| 206 | return SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO; |
| 207 | case OperandCapability: |
| 208 | return SPV_OPERAND_TYPE_CAPABILITY; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 209 | |
| 210 | // Used by GroupMemberDecorate |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 211 | case OperandVariableIdLiteral: |
| 212 | return SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 213 | |
| 214 | // Used by Switch |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 215 | case OperandVariableLiteralId: |
| 216 | return SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 217 | |
| 218 | // These exceptional cases shouldn't occur. |
| 219 | case OperandCount: |
| 220 | default: |
| 221 | break; |
| 222 | } |
| 223 | assert(0 && "Unexpected operand class"); |
| 224 | return SPV_OPERAND_TYPE_NONE; |
| 225 | } |
| 226 | |
Lei Zhang | a94701d | 2015-09-14 10:05:37 -0400 | [diff] [blame] | 227 | } // anonymous namespace |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 228 | |
| 229 | // Finish populating the opcodeTableEntries array. |
| 230 | void spvOpcodeTableInitialize() { |
| 231 | // Compute the operandTypes field for each entry. |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 232 | for (auto& opcode : opcodeTableEntries) { |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 233 | opcode.numTypes = 0; |
| 234 | // Type ID always comes first, if present. |
| 235 | if (opcode.hasType) |
Andrew Woloszyn | 537e776 | 2015-09-29 11:28:34 -0400 | [diff] [blame] | 236 | opcode.operandTypes[opcode.numTypes++] = SPV_OPERAND_TYPE_TYPE_ID; |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 237 | // Result ID always comes next, if present |
| 238 | if (opcode.hasResult) |
| 239 | opcode.operandTypes[opcode.numTypes++] = SPV_OPERAND_TYPE_RESULT_ID; |
Lei Zhang | a94701d | 2015-09-14 10:05:37 -0400 | [diff] [blame] | 240 | const uint16_t maxNumOperands = |
| 241 | sizeof(opcode.operandTypes) / sizeof(opcode.operandTypes[0]); |
| 242 | const uint16_t maxNumClasses = |
| 243 | sizeof(opcode.operandClass) / sizeof(opcode.operandClass[0]); |
| 244 | for (uint16_t classIndex = 0; |
| 245 | opcode.numTypes < maxNumOperands && classIndex < maxNumClasses; |
| 246 | classIndex++) { |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 247 | const OperandClass operandClass = opcode.operandClass[classIndex]; |
Lei Zhang | a94701d | 2015-09-14 10:05:37 -0400 | [diff] [blame] | 248 | opcode.operandTypes[opcode.numTypes++] = |
| 249 | convertOperandClassToType(opcode.opcode, operandClass); |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 250 | // The OperandNone value is not explicitly represented in the .inc file. |
| 251 | // However, it is the zero value, and is created via implicit value |
| 252 | // initialization. |
| 253 | if (operandClass == OperandNone) { |
| 254 | opcode.numTypes--; |
| 255 | break; |
| 256 | } |
| 257 | } |
| 258 | // We should have written the terminating SPV_OPERAND_TYPE_NONE entry, but |
| 259 | // also without overflowing. |
Lei Zhang | a94701d | 2015-09-14 10:05:37 -0400 | [diff] [blame] | 260 | assert((opcode.numTypes < maxNumOperands) && |
| 261 | "Operand class list is too long. Expand " |
| 262 | "spv_opcode_desc_t.operandClass"); |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 263 | } |
| 264 | opcodeTableInitialized = true; |
| 265 | } |
| 266 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 267 | const char* spvGeneratorStr(uint32_t generator) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 268 | switch (generator) { |
| 269 | case SPV_GENERATOR_KHRONOS: |
| 270 | return "Khronos"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 271 | case SPV_GENERATOR_LUNARG: |
| 272 | return "LunarG"; |
David Neto | 1780fc4 | 2015-10-26 15:43:12 -0400 | [diff] [blame] | 273 | case SPV_GENERATOR_VALVE: |
| 274 | return "Valve"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 275 | case SPV_GENERATOR_CODEPLAY: |
| 276 | return "Codeplay Software Ltd."; |
David Neto | 1780fc4 | 2015-10-26 15:43:12 -0400 | [diff] [blame] | 277 | case SPV_GENERATOR_NVIDIA: |
| 278 | return "NVIDIA"; |
| 279 | case SPV_GENERATOR_ARM: |
| 280 | return "ARM"; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 281 | default: |
| 282 | return "Unknown"; |
| 283 | } |
| 284 | } |
| 285 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 286 | uint32_t spvOpcodeMake(uint16_t wordCount, SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 287 | return ((uint32_t)opcode) | (((uint32_t)wordCount) << 16); |
| 288 | } |
| 289 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 290 | void spvOpcodeSplit(const uint32_t word, uint16_t* pWordCount, SpvOp* pOpcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 291 | if (pWordCount) { |
| 292 | *pWordCount = (uint16_t)((0xffff0000 & word) >> 16); |
| 293 | } |
| 294 | if (pOpcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 295 | *pOpcode = (SpvOp)(0x0000ffff & word); |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 299 | spv_result_t spvOpcodeTableGet(spv_opcode_table* pInstTable) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 300 | if (!pInstTable) return SPV_ERROR_INVALID_POINTER; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 301 | |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 302 | static spv_opcode_table_t table = { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 303 | sizeof(opcodeTableEntries) / sizeof(spv_opcode_desc_t), |
| 304 | opcodeTableEntries}; |
| 305 | |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 306 | // TODO(dneto): Consider thread safety of initialization. |
| 307 | // That is, ordering effects of the flag vs. the table updates. |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 308 | if (!opcodeTableInitialized) spvOpcodeTableInitialize(); |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 309 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 310 | *pInstTable = &table; |
| 311 | |
| 312 | return SPV_SUCCESS; |
| 313 | } |
| 314 | |
| 315 | spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table, |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 316 | const char* name, |
| 317 | spv_opcode_desc* pEntry) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 318 | if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER; |
| 319 | if (!table) return SPV_ERROR_INVALID_TABLE; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 320 | |
| 321 | // TODO: This lookup of the Opcode table is suboptimal! Binary sort would be |
| 322 | // preferable but the table requires sorting on the Opcode name, but it's |
| 323 | // static |
| 324 | // const initialized and matches the order of the spec. |
| 325 | const size_t nameLength = strlen(name); |
| 326 | for (uint64_t opcodeIndex = 0; opcodeIndex < table->count; ++opcodeIndex) { |
| 327 | if (nameLength == strlen(table->entries[opcodeIndex].name) && |
| 328 | !strncmp(name, table->entries[opcodeIndex].name, nameLength)) { |
| 329 | // NOTE: Found out Opcode! |
| 330 | *pEntry = &table->entries[opcodeIndex]; |
| 331 | return SPV_SUCCESS; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | return SPV_ERROR_INVALID_LOOKUP; |
| 336 | } |
| 337 | |
| 338 | spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table, |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 339 | const SpvOp opcode, |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 340 | spv_opcode_desc* pEntry) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 341 | if (!table) return SPV_ERROR_INVALID_TABLE; |
| 342 | if (!pEntry) return SPV_ERROR_INVALID_POINTER; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 343 | |
| 344 | // TODO: As above this lookup is not optimal. |
| 345 | for (uint64_t opcodeIndex = 0; opcodeIndex < table->count; ++opcodeIndex) { |
| 346 | if (opcode == table->entries[opcodeIndex].opcode) { |
| 347 | // NOTE: Found the Opcode! |
| 348 | *pEntry = &table->entries[opcodeIndex]; |
| 349 | return SPV_SUCCESS; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return SPV_ERROR_INVALID_LOOKUP; |
| 354 | } |
| 355 | |
Lei Zhang | dfc5008 | 2015-08-21 11:50:55 -0400 | [diff] [blame] | 356 | int16_t spvOpcodeResultIdIndex(spv_opcode_desc entry) { |
David Neto | 78c3b43 | 2015-08-27 13:03:52 -0400 | [diff] [blame] | 357 | for (int16_t i = 0; i < entry->numTypes; ++i) { |
Lei Zhang | dfc5008 | 2015-08-21 11:50:55 -0400 | [diff] [blame] | 358 | if (SPV_OPERAND_TYPE_RESULT_ID == entry->operandTypes[i]) return i; |
| 359 | } |
| 360 | return SPV_OPERAND_INVALID_RESULT_ID_INDEX; |
| 361 | } |
| 362 | |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 363 | int32_t spvOpcodeRequiresCapabilities(spv_opcode_desc entry) { |
David Neto | 9db3a53 | 2015-10-07 16:58:38 -0400 | [diff] [blame] | 364 | return entry->capabilities != 0; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 365 | } |
| 366 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 367 | void spvInstructionCopy(const uint32_t* words, const SpvOp opcode, |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 368 | const uint16_t wordCount, const spv_endianness_t endian, |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 369 | spv_instruction_t* pInst) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 370 | pInst->opcode = opcode; |
David Neto | b5dc8fc | 2015-10-06 16:22:00 -0400 | [diff] [blame] | 371 | pInst->words.resize(wordCount); |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 372 | for (uint16_t wordIndex = 0; wordIndex < wordCount; ++wordIndex) { |
| 373 | pInst->words[wordIndex] = spvFixWord(words[wordIndex], endian); |
| 374 | if (!wordIndex) { |
| 375 | uint16_t thisWordCount; |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 376 | SpvOp thisOpcode; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 377 | spvOpcodeSplit(pInst->words[wordIndex], &thisWordCount, &thisOpcode); |
| 378 | assert(opcode == thisOpcode && wordCount == thisWordCount && |
| 379 | "Endianness failed!"); |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 384 | const char* spvOpcodeString(const SpvOp opcode) { |
David Neto | 201caf7 | 2015-11-04 17:38:17 -0500 | [diff] [blame^] | 385 | // Use the syntax table so it's sure to be complete. |
David Neto | 1bcd3d1 | 2015-11-02 16:03:12 -0500 | [diff] [blame] | 386 | #define Instruction(Name, ...) \ |
| 387 | case SpvOp##Name: \ |
| 388 | return #Name; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 389 | switch (opcode) { |
David Neto | 1bcd3d1 | 2015-11-02 16:03:12 -0500 | [diff] [blame] | 390 | #include "opcode.inc" |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 391 | default: |
| 392 | assert(0 && "Unreachable!"); |
| 393 | } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 394 | return "unknown"; |
David Neto | 1bcd3d1 | 2015-11-02 16:03:12 -0500 | [diff] [blame] | 395 | #undef Instruction |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 396 | } |
| 397 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 398 | int32_t spvOpcodeIsScalarType(const SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 399 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 400 | case SpvOpTypeInt: |
| 401 | case SpvOpTypeFloat: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 402 | return true; |
| 403 | default: |
| 404 | return false; |
| 405 | } |
| 406 | } |
| 407 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 408 | int32_t spvOpcodeIsConstant(const SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 409 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 410 | case SpvOpConstantTrue: |
| 411 | case SpvOpConstantFalse: |
| 412 | case SpvOpConstant: |
| 413 | case SpvOpConstantComposite: |
| 414 | case SpvOpConstantSampler: |
| 415 | // case SpvOpConstantNull: |
| 416 | case SpvOpConstantNull: |
| 417 | case SpvOpSpecConstantTrue: |
| 418 | case SpvOpSpecConstantFalse: |
| 419 | case SpvOpSpecConstant: |
| 420 | case SpvOpSpecConstantComposite: |
| 421 | // case SpvOpSpecConstantOp: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 422 | return true; |
| 423 | default: |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 428 | int32_t spvOpcodeIsComposite(const SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 429 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 430 | case SpvOpTypeVector: |
| 431 | case SpvOpTypeMatrix: |
| 432 | case SpvOpTypeArray: |
| 433 | case SpvOpTypeStruct: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 434 | return true; |
| 435 | default: |
| 436 | return false; |
| 437 | } |
| 438 | } |
| 439 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 440 | int32_t spvOpcodeAreTypesEqual(const spv_instruction_t* pTypeInst0, |
| 441 | const spv_instruction_t* pTypeInst1) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 442 | if (pTypeInst0->opcode != pTypeInst1->opcode) return false; |
| 443 | if (pTypeInst0->words[1] != pTypeInst1->words[1]) return false; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 444 | return true; |
| 445 | } |
| 446 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 447 | int32_t spvOpcodeIsPointer(const SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 448 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 449 | case SpvOpVariable: |
| 450 | case SpvOpAccessChain: |
| 451 | case SpvOpInBoundsAccessChain: |
| 452 | case SpvOpFunctionParameter: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 453 | return true; |
| 454 | default: |
| 455 | return false; |
| 456 | } |
| 457 | } |
| 458 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 459 | int32_t spvOpcodeIsObject(const SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 460 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 461 | case SpvOpConstantTrue: |
| 462 | case SpvOpConstantFalse: |
| 463 | case SpvOpConstant: |
| 464 | case SpvOpConstantComposite: |
| 465 | // TODO: case SpvOpConstantSampler: |
| 466 | case SpvOpConstantNull: |
| 467 | case SpvOpSpecConstantTrue: |
| 468 | case SpvOpSpecConstantFalse: |
| 469 | case SpvOpSpecConstant: |
| 470 | case SpvOpSpecConstantComposite: |
| 471 | // TODO: case SpvOpSpecConstantOp: |
| 472 | case SpvOpVariable: |
| 473 | case SpvOpAccessChain: |
| 474 | case SpvOpInBoundsAccessChain: |
| 475 | case SpvOpConvertFToU: |
| 476 | case SpvOpConvertFToS: |
| 477 | case SpvOpConvertSToF: |
| 478 | case SpvOpConvertUToF: |
| 479 | case SpvOpUConvert: |
| 480 | case SpvOpSConvert: |
| 481 | case SpvOpFConvert: |
| 482 | case SpvOpConvertPtrToU: |
| 483 | // TODO: case SpvOpConvertUToPtr: |
| 484 | case SpvOpPtrCastToGeneric: |
| 485 | // TODO: case SpvOpGenericCastToPtr: |
| 486 | case SpvOpBitcast: |
| 487 | // TODO: case SpvOpGenericCastToPtrExplicit: |
| 488 | case SpvOpSatConvertSToU: |
| 489 | case SpvOpSatConvertUToS: |
| 490 | case SpvOpVectorExtractDynamic: |
| 491 | case SpvOpCompositeConstruct: |
| 492 | case SpvOpCompositeExtract: |
| 493 | case SpvOpCopyObject: |
| 494 | case SpvOpTranspose: |
| 495 | case SpvOpSNegate: |
| 496 | case SpvOpFNegate: |
| 497 | case SpvOpNot: |
| 498 | case SpvOpIAdd: |
| 499 | case SpvOpFAdd: |
| 500 | case SpvOpISub: |
| 501 | case SpvOpFSub: |
| 502 | case SpvOpIMul: |
| 503 | case SpvOpFMul: |
| 504 | case SpvOpUDiv: |
| 505 | case SpvOpSDiv: |
| 506 | case SpvOpFDiv: |
| 507 | case SpvOpUMod: |
| 508 | case SpvOpSRem: |
| 509 | case SpvOpSMod: |
| 510 | case SpvOpVectorTimesScalar: |
| 511 | case SpvOpMatrixTimesScalar: |
| 512 | case SpvOpVectorTimesMatrix: |
| 513 | case SpvOpMatrixTimesVector: |
| 514 | case SpvOpMatrixTimesMatrix: |
| 515 | case SpvOpOuterProduct: |
| 516 | case SpvOpDot: |
| 517 | case SpvOpShiftRightLogical: |
| 518 | case SpvOpShiftRightArithmetic: |
| 519 | case SpvOpShiftLeftLogical: |
| 520 | case SpvOpBitwiseOr: |
| 521 | case SpvOpBitwiseXor: |
| 522 | case SpvOpBitwiseAnd: |
| 523 | case SpvOpAny: |
| 524 | case SpvOpAll: |
| 525 | case SpvOpIsNan: |
| 526 | case SpvOpIsInf: |
| 527 | case SpvOpIsFinite: |
| 528 | case SpvOpIsNormal: |
| 529 | case SpvOpSignBitSet: |
| 530 | case SpvOpLessOrGreater: |
| 531 | case SpvOpOrdered: |
| 532 | case SpvOpUnordered: |
| 533 | case SpvOpLogicalOr: |
| 534 | case SpvOpLogicalAnd: |
| 535 | case SpvOpSelect: |
| 536 | case SpvOpIEqual: |
| 537 | case SpvOpFOrdEqual: |
| 538 | case SpvOpFUnordEqual: |
| 539 | case SpvOpINotEqual: |
| 540 | case SpvOpFOrdNotEqual: |
| 541 | case SpvOpFUnordNotEqual: |
| 542 | case SpvOpULessThan: |
| 543 | case SpvOpSLessThan: |
| 544 | case SpvOpFOrdLessThan: |
| 545 | case SpvOpFUnordLessThan: |
| 546 | case SpvOpUGreaterThan: |
| 547 | case SpvOpSGreaterThan: |
| 548 | case SpvOpFOrdGreaterThan: |
| 549 | case SpvOpFUnordGreaterThan: |
| 550 | case SpvOpULessThanEqual: |
| 551 | case SpvOpSLessThanEqual: |
| 552 | case SpvOpFOrdLessThanEqual: |
| 553 | case SpvOpFUnordLessThanEqual: |
| 554 | case SpvOpUGreaterThanEqual: |
| 555 | case SpvOpSGreaterThanEqual: |
| 556 | case SpvOpFOrdGreaterThanEqual: |
| 557 | case SpvOpFUnordGreaterThanEqual: |
| 558 | case SpvOpDPdx: |
| 559 | case SpvOpDPdy: |
| 560 | case SpvOpFwidth: |
| 561 | case SpvOpDPdxFine: |
| 562 | case SpvOpDPdyFine: |
| 563 | case SpvOpFwidthFine: |
| 564 | case SpvOpDPdxCoarse: |
| 565 | case SpvOpDPdyCoarse: |
| 566 | case SpvOpFwidthCoarse: |
| 567 | case SpvOpReturnValue: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 568 | return true; |
| 569 | default: |
| 570 | return false; |
| 571 | } |
| 572 | } |
| 573 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 574 | int32_t spvOpcodeIsBasicTypeNullable(SpvOp opcode) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 575 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 576 | case SpvOpTypeBool: |
| 577 | case SpvOpTypeInt: |
| 578 | case SpvOpTypeFloat: |
| 579 | case SpvOpTypePointer: |
| 580 | case SpvOpTypeEvent: |
| 581 | case SpvOpTypeDeviceEvent: |
| 582 | case SpvOpTypeReserveId: |
| 583 | case SpvOpTypeQueue: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 584 | return true; |
| 585 | default: |
| 586 | return false; |
| 587 | } |
| 588 | } |
| 589 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 590 | int32_t spvInstructionIsInBasicBlock(const spv_instruction_t* pFirstInst, |
| 591 | const spv_instruction_t* pInst) { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 592 | while (pFirstInst != pInst) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 593 | if (SpvOpFunction == pInst->opcode) break; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 594 | pInst--; |
| 595 | } |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 596 | if (SpvOpFunction != pInst->opcode) return false; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 597 | return true; |
| 598 | } |
| 599 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 600 | int32_t spvOpcodeIsValue(SpvOp opcode) { |
Lei Zhang | 4005670 | 2015-09-11 14:31:27 -0400 | [diff] [blame] | 601 | if (spvOpcodeIsPointer(opcode)) return true; |
| 602 | if (spvOpcodeIsConstant(opcode)) return true; |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 603 | switch (opcode) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 604 | case SpvOpLoad: |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 605 | // TODO: Other Opcode's resulting in a value |
| 606 | return true; |
| 607 | default: |
| 608 | return false; |
| 609 | } |
| 610 | } |
Andrew Woloszyn | 537e776 | 2015-09-29 11:28:34 -0400 | [diff] [blame] | 611 | |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 612 | int32_t spvOpcodeGeneratesType(SpvOp op) { |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 613 | switch (op) { |
Lei Zhang | b36e704 | 2015-10-28 13:40:52 -0400 | [diff] [blame] | 614 | case SpvOpTypeVoid: |
| 615 | case SpvOpTypeBool: |
| 616 | case SpvOpTypeInt: |
| 617 | case SpvOpTypeFloat: |
| 618 | case SpvOpTypeVector: |
| 619 | case SpvOpTypeMatrix: |
| 620 | case SpvOpTypeImage: |
| 621 | case SpvOpTypeSampler: |
| 622 | case SpvOpTypeSampledImage: |
| 623 | case SpvOpTypeArray: |
| 624 | case SpvOpTypeRuntimeArray: |
| 625 | case SpvOpTypeStruct: |
| 626 | case SpvOpTypeOpaque: |
| 627 | case SpvOpTypePointer: |
| 628 | case SpvOpTypeFunction: |
| 629 | case SpvOpTypeEvent: |
| 630 | case SpvOpTypeDeviceEvent: |
| 631 | case SpvOpTypeReserveId: |
| 632 | case SpvOpTypeQueue: |
| 633 | case SpvOpTypePipe: |
Andrew Woloszyn | 537e776 | 2015-09-29 11:28:34 -0400 | [diff] [blame] | 634 | return true; |
David Neto | aef608c | 2015-11-02 14:59:02 -0500 | [diff] [blame] | 635 | default: |
| 636 | // In particular, OpTypeForwardPointer does not generate a type, |
| 637 | // but declares a storage class for a pointer type generated |
| 638 | // by a different instruction. |
| 639 | break; |
Andrew Woloszyn | 537e776 | 2015-09-29 11:28:34 -0400 | [diff] [blame] | 640 | } |
| 641 | return 0; |
| 642 | } |