stage2 修复大量AI生成的风格问题 stage1 修复对于vm abi的错误生成
This commit is contained in:
1 parent
0e38858785
commit
76f980654c
40 files changed
+619
-938
No files matched your search
+2
-13
@@ -1,12 +1,7 @@
|
||||
// Expect retcode = 0
|
||||
|
||||
// IR -> C99 后端(P1a 子集)。
|
||||
//
|
||||
// 设计:每个 IR ref 一个 C 局部变量(C 编译器 -O2 会做 mem2reg),标签用 goto;
|
||||
// 类型直接由 IR 的 tid 决定,生成期无运行时分发。
|
||||
//
|
||||
// 每个非 extern 函数的 C 名为 `spl_f<fid>`;extern 函数直接用其 SPL 名
|
||||
// (由 runtime 提供)。暂不支持聚合/切片/全局数据。
|
||||
// IR -> C99。每个 IR ref 生成一个 C 局部变量(交给 C 编译器 mem2reg),标签用 goto;
|
||||
// 类型由 IR tid 决定,生成期无运行时分发。非 extern 函数名为 `spl_f<fid>`。
|
||||
|
||||
type .{ .Vec } = @import("utils/vec.spl");
|
||||
type .{ .ByteView } = @import("utils/byte_view.spl");
|
||||
@@ -83,7 +78,6 @@ fn put_unsupported(self: *Ir2C, what: []u8) {
|
||||
put(self, " */\n");
|
||||
}
|
||||
|
||||
// ---- 类型查询 ----
|
||||
|
||||
fn info_of(self: *Ir2C, tid: usize): *LayoutM.LayoutInfo {
|
||||
ret LayoutM.info_of(self.layout, tid);
|
||||
@@ -168,7 +162,6 @@ fn fn_ret_type(self: *Ir2C, fn_tid: usize): usize {
|
||||
ret 0;
|
||||
}
|
||||
|
||||
// ---- C 类型 ----
|
||||
|
||||
fn put_type(self: *Ir2C, tid: usize): bool {
|
||||
var te = TypeTable.node(self.ty, tid);
|
||||
@@ -231,7 +224,6 @@ fn c_fn_name(self: *Ir2C, fid: usize) {
|
||||
put_u(self, fid);
|
||||
}
|
||||
|
||||
// ---- 常量解析 ----
|
||||
|
||||
fn const_node(self: *Ir2C, f: *IrFunc, ref: usize): usize {
|
||||
if ref == 0 || ref >= f.nodes.len { ret 0; }
|
||||
@@ -250,7 +242,6 @@ fn const_node(self: *Ir2C, f: *IrFunc, ref: usize): usize {
|
||||
ret 0;
|
||||
}
|
||||
|
||||
// ---- 聚合字段 ----
|
||||
|
||||
fn field_tid(self: *Ir2C, tid: usize, idx: usize): usize {
|
||||
var te = TypeTable.node(self.ty, tid);
|
||||
@@ -436,7 +427,6 @@ fn emit_agg_insert(self: *Ir2C, ref: usize, n: *IrEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 节点发射 ----
|
||||
|
||||
fn emit_arith(self: *Ir2C, ref: usize, n: *IrEntry) {
|
||||
match n.body {
|
||||
@@ -1224,7 +1214,6 @@ fn emit_def(self: *Ir2C, fid: usize) {
|
||||
put(self, "spl_trap();\n}\n");
|
||||
}
|
||||
|
||||
// ---- driver ----
|
||||
|
||||
fn find_main(self: *Ir2C): usize {
|
||||
var i: usize = 1;
|
||||
|
||||
Reference in new issue
Block a user