From 251d24fb3074a4dc3618d3f3c922e6b2e05a0e5d Mon Sep 17 00:00:00 2001 From: Mid <> Date: Sun, 14 Sep 2025 10:43:37 +0300 Subject: [PATCH] in bits, not bytes --- src/ast/stack.c | 2 +- src/parse.c | 6 +++--- src/scope.c | 1 + src/types.c | 1 + src/types.h | 4 ++-- src/x86/dumberdowner.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ast/stack.c b/src/ast/stack.c index e3ba48c..1de04d2 100644 --- a/src/ast/stack.c +++ b/src/ast/stack.c @@ -31,7 +31,7 @@ static void spill2stack_visitor(AST **aptr, AST *stmt, AST *stmtPrev, AST *chunk ASTExprStackPointer *rsp = calloc(1, sizeof(*rsp)); rsp->nodeKind = AST_EXPR_STACK_POINTER; - rsp->type = type_u(arch_gpr_size()); + rsp->type = type_u(8 * arch_gpr_size()); ASTExprPrimitive *offset = calloc(1, sizeof(*offset)); offset->nodeKind = AST_EXPR_PRIMITIVE; diff --git a/src/parse.c b/src/parse.c index b415fce..c4b4c35 100644 --- a/src/parse.c +++ b/src/parse.c @@ -228,7 +228,7 @@ AST *nct_parse_expression(Parser *P, int lOP) { ASTExprStackPointer *ret = alloc_node(P, sizeof(*ret)); ret->nodeKind = AST_EXPR_STACK_POINTER; - ret->type = type_u(arch_sp_size()); + ret->type = type_u(8 * arch_sp_size()); e = (AST*) ret; } else if(!strcmp(peek(P, 0).content, "@salloc")) { @@ -255,7 +255,7 @@ AST *nct_parse_expression(Parser *P, int lOP) { ret->ofExpr = nct_parse_expression(P, lOP - 1); } - ret->type = type_u(arch_gpr_size()); + ret->type = type_u(8 * arch_gpr_size()); e = (AST*) ret; } else { @@ -461,7 +461,7 @@ AST *nct_parse_expression(Parser *P, int lOP) { if(typesize != 1) { ASTExprPrimitive *scale = alloc_node(P, sizeof(*scale)); scale->nodeKind = AST_EXPR_PRIMITIVE; - scale->type = type_u(arch_gpr_size()); + scale->type = type_u(8 * arch_gpr_size()); scale->val = typesize; ASTExprBinaryOp *mul = alloc_node(P, sizeof(*mul)); diff --git a/src/scope.c b/src/scope.c index 706fcdb..7fa8dfe 100644 --- a/src/scope.c +++ b/src/scope.c @@ -82,6 +82,7 @@ void vte_precolor(ScopeItem *vte, int class, int color) { assert(!vte->data.var.precolored && "already precolored"); vte->data.var.precolored = true; + vte->data.var.preclassed = true; vte->data.var.registerClass = class; vte->data.var.color = color; } diff --git a/src/types.c b/src/types.c index 362d825..e6dd79d 100644 --- a/src/types.c +++ b/src/types.c @@ -7,6 +7,7 @@ #include"ast/ast.h" #include"reporting.h" #include +#include"x86/arch.h" #include"ntc.h" diff --git a/src/types.h b/src/types.h index ee8f8f4..1360ae4 100644 --- a/src/types.h +++ b/src/types.h @@ -115,9 +115,9 @@ static inline bool type_is_segmented_pointer(Type *type) { return type->type == TYPE_TYPE_RECORD && !!strstr(type->record.name, " @far*"); } -static inline Type *type_u(size_t size) { +static inline Type *type_u(size_t bits) { char buf[32]; - snprintf(buf, sizeof(buf), "u%lu", size); + snprintf(buf, sizeof(buf), "u%lu", bits); return primitive_parse(buf); } diff --git a/src/x86/dumberdowner.c b/src/x86/dumberdowner.c index 4de043f..a0a3e0b 100644 --- a/src/x86/dumberdowner.c +++ b/src/x86/dumberdowner.c @@ -474,7 +474,7 @@ static void pre_dumb_visitor(AST **nptr, AST *stmt, AST *stmtPrev, AST *chunk, A ASTExprPrimitive *offset = calloc(1, sizeof(*offset)); offset->nodeKind = AST_EXPR_PRIMITIVE; - offset->type = type_u(x86_max_gpr_size()); + offset->type = type_u(8 * x86_max_gpr_size()); offset->val = 4 + i * x86_max_gpr_size(); offset->stackGrowth = true;