authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-01-29 17:30:18+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-02-04 22:44:56+02:00
log5a7d43df23664385d6841ef98b17ff9447be1ec6
tree2c298f5d587963e669988e694932e286bd75ce1d
parentb2f84c6714c30589c35fce72bab530cef4b05eca

stage1: make f80 always size 16, align 16


2 files changed, 11 insertions(+), 6 deletions(-)

lib/std/math.zig+2
...@@ -46,8 +46,10 @@ pub const f128_toint = 1.0 / f128_epsilon;...@@ -46,8 +46,10 @@ pub const f128_toint = 1.0 / f128_epsilon;
46pub const F80Repr = if (@import("builtin").cpu.arch.endian() == .Little) extern struct {46pub const F80Repr = if (@import("builtin").cpu.arch.endian() == .Little) extern struct {
47 fraction: u64,47 fraction: u64,
48 exp: u16,48 exp: u16,
49 _pad: u32 = undefined,
49} else extern struct {50} else extern struct {
50 exp: u16,51 exp: u16,
52 _pad: u32 = undefined, // TODO verify compatibility with hardware
51 fraction: u64,53 fraction: u64,
52};54};
5355
src/stage1/codegen.cpp+9-6
...@@ -8197,6 +8197,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n...@@ -8197,6 +8197,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n
8197 buf[1] = tmp;8197 buf[1] = tmp;
8198#endif8198#endif
8199 LLVMValueRef as_i128 = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf);8199 LLVMValueRef as_i128 = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf);
8200 if (!target_has_f80(g->zig_target)) return as_i128;
8200 LLVMValueRef as_int = LLVMConstTrunc(as_i128, LLVMIntType(80));8201 LLVMValueRef as_int = LLVMConstTrunc(as_i128, LLVMIntType(80));
8201 return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry));8202 return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry));
8202 }8203 }
...@@ -9420,13 +9421,15 @@ static void define_builtin_types(CodeGen *g) {...@@ -9420,13 +9421,15 @@ static void define_builtin_types(CodeGen *g) {
9420 add_fp_entry(g, "f64", 64, LLVMDoubleType(), &g->builtin_types.entry_f64);9421 add_fp_entry(g, "f64", 64, LLVMDoubleType(), &g->builtin_types.entry_f64);
9421 add_fp_entry(g, "f128", 128, LLVMFP128Type(), &g->builtin_types.entry_f128);9422 add_fp_entry(g, "f128", 128, LLVMFP128Type(), &g->builtin_types.entry_f128);
94229423
9423 if (target_has_f80(g->zig_target)) {9424 {
9424 add_fp_entry(g, "f80", 80, LLVMX86FP80Type(), &g->builtin_types.entry_f80);
9425 } else {
9426 ZigType *entry = new_type_table_entry(ZigTypeIdFloat);9425 ZigType *entry = new_type_table_entry(ZigTypeIdFloat);
9427 entry->llvm_type = get_int_type(g, false, 128)->llvm_type;9426 if (target_has_f80(g->zig_target)) {
9428 entry->size_in_bits = 8 * LLVMStoreSizeOfType(g->target_data_ref, entry->llvm_type);9427 entry->llvm_type = LLVMX86FP80Type();
9429 entry->abi_size = LLVMABISizeOfType(g->target_data_ref, entry->llvm_type);9428 } else {
9429 entry->llvm_type = get_int_type(g, false, 128)->llvm_type;
9430 }
9431 entry->size_in_bits = 8 * 16;
9432 entry->abi_size = 16;
9430 entry->abi_align = 16;9433 entry->abi_align = 16;
9431 buf_init_from_str(&entry->name, "f80");9434 buf_init_from_str(&entry->name, "f80");
9432 entry->data.floating.bit_count = 80;9435 entry->data.floating.bit_count = 80;