mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-04 12:07:45 +00:00
Add equal procedure field to runtime.Type_Info_Struct
This commit is contained in:
11
src/ir.cpp
11
src/ir.cpp
@@ -12353,8 +12353,13 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 6), is_raw_union);
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 7), is_custom_align);
|
||||
|
||||
if (is_type_comparable(t) && !is_type_simple_compare(t)) {
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 8), ir_get_compare_proc_for_type(proc->module, t));
|
||||
}
|
||||
|
||||
|
||||
if (t->Struct.soa_kind != StructSoa_None) {
|
||||
irValue *kind = ir_emit_struct_ep(proc, tag, 8);
|
||||
irValue *kind = ir_emit_struct_ep(proc, tag, 9);
|
||||
Type *kind_type = type_deref(ir_type(kind));
|
||||
|
||||
irValue *soa_kind = ir_value_constant(kind_type, exact_value_i64(t->Struct.soa_kind));
|
||||
@@ -12363,8 +12368,8 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
|
||||
|
||||
|
||||
ir_emit_store(proc, kind, soa_kind);
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 9), soa_type);
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 10), soa_len);
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 10), soa_type);
|
||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 11), soa_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12178,7 +12178,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da
|
||||
case Type_Struct: {
|
||||
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_struct_ptr);
|
||||
|
||||
LLVMValueRef vals[11] = {};
|
||||
LLVMValueRef vals[12] = {};
|
||||
|
||||
|
||||
{
|
||||
@@ -12188,18 +12188,22 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da
|
||||
vals[5] = is_packed.value;
|
||||
vals[6] = is_raw_union.value;
|
||||
vals[7] = is_custom_align.value;
|
||||
if (is_type_comparable(t) && !is_type_simple_compare(t)) {
|
||||
vals[8] = lb_get_compare_proc_for_type(m, t).value;
|
||||
}
|
||||
|
||||
|
||||
if (t->Struct.soa_kind != StructSoa_None) {
|
||||
lbValue kind = lb_emit_struct_ep(p, tag, 8);
|
||||
lbValue kind = lb_emit_struct_ep(p, tag, 9);
|
||||
Type *kind_type = type_deref(kind.type);
|
||||
|
||||
lbValue soa_kind = lb_const_value(m, kind_type, exact_value_i64(t->Struct.soa_kind));
|
||||
lbValue soa_type = lb_type_info(m, t->Struct.soa_elem);
|
||||
lbValue soa_len = lb_const_int(m, t_int, t->Struct.soa_count);
|
||||
|
||||
vals[8] = soa_kind.value;
|
||||
vals[9] = soa_type.value;
|
||||
vals[10] = soa_len.value;
|
||||
vals[9] = soa_kind.value;
|
||||
vals[1] = soa_type.value;
|
||||
vals[11] = soa_len.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,54 +1321,6 @@ Type *core_array_type(Type *t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
// NOTE(bill): type can be easily compared using memcmp
|
||||
bool is_type_simple_compare(Type *t) {
|
||||
t = core_type(t);
|
||||
switch (t->kind) {
|
||||
case Type_Array:
|
||||
return is_type_simple_compare(t->Array.elem);
|
||||
|
||||
case Type_EnumeratedArray:
|
||||
return is_type_simple_compare(t->EnumeratedArray.elem);
|
||||
|
||||
case Type_Basic:
|
||||
if (t->Basic.flags & BasicFlag_SimpleCompare) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
case Type_Pointer:
|
||||
case Type_Proc:
|
||||
case Type_BitSet:
|
||||
case Type_BitField:
|
||||
return true;
|
||||
|
||||
case Type_Struct:
|
||||
for_array(i, t->Struct.fields) {
|
||||
Entity *f = t->Struct.fields[i];
|
||||
if (!is_type_simple_compare(f->type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case Type_Union:
|
||||
for_array(i, t->Union.variants) {
|
||||
Type *v = t->Union.variants[i];
|
||||
if (!is_type_simple_compare(v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case Type_SimdVector:
|
||||
return is_type_simple_compare(t->SimdVector.elem);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Type *base_complex_elem_type(Type *t) {
|
||||
@@ -1978,6 +1930,55 @@ bool is_type_comparable(Type *t) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOTE(bill): type can be easily compared using memcmp
|
||||
bool is_type_simple_compare(Type *t) {
|
||||
t = core_type(t);
|
||||
switch (t->kind) {
|
||||
case Type_Array:
|
||||
return is_type_simple_compare(t->Array.elem);
|
||||
|
||||
case Type_EnumeratedArray:
|
||||
return is_type_simple_compare(t->EnumeratedArray.elem);
|
||||
|
||||
case Type_Basic:
|
||||
if (t->Basic.flags & BasicFlag_SimpleCompare) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
case Type_Pointer:
|
||||
case Type_Proc:
|
||||
case Type_BitSet:
|
||||
case Type_BitField:
|
||||
return true;
|
||||
|
||||
case Type_Struct:
|
||||
for_array(i, t->Struct.fields) {
|
||||
Entity *f = t->Struct.fields[i];
|
||||
if (!is_type_simple_compare(f->type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case Type_Union:
|
||||
for_array(i, t->Union.variants) {
|
||||
Type *v = t->Union.variants[i];
|
||||
if (!is_type_simple_compare(v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case Type_SimdVector:
|
||||
return is_type_simple_compare(t->SimdVector.elem);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Type *strip_type_aliasing(Type *x) {
|
||||
if (x == nullptr) {
|
||||
return x;
|
||||
|
||||
Reference in New Issue
Block a user