return ((uint32_t) v) << start;
}
+static inline uint32_t
+__gen_padded(uint32_t v, uint32_t start, uint32_t end)
+{
+ unsigned shift = __builtin_ctz(v);
+ unsigned odd = v >> (shift + 1);
+
+#ifndef NDEBUG
+ assert((v >> shift) & 1);
+ assert(shift <= 31);
+ assert(odd <= 7);
+ assert((end - start + 1) == 8);
+#endif
+
+ return __gen_uint(shift | (odd << 5), start, end);
+}
+
+
static inline uint64_t
__gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
{
return (val << (64 - size)) >> (64 - size);
}
+static inline uint64_t
+__gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
+{
+ unsigned val = __gen_unpack_uint(cl, start, end);
+ unsigned shift = val & 0b11111;
+ unsigned odd = val >> 5;
+
+ return (2*odd + 1) << shift;
+}
+
#define pan_pack(dst, T, name) \
for (struct MALI_ ## T name = { MALI_ ## T ## _header }, \
*_loop_terminate = (void *) (dst); \
type = 'uint64_t'
elif self.type == 'int':
type = 'int32_t'
- elif self.type == 'uint':
+ elif self.type in ['uint', 'padded']:
type = 'uint32_t'
elif self.type in self.parser.structs:
type = 'struct ' + self.parser.gen_prefix(safe_name(self.type.upper()))
if field.type == "uint" or field.type == "address":
s = "__gen_uint(%s, %d, %d)" % \
(value, start, end)
+ elif field.type == "padded":
+ s = "__gen_padded(%s, %d, %d)" % \
+ (value, start, end)
elif field.type in self.parser.enums:
s = "__gen_uint(%s, %d, %d)" % \
(value, start, end)
convert = "__gen_unpack_uint"
elif field.type == "int":
convert = "__gen_unpack_sint"
+ elif field.type == "padded":
+ convert = "__gen_unpack_padded"
elif field.type == "bool":
convert = "__gen_unpack_uint"
elif field.type == "float":