98 CTASSERTF(underlying->
kind == eTypeDigit,
"expected digit, got %d", underlying->
kind);
115 for (
size_t i = 0; i < len; i++)
144 for (
size_t i = 0; i < len; i++)
167 for (
size_t i = 0; i < len; i++)
194 case eTreeTypeAlias:
return ssa_type_create(cache,
tree_get_type(type), arena);
199 case eTreeTypeClosure:
204 collect_params(cache, type, arena),
208 case eTreeTypeReference:
212 case eTreeTypePointer:
215 case eTreeTypeOpaque:
219 case eTreeTypeStruct:
return ssa_type_struct(name, quals, collect_fields(cache, type, arena));
220 case eTreeTypeUnion:
return ssa_type_union(name, quals, collect_fields(cache, type, arena));
229 if (old != NULL) {
return old; }
236 ssa_type_t *result = ssa_type_create(cache, type, arena);
CT_PUREFN CT_TREE_API tree_kind_t tree_get_kind(const tree_t *tree)
CT_PUREFN CT_TREE_API const char * tree_get_name(const tree_t *tree)
CT_PUREFN CT_TREE_API const tree_t * tree_get_type(const tree_t *tree)
CT_PUREFN CT_TREE_API bool tree_is(const tree_t *self, tree_kind_t kind)
ssa_type_t * ssa_type_create_cached(map_t *cache, const tree_t *type)
ssa_type_t * ssa_type_union(const char *name, tree_quals_t quals, typevec_t *fields)
ssa_type_t * ssa_type_new(ssa_kind_t kind, const char *name, tree_quals_t quals)
ssa_type_t * ssa_type_empty(const char *name, tree_quals_t quals)
ssa_type_t * ssa_type_opaque_pointer(const char *name, tree_quals_t quals)
ssa_type_t * ssa_type_unit(const char *name, tree_quals_t quals)
ssa_type_t * ssa_type_enum(const char *name, tree_quals_t quals, ssa_type_t *underlying, typevec_t *cases)
ssa_type_t * ssa_type_struct(const char *name, tree_quals_t quals, typevec_t *fields)
ssa_type_t * ssa_type_closure(const char *name, tree_quals_t quals, ssa_type_t *result, typevec_t *params, bool variadic)
CT_PUREFN CT_TREE_API tree_arity_t tree_fn_get_arity(const tree_t *self)
CT_TREE_API const char * tree_to_string(const tree_t *self)
CT_PUREFN CT_TREE_API const tree_t * tree_fn_get_return(const tree_t *self)
CT_PUREFN CT_TREE_API tree_quals_t tree_ty_get_quals(const tree_t *self)
CT_PUREFN CT_TREE_API vector_t * tree_enum_get_cases(const tree_t *self)
CT_PUREFN CT_TREE_API const vector_t * tree_fn_get_params(const tree_t *self)
CT_NOALIAS CT_BASE_API void * ctu_memcpy(STA_WRITES(size) void *CT_RESTRICT dst, STA_READS(size) const void *CT_RESTRICT src, size_t size)
copy memory from one location to another equivalent to memcpy but with safety checks
CT_MEMORY_API arena_t * get_global_arena(void)
get the global memory arena
CT_STD_API void map_set(map_t *map, const void *key, void *value)
set a key-value pair in a map
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get(const map_t *map, const void *key)
get a value from a map
#define ARENA_MALLOC(size, name, parent, arena)
allocate memory from a custom allocator
#define CT_NEVER(...)
assert that a code path is never reached
#define CTASSERTF(expr,...)
assert a condition with a message and optional format arguments
ssa_type_t * ssa_type_bool(const char *name, tree_quals_t quals)
ssa_type_t * ssa_type_pointer(const char *name, tree_quals_t quals, ssa_type_t *pointer, size_t length)
ssa_type_t * ssa_type_digit(const char *name, tree_quals_t quals, sign_t sign, digit_t digit)
tree_quals_t
all type qualifiers
tree_kind_t
all tree node types
CT_STD_API void typevec_set(typevec_t *vec, size_t index, const void *src)
set an element in the vector
CT_NODISCARD CT_STD_API typevec_t * typevec_of(size_t width, size_t len, arena_t *arena)
create a new typed vector with an initial size and length
CT_NODISCARD CT_PUREFN CT_STD_API void * vector_get(const vector_t *vector, size_t index)
get a value from a vector
CT_NODISCARD CT_PUREFN CT_STD_API size_t vector_len(const vector_t *vector)
get the length of a vector
const ssa_type_t * result
const ssa_type_t * pointer
ssa_type_closure_t closure
ssa_type_pointer_t pointer
const tree_t * underlying
A vector with a fixed type size.
a generic vector of pointers