// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/backend/semantics.c
// Function: calc_cast_constexpr
static void _calc_cast_constexpr(
	ParserContext *ctx,
	uint8_t target_type,
	ParserASTNode *target,
	ParserASTNode *source
) {
	assert(ctx);
	assert(target);
	assert(source);

	uint8_t source_type = _get_type_by_type_node(ctx, BE_EXPR_AST_NODE_GET_TYPE_NODE(source));

	// 常量表达式不能把指针类型转换为非指针类型。
	if (source_type == BE_TYPE_POINTER
			&& target_type != BE_TYPE_POINTER) {
		_SYNERR_NODE(ctx, source, "not a compile-time constant.");
	}

	#define	_A(target_t, target_t_c)	\
		case BE_TYPE_##target_t: {	\
			switch (source_type) {	\
				case BE_TYPE_CHAR: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_CHAR_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_INT8: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_INT16: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_INT32: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_INT64: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_UINT8: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_UINT16: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_UINT32: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_UINT64: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_FLOAT: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_FLOAT_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_DOUBLE: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_DOUBLE_VAL(source)	\
					);	\
					break;	\
				}	\
				case BE_TYPE_POINTER: {	\
					BE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) BE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_POINTER_VAL(source)	\
					);	\
					break;	\
				}	\
				default: {	\
					assert(0);	\
				}	\
			}	\
			break;	\
		}


	switch (target_type) {
		_A(CHAR, char)
		_A(INT8, int8_t)
		_A(INT16, int16_t)
		_A(INT32, int32_t)
		_A(INT64, int64_t)
		_A(UINT8, uint8_t)
		_A(UINT16, uint16_t)
		_A(UINT32, uint32_t)
		_A(UINT64, uint64_t)
		_A(FLOAT, float)
		_A(DOUBLE, double)
		_A(POINTER, uint64_t)
		default: {
			assert(0);
		}
	}


	#undef	_A
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
testq %rcx, %rcx
je 0x323e0
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rdi
callq 0x31d4d
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x31e85
movups 0x1b0c2(%rip), %xmm0    # 0x4cf26
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1b0a2(%rip), %xmm0    # 0x4cf19
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x323ff
leaq 0x19c7d(%rip), %rcx     # 0x4bb18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31ebf
leaq 0x19f62(%rip), %rcx     # 0x4be18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc4a3(%rip), %rdi      # 0x3e369
leaq 0x1a273(%rip), %rsi     # 0x4c140
leaq 0x1afef(%rip), %rcx     # 0x4cec3
movl $0x5fb, %edx            # imm = 0x5FB
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31ef9
leaq 0x19c68(%rip), %rcx     # 0x4bb58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc469(%rip), %rdi      # 0x3e369
leaq 0x1a239(%rip), %rsi     # 0x4c140
leaq 0x1afb5(%rip), %rcx     # 0x4cec3
movl $0x606, %edx            # imm = 0x606
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3241e
leaq 0x19caa(%rip), %rcx     # 0x4bbd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x323a2
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3243d
leaq 0x19c3e(%rip), %rcx     # 0x4bb98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x323bb
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3249a
leaq 0x19c92(%rip), %rcx     # 0x4bc18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x1a168(%rip), %xmm0    # 0x4c110
cvttss2si %xmm0, %rdx
jmp 0x321b0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3245c
leaq 0x19d50(%rip), %rcx     # 0x4bd18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x32335
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31ff8
leaq 0x19de9(%rip), %rcx     # 0x4bdd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc36a(%rip), %rdi      # 0x3e369
leaq 0x1a13a(%rip), %rsi     # 0x4c140
leaq 0x1aeb6(%rip), %rcx     # 0x4cec3
movl $0x5fc, %edx            # imm = 0x5FC
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x324b9
leaq 0x19cab(%rip), %rcx     # 0x4bcd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x323ca
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32063
leaq 0x19d3e(%rip), %rcx     # 0x4bd98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc2ff(%rip), %rdi      # 0x3e369
leaq 0x1a0cf(%rip), %rsi     # 0x4c140
leaq 0x1ae4b(%rip), %rcx     # 0x4cec3
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x324d8
leaq 0x19bc0(%rip), %rcx     # 0x4bc58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x322f9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3247b
leaq 0x19c93(%rip), %rcx     # 0x4bd58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x32392
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x324f7
leaq 0x19ba8(%rip), %rcx     # 0x4bc98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x323ca
movsbq 0x88(%r15), %rax
jmp 0x32335
movsbl 0x88(%r15), %eax
jmp 0x32392
movsbl 0x88(%r15), %eax
jmp 0x32269
movl 0x88(%r15), %eax
jmp 0x32335
cvttsd2si 0x88(%r15), %eax
jmp 0x32187
movswq 0x88(%r15), %rax
jmp 0x32335
movzbl 0x88(%r15), %eax
jmp 0x32335
movslq 0x88(%r15), %rax
jmp 0x32335
movzwl 0x88(%r15), %eax
jmp 0x32335
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x323ca
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x19f5d(%rip), %xmm0    # 0x4c108
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x323ca
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x32348
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x323a9
cvttsd2si 0x88(%r15), %eax
jmp 0x32269
movsd 0x88(%r15), %xmm0
unpcklps 0x19f12(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x19f1a(%rip), %xmm0    # 0x4c130
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x323ca
movzwl 0x88(%r15), %eax
jmp 0x32392
movzbl 0x88(%r15), %eax
jmp 0x32269
movzbl 0x88(%r15), %eax
jmp 0x32392
movswl 0x88(%r15), %eax
jmp 0x32392
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x323ca
xorps %xmm0, %xmm0
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x323a9
movsd 0x88(%r15), %xmm0
jmp 0x323c2
movss 0x88(%r15), %xmm0
jmp 0x323a9
cvttsd2si 0x88(%r15), %rax
jmp 0x32335
xorps %xmm0, %xmm0
cvtss2sd 0x88(%r15), %xmm0
jmp 0x323c2
xorps %xmm0, %xmm0
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x323a9
movzbl 0x88(%r15), %eax
jmp 0x323a2
xorps %xmm0, %xmm0
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x323c2
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x323ca
cvttsd2si 0x88(%r15), %eax
jmp 0x32392
movswl 0x88(%r15), %eax
jmp 0x323a2
movzbl 0x88(%r15), %eax
jmp 0x323bb
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x323ca
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x323a9
xorps %xmm0, %xmm0
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x323a9
movswl 0x88(%r15), %eax
jmp 0x323bb
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
jmp 0x323c2
xorps %xmm0, %xmm0
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x323c2
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x323ca
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x323ca
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x88(%rbx)
movb %r14b, 0x71(%rbx)
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13723(%rip), %rdi     # 0x45b0a
leaq 0x19d52(%rip), %rsi     # 0x4c140
leaq 0x1aace(%rip), %rcx     # 0x4cec3
movl $0x591, %edx            # imm = 0x591
callq 0x30a0
leaq 0xbf63(%rip), %rdi      # 0x3e369
leaq 0x19d33(%rip), %rsi     # 0x4c140
leaq 0x1aaaf(%rip), %rcx     # 0x4cec3
movl $0x608, %edx            # imm = 0x608
callq 0x30a0
leaq 0xbf44(%rip), %rdi      # 0x3e369
leaq 0x19d14(%rip), %rsi     # 0x4c140
leaq 0x1aa90(%rip), %rcx     # 0x4cec3
movl $0x604, %edx            # imm = 0x604
callq 0x30a0
leaq 0xbf25(%rip), %rdi      # 0x3e369
leaq 0x19cf5(%rip), %rsi     # 0x4c140
leaq 0x1aa71(%rip), %rcx     # 0x4cec3
movl $0x605, %edx            # imm = 0x605
callq 0x30a0
leaq 0xbf06(%rip), %rdi      # 0x3e369
leaq 0x19cd6(%rip), %rsi     # 0x4c140
leaq 0x1aa52(%rip), %rcx     # 0x4cec3
movl $0x5ff, %edx            # imm = 0x5FF
callq 0x30a0
leaq 0xbee7(%rip), %rdi      # 0x3e369
leaq 0x19cb7(%rip), %rsi     # 0x4c140
leaq 0x1aa33(%rip), %rcx     # 0x4cec3
movl $0x5fe, %edx            # imm = 0x5FE
callq 0x30a0
leaq 0xbec8(%rip), %rdi      # 0x3e369
leaq 0x19c98(%rip), %rsi     # 0x4c140
leaq 0x1aa14(%rip), %rcx     # 0x4cec3
movl $0x603, %edx            # imm = 0x603
callq 0x30a0
leaq 0xbea9(%rip), %rdi      # 0x3e369
leaq 0x19c79(%rip), %rsi     # 0x4c140
leaq 0x1a9f5(%rip), %rcx     # 0x4cec3
movl $0x600, %edx            # imm = 0x600
callq 0x30a0
leaq 0xbe8a(%rip), %rdi      # 0x3e369
leaq 0x19c5a(%rip), %rsi     # 0x4c140
leaq 0x1a9d6(%rip), %rcx     # 0x4cec3
movl $0x602, %edx            # imm = 0x602
callq 0x30a0
leaq 0xbe6b(%rip), %rdi      # 0x3e369
leaq 0x19c3b(%rip), %rsi     # 0x4c140
leaq 0x1a9b7(%rip), %rcx     # 0x4cec3
movl $0x601, %edx            # imm = 0x601
callq 0x30a0