// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::get_argument_address_space[abi:cxx11](spirv_cross::SPIRVariable const&)
string CompilerMSL::get_argument_address_space(const SPIRVariable &argument)
{
	const auto &type = get<SPIRType>(argument.basetype);

	switch (type.storage)
	{
	case StorageClassWorkgroup:
		return "threadgroup";

	case StorageClassStorageBuffer:
	{
		bool readonly = ir.get_buffer_block_flags(argument).get(DecorationNonWritable);
		return readonly ? "const device" : "device";
	}

	case StorageClassUniform:
	case StorageClassUniformConstant:
	case StorageClassPushConstant:
		if (type.basetype == SPIRType::Struct)
		{
			bool ssbo = has_decoration(type.self, DecorationBufferBlock);
			if (ssbo)
			{
				bool readonly = ir.get_buffer_block_flags(argument).get(DecorationNonWritable);
				return readonly ? "const device" : "device";
			}
			else
				return "constant";
		}
		break;

	case StorageClassFunction:
	case StorageClassGeneric:
		// No address space for plain values.
		return type.pointer ? "thread" : "";

	default:
		break;
	}

	return "thread";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x64(%rax), %eax
movq %rax, -0xd0(%rbp)
subq $0xc, %rax
ja 0xf3858
movq -0xd0(%rbp), %rax
leaq 0x568cf(%rip), %rcx     # 0x149df8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x21(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x596f6(%rip), %rsi     # 0x14cc4d
callq 0x7520
jmp 0xf355e
leaq -0x21(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
movq -0xd8(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
leaq -0x78(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x54c20
movq -0x100(%rbp), %rdi
movl $0x18, %esi
callq 0xef50
movb %al, -0xf1(%rbp)
jmp 0xf35be
leaq -0x78(%rbp), %rdi
callq 0xf250
movb -0xf1(%rbp), %al
andb $0x1, %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %dl
leaq 0x59ef8(%rip), %rcx     # 0x14d4d4
leaq 0x59ef7(%rip), %rax     # 0x14d4da
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x110(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
callq 0x7520
jmp 0xf361d
leaq -0x79(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xf250
jmp 0xf38c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
movq -0x20(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0xf37dc
movq -0xd8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x3, %edx
callq 0x1f560
andb $0x1, %al
movb %al, -0x7a(%rbp)
testb $0x1, -0x7a(%rbp)
je 0xf377f
movq -0xd8(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x54c20
movq -0x120(%rbp), %rdi
movl $0x18, %esi
callq 0xef50
movb %al, -0x111(%rbp)
jmp 0xf36cf
leaq -0xc0(%rbp), %rdi
callq 0xf250
movb -0x111(%rbp), %al
andb $0x1, %al
movb %al, -0x7b(%rbp)
movb -0x7b(%rbp), %dl
leaq 0x59de4(%rip), %rcx     # 0x14d4d4
leaq 0x59de3(%rip), %rax     # 0x14d4da
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x130(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
callq 0x7520
jmp 0xf3734
leaq -0xc1(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xf250
jmp 0xf38c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
leaq -0xc2(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x138(%rbp), %rdx
leaq 0x4db1e(%rip), %rsi     # 0x1412c5
callq 0x7520
jmp 0xf37ae
leaq -0xc2(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc2(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
jmp 0xf385a
movq -0x20(%rbp), %rax
movb 0x60(%rax), %dl
leaq 0x59cf5(%rip), %rcx     # 0x14d4e1
leaq 0x4b0ab(%rip), %rax     # 0x13e89e
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x148(%rbp)
leaq -0xc3(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
callq 0x7520
jmp 0xf3830
leaq -0xc3(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc3(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
jmp 0xf385a
leaq -0xc4(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdi
movq -0x150(%rbp), %rdx
leaq 0x59c5f(%rip), %rsi     # 0x14d4e1
callq 0x7520
jmp 0xf3889
leaq -0xc4(%rbp), %rdi
callq 0x73d0
jmp 0xf38b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc4(%rbp), %rdi
callq 0x73d0
jmp 0xf38c1
movq -0xe0(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)