From 6ae8fe193bd5397b9fceea98ba684d9d870286cf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 7 Apr 2022 23:11:11 -0700 Subject: [PATCH] Liveness: utilize Air.refToIndex --- src/Liveness.zig | 4 +--- src/arch/x86_64/CodeGen.zig | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Liveness.zig b/src/Liveness.zig index 59f7f5be91b22291950d62c27a9f9c501c6efe35..2ba59ec1ded95005be6a178d9a2f28a5591a2bd8 100644 --- a/src/Liveness.zig +++ b/src/Liveness.zig @@ -796,9 +796,7 @@ const ExtraTombs = struct { assert(this_bit_index < 32); // TODO mechanism for when there are greater than 32 operands et.bit_index += 1; const gpa = et.analysis.gpa; - const op_int = @enumToInt(op_ref); - if (op_int < Air.Inst.Ref.typed_value_map.len) return; - const op_index: Air.Inst.Index = op_int - @intCast(u32, Air.Inst.Ref.typed_value_map.len); + const op_index = Air.refToIndex(op_ref) orelse return; const prev = try et.analysis.table.fetchPut(gpa, op_index, {}); if (prev == null) { // Death. diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 7f5144a6dce825a31bca005832dd1ca206aa98fd..f52742ffa5617ccc6d5233ed8918b5699ba4fa59 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -280,9 +280,7 @@ const BigTomb = struct { const this_bit_index = bt.bit_index; bt.bit_index += 1; - const op_int = @enumToInt(op_ref); - if (op_int < Air.Inst.Ref.typed_value_map.len) return; - const op_index = @intCast(Air.Inst.Index, op_int - Air.Inst.Ref.typed_value_map.len); + const op_index = Air.refToIndex(op_ref) orelse return; if (this_bit_index < Liveness.bpi - 1) { const dies = @truncate(u1, bt.tomb_bits >> @intCast(Liveness.OperandInt, this_bit_index)) != 0; -- 2.54.0