Lines Matching refs:binary
131 """Provides methods for verifying preamble for a SPIR-V binary."""
133 def verify_binary_length_and_header(self, binary, spv_version=0x10000):
134 """Checks that the given SPIR-V binary has valid length and header.
140 binary: a bytes object containing the SPIR-V binary
145 def read_word(binary, index, little_endian):
146 """Reads the index-th word from the given binary file."""
147 word = binary[index * 4:(index + 1) * 4]
152 def check_endianness(binary):
153 """Checks the endianness of the given SPIR-V binary.
159 first_word = read_word(binary, 0, True)
162 first_word = read_word(binary, 0, False)
167 num_bytes = len(binary)
169 return False, ('Incorrect SPV binary: size should be a multiple'
172 return False, 'Incorrect SPV binary: size less than 5 words'
174 preamble = binary[0:19]
178 return False, 'Incorrect SPV binary: wrong magic number'
186 return False, 'Incorrect SPV binary: wrong version number: ' + hex(version) + ' expected ' + hex(spv_version)
191 return False, ('Incorrect SPV binary: wrong generator magic ' 'number')
194 return False, 'Incorrect SPV binary: the 5th byte should be 0'
205 """Checks that the given SPIR-V binary file has correct preamble."""
217 binary = bytes(object_file.read())
218 return self.verify_binary_length_and_header(binary, spv_version)