// File: /workspace/github_c_makefile_star2_O3/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 0x312eb
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rsi
callq 0x2a712
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x30d90
movups 0x1ae61(%rip), %xmm0    # 0x4bbd0
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1ae41(%rip), %xmm0    # 0x4bbc3
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3130a
leaq 0x19512(%rip), %rcx     # 0x4a2b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x30dca
leaq 0x197f7(%rip), %rcx     # 0x4a5b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe58f(%rip), %rdi      # 0x3f360
leaq 0x19b22(%rip), %rsi     # 0x4a8fa
leaq 0x1ad8e(%rip), %rcx     # 0x4bb6d
movl $0x8e3, %edx            # imm = 0x8E3
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x30e04
leaq 0x194fd(%rip), %rcx     # 0x4a2f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe555(%rip), %rdi      # 0x3f360
leaq 0x19ae8(%rip), %rsi     # 0x4a8fa
leaq 0x1ad54(%rip), %rcx     # 0x4bb6d
movl $0x8ee, %edx            # imm = 0x8EE
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31329
leaq 0x1953f(%rip), %rcx     # 0x4a378
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x312ad
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31348
leaq 0x194d3(%rip), %rcx     # 0x4a338
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x312c6
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x313a5
leaq 0x19527(%rip), %rcx     # 0x4a3b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x19a15(%rip), %xmm0    # 0x4a8c8
cvttss2si %xmm0, %rdx
jmp 0x310bb
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31367
leaq 0x195e5(%rip), %rcx     # 0x4a4b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x31240
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x30f03
leaq 0x1967e(%rip), %rcx     # 0x4a578
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe456(%rip), %rdi      # 0x3f360
leaq 0x199e9(%rip), %rsi     # 0x4a8fa
leaq 0x1ac55(%rip), %rcx     # 0x4bb6d
movl $0x8e4, %edx            # imm = 0x8E4
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x313c4
leaq 0x19540(%rip), %rcx     # 0x4a478
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x312d5
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x30f6e
leaq 0x195d3(%rip), %rcx     # 0x4a538
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xe3eb(%rip), %rdi      # 0x3f360
leaq 0x1997e(%rip), %rsi     # 0x4a8fa
leaq 0x1abea(%rip), %rcx     # 0x4bb6d
movl $0x8e5, %edx            # imm = 0x8E5
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x313e3
leaq 0x19455(%rip), %rcx     # 0x4a3f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x31204
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31386
leaq 0x19528(%rip), %rcx     # 0x4a4f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x3129d
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x31402
leaq 0x1943d(%rip), %rcx     # 0x4a438
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x312d5
movsbq 0x88(%r15), %rax
jmp 0x31240
movsbl 0x88(%r15), %eax
jmp 0x3129d
movsbl 0x88(%r15), %eax
jmp 0x31174
movl 0x88(%r15), %eax
jmp 0x31240
cvttsd2si 0x88(%r15), %eax
jmp 0x31092
movswq 0x88(%r15), %rax
jmp 0x31240
movzbl 0x88(%r15), %eax
jmp 0x31240
movslq 0x88(%r15), %rax
jmp 0x31240
movzwl 0x88(%r15), %eax
jmp 0x31240
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x312d5
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x1980a(%rip), %xmm0    # 0x4a8c0
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x312d5
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x31253
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x312b4
cvttsd2si 0x88(%r15), %eax
jmp 0x31174
movsd 0x88(%r15), %xmm0
unpcklps 0x197b7(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x197bf(%rip), %xmm0    # 0x4a8e0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x312d5
movzwl 0x88(%r15), %eax
jmp 0x3129d
movzbl 0x88(%r15), %eax
jmp 0x31174
movzbl 0x88(%r15), %eax
jmp 0x3129d
movswl 0x88(%r15), %eax
jmp 0x3129d
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x312d5
xorps %xmm0, %xmm0
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x312b4
movsd 0x88(%r15), %xmm0
jmp 0x312cd
movss 0x88(%r15), %xmm0
jmp 0x312b4
cvttsd2si 0x88(%r15), %rax
jmp 0x31240
xorps %xmm0, %xmm0
cvtss2sd 0x88(%r15), %xmm0
jmp 0x312cd
xorps %xmm0, %xmm0
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x312b4
movzbl 0x88(%r15), %eax
jmp 0x312ad
xorps %xmm0, %xmm0
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x312cd
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x312d5
cvttsd2si 0x88(%r15), %eax
jmp 0x3129d
movswl 0x88(%r15), %eax
jmp 0x312ad
movzbl 0x88(%r15), %eax
jmp 0x312c6
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x312d5
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x312b4
xorps %xmm0, %xmm0
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x312b4
movswl 0x88(%r15), %eax
jmp 0x312c6
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
jmp 0x312cd
xorps %xmm0, %xmm0
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x312cd
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x312d5
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x312d5
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 0xd234(%rip), %rdi      # 0x3e526
leaq 0x19601(%rip), %rsi     # 0x4a8fa
leaq 0x1a86d(%rip), %rcx     # 0x4bb6d
movl $0x879, %edx            # imm = 0x879
callq 0x30a0
leaq 0xe04f(%rip), %rdi      # 0x3f360
leaq 0x195e2(%rip), %rsi     # 0x4a8fa
leaq 0x1a84e(%rip), %rcx     # 0x4bb6d
movl $0x8f0, %edx            # imm = 0x8F0
callq 0x30a0
leaq 0xe030(%rip), %rdi      # 0x3f360
leaq 0x195c3(%rip), %rsi     # 0x4a8fa
leaq 0x1a82f(%rip), %rcx     # 0x4bb6d
movl $0x8ec, %edx            # imm = 0x8EC
callq 0x30a0
leaq 0xe011(%rip), %rdi      # 0x3f360
leaq 0x195a4(%rip), %rsi     # 0x4a8fa
leaq 0x1a810(%rip), %rcx     # 0x4bb6d
movl $0x8ed, %edx            # imm = 0x8ED
callq 0x30a0
leaq 0xdff2(%rip), %rdi      # 0x3f360
leaq 0x19585(%rip), %rsi     # 0x4a8fa
leaq 0x1a7f1(%rip), %rcx     # 0x4bb6d
movl $0x8e7, %edx            # imm = 0x8E7
callq 0x30a0
leaq 0xdfd3(%rip), %rdi      # 0x3f360
leaq 0x19566(%rip), %rsi     # 0x4a8fa
leaq 0x1a7d2(%rip), %rcx     # 0x4bb6d
movl $0x8e6, %edx            # imm = 0x8E6
callq 0x30a0
leaq 0xdfb4(%rip), %rdi      # 0x3f360
leaq 0x19547(%rip), %rsi     # 0x4a8fa
leaq 0x1a7b3(%rip), %rcx     # 0x4bb6d
movl $0x8eb, %edx            # imm = 0x8EB
callq 0x30a0
leaq 0xdf95(%rip), %rdi      # 0x3f360
leaq 0x19528(%rip), %rsi     # 0x4a8fa
leaq 0x1a794(%rip), %rcx     # 0x4bb6d
movl $0x8e8, %edx            # imm = 0x8E8
callq 0x30a0
leaq 0xdf76(%rip), %rdi      # 0x3f360
leaq 0x19509(%rip), %rsi     # 0x4a8fa
leaq 0x1a775(%rip), %rcx     # 0x4bb6d
movl $0x8ea, %edx            # imm = 0x8EA
callq 0x30a0
leaq 0xdf57(%rip), %rdi      # 0x3f360
leaq 0x194ea(%rip), %rsi     # 0x4a8fa
leaq 0x1a756(%rip), %rcx     # 0x4bb6d
movl $0x8e9, %edx            # imm = 0x8E9
callq 0x30a0