// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/compiler/frontend/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, FE_EXPR_AST_NODE_GET_TYPE_NODE(source));

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

	#define	_A(target_t, target_t_c)	\
		case FE_TYPE_##target_t: {	\
			switch (source_type) {	\
				case FE_TYPE_CHAR: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_CHAR_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT8: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT16: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT32: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_INT64: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_INT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT8: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT8_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT16: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT16_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT32: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT32_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_UINT64: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_UINT64_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_FLOAT: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_FLOAT_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_DOUBLE: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_EXPR_AST_NODE_GET_CONSTEXPR_RESULT_DOUBLE_VAL(source)	\
					);	\
					break;	\
				}	\
				case FE_TYPE_POINTER: {	\
					FE_EXPR_AST_NODE_SET_CONSTEXPR_RESULT_##target_t##_VAL(	\
						target,	\
						(target_t_c) FE_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 0x2eef1
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rsi
callq 0x285a5
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x2e9c6
movups 0x1a26b(%rip), %xmm0    # 0x48c10
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1a24b(%rip), %xmm0    # 0x48c03
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ef10
leaq 0x1891c(%rip), %rcx     # 0x472f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ea00
leaq 0x18c01(%rip), %rcx     # 0x475f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd959(%rip), %rdi      # 0x3c360
leaq 0x18f2c(%rip), %rsi     # 0x4793a
leaq 0x1a198(%rip), %rcx     # 0x48bad
movl $0x8e3, %edx            # imm = 0x8E3
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ea3a
leaq 0x18907(%rip), %rcx     # 0x47338
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd91f(%rip), %rdi      # 0x3c360
leaq 0x18ef2(%rip), %rsi     # 0x4793a
leaq 0x1a15e(%rip), %rcx     # 0x48bad
movl $0x8ee, %edx            # imm = 0x8EE
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ef2f
leaq 0x18949(%rip), %rcx     # 0x473b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x2eeb9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ef4e
leaq 0x188dd(%rip), %rcx     # 0x47378
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x2eecf
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2efab
leaq 0x18931(%rip), %rcx     # 0x473f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x18e23(%rip), %xmm0    # 0x4790c
cvttss2si %xmm0, %rdx
jmp 0x2ecf1
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ef6d
leaq 0x189ef(%rip), %rcx     # 0x474f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x2ee5b
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2eb39
leaq 0x18a88(%rip), %rcx     # 0x475b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd820(%rip), %rdi      # 0x3c360
leaq 0x18df3(%rip), %rsi     # 0x4793a
leaq 0x1a05f(%rip), %rcx     # 0x48bad
movl $0x8e4, %edx            # imm = 0x8E4
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2efca
leaq 0x1894a(%rip), %rcx     # 0x474b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x2eedb
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2eba4
leaq 0x189dd(%rip), %rcx     # 0x47578
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd7b5(%rip), %rdi      # 0x3c360
leaq 0x18d88(%rip), %rsi     # 0x4793a
leaq 0x19ff4(%rip), %rcx     # 0x48bad
movl $0x8e5, %edx            # imm = 0x8E5
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2efe9
leaq 0x1885f(%rip), %rcx     # 0x47438
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x2ee28
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2ef8c
leaq 0x18932(%rip), %rcx     # 0x47538
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x2eea9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f008
leaq 0x18847(%rip), %rcx     # 0x47478
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x2eedb
movsbq 0x88(%r15), %rax
jmp 0x2ee5b
movsbl 0x88(%r15), %eax
jmp 0x2eea9
movsbl 0x88(%r15), %eax
jmp 0x2eda7
movl 0x88(%r15), %eax
jmp 0x2ee5b
cvttsd2si 0x88(%r15), %eax
jmp 0x2ecc8
movswq 0x88(%r15), %rax
jmp 0x2ee5b
movzbl 0x88(%r15), %eax
jmp 0x2ee5b
movslq 0x88(%r15), %rax
jmp 0x2ee5b
movzwl 0x88(%r15), %eax
jmp 0x2ee5b
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x2eedb
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x18c14(%rip), %xmm0    # 0x47900
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x2eedb
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x2ee6b
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x2eebd
cvttsd2si 0x88(%r15), %eax
jmp 0x2eda7
movsd 0x88(%r15), %xmm0
unpcklps 0x18bc4(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x18bcc(%rip), %xmm0    # 0x47920
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x2eedb
movzwl 0x88(%r15), %eax
jmp 0x2eea9
movzbl 0x88(%r15), %eax
jmp 0x2eda7
movzbl 0x88(%r15), %eax
jmp 0x2eea9
movswl 0x88(%r15), %eax
jmp 0x2eea9
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x2eedb
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x2eebd
movsd 0x88(%r15), %xmm0
jmp 0x2eed3
movss 0x88(%r15), %xmm0
jmp 0x2eebd
cvttsd2si 0x88(%r15), %rax
jmp 0x2ee5b
cvtss2sd 0x88(%r15), %xmm0
jmp 0x2eed3
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x2eebd
movzbl 0x88(%r15), %eax
jmp 0x2eeb9
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x2eed3
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x2eedb
cvttsd2si 0x88(%r15), %eax
jmp 0x2eea9
movswl 0x88(%r15), %eax
jmp 0x2eeb9
movzbl 0x88(%r15), %eax
jmp 0x2eecf
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x2eedb
movl 0x88(%r15), %eax
cvtsi2ss %rax, %xmm0
jmp 0x2eebd
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x2eebd
movswl 0x88(%r15), %eax
jmp 0x2eecf
movl 0x88(%r15), %eax
cvtsi2sd %rax, %xmm0
jmp 0x2eed3
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x2eed3
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x2eedb
movzwl 0x88(%r15), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x2eedb
movzwl 0x88(%r15), %eax
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 0xc62e(%rip), %rdi      # 0x3b526
leaq 0x18a3b(%rip), %rsi     # 0x4793a
leaq 0x19ca7(%rip), %rcx     # 0x48bad
movl $0x879, %edx            # imm = 0x879
callq 0x30a0
leaq 0xd449(%rip), %rdi      # 0x3c360
leaq 0x18a1c(%rip), %rsi     # 0x4793a
leaq 0x19c88(%rip), %rcx     # 0x48bad
movl $0x8f0, %edx            # imm = 0x8F0
callq 0x30a0
leaq 0xd42a(%rip), %rdi      # 0x3c360
leaq 0x189fd(%rip), %rsi     # 0x4793a
leaq 0x19c69(%rip), %rcx     # 0x48bad
movl $0x8ec, %edx            # imm = 0x8EC
callq 0x30a0
leaq 0xd40b(%rip), %rdi      # 0x3c360
leaq 0x189de(%rip), %rsi     # 0x4793a
leaq 0x19c4a(%rip), %rcx     # 0x48bad
movl $0x8ed, %edx            # imm = 0x8ED
callq 0x30a0
leaq 0xd3ec(%rip), %rdi      # 0x3c360
leaq 0x189bf(%rip), %rsi     # 0x4793a
leaq 0x19c2b(%rip), %rcx     # 0x48bad
movl $0x8e7, %edx            # imm = 0x8E7
callq 0x30a0
leaq 0xd3cd(%rip), %rdi      # 0x3c360
leaq 0x189a0(%rip), %rsi     # 0x4793a
leaq 0x19c0c(%rip), %rcx     # 0x48bad
movl $0x8e6, %edx            # imm = 0x8E6
callq 0x30a0
leaq 0xd3ae(%rip), %rdi      # 0x3c360
leaq 0x18981(%rip), %rsi     # 0x4793a
leaq 0x19bed(%rip), %rcx     # 0x48bad
movl $0x8eb, %edx            # imm = 0x8EB
callq 0x30a0
leaq 0xd38f(%rip), %rdi      # 0x3c360
leaq 0x18962(%rip), %rsi     # 0x4793a
leaq 0x19bce(%rip), %rcx     # 0x48bad
movl $0x8e8, %edx            # imm = 0x8E8
callq 0x30a0
leaq 0xd370(%rip), %rdi      # 0x3c360
leaq 0x18943(%rip), %rsi     # 0x4793a
leaq 0x19baf(%rip), %rcx     # 0x48bad
movl $0x8ea, %edx            # imm = 0x8EA
callq 0x30a0
leaq 0xd351(%rip), %rdi      # 0x3c360
leaq 0x18924(%rip), %rsi     # 0x4793a
leaq 0x19b90(%rip), %rcx     # 0x48bad
movl $0x8e9, %edx            # imm = 0x8E9
callq 0x30a0