From cccbc7fd0e246cd8ae1ff3948669f401a55ab451 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 May 2019 19:06:10 -0400 Subject: [PATCH] emit_x64_saturation: Use const on locals where applicable Normalizes the use of const in the source file. --- src/backend/x64/emit_x64_saturation.cpp | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/backend/x64/emit_x64_saturation.cpp b/src/backend/x64/emit_x64_saturation.cpp index 38b4efa6..8d917bc1 100644 --- a/src/backend/x64/emit_x64_saturation.cpp +++ b/src/backend/x64/emit_x64_saturation.cpp @@ -214,27 +214,27 @@ void EmitX64::EmitSignedSaturation(EmitContext& ctx, IR::Inst* inst) { auto overflow_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp); auto args = ctx.reg_alloc.GetArgumentInfo(inst); - size_t N = args[1].GetImmediateU8(); + const size_t N = args[1].GetImmediateU8(); ASSERT(N >= 1 && N <= 32); if (N == 32) { if (overflow_inst) { - auto no_overflow = IR::Value(false); + const auto no_overflow = IR::Value(false); overflow_inst->ReplaceUsesWith(no_overflow); } ctx.reg_alloc.DefineValue(inst, args[0]); return; } - u32 mask = (1u << N) - 1; - u32 positive_saturated_value = (1u << (N - 1)) - 1; - u32 negative_saturated_value = 1u << (N - 1); - u32 sext_negative_satured_value = Common::SignExtend(N, negative_saturated_value); + const u32 mask = (1u << N) - 1; + const u32 positive_saturated_value = (1u << (N - 1)) - 1; + const u32 negative_saturated_value = 1u << (N - 1); + const u32 sext_negative_satured_value = Common::SignExtend(N, negative_saturated_value); - Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr().cvt32(); - Xbyak::Reg32 reg_a = ctx.reg_alloc.UseGpr(args[0]).cvt32(); - Xbyak::Reg32 overflow = ctx.reg_alloc.ScratchGpr().cvt32(); - Xbyak::Reg32 tmp = ctx.reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 reg_a = ctx.reg_alloc.UseGpr(args[0]).cvt32(); + const Xbyak::Reg32 overflow = ctx.reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 tmp = ctx.reg_alloc.ScratchGpr().cvt32(); // overflow now contains a value between 0 and mask if it was originally between {negative,positive}_saturated_value. code.lea(overflow, code.ptr[reg_a.cvt64() + negative_saturated_value]); @@ -295,14 +295,14 @@ void EmitX64::EmitUnsignedSaturation(EmitContext& ctx, IR::Inst* inst) { auto overflow_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp); auto args = ctx.reg_alloc.GetArgumentInfo(inst); - size_t N = args[1].GetImmediateU8(); + const size_t N = args[1].GetImmediateU8(); ASSERT(N <= 31); - u32 saturated_value = (1u << N) - 1; + const u32 saturated_value = (1u << N) - 1; - Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr().cvt32(); - Xbyak::Reg32 reg_a = ctx.reg_alloc.UseGpr(args[0]).cvt32(); - Xbyak::Reg32 overflow = ctx.reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr().cvt32(); + const Xbyak::Reg32 reg_a = ctx.reg_alloc.UseGpr(args[0]).cvt32(); + const Xbyak::Reg32 overflow = ctx.reg_alloc.ScratchGpr().cvt32(); // Pseudocode: result = clamp(reg_a, 0, saturated_value); code.xor_(overflow, overflow);