// File: /workspace/github_c_makefile_star2_O2/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 0x2f812
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rdi
callq 0x2f1bd
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x2f2e7
movups 0x1ac90(%rip), %xmm0    # 0x49f56
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1ac70(%rip), %xmm0    # 0x49f49
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f831
leaq 0x1984b(%rip), %rcx     # 0x48b48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f321
leaq 0x19b30(%rip), %rcx     # 0x48e48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc041(%rip), %rdi      # 0x3b369
leaq 0x19e41(%rip), %rsi     # 0x49170
leaq 0x1abbd(%rip), %rcx     # 0x49ef3
movl $0x5fb, %edx            # imm = 0x5FB
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f35b
leaq 0x19836(%rip), %rcx     # 0x48b88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc007(%rip), %rdi      # 0x3b369
leaq 0x19e07(%rip), %rsi     # 0x49170
leaq 0x1ab83(%rip), %rcx     # 0x49ef3
movl $0x606, %edx            # imm = 0x606
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f850
leaq 0x19878(%rip), %rcx     # 0x48c08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x2f7da
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f86f
leaq 0x1980c(%rip), %rcx     # 0x48bc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x2f7f0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f8cc
leaq 0x19860(%rip), %rcx     # 0x48c48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x19d3a(%rip), %xmm0    # 0x49144
cvttss2si %xmm0, %rdx
jmp 0x2f612
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f88e
leaq 0x1991e(%rip), %rcx     # 0x48d48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x2f77c
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f45a
leaq 0x199b7(%rip), %rcx     # 0x48e08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xbf08(%rip), %rdi      # 0x3b369
leaq 0x19d08(%rip), %rsi     # 0x49170
leaq 0x1aa84(%rip), %rcx     # 0x49ef3
movl $0x5fc, %edx            # imm = 0x5FC
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f8eb
leaq 0x19879(%rip), %rcx     # 0x48d08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x2f7fc
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f4c5
leaq 0x1990c(%rip), %rcx     # 0x48dc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xbe9d(%rip), %rdi      # 0x3b369
leaq 0x19c9d(%rip), %rsi     # 0x49170
leaq 0x1aa19(%rip), %rcx     # 0x49ef3
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f90a
leaq 0x1978e(%rip), %rcx     # 0x48c88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x2f749
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f8ad
leaq 0x19861(%rip), %rcx     # 0x48d88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x2f7ca
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x2f929
leaq 0x19776(%rip), %rcx     # 0x48cc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x2f7fc
movsbq 0x88(%r15), %rax
jmp 0x2f77c
movsbl 0x88(%r15), %eax
jmp 0x2f7ca
movsbl 0x88(%r15), %eax
jmp 0x2f6c8
movl 0x88(%r15), %eax
jmp 0x2f77c
cvttsd2si 0x88(%r15), %eax
jmp 0x2f5e9
movswq 0x88(%r15), %rax
jmp 0x2f77c
movzbl 0x88(%r15), %eax
jmp 0x2f77c
movslq 0x88(%r15), %rax
jmp 0x2f77c
movzwl 0x88(%r15), %eax
jmp 0x2f77c
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x2f7fc
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x19b2b(%rip), %xmm0    # 0x49138
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x2f7fc
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x2f78c
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x2f7de
cvttsd2si 0x88(%r15), %eax
jmp 0x2f6c8
movsd 0x88(%r15), %xmm0
unpcklps 0x19ae3(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x19aeb(%rip), %xmm0    # 0x49160
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x2f7fc
movzwl 0x88(%r15), %eax
jmp 0x2f7ca
movzbl 0x88(%r15), %eax
jmp 0x2f6c8
movzbl 0x88(%r15), %eax
jmp 0x2f7ca
movswl 0x88(%r15), %eax
jmp 0x2f7ca
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x2f7fc
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x2f7de
movsd 0x88(%r15), %xmm0
jmp 0x2f7f4
movss 0x88(%r15), %xmm0
jmp 0x2f7de
cvttsd2si 0x88(%r15), %rax
jmp 0x2f77c
cvtss2sd 0x88(%r15), %xmm0
jmp 0x2f7f4
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x2f7de
movzbl 0x88(%r15), %eax
jmp 0x2f7da
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x2f7f4
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x2f7fc
cvttsd2si 0x88(%r15), %eax
jmp 0x2f7ca
movswl 0x88(%r15), %eax
jmp 0x2f7da
movzbl 0x88(%r15), %eax
jmp 0x2f7f0
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x2f7fc
movl 0x88(%r15), %eax
cvtsi2ss %rax, %xmm0
jmp 0x2f7de
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x2f7de
movswl 0x88(%r15), %eax
jmp 0x2f7f0
movl 0x88(%r15), %eax
cvtsi2sd %rax, %xmm0
jmp 0x2f7f4
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x2f7f4
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x2f7fc
movzwl 0x88(%r15), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x2f7fc
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 0x13321(%rip), %rdi     # 0x42b3a
leaq 0x19950(%rip), %rsi     # 0x49170
leaq 0x1a6cc(%rip), %rcx     # 0x49ef3
movl $0x591, %edx            # imm = 0x591
callq 0x30a0
leaq 0xbb31(%rip), %rdi      # 0x3b369
leaq 0x19931(%rip), %rsi     # 0x49170
leaq 0x1a6ad(%rip), %rcx     # 0x49ef3
movl $0x608, %edx            # imm = 0x608
callq 0x30a0
leaq 0xbb12(%rip), %rdi      # 0x3b369
leaq 0x19912(%rip), %rsi     # 0x49170
leaq 0x1a68e(%rip), %rcx     # 0x49ef3
movl $0x604, %edx            # imm = 0x604
callq 0x30a0
leaq 0xbaf3(%rip), %rdi      # 0x3b369
leaq 0x198f3(%rip), %rsi     # 0x49170
leaq 0x1a66f(%rip), %rcx     # 0x49ef3
movl $0x605, %edx            # imm = 0x605
callq 0x30a0
leaq 0xbad4(%rip), %rdi      # 0x3b369
leaq 0x198d4(%rip), %rsi     # 0x49170
leaq 0x1a650(%rip), %rcx     # 0x49ef3
movl $0x5ff, %edx            # imm = 0x5FF
callq 0x30a0
leaq 0xbab5(%rip), %rdi      # 0x3b369
leaq 0x198b5(%rip), %rsi     # 0x49170
leaq 0x1a631(%rip), %rcx     # 0x49ef3
movl $0x5fe, %edx            # imm = 0x5FE
callq 0x30a0
leaq 0xba96(%rip), %rdi      # 0x3b369
leaq 0x19896(%rip), %rsi     # 0x49170
leaq 0x1a612(%rip), %rcx     # 0x49ef3
movl $0x603, %edx            # imm = 0x603
callq 0x30a0
leaq 0xba77(%rip), %rdi      # 0x3b369
leaq 0x19877(%rip), %rsi     # 0x49170
leaq 0x1a5f3(%rip), %rcx     # 0x49ef3
movl $0x600, %edx            # imm = 0x600
callq 0x30a0
leaq 0xba58(%rip), %rdi      # 0x3b369
leaq 0x19858(%rip), %rsi     # 0x49170
leaq 0x1a5d4(%rip), %rcx     # 0x49ef3
movl $0x602, %edx            # imm = 0x602
callq 0x30a0
leaq 0xba39(%rip), %rdi      # 0x3b369
leaq 0x19839(%rip), %rsi     # 0x49170
leaq 0x1a5b5(%rip), %rcx     # 0x49ef3
movl $0x601, %edx            # imm = 0x601
callq 0x30a0