feat(abi): 新增ABI类型布局描述接口和Windows x64实现
- 新增scc_abi包,包含基础类型布局描述接口 - 实现Windows x64 ABI类型布局计算功能 - 定义基本类型枚举和布局信息结构体 - 提供类型布局计算的核心接口函数 refactor(ast2ir): 使用新的ABI接口替换旧的类型转换实现 - 将旧的scc_type_abi_t替换为新的scc_abi_type_calc_t - 更新AST到IR的类型转换逻辑,使用新的ABI计算接口 - 修改上下文初始化和类型解析相关代码 - 移除废弃的头文件和相关实现 refactor(ir): 统一IR节点引用类型命名并完善构建器功能 - 将scc_ir_node_ref_vec_t重命名为scc_ir_value_ref_vec_t保持一致性 - 更新聚合类型的字段名称从elements到fields - 添加全局变量分配构建器函数scc_ir_builder_global_alloca - 清理构建器中多余的注释和代码
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
#ifndef __SCC_WIN_X64_TYPE_ABI_H__
|
||||
#define __SCC_WIN_X64_TYPE_ABI_H__
|
||||
|
||||
#include "../scc_type_abi.h"
|
||||
|
||||
/**
|
||||
* @brief Windows x64 ABI Type
|
||||
* @details
|
||||
* https://learn.microsoft.com/zh-cn/cpp/build/x64-software-conventions?view=msvc-180
|
||||
*/
|
||||
static const scc_type_abi_t scc_win_x64_type_abi[] = {
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNKNOWN,
|
||||
.ir_type = SCC_IR_TYPE_unknown,
|
||||
.size = 0,
|
||||
.alignment = 0,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_VOID,
|
||||
.ir_type = SCC_IR_TYPE_void,
|
||||
.size = 0,
|
||||
.alignment = 0,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_BOOL,
|
||||
.ir_type = SCC_IR_TYPE_u8,
|
||||
.size = 1,
|
||||
.alignment = 1,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_CHAR,
|
||||
.ir_type = SCC_IR_TYPE_i8,
|
||||
.size = 1,
|
||||
.alignment = 1,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SIGNED_CHAR,
|
||||
.ir_type = SCC_IR_TYPE_i8,
|
||||
.size = 1,
|
||||
.alignment = 1,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNSIGNED_CHAR,
|
||||
.ir_type = SCC_IR_TYPE_u8,
|
||||
.size = 1,
|
||||
.alignment = 1,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SHORT,
|
||||
.ir_type = SCC_IR_TYPE_i16,
|
||||
.size = 2,
|
||||
.alignment = 2,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SIGNED_SHORT,
|
||||
.ir_type = SCC_IR_TYPE_i16,
|
||||
.size = 2,
|
||||
.alignment = 2,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNSIGNED_SHORT,
|
||||
.ir_type = SCC_IR_TYPE_u16,
|
||||
.size = 2,
|
||||
.alignment = 2,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_INT,
|
||||
.ir_type = SCC_IR_TYPE_i32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SIGNED_INT,
|
||||
.ir_type = SCC_IR_TYPE_i32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNSIGNED_INT,
|
||||
.ir_type = SCC_IR_TYPE_u32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_LONG,
|
||||
.ir_type = SCC_IR_TYPE_i32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SIGNED_LONG,
|
||||
.ir_type = SCC_IR_TYPE_i32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNSIGNED_LONG,
|
||||
.ir_type = SCC_IR_TYPE_u32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_LONG_LONG,
|
||||
.ir_type = SCC_IR_TYPE_i64,
|
||||
.size = 8,
|
||||
.alignment = 8,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_SIGNED_LONG_LONG,
|
||||
.ir_type = SCC_IR_TYPE_i64,
|
||||
.size = 8,
|
||||
.alignment = 8,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNSIGNED_LONG_LONG,
|
||||
.ir_type = SCC_IR_TYPE_i64,
|
||||
.size = 8,
|
||||
.alignment = 8,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_FLOAT,
|
||||
.ir_type = SCC_IR_TYPE_f32,
|
||||
.size = 4,
|
||||
.alignment = 4,
|
||||
},
|
||||
{
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_DOUBLE,
|
||||
.ir_type = SCC_IR_TYPE_f64,
|
||||
.size = 8,
|
||||
.alignment = 8,
|
||||
},
|
||||
{
|
||||
// nullptr
|
||||
.ast_type = SCC_AST_BUILTIN_TYPE_UNKNOWN,
|
||||
.ir_type = SCC_IR_TYPE_unknown,
|
||||
.size = 0,
|
||||
.alignment = 0,
|
||||
},
|
||||
};
|
||||
|
||||
#endif /* __SCC_WIN_X64_TYPE_ABI_H__ */
|
||||
@@ -8,19 +8,20 @@
|
||||
|
||||
typedef struct {
|
||||
scc_ir_builder_t builder;
|
||||
scc_hashtable_t decl2ir_ref; ///< decl to ir_ref
|
||||
scc_hashtable_t symtab; ///< symbol to ir_ref
|
||||
scc_hashtable_t ast2ir_cache; ///< ast node to ir ref cache
|
||||
scc_hashtable_t symtab; ///< symbol to ir_ref
|
||||
// scc_strpool_t strpool; ///< string pool
|
||||
const scc_type_abi_t *abi;
|
||||
const scc_abi_type_calc_t *abi;
|
||||
} scc_ast2ir_ctx_t;
|
||||
|
||||
void scc_ast2ir_ctx_init(scc_ast2ir_ctx_t *ctx, const scc_type_abi_t *abi,
|
||||
void scc_ast2ir_ctx_init(scc_ast2ir_ctx_t *ctx, const scc_abi_type_calc_t *abi,
|
||||
scc_ir_cprog_t *cprog);
|
||||
void scc_ast2ir_ctx_drop(scc_ast2ir_ctx_t *ctx);
|
||||
|
||||
void scc_ast2ir_translation_unit(scc_ast2ir_ctx_t *ctx,
|
||||
scc_ast_translation_unit_t *tu);
|
||||
void scc_ast2ir_decl(scc_ast2ir_ctx_t *ctx, scc_ast_decl_t *decl);
|
||||
void scc_ast2ir_decl(scc_ast2ir_ctx_t *ctx, scc_ast_decl_t *decl,
|
||||
cbool is_global);
|
||||
scc_ir_value_ref_t scc_ast2ir_expr(scc_ast2ir_ctx_t *ctx, scc_ast_expr_t *expr,
|
||||
cbool is_lvalue);
|
||||
void scc_ast2ir_stmt(scc_ast2ir_ctx_t *ctx, scc_ast_stmt_t *stmt);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef __SCC_TYPE_ABI_H__
|
||||
#define __SCC_TYPE_ABI_H__
|
||||
|
||||
#include <ast_def.h>
|
||||
#include <ir_def.h>
|
||||
|
||||
typedef struct {
|
||||
scc_ast_builtin_type_t ast_type;
|
||||
scc_ir_type_tag_t ir_type;
|
||||
usize size;
|
||||
usize alignment;
|
||||
} scc_type_abi_t;
|
||||
|
||||
#endif /* __SCC_TYPE_ABI_H__ */
|
||||
Reference in New Issue
Block a user