diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-06-16 19:48:26 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-06-16 19:51:23 -0400 |
| commit | 188234b4cd9b029e3778191432f34c9c6fc279dd (patch) | |
| tree | 046283ffc85b60afa9d28fe9f259cc9b793b3cfc /Source/Core/Common/GekkoDisassembler.cpp | |
| parent | d8c3f09c9fcf2f152a4cf6977ab3385092877187 (diff) | |
Common/GekkoDisassembler: Use std::string_view where applicable
Avoids the use of the null pointer to represent an empty string.
Instead, we can simply pass an empty string_view instance. Using
std::string_view enforces this invariant at the API level.
Diffstat (limited to 'Source/Core/Common/GekkoDisassembler.cpp')
| -rw-r--r-- | Source/Core/Common/GekkoDisassembler.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Source/Core/Common/GekkoDisassembler.cpp b/Source/Core/Common/GekkoDisassembler.cpp index 2a77d9d985..5f3e959e75 100644 --- a/Source/Core/Common/GekkoDisassembler.cpp +++ b/Source/Core/Common/GekkoDisassembler.cpp @@ -515,7 +515,7 @@ void GekkoDisassembler::cmpi(u32 in, int uimm) } } -void GekkoDisassembler::addi(u32 in, const std::string& ext) +void GekkoDisassembler::addi(u32 in, std::string_view ext) { if ((in & 0x08000000) && !PPCGETA(in)) { @@ -539,7 +539,7 @@ void GekkoDisassembler::addi(u32 in, const std::string& ext) } // Build a branch instr. and return number of chars written to operand. -size_t GekkoDisassembler::branch(u32 in, const char* bname, int aform, int bdisp) +size_t GekkoDisassembler::branch(u32 in, std::string_view bname, int aform, int bdisp) { int bo = (int)PPCGETD(in); int bi = (int)PPCGETA(in); @@ -639,7 +639,7 @@ void GekkoDisassembler::mcrf(u32 in, char c) } } -void GekkoDisassembler::crop(u32 in, const char* n1, const char* n2) +void GekkoDisassembler::crop(u32 in, std::string_view n1, std::string_view n2) { int crd = (int)PPCGETD(in); int cra = (int)PPCGETA(in); @@ -647,8 +647,8 @@ void GekkoDisassembler::crop(u32 in, const char* n1, const char* n2) if ((in & 1) == 0) { - m_opcode = fmt::format("cr{}", (cra == crb && n2) ? n2 : n1); - if (cra == crb && n2) + m_opcode = fmt::format("cr{}", (cra == crb && !n2.empty()) ? n2 : n1); + if (cra == crb && !n2.empty()) m_operands = fmt::format("{}, {}", crd, cra); else m_operands = fmt::format("{}, {}, {}", crd, cra, crb); @@ -659,7 +659,7 @@ void GekkoDisassembler::crop(u32 in, const char* n1, const char* n2) } } -void GekkoDisassembler::nooper(u32 in, const char* name, unsigned char dmode) +void GekkoDisassembler::nooper(u32 in, std::string_view name, unsigned char dmode) { if (in & (PPCDMASK | PPCAMASK | PPCBMASK | 1)) { @@ -672,7 +672,7 @@ void GekkoDisassembler::nooper(u32 in, const char* name, unsigned char dmode) } } -void GekkoDisassembler::rlw(u32 in, const char* name, int i) +void GekkoDisassembler::rlw(u32 in, std::string_view name, int i) { int s = (int)PPCGETD(in); int a = (int)PPCGETA(in); @@ -685,13 +685,13 @@ void GekkoDisassembler::rlw(u32 in, const char* name, int i) bsh, mb, me, HelperRotateMask(bsh, mb, me)); } -void GekkoDisassembler::ori(u32 in, const char* name) +void GekkoDisassembler::ori(u32 in, std::string_view name) { m_opcode = name; m_operands = imm(in, 1, 1, true); } -void GekkoDisassembler::rld(u32 in, const char* name, int i) +void GekkoDisassembler::rld(u32 in, std::string_view name, int i) { int s = (int)PPCGETD(in); int a = (int)PPCGETA(in); @@ -760,8 +760,8 @@ void GekkoDisassembler::trap(u32 in, unsigned char dmode) } // Standard instruction: xxxx rD,rA,rB -void GekkoDisassembler::dab(u32 in, const char* name, int mask, int smode, int chkoe, int chkrc, - unsigned char dmode) +void GekkoDisassembler::dab(u32 in, std::string_view name, int mask, int smode, int chkoe, + int chkrc, unsigned char dmode) { if (chkrc >= 0 && ((in & 1) != (unsigned int)chkrc)) { @@ -782,7 +782,7 @@ void GekkoDisassembler::dab(u32 in, const char* name, int mask, int smode, int c } // Last operand is no register: xxxx rD,rA,NB -void GekkoDisassembler::rrn(u32 in, const char* name, int smode, int chkoe, int chkrc, +void GekkoDisassembler::rrn(u32 in, std::string_view name, int smode, int chkoe, int chkrc, unsigned char dmode) { if (chkrc >= 0 && ((in & 1) != (unsigned int)chkrc)) @@ -943,7 +943,7 @@ void GekkoDisassembler::sradi(u32 in) m_operands = fmt::format("{}, {}, {}", regnames[a], regnames[s], bsh); } -void GekkoDisassembler::ldst(u32 in, const char* name, char reg, unsigned char dmode) +void GekkoDisassembler::ldst(u32 in, std::string_view name, char reg, unsigned char dmode) { int s = (int)PPCGETD(in); int a = (int)PPCGETA(in); @@ -968,7 +968,7 @@ void GekkoDisassembler::ldst(u32 in, const char* name, char reg, unsigned char d } // Standard floating point instruction: xxxx fD,fA,fC,fB -void GekkoDisassembler::fdabc(u32 in, const char* name, int mask, unsigned char dmode) +void GekkoDisassembler::fdabc(u32 in, std::string_view name, int mask, unsigned char dmode) { int err = 0; @@ -1005,7 +1005,7 @@ void GekkoDisassembler::fmr(u32 in) } // Indexed float instruction: xxxx fD,rA,rB -void GekkoDisassembler::fdab(u32 in, const char* name, int mask) +void GekkoDisassembler::fdab(u32 in, std::string_view name, int mask) { m_opcode = name; m_operands = fd_ra_rb(in, mask); @@ -1390,7 +1390,7 @@ u32* GekkoDisassembler::DoDisassembly(bool big_endian) break; case 129: - crop(in, "andc", nullptr); // crandc + crop(in, "andc", {}); // crandc break; case 150: @@ -1402,11 +1402,11 @@ u32* GekkoDisassembler::DoDisassembly(bool big_endian) break; case 225: - crop(in, "nand", nullptr); // crnand + crop(in, "nand", {}); // crnand break; case 257: - crop(in, "and", nullptr); // crand + crop(in, "and", {}); // crand break; case 289: @@ -1414,7 +1414,7 @@ u32* GekkoDisassembler::DoDisassembly(bool big_endian) break; case 417: - crop(in, "orc", nullptr); // crorc + crop(in, "orc", {}); // crorc break; case 449: |
