| ... | @@ -141,26 +141,13 @@ pub fn generateFunction( | ... | @@ -141,26 +141,13 @@ pub fn generateFunction( |
| 141 | } | 141 | } |
| 142 | | 142 | |
| 143 | fn writeFloat(comptime F: type, f: F, target: Target, endian: std.builtin.Endian, code: []u8) void { | 143 | fn writeFloat(comptime F: type, f: F, target: Target, endian: std.builtin.Endian, code: []u8) void { |
| 144 | if (F == f80) { | 144 | _ = target; |
| 145 | switch (target.cpu.arch) { | 145 | const Int = @Type(.{ .Int = .{ |
| 146 | .i386, .x86_64 => { | 146 | .signedness = .unsigned, |
| 147 | const repr = math.break_f80(f); | 147 | .bits = @typeInfo(F).Float.bits, |
| 148 | mem.writeIntLittle(u64, code[0..8], repr.fraction); | 148 | } }); |
| 149 | mem.writeIntLittle(u16, code[8..10], repr.exp); | 149 | const int = @bitCast(Int, f); |
| 150 | // TODO set the rest of the bytes to undefined. should we use 0xaa | 150 | mem.writeInt(Int, code[0..@sizeOf(Int)], int, endian); |
| 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 | } | | |
| 164 | } | 151 | } |
| 165 | | 152 | |
| 166 | pub fn generateSymbol( | 153 | pub fn generateSymbol( |
| ... | @@ -202,7 +189,14 @@ pub fn generateSymbol( | ... | @@ -202,7 +189,14 @@ pub fn generateSymbol( |
| 202 | 16 => writeFloat(f16, typed_value.val.toFloat(f16), target, endian, try code.addManyAsArray(2)), | 189 | 16 => writeFloat(f16, typed_value.val.toFloat(f16), target, endian, try code.addManyAsArray(2)), |
| 203 | 32 => writeFloat(f32, typed_value.val.toFloat(f32), target, endian, try code.addManyAsArray(4)), | 190 | 32 => writeFloat(f32, typed_value.val.toFloat(f32), target, endian, try code.addManyAsArray(4)), |
| 204 | 64 => writeFloat(f64, typed_value.val.toFloat(f64), target, endian, try code.addManyAsArray(8)), | 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 | 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)), | 200 | 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)), |
| 207 | else => unreachable, | 201 | else => unreachable, |
| 208 | } | 202 | } |