authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-27 14:52:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-27 14:52:12-07:00
log3fc0e0c57bcc8eb4a14712abc20c16677722fce0
tree849d11d95c2052e3b009cbf5ca112d15159644b9
parentc8f844027185b808e2176a73fd41c955bc6e153e

Sema: implement `@setFloatMode`

We are putting off actual optimization of floats because we have a couple proposals being considered which would change how it works. In the meantime, lowering optimized float mode to be the same as strict is a perfectly legal way to implement the Zig language specification.

1 files changed, 7 insertions(+), 1 deletions(-)

src/Sema.zig+7-1
...@@ -4315,7 +4315,13 @@ fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -4315,7 +4315,13 @@ fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
4315fn zirSetFloatMode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {4315fn zirSetFloatMode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
4316 const inst_data = sema.code.instructions.items(.data)[inst].un_node;4316 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
4317 const src: LazySrcLoc = inst_data.src();4317 const src: LazySrcLoc = inst_data.src();
4318 return sema.fail(block, src, "TODO: implement Sema.zirSetFloatMode", .{});4318 const float_mode = try sema.resolveBuiltinEnum(block, src, inst_data.operand, "FloatMode");
4319 switch (float_mode) {
4320 .Strict => return,
4321 .Optimized => {
4322 // TODO implement optimized float mode
4323 },
4324 }
4319}4325}
43204326
4321fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {4327fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {