| ... | ... | @@ -1120,8 +1120,8 @@ pub const Value = extern union { |
| 1120 | 1120 | fn floatReadFromMemory(comptime F: type, target: Target, buffer: []const u8) F { |
| 1121 | 1121 | if (F == f80) { |
| 1122 | 1122 | // TODO: use std.math.F80Repr? |
| 1123 | | const big_int = std.mem.readInt(u128, buffer[0..16], target.cpu.arch.endian()); |
| 1124 | | const int = @truncate(u80, big_int); |
| 1123 | const int = std.mem.readInt(u128, buffer[0..16], target.cpu.arch.endian()); |
| 1124 | // TODO shouldn't this be a bitcast from u80 to f80 instead of u128 to f80? |
| 1125 | 1125 | return @bitCast(F, int); |
| 1126 | 1126 | } |
| 1127 | 1127 | const Int = @Type(.{ .Int = .{ |
| ... | ... | @@ -1143,8 +1143,18 @@ pub const Value = extern union { |
| 1143 | 1143 | |
| 1144 | 1144 | .zero => 0, |
| 1145 | 1145 | .one => 1, |
| 1146 | | .int_u64 => @intToFloat(T, val.castTag(.int_u64).?.data), |
| 1147 | | .int_i64 => @intToFloat(T, val.castTag(.int_i64).?.data), |
| 1146 | .int_u64 => { |
| 1147 | if (T == f80) { |
| 1148 | @panic("TODO we can't lower this properly on non-x86 llvm backend yet"); |
| 1149 | } |
| 1150 | return @intToFloat(T, val.castTag(.int_u64).?.data); |
| 1151 | }, |
| 1152 | .int_i64 => { |
| 1153 | if (T == f80) { |
| 1154 | @panic("TODO we can't lower this properly on non-x86 llvm backend yet"); |
| 1155 | } |
| 1156 | return @intToFloat(T, val.castTag(.int_i64).?.data); |
| 1157 | }, |
| 1148 | 1158 | |
| 1149 | 1159 | .int_big_positive => @floatCast(T, bigIntToFloat(val.castTag(.int_big_positive).?.data, true)), |
| 1150 | 1160 | .int_big_negative => @floatCast(T, bigIntToFloat(val.castTag(.int_big_negative).?.data, false)), |
| ... | ... | @@ -2202,7 +2212,9 @@ pub const Value = extern union { |
| 2202 | 2212 | 16 => return Value.Tag.float_16.create(arena, @intToFloat(f16, x)), |
| 2203 | 2213 | 32 => return Value.Tag.float_32.create(arena, @intToFloat(f32, x)), |
| 2204 | 2214 | 64 => return Value.Tag.float_64.create(arena, @intToFloat(f64, x)), |
| 2205 | | 80 => return Value.Tag.float_80.create(arena, @intToFloat(f80, x)), |
| 2215 | // We can't lower this properly on non-x86 llvm backends yet |
| 2216 | //80 => return Value.Tag.float_80.create(arena, @intToFloat(f80, x)), |
| 2217 | 80 => @panic("TODO f80 intToFloat"), |
| 2206 | 2218 | 128 => return Value.Tag.float_128.create(arena, @intToFloat(f128, x)), |
| 2207 | 2219 | else => unreachable, |
| 2208 | 2220 | } |