// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_constant(spirv_cross::SPIRConstant const&)
void CompilerGLSL::emit_constant(const SPIRConstant &constant)
{
	auto &type = get<SPIRType>(constant.constant_type);
	auto name = to_name(constant.self);

	SpecializationConstant wg_x, wg_y, wg_z;
	uint32_t workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z);

	if (constant.self == workgroup_size_id || constant.self == wg_x.id || constant.self == wg_y.id ||
	    constant.self == wg_z.id)
	{
		// These specialization constants are implicitly declared by emitting layout() in;
		return;
	}

	// Only scalars have constant IDs.
	if (has_decoration(constant.self, DecorationSpecId))
	{
		statement("layout(constant_id = ", get_decoration(constant.self, DecorationSpecId), ") const ",
		          variable_decl(type, name), " = ", constant_expression(constant), ";");
	}
	else
	{
		statement("const ", variable_decl(type, name), " = ", constant_expression(constant), ";");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x100(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x100(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x38(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0x100(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x251e0
movl %eax, -0xf4(%rbp)
jmp 0x6494e
movl -0xf4(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x54(%rbp), %eax
je 0x64987
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x40(%rbp), %eax
je 0x64987
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x48(%rbp), %eax
je 0x64987
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x50(%rbp), %eax
jne 0x649a4
movl $0x1, -0x68(%rbp)
jmp 0x64b9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x64bae
movq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x1, %edx
callq 0x1f560
movb %al, -0x101(%rbp)
jmp 0x649c4
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x649d3
jmp 0x64ad6
movq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x1, %edx
callq 0x23520
movl %eax, -0x108(%rbp)
jmp 0x649f3
movq -0x100(%rbp), %rsi
movl -0x108(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0xc8(%rax), %rax
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rcx
xorl %r8d, %r8d
callq *%rax
jmp 0x64a23
movq -0x100(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x64bc0
jmp 0x64a3c
movq -0x100(%rbp), %rdi
leaq 0xe465c(%rip), %rcx     # 0x1490a6
movq %rsp, %rax
movq %rcx, 0x8(%rax)
leaq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
leaq 0xdcc01(%rip), %rsi     # 0x141663
leaq 0xdcc10(%rip), %rcx     # 0x141679
leaq 0xe459f(%rip), %r9      # 0x14900f
leaq -0x6c(%rbp), %rdx
leaq -0x90(%rbp), %r8
callq 0xa0450
jmp 0x64a82
leaq -0xb0(%rbp), %rdi
callq 0x7708
leaq -0x90(%rbp), %rdi
callq 0x7708
jmp 0x64b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x64ac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7708
leaq -0x90(%rbp), %rdi
callq 0x7708
jmp 0x64bae
movq -0x100(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0xc8(%rax), %rax
leaq -0xd0(%rbp), %rdi
leaq -0x38(%rbp), %rcx
xorl %r8d, %r8d
callq *%rax
jmp 0x64afd
movq -0x100(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
callq 0x64bc0
jmp 0x64b16
movq -0x100(%rbp), %rdi
leaq 0xdcb57(%rip), %rsi     # 0x14167b
leaq 0xe44e4(%rip), %rcx     # 0x14900f
leaq 0xe4574(%rip), %r9      # 0x1490a6
leaq -0xd0(%rbp), %rdx
leaq -0xf0(%rbp), %r8
callq 0xa0300
jmp 0x64b47
leaq -0xf0(%rbp), %rdi
callq 0x7708
leaq -0xd0(%rbp), %rdi
callq 0x7708
jmp 0x64b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x64b87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x7708
leaq -0xd0(%rbp), %rdi
callq 0x7708
jmp 0x64bae
movl $0x0, -0x68(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x60(%rbp), %rdi
callq 0x7640