mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Separate ssa_struct_gep and ssa_array_gep procedures
This commit is contained in:
+19
-15
@@ -246,7 +246,7 @@ CycleChecker *cycle_checker_add(CycleChecker *cc, Entity *e) {
|
||||
return NULL;
|
||||
}
|
||||
if (cc->path.data == NULL) {
|
||||
array_init(&cc->path, gb_heap_allocator());
|
||||
array_init(&cc->path, heap_allocator());
|
||||
}
|
||||
GB_ASSERT(e != NULL && e->kind == Entity_TypeName);
|
||||
array_add(&cc->path, e);
|
||||
@@ -262,7 +262,7 @@ void cycle_checker_destroy(CycleChecker *cc) {
|
||||
|
||||
void init_declaration_info(DeclInfo *d, Scope *scope) {
|
||||
d->scope = scope;
|
||||
map_init(&d->deps, gb_heap_allocator());
|
||||
map_init(&d->deps, heap_allocator());
|
||||
}
|
||||
|
||||
DeclInfo *make_declaration_info(gbAllocator a, Scope *scope) {
|
||||
@@ -296,10 +296,10 @@ b32 decl_info_has_init(DeclInfo *d) {
|
||||
Scope *make_scope(Scope *parent, gbAllocator allocator) {
|
||||
Scope *s = gb_alloc_item(allocator, Scope);
|
||||
s->parent = parent;
|
||||
map_init(&s->elements, gb_heap_allocator());
|
||||
map_init(&s->implicit, gb_heap_allocator());
|
||||
array_init(&s->shared, gb_heap_allocator());
|
||||
array_init(&s->imported, gb_heap_allocator());
|
||||
map_init(&s->elements, heap_allocator());
|
||||
map_init(&s->implicit, heap_allocator());
|
||||
array_init(&s->shared, heap_allocator());
|
||||
array_init(&s->imported, heap_allocator());
|
||||
|
||||
if (parent != NULL && parent != universal_scope) {
|
||||
DLIST_APPEND(parent->first_child, parent->last_child, s);
|
||||
@@ -506,7 +506,7 @@ void add_global_constant(gbAllocator a, String name, Type *type, ExactValue valu
|
||||
|
||||
void init_universal_scope(void) {
|
||||
// NOTE(bill): No need to free these
|
||||
gbAllocator a = gb_heap_allocator();
|
||||
gbAllocator a = heap_allocator();
|
||||
universal_scope = make_scope(NULL, a);
|
||||
|
||||
// Types
|
||||
@@ -536,7 +536,7 @@ void init_universal_scope(void) {
|
||||
|
||||
|
||||
void init_checker_info(CheckerInfo *i) {
|
||||
gbAllocator a = gb_heap_allocator();
|
||||
gbAllocator a = heap_allocator();
|
||||
map_init(&i->types, a);
|
||||
map_init(&i->definitions, a);
|
||||
map_init(&i->uses, a);
|
||||
@@ -566,7 +566,7 @@ void destroy_checker_info(CheckerInfo *i) {
|
||||
void init_checker(Checker *c, Parser *parser, BaseTypeSizes sizes) {
|
||||
PROF_PROC();
|
||||
|
||||
gbAllocator a = gb_heap_allocator();
|
||||
gbAllocator a = heap_allocator();
|
||||
|
||||
c->parser = parser;
|
||||
init_checker_info(&c->info);
|
||||
@@ -576,7 +576,7 @@ void init_checker(Checker *c, Parser *parser, BaseTypeSizes sizes) {
|
||||
array_init(&c->procs, a);
|
||||
|
||||
// NOTE(bill): Is this big enough or too small?
|
||||
isize item_size = gb_max(gb_max(gb_size_of(Entity), gb_size_of(Type)), gb_size_of(Scope));
|
||||
isize item_size = gb_max3(gb_size_of(Entity), gb_size_of(Type), gb_size_of(Scope));
|
||||
isize total_token_count = 0;
|
||||
for_array(i, c->parser->files) {
|
||||
AstFile *f = &c->parser->files[i];
|
||||
@@ -888,7 +888,7 @@ void add_dependency_to_map(Map<Entity *> *map, CheckerInfo *info, Entity *node)
|
||||
|
||||
Map<Entity *> generate_minimum_dependency_map(CheckerInfo *info, Entity *start) {
|
||||
Map<Entity *> map = {}; // Key: Entity *
|
||||
map_init(&map, gb_heap_allocator());
|
||||
map_init(&map, heap_allocator());
|
||||
|
||||
for_array(i, info->entities.entries) {
|
||||
auto *entry = &info->entities.entries[i];
|
||||
@@ -913,6 +913,10 @@ Map<Entity *> generate_minimum_dependency_map(CheckerInfo *info, Entity *start)
|
||||
void init_preload_types(Checker *c) {
|
||||
PROF_PROC();
|
||||
|
||||
if (t_u8_ptr == NULL) {
|
||||
t_u8_ptr = make_type_pointer(c->allocator, t_u8);
|
||||
}
|
||||
|
||||
if (t_type_info == NULL) {
|
||||
Entity *e = current_scope_lookup_entity(c->global_scope, make_string("Type_Info"));
|
||||
if (e == NULL) {
|
||||
@@ -983,11 +987,11 @@ void add_implicit_value(Checker *c, ImplicitValueId id, String name, String back
|
||||
|
||||
void check_parsed_files(Checker *c) {
|
||||
Array<AstNode *> import_decls;
|
||||
array_init(&import_decls, gb_heap_allocator());
|
||||
array_init(&import_decls, heap_allocator());
|
||||
defer (array_free(&import_decls));
|
||||
|
||||
Map<Scope *> file_scopes; // Key: String (fullpath)
|
||||
map_init(&file_scopes, gb_heap_allocator());
|
||||
map_init(&file_scopes, heap_allocator());
|
||||
defer (map_destroy(&file_scopes));
|
||||
|
||||
// Map full filepaths to Scopes
|
||||
@@ -1069,7 +1073,7 @@ void check_parsed_files(Checker *c) {
|
||||
Entity **entities = gb_alloc_array(c->allocator, Entity *, entity_count);
|
||||
DeclInfo *di = NULL;
|
||||
if (vd->values.count > 0) {
|
||||
di = make_declaration_info(gb_heap_allocator(), file_scope);
|
||||
di = make_declaration_info(heap_allocator(), file_scope);
|
||||
di->entities = entities;
|
||||
di->entity_count = entity_count;
|
||||
di->type_expr = vd->type;
|
||||
@@ -1089,7 +1093,7 @@ void check_parsed_files(Checker *c) {
|
||||
DeclInfo *d = di;
|
||||
if (d == NULL) {
|
||||
AstNode *init_expr = value;
|
||||
d = make_declaration_info(gb_heap_allocator(), file_scope);
|
||||
d = make_declaration_info(heap_allocator(), file_scope);
|
||||
d->type_expr = vd->type;
|
||||
d->init_expr = init_expr;
|
||||
d->var_decl_tags = vd->tags;
|
||||
|
||||
@@ -249,7 +249,7 @@ void check_fields(Checker *c, AstNode *node, AstNodeArray decls,
|
||||
PROF_PROC();
|
||||
|
||||
Map<Entity *> entity_map = {};
|
||||
map_init(&entity_map, gb_heap_allocator());
|
||||
map_init(&entity_map, heap_allocator());
|
||||
defer (map_destroy(&entity_map));
|
||||
|
||||
isize other_field_index = 0;
|
||||
@@ -662,7 +662,7 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
|
||||
ast_node(et, EnumType, node);
|
||||
|
||||
Map<Entity *> entity_map = {};
|
||||
map_init(&entity_map, gb_heap_allocator());
|
||||
map_init(&entity_map, heap_allocator());
|
||||
defer (map_destroy(&entity_map));
|
||||
|
||||
Type *base_type = t_int;
|
||||
@@ -4458,5 +4458,5 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
|
||||
}
|
||||
|
||||
gbString expr_to_string(AstNode *expression) {
|
||||
return write_expr_to_string(gb_string_make(gb_heap_allocator(), ""), expression);
|
||||
return write_expr_to_string(gb_string_make(heap_allocator(), ""), expression);
|
||||
}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
|
||||
};
|
||||
|
||||
Map<TypeAndToken> seen = {}; // Multimap
|
||||
map_init(&seen, gb_heap_allocator());
|
||||
map_init(&seen, heap_allocator());
|
||||
defer (map_destroy(&seen));
|
||||
for_array(i, bs->stmts) {
|
||||
AstNode *stmt = bs->stmts[i];
|
||||
@@ -1319,7 +1319,7 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) {
|
||||
|
||||
|
||||
Map<b32> seen = {};
|
||||
map_init(&seen, gb_heap_allocator());
|
||||
map_init(&seen, heap_allocator());
|
||||
defer (map_destroy(&seen));
|
||||
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ struct Type {
|
||||
};
|
||||
};
|
||||
|
||||
gbString type_to_string(Type *type, gbAllocator a = gb_heap_allocator());
|
||||
gbString type_to_string(Type *type, gbAllocator a = heap_allocator());
|
||||
|
||||
Type *base_type(Type *t) {
|
||||
for (;;) {
|
||||
@@ -359,6 +359,8 @@ gb_global Type *t_byte = &basic_type_aliases[0];
|
||||
gb_global Type *t_rune = &basic_type_aliases[1];
|
||||
|
||||
|
||||
gb_global Type *t_u8_ptr = NULL;
|
||||
|
||||
gb_global Type *t_type_info = NULL;
|
||||
gb_global Type *t_type_info_ptr = NULL;
|
||||
gb_global Type *t_type_info_member = NULL;
|
||||
@@ -791,7 +793,7 @@ void selection_add_index(Selection *s, isize index) {
|
||||
// IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form
|
||||
// of heap allocation
|
||||
if (s->index.data == NULL) {
|
||||
array_init(&s->index, gb_heap_allocator());
|
||||
array_init(&s->index, heap_allocator());
|
||||
}
|
||||
array_add(&s->index, index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user