authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-02 17:08:16+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-02 17:08:16+01:00
logb0bb1583cb03e2125b2b407d762baf42e7cfd527
tree23df17361a5dbc8488ac232d220aa9fec8118050
parentc9d1db7e8eda6374bfc5ba51097e24d93ab91ddb

codegen: leave f80 explicitly unhandled for now


1 files changed, 15 insertions(+), 21 deletions(-)

src/codegen.zig+15-21
......@@ -141,26 +141,13 @@ pub fn generateFunction(
141141}
142142
143143fn 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);
164151}
165152
166153pub fn generateSymbol(
......@@ -202,7 +189,14 @@ pub fn generateSymbol(
202189 16 => writeFloat(f16, typed_value.val.toFloat(f16), target, endian, try code.addManyAsArray(2)),
203190 32 => writeFloat(f32, typed_value.val.toFloat(f32), target, endian, try code.addManyAsArray(4)),
204191 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 },
206200 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)),
207201 else => unreachable,
208202 }