// File: rossy[P]crossc/SPIRV-Cross/spirv_cpp.cpp
// Function: spirv_cross::CompilerCPP::emit_push_constant_block(spirv_cross::SPIRVariable const&)
void CompilerCPP::emit_push_constant_block(const SPIRVariable &var)
{
	add_resource_name(var.self);

	auto &type = get<SPIRType>(var.basetype);
	auto &flags = ir.meta[var.self].decoration.decoration_flags;
	if (flags.get(DecorationBinding) || flags.get(DecorationDescriptorSet))
		SPIRV_CROSS_THROW("Push constant blocks cannot be compiled to GLSL with Binding or Set syntax. "
		                  "Remap to location with reflection API first or disable these decorations.");

	emit_block_struct(type);
	auto buffer_name = to_name(type.self);
	auto instance_name = to_name(var.self);

	statement("internal::PushConstant<", buffer_name, type_to_array_glsl(type), "> ", instance_name, ";");
	statement_no_indent("#define ", instance_name, " __res->", instance_name, ".get()");
	resource_registrations.push_back(join("s.register_push_constant(", instance_name, "__", ");"));
	statement("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0xe0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0xe0(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
addq $0x60, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x21, %esi
callq 0xef50
testb $0x1, %al
jne 0xcb3f
movq -0x20(%rbp), %rdi
movl $0x22, %esi
callq 0xef50
testb $0x1, %al
jne 0xcb3f
jmp 0xcbf7
movb $0x1, -0x55(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xf0(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdx
leaq 0x13170f(%rip), %rsi    # 0x13e281
leaq -0x40(%rbp), %rdi
callq 0x7520
jmp 0xcb7d
movq -0xf0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9c50
jmp 0xcb8f
movq -0xf0(%rbp), %rdi
movb $0x0, -0x55(%rbp)
leaq 0x1a1237(%rip), %rsi    # 0x1addd8
leaq -0x2f18(%rip), %rdx     # 0x9c90
callq 0x7610
jmp 0xcdde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xcbd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7708
leaq -0x41(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x55(%rbp)
jne 0xcbe6
jmp 0xcbf2
movq -0xf0(%rbp), %rdi
callq 0x72c0
jmp 0xcdd5
movq -0xe0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xc1d0
movq -0xe0(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x78(%rbp), %rdi
movl $0x1, %ecx
movl %ecx, -0xf4(%rbp)
callq *%rax
movq -0xe0(%rbp), %rsi
movl -0xf4(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x98(%rbp), %rdi
callq *%rax
jmp 0xcc53
movq -0xe0(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x61340
jmp 0xcc6c
movq -0xe0(%rbp), %rdi
leaq 0x13c42c(%rip), %rcx    # 0x1490a6
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x131690(%rip), %rsi    # 0x13e317
leaq 0x131546(%rip), %r8     # 0x13e1d4
leaq -0x78(%rbp), %rdx
leaq -0xb8(%rbp), %rcx
leaq -0x98(%rbp), %r9
callq 0xf6a0
jmp 0xcca7
leaq -0xb8(%rbp), %rdi
callq 0x7708
movq -0xe0(%rbp), %rdi
leaq 0x13151a(%rip), %rsi    # 0x13e1db
leaq 0x13151c(%rip), %rcx    # 0x13e1e4
leaq 0x131520(%rip), %r9     # 0x13e1ef
leaq -0x98(%rbp), %r8
movq %r8, %rdx
callq 0xf810
jmp 0xcce0
movq -0xe0(%rbp), %rax
addq $0x788, %rax            # imm = 0x788
movq %rax, -0x100(%rbp)
leaq 0x131634(%rip), %rsi    # 0x13e32f
leaq 0x131509(%rip), %rcx    # 0x13e20b
leaq 0x13c39c(%rip), %r8     # 0x1490a5
leaq -0xd8(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xf880
jmp 0xcd1e
movq -0x100(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xecd0
jmp 0xcd33
leaq -0xd8(%rbp), %rdi
callq 0x7708
movq -0xe0(%rbp), %rdi
leaq 0x131b51(%rip), %rsi    # 0x13e89e
callq 0xedf0
jmp 0xcd54
leaq -0x98(%rbp), %rdi
callq 0x7708
leaq -0x78(%rbp), %rdi
callq 0x7708
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xcdcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xcdc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xcdc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
leaq -0x78(%rbp), %rdi
callq 0x7708
movq -0x50(%rbp), %rdi
callq 0x7640
nop