// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::type_to_glsl[abi:cxx11](spirv_cross::SPIRType const&, unsigned int)
string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id)
{
	// Ignore the pointer type since GLSL doesn't have pointers.

	string type_name;

	switch (type.basetype)
	{
	case SPIRType::Struct:
		// Need OpName lookup here to get a "sensible" name for a struct.
		return to_name(type.self);

	case SPIRType::Image:
	case SPIRType::SampledImage:
		return image_type_glsl(type, id);

	case SPIRType::Sampler:
		return sampler_type(type);

	case SPIRType::Void:
		return "void";

	case SPIRType::AtomicCounter:
		return "atomic_uint";

	// Scalars
	case SPIRType::Boolean:
		type_name = "bool";
		break;
	case SPIRType::Char:
		type_name = "char";
		break;
	case SPIRType::Int:
		type_name = (type.width == 16 ? "short" : "int");
		break;
	case SPIRType::UInt:
		type_name = (type.width == 16 ? "ushort" : "uint");
		break;
	case SPIRType::Int64:
		type_name = "long"; // Currently unsupported
		break;
	case SPIRType::UInt64:
		type_name = "size_t";
		break;
	case SPIRType::Half:
		type_name = "half";
		break;
	case SPIRType::Float:
		type_name = "float";
		break;
	case SPIRType::Double:
		type_name = "double"; // Currently unsupported
		break;

	default:
		return "unknown_type";
	}

	// Matrix?
	if (type.columns > 1)
		type_name += to_string(type.columns) + "x";

	// Vector or Matrix?
	if (type.vecsize > 1)
		type_name += to_string(type.vecsize);

	return type_name;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7530
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0xe, %eax
ja 0x10c1f0
movq -0xc0(%rbp), %rax
leaq 0x3e388(%rip), %rcx     # 0x14a330
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
movl $0x1, %ecx
callq *%rax
jmp 0x10bfd6
movl $0x1, -0x50(%rbp)
jmp 0x10c351
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x10c36a
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq (%rsi), %rax
movq 0xb0(%rax), %rax
callq *%rax
jmp 0x10c016
movl $0x1, -0x50(%rbp)
jmp 0x10c351
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movq -0x18(%rbp), %rdx
callq 0x102c40
jmp 0x10c03b
movl $0x1, -0x50(%rbp)
jmp 0x10c351
leaq -0x51(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x7650
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x36169(%rip), %rsi     # 0x1421d5
callq 0x7520
jmp 0x10c073
leaq -0x51(%rbp), %rdi
callq 0x73d0
movl $0x1, -0x50(%rbp)
jmp 0x10c351
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x73d0
jmp 0x10c36a
leaq -0x52(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7650
movq -0xd8(%rbp), %rdi
movq -0xe8(%rbp), %rdx
leaq 0x35bb1(%rip), %rsi     # 0x141c78
callq 0x7520
jmp 0x10c0ce
leaq -0x52(%rbp), %rdi
callq 0x73d0
movl $0x1, -0x50(%rbp)
jmp 0x10c351
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x52(%rbp), %rdi
callq 0x73d0
jmp 0x10c36a
leaq 0x35b8a(%rip), %rsi     # 0x141c8e
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c10f
jmp 0x10c24b
leaq 0x4149f(%rip), %rsi     # 0x14d5ba
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c126
jmp 0x10c24b
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
subl $0x10, %eax
leaq 0x41484(%rip), %rax     # 0x14d5c0
leaq 0x356f0(%rip), %rsi     # 0x141833
cmoveq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c152
jmp 0x10c24b
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
subl $0x10, %eax
leaq 0x41457(%rip), %rax     # 0x14d5bf
leaq 0x40f73(%rip), %rsi     # 0x14d0e2
cmoveq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c17e
jmp 0x10c24b
leaq 0x35d7f(%rip), %rsi     # 0x141f09
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c195
jmp 0x10c24b
leaq 0x41425(%rip), %rsi     # 0x14d5c6
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c1ac
jmp 0x10c24b
leaq 0x35be7(%rip), %rsi     # 0x141d9f
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c1c3
jmp 0x10c24b
leaq 0x40f1a(%rip), %rsi     # 0x14d0e9
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c1da
jmp 0x10c24b
leaq 0x3c3fe(%rip), %rsi     # 0x1485e1
leaq -0x40(%rbp), %rdi
callq 0x7510
jmp 0x10c1ee
jmp 0x10c24b
leaq -0x53(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x7650
movq -0xd8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x413b8(%rip), %rsi     # 0x14d5cd
callq 0x7520
jmp 0x10c21c
leaq -0x53(%rbp), %rdi
callq 0x73d0
movl $0x1, -0x50(%rbp)
jmp 0x10c351
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x53(%rbp), %rdi
callq 0x73d0
jmp 0x10c36a
movq -0x18(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jbe 0x10c2e1
movq -0x18(%rbp), %rax
movl 0x18(%rax), %esi
leaq -0x98(%rbp), %rdi
callq 0x45220
jmp 0x10c26e
leaq 0x37fec(%rip), %rdx     # 0x144261
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x11910
jmp 0x10c287
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x7470
jmp 0x10c296
leaq -0x78(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
jmp 0x10c2e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x10c2d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
jmp 0x10c36a
movq -0x18(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jbe 0x10c33a
movq -0x18(%rbp), %rax
movl 0x14(%rax), %esi
leaq -0xb8(%rbp), %rdi
callq 0x45220
jmp 0x10c300
leaq -0x40(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x7470
jmp 0x10c312
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0x10c33a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0x10c36a
movq -0xd8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x7210
movl $0x1, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7708
movq -0xd0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x7708
movq -0x48(%rbp), %rdi
callq 0x7640
nopl (%rax)