// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::emit_barrier(unsigned int, unsigned int, unsigned int)
void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem)
{
	if (get_entry_point().model != ExecutionModelGLCompute)
		return;

	string bar_stmt = "threadgroup_barrier(mem_flags::";

	uint32_t mem_sem = id_mem_sem ? get<SPIRConstant>(id_mem_sem).scalar() : uint32_t(MemorySemanticsMaskNone);

	if (mem_sem & MemorySemanticsCrossWorkgroupMemoryMask)
		bar_stmt += "mem_device";
	else if (mem_sem & (MemorySemanticsSubgroupMemoryMask | MemorySemanticsWorkgroupMemoryMask |
	                    MemorySemanticsAtomicCounterMemoryMask))
		bar_stmt += "mem_threadgroup";
	else if (mem_sem & MemorySemanticsImageMemoryMask)
		bar_stmt += "mem_texture";
	else
		bar_stmt += "mem_none";

	if (msl_options.is_ios() && msl_options.supports_msl_version(2))
	{
		bar_stmt += ", ";

		// Use the wider of the two scopes (smaller value)
		uint32_t exe_scope = id_exe_scope ? get<SPIRConstant>(id_exe_scope).scalar() : uint32_t(ScopeInvocation);
		uint32_t mem_scope = id_mem_scope ? get<SPIRConstant>(id_mem_scope).scalar() : uint32_t(ScopeInvocation);
		uint32_t scope = min(exe_scope, mem_scope);
		switch (scope)
		{
		case ScopeCrossDevice:
		case ScopeDevice:
			bar_stmt += "memory_scope_device";
			break;

		case ScopeSubgroup:
		case ScopeInvocation:
			bar_stmt += "memory_scope_simdgroup";
			break;

		case ScopeWorkgroup:
		default:
			bar_stmt += "memory_scope_threadgroup";
			break;
		}
	}

	bar_stmt += ");";

	statement(bar_stmt);

	assert(current_emitting_block);
	flush_control_dependent_expressions(current_emitting_block->self);
	flush_all_active_variables();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
callq 0x16254
cmpl $0x5, 0xb8(%rax)
jne 0x93592
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x300ef(%rip), %rsi     # 0xc3539
leaq 0x30107(%rip), %rdx     # 0xc3558
leaq 0x8(%rsp), %rdi
callq 0x7c64
testl %r15d, %r15d
je 0x93470
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1c66e
movl 0x10(%rax), %eax
jmp 0x93472
xorl %eax, %eax
btl $0x9, %eax
jb 0x93488
testl $0x580, %eax            # imm = 0x580
je 0x93491
leaq 0x300de(%rip), %rsi     # 0xc3564
jmp 0x934a7
leaq 0x300ca(%rip), %rsi     # 0xc3559
jmp 0x934a7
btl $0xb, %eax
leaq 0x300e4(%rip), %rax     # 0xc3580
leaq 0x300d1(%rip), %rsi     # 0xc3574
cmovaeq %rax, %rsi
leaq 0x8(%rsp), %rdi
callq 0x64e0
cmpl $0x0, 0x7cc(%rbx)
jne 0x9353e
cmpl $0x4e20, 0x7d0(%rbx)    # imm = 0x4E20
jb 0x9353e
leaq 0x27bea(%rip), %rsi     # 0xbb0bb
leaq 0x8(%rsp), %rdi
callq 0x64e0
movl $0x4, %r13d
movl $0x4, %r15d
testl %r14d, %r14d
je 0x934fb
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1c66e
movl 0x10(%rax), %r15d
testl %ebp, %ebp
je 0x9350d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1c66e
movl 0x10(%rax), %r13d
cmpl %r15d, %r13d
cmovbl %r13d, %r15d
cmpl $0x5, %r15d
jae 0x9352d
movl %r15d, %eax
leaq 0x2dc04(%rip), %rcx     # 0xc1128
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
jmp 0x93534
leaq 0x30080(%rip), %rsi     # 0xc35b4
leaq 0x8(%rsp), %rdi
callq 0x64e0
leaq 0x2c5a3(%rip), %rsi     # 0xbfae8
leaq 0x8(%rsp), %rdi
callq 0x64e0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xb674
movq 0x410(%rbx), %rax
testq %rax, %rax
je 0x935a1
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x12ff8
movq %rbx, %rdi
callq 0x13070
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x93592
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x276db(%rip), %rdi     # 0xbac83
leaq 0x2de84(%rip), %rsi     # 0xc1433
leaq 0x30017(%rip), %rcx     # 0xc35cd
movl $0x9e7, %edx            # imm = 0x9E7
callq 0x61b0
jmp 0x935c6
jmp 0x935c6
jmp 0x935c6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x935e0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0