fix(abi): 修复void类型的ABI计算缺少break语句
在scc_type_abi.c文件中,void类型的case分支缺少break语句, 导致执行流程错误地进入下一个case分支。 feat(ast): 为参数声明添加索引字段 在ast_def.h头文件中为参数声明结构体添加param_idx字段, 用于跟踪参数在函数参数列表中的位置索引。 feat(ast): 更新参数初始化函数以支持索引参数 修改scc_ast.h中的scc_ast_decl_param_init函数签名, 添加参数索引idx参数,并将该值存储到参数声明结构体中。 feat(ast2ir): 添加IR转换上下文的值使用提示选项 在ast2ir.h中为scc_ast2ir_ctx_t结构体添加hint_using_value字段, 控制参数转换时是使用值还是分配内存的方式。 fix(ast2ir): 正确处理void类型到IR的转换 当遇到大小为0的类型(如void)时,直接返回void类型, 而不是尝试匹配其他大小分支。 refactor(ast2ir): 统一基本块引用类型为value_ref 将逻辑表达式、条件语句、循环语句中的基本块引用类型 从bblock_ref_t改为value_ref_t,保持类型一致性。 fix(ast2ir): 修正函数引用空值检查 使用SCC_IR_REF_nullptr常量替代0进行函数引用的空值检查, 提高代码的可读性和正确性。 refactor(ast2ir): 简化参数处理逻辑 移除不必要的函数参数获取和命名设置逻辑, 通过递归调用scc_ast2ir_decl来处理参数声明。 feat(ast2ir): 实现参数声明到IR的转换 为参数声明添加完整的IR转换逻辑,包括类型转换、 参数引用创建和内存分配处理。 refactor(ast2ir): 更新哈希表初始化接口 适配新的哈希表初始化函数签名,添加userdata参数支持, 并初始化hint_using_value字段为false。 refactor(ir): 移除函数参数的预分配逻辑 删除IR构建器中函数参数的预分配和循环添加逻辑, 简化函数开始构建的处理流程。 refactor(ir): 更新类型哈希表键值处理 修改类型哈希表的哈希和比较函数以接受模块参数, 正确处理空引用情况并支持新的键值传递方式。 fix(ir): 修复IR转储中的字符串格式 移除IR函数转储时多余的换行符,确保输出格式正确。 refactor(ir): 更新模块哈希表初始化 适配哈希表初始化接口变更,添加userdata参数, 并为各种向量预留UID 0作为无效引用。 fix(ir): 修复模块清理中的循环起始索引 将模块清理循环的起始索引从0改为1,跳过预留的 无效引用项,避免访问空指针。 refactor(ir): 调整向量和哈希表操作顺序 调整模块中向量push和哈希表set的操作顺序, 确保数据一致性和正确的UID分配。 chore(build): 移除ir2mcode模块相关文件 移除ir2mcode相关的头文件和源文件,这些组件 将在后续重构中重新设计或替换。
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
#ifndef __SCC_FRAME_ALLOC_H__
|
||||
#define __SCC_FRAME_ALLOC_H__
|
||||
|
||||
#include <scc_ir.h>
|
||||
|
||||
typedef struct scc_frame_alloc_ops scc_frame_alloc_ops_t;
|
||||
struct scc_frame_alloc_ops {
|
||||
/// maybe have direct function to new
|
||||
scc_frame_alloc_ops_t *(*new)(scc_ir_func_t *func);
|
||||
int (*drop)(scc_frame_alloc_ops_t *alloc);
|
||||
|
||||
int (*alloc_spill_slot)(scc_frame_alloc_ops_t *frame, int size, int align);
|
||||
int (*alloc_local_slot)(scc_frame_alloc_ops_t *frame, int size, int align,
|
||||
const char *name);
|
||||
|
||||
void (*finalize)(scc_frame_alloc_ops_t *frame);
|
||||
int (*get_slot_offset)(scc_frame_alloc_ops_t *frame, int slot_id);
|
||||
int (*get_frame_size)(scc_frame_alloc_ops_t *frame);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
#ifndef __SCC_REG_ALLOC_H__
|
||||
#define __SCC_REG_ALLOC_H__
|
||||
|
||||
#include "frame_alloc.h"
|
||||
#include <scc_core.h>
|
||||
#include <scc_ir.h>
|
||||
#include <scc_utils.h>
|
||||
|
||||
typedef enum {
|
||||
SCC_REG_KIND_UNDEF,
|
||||
SCC_REG_KIND_FUNC_ARG,
|
||||
SCC_REG_KIND_GPR, ///< 通用寄存器(整数)
|
||||
SCC_REG_KIND_FPR, ///< 浮点数寄存器
|
||||
SCC_REG_KIND_STACK, ///< 栈
|
||||
SCC_REG_KIND_STACK_ADDR, ///< 栈地址(如 alloc 节点)
|
||||
SCC_REG_KIND_IMM, ///< 整数立即数
|
||||
SCC_REG_KIND_IMM_FP, ///< 浮点数常量
|
||||
} scc_reg_kind_t;
|
||||
|
||||
typedef struct {
|
||||
scc_reg_kind_t kind;
|
||||
union {
|
||||
usize data;
|
||||
int slot_idx;
|
||||
int gpr_idx;
|
||||
int fpr_idx;
|
||||
} data;
|
||||
} scc_reg_loc_t;
|
||||
typedef SCC_VEC(scc_reg_loc_t) scc_reg_loc_vec_t;
|
||||
|
||||
struct scc_reg_alloc;
|
||||
typedef struct scc_reg_alloc scc_reg_alloc_t;
|
||||
typedef void (*scc_reg_alloc_func_t)(scc_reg_alloc_t *ctx, scc_ir_func_t *func,
|
||||
scc_frame_alloc_ops_t *frame_alloc);
|
||||
|
||||
typedef struct scc_reg_alloc {
|
||||
scc_frame_alloc_ops_t *frame_alloc;
|
||||
scc_ir_module_t *ir_module; ///< IR存储节点
|
||||
scc_hashtable_t node2loc; ///< 输出结果哈希表
|
||||
scc_reg_loc_vec_t loc_vec;
|
||||
scc_reg_alloc_func_t reg_alloc_func;
|
||||
} scc_reg_alloc_t;
|
||||
|
||||
void scc_reg_alloc_init(scc_reg_alloc_t *ctx, scc_reg_alloc_func_t strategy,
|
||||
scc_ir_module_t *ir_module);
|
||||
static inline scc_hashtable_t *
|
||||
scc_reg_alloc_run(scc_reg_alloc_t *ctx, scc_ir_func_t *func,
|
||||
const scc_frame_alloc_ops_t *frame_alloc) {
|
||||
if (ctx->frame_alloc != nullptr) {
|
||||
ctx->frame_alloc->drop(ctx->frame_alloc);
|
||||
ctx->frame_alloc = nullptr;
|
||||
}
|
||||
Assert(ctx->frame_alloc == nullptr);
|
||||
ctx->frame_alloc = frame_alloc->new(func);
|
||||
Assert(ctx->frame_alloc != nullptr);
|
||||
ctx->reg_alloc_func(ctx, func, ctx->frame_alloc);
|
||||
ctx->frame_alloc->finalize(ctx->frame_alloc);
|
||||
return &ctx->node2loc;
|
||||
}
|
||||
|
||||
static inline usize scc_reg_stack_size(scc_reg_alloc_t *ctx) {
|
||||
return ctx->frame_alloc->get_frame_size(ctx->frame_alloc);
|
||||
}
|
||||
|
||||
static inline int scc_reg_stack_offset(scc_reg_alloc_t *ctx,
|
||||
scc_reg_loc_t *loc) {
|
||||
Assert(loc->kind == SCC_REG_KIND_STACK ||
|
||||
loc->kind == SCC_REG_KIND_STACK_ADDR);
|
||||
return ctx->frame_alloc->get_slot_offset(ctx->frame_alloc,
|
||||
loc->data.slot_idx);
|
||||
}
|
||||
|
||||
void scc_reg_alloc_strategy_pure_stack(scc_reg_alloc_t *ctx,
|
||||
scc_ir_func_t *func,
|
||||
scc_frame_alloc_ops_t *frame_alloc);
|
||||
|
||||
#endif /* __SCC_REG_ALLOC_H__ */
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef __SCC_IR2MCODE_H__
|
||||
#define __SCC_IR2MCODE_H__
|
||||
|
||||
#include "reg_alloc.h"
|
||||
#include <scc_core.h>
|
||||
#include <scc_ir.h>
|
||||
#include <scc_mcode.h>
|
||||
#include <sccf_builder.h>
|
||||
|
||||
typedef struct {
|
||||
scc_ir_cprog_t *cprog;
|
||||
sccf_builder_t *builder;
|
||||
scc_mcode_t sect_mcode;
|
||||
sccf_sect_data_t sect_data;
|
||||
|
||||
// FIXME
|
||||
usize stack_size;
|
||||
scc_reg_alloc_t reg_alloc;
|
||||
scc_hashtable_t *noderef2regloc;
|
||||
} scc_ir2mcode_ctx_t;
|
||||
|
||||
// amd64
|
||||
|
||||
void scc_ir2mcode_init(scc_ir2mcode_ctx_t *ctx, scc_ir_cprog_t *cprog,
|
||||
sccf_builder_t *builder, scc_mcode_arch_t arch);
|
||||
void scc_ir2mcode_drop(scc_ir2mcode_ctx_t *ctx);
|
||||
|
||||
void scc_ir2mcode(scc_ir2mcode_ctx_t *ctx);
|
||||
|
||||
#endif /* __SCC_IR2MCODE_H__ */
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
#include <scc_ir.h>
|
||||
int scc_ir2mcode_type_width(scc_ir_module_t *ctx, scc_ir_type_t *type);
|
||||
Reference in New Issue
Block a user