}
}
+static void
+vtn_emit_make_visible_barrier(struct vtn_builder *b, SpvMemoryAccessMask access,
+ SpvScope scope, enum vtn_variable_mode mode)
+{
+ if (!(access & SpvMemoryAccessMakePointerVisibleMask))
+ return;
+
+ vtn_emit_memory_barrier(b, scope, SpvMemorySemanticsMakeVisibleMask |
+ SpvMemorySemanticsAcquireMask |
+ vtn_mode_to_memory_semantics(mode));
+}
+
+static void
+vtn_emit_make_available_barrier(struct vtn_builder *b, SpvMemoryAccessMask access,
+ SpvScope scope, enum vtn_variable_mode mode)
+{
+ if (!(access & SpvMemoryAccessMakePointerAvailableMask))
+ return;
+
+ vtn_emit_memory_barrier(b, scope, SpvMemorySemanticsMakeAvailableMask |
+ SpvMemorySemanticsReleaseMask |
+ vtn_mode_to_memory_semantics(mode));
+}
+
void
vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
SpvMemoryAccessMask access;
SpvScope scope;
vtn_get_mem_operands(b, w, count, &idx, &access, &alignment, NULL, &scope);
- if (access & SpvMemoryAccessMakePointerVisibleMask) {
- SpvMemorySemanticsMask semantics =
- SpvMemorySemanticsMakeVisibleMask |
- SpvMemorySemanticsAcquireMask |
- vtn_mode_to_memory_semantics(src->mode);
- vtn_emit_memory_barrier(b, scope, semantics);
- }
+
+ vtn_emit_make_visible_barrier(b, access, scope, src->mode);
vtn_push_ssa_value(b, w[2], vtn_variable_load(b, src));
break;
struct vtn_ssa_value *src = vtn_ssa_value(b, w[2]);
vtn_variable_store(b, src, dest);
- if (access & SpvMemoryAccessMakePointerAvailableMask) {
- SpvMemorySemanticsMask semantics =
- SpvMemorySemanticsMakeAvailableMask |
- SpvMemorySemanticsReleaseMask |
- vtn_mode_to_memory_semantics(dest->mode);
- vtn_emit_memory_barrier(b, scope, semantics);
- }
+ vtn_emit_make_available_barrier(b, access, scope, dest->mode);
break;
}