mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 08:38:51 +00:00
Improve llreg integer type generation for SysV ABI
This commit is contained in:
+25
-4
@@ -787,15 +787,35 @@ namespace lbAbiAmd64SysV {
|
||||
|
||||
gb_internal LLVMTypeRef llreg(LLVMContextRef c, Array<RegClass> const ®_classes, LLVMTypeRef type) {
|
||||
auto types = array_make<LLVMTypeRef>(heap_allocator(), 0, reg_classes.count);
|
||||
|
||||
bool all_ints = true;
|
||||
for (RegClass reg_class : reg_classes) {
|
||||
if (reg_class != RegClass_Int) {
|
||||
all_ints = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (all_ints) {
|
||||
i64 sz = lb_sizeof(type);
|
||||
for_array(i, reg_classes) {
|
||||
GB_ASSERT(sz != 0);
|
||||
// TODO(bill): is this even correct? BECAUSE LLVM DOES NOT DOCUMENT ANY OF THIS!!!
|
||||
if (sz >= 8) {
|
||||
array_add(&types, LLVMIntTypeInContext(c, 64));
|
||||
sz -= 8;
|
||||
} else {
|
||||
array_add(&types, LLVMIntTypeInContext(c, cast(unsigned)(sz*8)));
|
||||
sz = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (isize i = 0; i < reg_classes.count; /**/) {
|
||||
RegClass reg_class = reg_classes[i];
|
||||
switch (reg_class) {
|
||||
case RegClass_Int:
|
||||
if (reg_classes.count == 1) {
|
||||
array_add(&types, LLVMIntTypeInContext(c, cast(unsigned)(lb_sizeof(type)*8)));
|
||||
} else {
|
||||
// TODO(bill): is this even correct? BECAUSE LLVM DOES NOT DOCUMENT ANY OF THIS!!!
|
||||
array_add(&types, LLVMIntTypeInContext(c, 64));
|
||||
}
|
||||
break;
|
||||
case RegClass_SSEFv:
|
||||
case RegClass_SSEDv:
|
||||
@@ -851,6 +871,7 @@ namespace lbAbiAmd64SysV {
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (types.count == 1) {
|
||||
return types[0];
|
||||
|
||||
Reference in New Issue
Block a user