aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorJacob G-W <jacoblevgw@gmail.com>2021-06-17 11:57:27 -0400
committerVeikka Tuominen <git@vexu.eu>2021-06-21 18:45:28 +0300
commita95fdb06352a6a1e60d0167bad62f5a46345177a (patch)
treedb2347ab29797d19c899bf2f6a043a984eb173c2 /src/Sema.zig
parentfc1feebdc0ffd4730c724780265d4ef6a9515dc8 (diff)
downloadzig-a95fdb06352a6a1e60d0167bad62f5a46345177a.tar.gz
zig-a95fdb06352a6a1e60d0167bad62f5a46345177a.zip
stage2: simplify codegen for errorToInt and intToError
We can just use bitcast instead of error_to_int, int_to_error since errorToInt and intToError do not actually do anything, just change types. This allows us to remove 2 air ops that were the exact same as bitcast
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 255746a763..7c39e35bf8 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -2506,7 +2506,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
}
try sema.requireRuntimeBlock(block, src);
- return block.addUnOp(src, result_ty, .error_to_int, op_coerced);
+ return block.addUnOp(src, result_ty, .bitcast, op_coerced);
}
fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
@@ -2539,7 +2539,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
// const is_gt_max = @panic("TODO get max errors in compilation");
// try sema.addSafetyCheck(block, is_gt_max, .invalid_error_code);
}
- return block.addUnOp(src, Type.initTag(.anyerror), .int_to_error, op);
+ return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op);
}
fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {