From fe95575b95e260a5c3e7250459a4137ae942e279 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 12 Apr 2019 14:51:42 -0400 Subject: [PATCH] general: Replace unreachable-imitating assertions with UNREACHABLE() We can just use the self-documenting assertion for indicating unreachable paths, instead of manually passing false and providing a message. --- src/backend/x64/a32_emit_x64.cpp | 8 ++++---- src/backend/x64/emit_x64.cpp | 2 +- src/backend/x64/oparg.h | 4 ++-- src/frontend/A32/translate/translate_arm.cpp | 4 ++-- src/frontend/A64/translate/impl/impl.cpp | 4 ++-- src/frontend/ir/ir_emitter.cpp | 12 ++++++------ 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/backend/x64/a32_emit_x64.cpp b/src/backend/x64/a32_emit_x64.cpp index b47d74fa..5517c2cb 100644 --- a/src/backend/x64/a32_emit_x64.cpp +++ b/src/backend/x64/a32_emit_x64.cpp @@ -1018,7 +1018,7 @@ void A32EmitX64::EmitA32CoprocSendOneWord(A32EmitContext& ctx, IR::Inst* inst) { return; } default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } } @@ -1060,7 +1060,7 @@ void A32EmitX64::EmitA32CoprocSendTwoWords(A32EmitContext& ctx, IR::Inst* inst) return; } default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } } @@ -1102,7 +1102,7 @@ void A32EmitX64::EmitA32CoprocGetOneWord(A32EmitContext& ctx, IR::Inst* inst) { return; } default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } } @@ -1147,7 +1147,7 @@ void A32EmitX64::EmitA32CoprocGetTwoWords(A32EmitContext& ctx, IR::Inst* inst) { return; } default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } } diff --git a/src/backend/x64/emit_x64.cpp b/src/backend/x64/emit_x64.cpp index 0ca09f4f..709023d5 100644 --- a/src/backend/x64/emit_x64.cpp +++ b/src/backend/x64/emit_x64.cpp @@ -128,7 +128,7 @@ void EmitX64::EmitGetNZCVFromOp(EmitContext& ctx, IR::Inst* inst) { case IR::Type::U64: return 64; default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return 0; } }(); diff --git a/src/backend/x64/oparg.h b/src/backend/x64/oparg.h index f24e2566..ac2df5f8 100644 --- a/src/backend/x64/oparg.h +++ b/src/backend/x64/oparg.h @@ -26,7 +26,7 @@ struct OpArg { case Type::Reg: return inner_reg; } - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } void setBit(int bits) { @@ -56,7 +56,7 @@ struct OpArg { return; } } - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } private: diff --git a/src/frontend/A32/translate/translate_arm.cpp b/src/frontend/A32/translate/translate_arm.cpp index 5cce30f2..6857a1ef 100644 --- a/src/frontend/A32/translate/translate_arm.cpp +++ b/src/frontend/A32/translate/translate_arm.cpp @@ -173,7 +173,7 @@ IR::ResultAndCarry ArmTranslatorVisitor::EmitImmShift(IR::U32 value, Sh else return ir.RotateRightExtended(value, carry_in); } - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } @@ -188,7 +188,7 @@ IR::ResultAndCarry ArmTranslatorVisitor::EmitRegShift(IR::U32 value, Sh case ShiftType::ROR: return ir.RotateRight(value, amount, carry_in); } - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } diff --git a/src/frontend/A64/translate/impl/impl.cpp b/src/frontend/A64/translate/impl/impl.cpp index 6250a574..ca21af86 100644 --- a/src/frontend/A64/translate/impl/impl.cpp +++ b/src/frontend/A64/translate/impl/impl.cpp @@ -368,7 +368,7 @@ IR::U32U64 TranslatorVisitor::ShiftReg(size_t bitsize, Reg reg, Imm<2> shift, IR case 0b11: return ir.RotateRight(result, amount); } - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } @@ -432,7 +432,7 @@ IR::U32U64 TranslatorVisitor::ExtendReg(size_t bitsize, Reg reg, Imm<3> option, break; } default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); } if (len < bitsize) { diff --git a/src/frontend/ir/ir_emitter.cpp b/src/frontend/ir/ir_emitter.cpp index 6324b346..53b546c0 100644 --- a/src/frontend/ir/ir_emitter.cpp +++ b/src/frontend/ir/ir_emitter.cpp @@ -330,7 +330,7 @@ U64 IREmitter::SignExtendToLong(const UAny& a) { case Type::U64: return U64(a); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } } @@ -346,7 +346,7 @@ U32 IREmitter::SignExtendToWord(const UAny& a) { case Type::U64: return Inst(Opcode::LeastSignificantWord, a); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } } @@ -374,7 +374,7 @@ U64 IREmitter::ZeroExtendToLong(const UAny& a) { case Type::U64: return U64(a); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } } @@ -390,7 +390,7 @@ U32 IREmitter::ZeroExtendToWord(const UAny& a) { case Type::U64: return Inst(Opcode::LeastSignificantWord, a); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } } @@ -817,7 +817,7 @@ UAny IREmitter::VectorGetElement(size_t esize, const U128& a, size_t index) { case 64: return Inst(Opcode::VectorGetElement64, a, Imm8(static_cast(index))); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } } @@ -834,7 +834,7 @@ U128 IREmitter::VectorSetElement(size_t esize, const U128& a, size_t index, cons case 64: return Inst(Opcode::VectorSetElement64, a, Imm8(static_cast(index)), elem); default: - ASSERT_MSG(false, "Unreachable"); + UNREACHABLE(); return {}; } }