From 95d9baea6723788b85261f3fd358e2316eefd098 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 2 May 2019 09:25:53 -0400 Subject: [PATCH] {A32, A64}/types: Use std::array deduction guides where applicable We also make the arrays static here, as MSVC tends to load the whole array every time the function is called, instead of storing the data within rodata. This also line breaks the elements a little earlier for readability. --- src/frontend/A32/types.cpp | 30 +++++++++++++++++++----------- src/frontend/A64/types.cpp | 8 +++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/frontend/A32/types.cpp b/src/frontend/A32/types.cpp index 3b2c1d70..49659293 100644 --- a/src/frontend/A32/types.cpp +++ b/src/frontend/A32/types.cpp @@ -13,32 +13,40 @@ namespace Dynarmic::A32 { const char* CondToString(Cond cond, bool explicit_al) { - constexpr std::array cond_strs = { - "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "al", "nv", + static constexpr std::array cond_strs = { + "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", + "hi", "ls", "ge", "lt", "gt", "le", "al", "nv", }; return (!explicit_al && cond == Cond::AL) ? "" : cond_strs.at(static_cast(cond)); } const char* RegToString(Reg reg) { - constexpr std::array reg_strs = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc" + static constexpr std::array reg_strs = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc" }; return reg_strs.at(static_cast(reg)); } const char* ExtRegToString(ExtReg reg) { - constexpr std::array reg_strs = { - "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", - "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", - "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", - "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31", + static constexpr std::array reg_strs = { + "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", + "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", + "s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", + "s25", "s26", "s27", "s28", "s29", "s30", "s31", + + "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", + "d9", "d10", "d11", "d12", "d13", "d14", "d15", "d16", + "d17", "d18", "d19", "d20", "d21", "d22", "d23", "d24", + "d25", "d26", "d27", "d28", "d29", "d30", "d31", }; return reg_strs.at(static_cast(reg)); } const char* CoprocRegToString(CoprocReg reg) { - constexpr std::array reg_strs = { - "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13", "c14", "c15" + static constexpr std::array reg_strs = { + "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", + "c9", "c10", "c11", "c12", "c13", "c14", "c15" }; return reg_strs.at(static_cast(reg)); } diff --git a/src/frontend/A64/types.cpp b/src/frontend/A64/types.cpp index 028672c5..bfffc42a 100644 --- a/src/frontend/A64/types.cpp +++ b/src/frontend/A64/types.cpp @@ -15,15 +15,17 @@ namespace Dynarmic::A64 { const char* CondToString(Cond cond) { - constexpr std::array cond_strs = { - "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "al", "nv" + static constexpr std::array cond_strs = { + "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", + "hi", "ls", "ge", "lt", "gt", "le", "al", "nv" }; return cond_strs.at(static_cast(cond)); } std::string RegToString(Reg reg) { - if (reg == Reg::R31) + if (reg == Reg::R31) { return "sp|zr"; + } return fmt::format("r{}", static_cast(reg)); }