+static bool
+vtn_get_mem_operands(struct vtn_builder *b, const uint32_t *w, unsigned count,
+ unsigned *idx, SpvMemoryAccessMask *access, unsigned *alignment,
+ SpvScope *dest_scope, SpvScope *src_scope)
+{
+ *access = 0;
+ *alignment = 0;
+ if (*idx >= count)
+ return false;
+
+ *access = w[(*idx)++];
+ if (*access & SpvMemoryAccessAlignedMask) {
+ vtn_assert(*idx < count);
+ *alignment = w[(*idx)++];
+ }
+
+ if (*access & SpvMemoryAccessMakePointerAvailableMask) {
+ vtn_assert(*idx < count);
+ vtn_assert(dest_scope);
+ *dest_scope = vtn_constant_uint(b, w[(*idx)++]);
+ }
+
+ if (*access & SpvMemoryAccessMakePointerVisibleMask) {
+ vtn_assert(*idx < count);
+ vtn_assert(src_scope);
+ *src_scope = vtn_constant_uint(b, w[(*idx)++]);
+ }
+
+ return true;
+}
+