in bits, not bytes

This commit is contained in:
Mid 2025-09-14 10:43:37 +03:00
parent cdcc1f6d3d
commit 251d24fb30
6 changed files with 9 additions and 7 deletions

View File

@ -31,7 +31,7 @@ static void spill2stack_visitor(AST **aptr, AST *stmt, AST *stmtPrev, AST *chunk
ASTExprStackPointer *rsp = calloc(1, sizeof(*rsp)); ASTExprStackPointer *rsp = calloc(1, sizeof(*rsp));
rsp->nodeKind = AST_EXPR_STACK_POINTER; 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)); ASTExprPrimitive *offset = calloc(1, sizeof(*offset));
offset->nodeKind = AST_EXPR_PRIMITIVE; offset->nodeKind = AST_EXPR_PRIMITIVE;

View File

@ -228,7 +228,7 @@ AST *nct_parse_expression(Parser *P, int lOP) {
ASTExprStackPointer *ret = alloc_node(P, sizeof(*ret)); ASTExprStackPointer *ret = alloc_node(P, sizeof(*ret));
ret->nodeKind = AST_EXPR_STACK_POINTER; ret->nodeKind = AST_EXPR_STACK_POINTER;
ret->type = type_u(arch_sp_size()); ret->type = type_u(8 * arch_sp_size());
e = (AST*) ret; e = (AST*) ret;
} else if(!strcmp(peek(P, 0).content, "@salloc")) { } 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->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; e = (AST*) ret;
} else { } else {
@ -461,7 +461,7 @@ AST *nct_parse_expression(Parser *P, int lOP) {
if(typesize != 1) { if(typesize != 1) {
ASTExprPrimitive *scale = alloc_node(P, sizeof(*scale)); ASTExprPrimitive *scale = alloc_node(P, sizeof(*scale));
scale->nodeKind = AST_EXPR_PRIMITIVE; scale->nodeKind = AST_EXPR_PRIMITIVE;
scale->type = type_u(arch_gpr_size()); scale->type = type_u(8 * arch_gpr_size());
scale->val = typesize; scale->val = typesize;
ASTExprBinaryOp *mul = alloc_node(P, sizeof(*mul)); ASTExprBinaryOp *mul = alloc_node(P, sizeof(*mul));

View File

@ -82,6 +82,7 @@ void vte_precolor(ScopeItem *vte, int class, int color) {
assert(!vte->data.var.precolored && "already precolored"); assert(!vte->data.var.precolored && "already precolored");
vte->data.var.precolored = true; vte->data.var.precolored = true;
vte->data.var.preclassed = true;
vte->data.var.registerClass = class; vte->data.var.registerClass = class;
vte->data.var.color = color; vte->data.var.color = color;
} }

View File

@ -7,6 +7,7 @@
#include"ast/ast.h" #include"ast/ast.h"
#include"reporting.h" #include"reporting.h"
#include<assert.h> #include<assert.h>
#include"x86/arch.h"
#include"ntc.h" #include"ntc.h"

View File

@ -115,9 +115,9 @@ static inline bool type_is_segmented_pointer(Type *type) {
return type->type == TYPE_TYPE_RECORD && !!strstr(type->record.name, " @far*"); 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]; char buf[32];
snprintf(buf, sizeof(buf), "u%lu", size); snprintf(buf, sizeof(buf), "u%lu", bits);
return primitive_parse(buf); return primitive_parse(buf);
} }

View File

@ -474,7 +474,7 @@ static void pre_dumb_visitor(AST **nptr, AST *stmt, AST *stmtPrev, AST *chunk, A
ASTExprPrimitive *offset = calloc(1, sizeof(*offset)); ASTExprPrimitive *offset = calloc(1, sizeof(*offset));
offset->nodeKind = AST_EXPR_PRIMITIVE; 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->val = 4 + i * x86_max_gpr_size();
offset->stackGrowth = true; offset->stackGrowth = true;