// File: /workspace/github_c_makefile_star2_O1/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 0x33207
movq %rcx, %r15
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r13
movq 0x68(%rcx), %rdi
callq 0x32b74
movl %eax, %r12d
cmpb $0x10, %al
setne %al
cmpb $0x10, %r14b
sete %cl
orb %al, %cl
jne 0x32cac
movups 0x1c2cb(%rip), %xmm0    # 0x4ef56
leaq -0x430(%rbp), %rdx
movups %xmm0, 0xd(%rdx)
movupd 0x1c2ab(%rip), %xmm0    # 0x4ef49
movapd %xmm0, (%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq *0x58(%r13)
movzbl %r14b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x33226
leaq 0x1ae86(%rip), %rcx     # 0x4db48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32ce6
leaq 0x1b16b(%rip), %rcx     # 0x4de48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd6a0(%rip), %rdi      # 0x4038d
leaq 0x1b47c(%rip), %rsi     # 0x4e170
leaq 0x1c1f8(%rip), %rcx     # 0x4eef3
movl $0x5fb, %edx            # imm = 0x5FB
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32d20
leaq 0x1ae71(%rip), %rcx     # 0x4db88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd666(%rip), %rdi      # 0x4038d
leaq 0x1b442(%rip), %rsi     # 0x4e170
leaq 0x1c1be(%rip), %rcx     # 0x4eef3
movl $0x606, %edx            # imm = 0x606
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x33245
leaq 0x1aeb3(%rip), %rcx     # 0x4dc08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x331c9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x33264
leaq 0x1ae47(%rip), %rcx     # 0x4dbc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x88(%r15), %eax
jmp 0x331e2
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x332c1
leaq 0x1ae9b(%rip), %rcx     # 0x4dc48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movss 0x88(%r15), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
subss 0x1b371(%rip), %xmm0    # 0x4e140
cvttss2si %xmm0, %rdx
jmp 0x32fd7
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x33283
leaq 0x1af59(%rip), %rcx     # 0x4dd48
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%r15), %rax
jmp 0x3315c
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32e1f
leaq 0x1aff2(%rip), %rcx     # 0x4de08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd567(%rip), %rdi      # 0x4038d
leaq 0x1b343(%rip), %rsi     # 0x4e170
leaq 0x1c0bf(%rip), %rcx     # 0x4eef3
movl $0x5fc, %edx            # imm = 0x5FC
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x332e0
leaq 0x1aeb4(%rip), %rcx     # 0x4dd08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x88(%r15), %al
movb %al, 0x88(%rbx)
jmp 0x331f1
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x32e8a
leaq 0x1af47(%rip), %rcx     # 0x4ddc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xd4fc(%rip), %rdi      # 0x4038d
leaq 0x1b2d8(%rip), %rsi     # 0x4e170
leaq 0x1c054(%rip), %rcx     # 0x4eef3
movl $0x5fd, %edx            # imm = 0x5FD
callq 0x30a0
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x332ff
leaq 0x1adc9(%rip), %rcx     # 0x4dc88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cvttss2si 0x88(%r15), %rax
jmp 0x33120
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x332a2
leaq 0x1ae9c(%rip), %rcx     # 0x4dd88
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x88(%r15), %eax
jmp 0x331b9
movzbl %r12b, %eax
decl %eax
cmpl $0xf, %eax
ja 0x3331e
leaq 0x1adb1(%rip), %rcx     # 0x4dcc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x331f1
movsbq 0x88(%r15), %rax
jmp 0x3315c
movsbl 0x88(%r15), %eax
jmp 0x331b9
movsbl 0x88(%r15), %eax
jmp 0x33090
movl 0x88(%r15), %eax
jmp 0x3315c
cvttsd2si 0x88(%r15), %eax
jmp 0x32fae
movswq 0x88(%r15), %rax
jmp 0x3315c
movzbl 0x88(%r15), %eax
jmp 0x3315c
movslq 0x88(%r15), %rax
jmp 0x3315c
movzwl 0x88(%r15), %eax
jmp 0x3315c
cvttss2si 0x88(%r15), %eax
movb %al, 0x88(%rbx)
jmp 0x331f1
movsd 0x88(%r15), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x1b166(%rip), %xmm0    # 0x4e138
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x88(%rbx)
jmp 0x331f1
movq 0x88(%r15), %rax
testq %rax, %rax
jns 0x3316f
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
jmp 0x331d0
cvttsd2si 0x88(%r15), %eax
jmp 0x33090
movsd 0x88(%r15), %xmm0
unpcklps 0x1b11b(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b123(%rip), %xmm0    # 0x4e160
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rbx)
jmp 0x331f1
movzwl 0x88(%r15), %eax
jmp 0x331b9
movzbl 0x88(%r15), %eax
jmp 0x33090
movzbl 0x88(%r15), %eax
jmp 0x331b9
movswl 0x88(%r15), %eax
jmp 0x331b9
cvttss2si 0x88(%r15), %eax
movw %ax, 0x88(%rbx)
jmp 0x331f1
xorps %xmm0, %xmm0
cvtsd2ss 0x88(%r15), %xmm0
jmp 0x331d0
movsd 0x88(%r15), %xmm0
jmp 0x331e9
movss 0x88(%r15), %xmm0
jmp 0x331d0
cvttsd2si 0x88(%r15), %rax
jmp 0x3315c
xorps %xmm0, %xmm0
cvtss2sd 0x88(%r15), %xmm0
jmp 0x331e9
xorps %xmm0, %xmm0
cvtsi2ssq 0x88(%r15), %xmm0
jmp 0x331d0
movzbl 0x88(%r15), %eax
jmp 0x331c9
xorps %xmm0, %xmm0
cvtsi2sdq 0x88(%r15), %xmm0
jmp 0x331e9
cvttsd2si 0x88(%r15), %rax
movl %eax, 0x88(%rbx)
jmp 0x331f1
cvttsd2si 0x88(%r15), %eax
jmp 0x331b9
movswl 0x88(%r15), %eax
jmp 0x331c9
movzbl 0x88(%r15), %eax
jmp 0x331e2
cvttss2si 0x88(%r15), %rax
movq %rax, 0x88(%rbx)
jmp 0x331f1
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x331d0
xorps %xmm0, %xmm0
cvtsi2ssl 0x88(%r15), %xmm0
jmp 0x331d0
movswl 0x88(%r15), %eax
jmp 0x331e2
movl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
jmp 0x331e9
xorps %xmm0, %xmm0
cvtsi2sdl 0x88(%r15), %xmm0
jmp 0x331e9
cvttss2si 0x88(%r15), %eax
movl %eax, 0x88(%rbx)
jmp 0x331f1
movzwl 0x88(%r15), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x88(%rbx)
jmp 0x331f1
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 0x1493c(%rip), %rdi     # 0x47b4a
leaq 0x1af5b(%rip), %rsi     # 0x4e170
leaq 0x1bcd7(%rip), %rcx     # 0x4eef3
movl $0x591, %edx            # imm = 0x591
callq 0x30a0
leaq 0xd160(%rip), %rdi      # 0x4038d
leaq 0x1af3c(%rip), %rsi     # 0x4e170
leaq 0x1bcb8(%rip), %rcx     # 0x4eef3
movl $0x608, %edx            # imm = 0x608
callq 0x30a0
leaq 0xd141(%rip), %rdi      # 0x4038d
leaq 0x1af1d(%rip), %rsi     # 0x4e170
leaq 0x1bc99(%rip), %rcx     # 0x4eef3
movl $0x604, %edx            # imm = 0x604
callq 0x30a0
leaq 0xd122(%rip), %rdi      # 0x4038d
leaq 0x1aefe(%rip), %rsi     # 0x4e170
leaq 0x1bc7a(%rip), %rcx     # 0x4eef3
movl $0x605, %edx            # imm = 0x605
callq 0x30a0
leaq 0xd103(%rip), %rdi      # 0x4038d
leaq 0x1aedf(%rip), %rsi     # 0x4e170
leaq 0x1bc5b(%rip), %rcx     # 0x4eef3
movl $0x5ff, %edx            # imm = 0x5FF
callq 0x30a0
leaq 0xd0e4(%rip), %rdi      # 0x4038d
leaq 0x1aec0(%rip), %rsi     # 0x4e170
leaq 0x1bc3c(%rip), %rcx     # 0x4eef3
movl $0x5fe, %edx            # imm = 0x5FE
callq 0x30a0
leaq 0xd0c5(%rip), %rdi      # 0x4038d
leaq 0x1aea1(%rip), %rsi     # 0x4e170
leaq 0x1bc1d(%rip), %rcx     # 0x4eef3
movl $0x603, %edx            # imm = 0x603
callq 0x30a0
leaq 0xd0a6(%rip), %rdi      # 0x4038d
leaq 0x1ae82(%rip), %rsi     # 0x4e170
leaq 0x1bbfe(%rip), %rcx     # 0x4eef3
movl $0x600, %edx            # imm = 0x600
callq 0x30a0
leaq 0xd087(%rip), %rdi      # 0x4038d
leaq 0x1ae63(%rip), %rsi     # 0x4e170
leaq 0x1bbdf(%rip), %rcx     # 0x4eef3
movl $0x602, %edx            # imm = 0x602
callq 0x30a0
leaq 0xd068(%rip), %rdi      # 0x4038d
leaq 0x1ae44(%rip), %rsi     # 0x4e170
leaq 0x1bbc0(%rip), %rcx     # 0x4eef3
movl $0x601, %edx            # imm = 0x601
callq 0x30a0