| ... | ... | @@ -141,26 +141,13 @@ pub fn generateFunction( |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | fn writeFloat(comptime F: type, f: F, target: Target, endian: std.builtin.Endian, code: []u8) void { |
| 144 | | if (F == f80) { |
| 145 | | switch (target.cpu.arch) { |
| 146 | | .i386, .x86_64 => { |
| 147 | | const repr = math.break_f80(f); |
| 148 | | mem.writeIntLittle(u64, code[0..8], repr.fraction); |
| 149 | | mem.writeIntLittle(u16, code[8..10], repr.exp); |
| 150 | | // TODO set the rest of the bytes to undefined. should we use 0xaa |
| 151 | | // or is there a different way? |
| 152 | | return; |
| 153 | | }, |
| 154 | | else => {}, |
| 155 | | } |
| 156 | | } else { |
| 157 | | const Int = @Type(.{ .Int = .{ |
| 158 | | .signedness = .unsigned, |
| 159 | | .bits = @typeInfo(F).Float.bits, |
| 160 | | } }); |
| 161 | | const int = @bitCast(Int, f); |
| 162 | | mem.writeInt(Int, code[0..@sizeOf(Int)], int, endian); |
| 163 | | } |
| 144 | _ = target; |
| 145 | const Int = @Type(.{ .Int = .{ |
| 146 | .signedness = .unsigned, |
| 147 | .bits = @typeInfo(F).Float.bits, |
| 148 | } }); |
| 149 | const int = @bitCast(Int, f); |
| 150 | mem.writeInt(Int, code[0..@sizeOf(Int)], int, endian); |
| 164 | 151 | } |
| 165 | 152 | |
| 166 | 153 | pub fn generateSymbol( |
| ... | ... | @@ -202,7 +189,14 @@ pub fn generateSymbol( |
| 202 | 189 | 16 => writeFloat(f16, typed_value.val.toFloat(f16), target, endian, try code.addManyAsArray(2)), |
| 203 | 190 | 32 => writeFloat(f32, typed_value.val.toFloat(f32), target, endian, try code.addManyAsArray(4)), |
| 204 | 191 | 64 => writeFloat(f64, typed_value.val.toFloat(f64), target, endian, try code.addManyAsArray(8)), |
| 205 | | 80 => writeFloat(f80, typed_value.val.toFloat(f80), target, endian, try code.addManyAsArray(10)), |
| 192 | 80 => return Result{ |
| 193 | .fail = try ErrorMsg.create( |
| 194 | bin_file.allocator, |
| 195 | src_loc, |
| 196 | "TODO handle f80 in generateSymbol", |
| 197 | .{}, |
| 198 | ), |
| 199 | }, |
| 206 | 200 | 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)), |
| 207 | 201 | else => unreachable, |
| 208 | 202 | } |