| 1 | // Copyright 2023 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "Common/Assembler/AssemblerTables.h" |
| 5 | |
| 6 | #include "Common/Assembler/AssemblerShared.h" |
| 7 | #include "Common/Assembler/CaseInsensitiveDict.h" |
| 8 | #include "Common/CommonTypes.h" |
| 9 | |
| 10 | namespace Common::GekkoAssembler::detail |
| 11 | { |
| 12 | namespace |
| 13 | { |
| 14 | constexpr size_t PLAIN_MNEMONIC = 0x0; |
| 15 | constexpr size_t RECORD_BIT = 0x1; |
| 16 | constexpr size_t OVERFLOW_EXCEPTION = 0x2; |
| 17 | // Since RC/OE are mutually exclusive from LK/AA, they can occupy the same slot |
| 18 | constexpr size_t LINK_BIT = 0x1; |
| 19 | constexpr size_t ABSOLUTE_ADDRESS_BIT = 0x2; |
| 20 | |
| 21 | // Compile-time helpers for mnemonic generation |
| 22 | // Generate inclusive mask [left, right] -- MSB=0 LSB=31 |
| 23 | constexpr u32 Mask(u32 left, u32 right) |
| 24 | { |
| 25 | return static_cast<u32>(((u64{1} << (32 - left)) - 1) & ~((u64{1} << (31 - right)) - 1)); |
| 26 | } |
| 27 | constexpr u32 InsertVal(u32 val, u32 left, u32 right) |
| 28 | { |
| 29 | return val << (31 - right) & Mask(left, right); |
| 30 | } |
| 31 | constexpr u32 InsertOpcode(u32 opcode) |
| 32 | { |
| 33 | return InsertVal(opcode, 0, 5); |
| 34 | } |
| 35 | constexpr u32 SprBitswap(u32 spr) |
| 36 | { |
| 37 | return ((spr & 0b0000011111) << 5) | ((spr & 0b1111100000) >> 5); |
| 38 | } |
| 39 | |
| 40 | constexpr MnemonicDesc INVALID_MNEMONIC = {0, 0, {}}; |
| 41 | constexpr ExtendedMnemonicDesc INVALID_EXT_MNEMONIC = {0, nullptr}; |
| 42 | |
| 43 | // All operands as referenced by the Gekko/Broadway user manual |
| 44 | // See section 12.1.2 under Chapter 12 |
| 45 | constexpr OperandDesc OpDesc_A = OperandDesc{Mask(11, 15), {16, false}}; |
| 46 | constexpr OperandDesc OpDesc_B = OperandDesc{Mask(16, 20), {11, false}}; |
| 47 | constexpr OperandDesc OpDesc_BD = OperandDesc{Mask(16, 29), {0, true}}; |
| 48 | constexpr OperandDesc OpDesc_BI = OperandDesc{Mask(11, 15), {16, false}}; |
| 49 | constexpr OperandDesc OpDesc_BO = OperandDesc{Mask(6, 10), {21, false}}; |
| 50 | constexpr OperandDesc OpDesc_C = OperandDesc{Mask(21, 25), {6, false}}; |
| 51 | constexpr OperandDesc OpDesc_Crba = OperandDesc{Mask(11, 15), {16, false}}; |
| 52 | constexpr OperandDesc OpDesc_Crbb = OperandDesc{Mask(16, 20), {11, false}}; |
| 53 | constexpr OperandDesc OpDesc_Crbd = OperandDesc{Mask(6, 10), {21, false}}; |
| 54 | constexpr OperandDesc OpDesc_Crfd = OperandDesc{Mask(6, 8), {23, false}}; |
| 55 | constexpr OperandDesc OpDesc_Crfs = OperandDesc{Mask(11, 13), {18, false}}; |
| 56 | constexpr OperandDesc OpDesc_CRM = OperandDesc{Mask(12, 19), {12, false}}; |
| 57 | constexpr OperandDesc OpDesc_D = OperandDesc{Mask(6, 10), {21, false}}; |
| 58 | constexpr OperandDesc OpDesc_FM = OperandDesc{Mask(7, 14), {17, false}}; |
| 59 | constexpr OperandDesc OpDesc_W1 = OperandDesc{Mask(16, 16), {15, false}}; |
| 60 | constexpr OperandDesc OpDesc_W2 = OperandDesc{Mask(21, 21), {10, false}}; |
| 61 | constexpr OperandDesc OpDesc_IMM = OperandDesc{Mask(16, 19), {12, false}}; |
| 62 | constexpr OperandDesc OpDesc_L = OperandDesc{Mask(10, 10), {21, false}}; |
| 63 | constexpr OperandDesc OpDesc_LI = OperandDesc{Mask(6, 29), {0, true}}; |
| 64 | constexpr OperandDesc OpDesc_MB = OperandDesc{Mask(21, 25), {6, false}}; |
| 65 | constexpr OperandDesc OpDesc_ME = OperandDesc{Mask(26, 30), {1, false}}; |
| 66 | constexpr OperandDesc OpDesc_NB = OperandDesc{Mask(16, 20), {11, false}}; |
| 67 | constexpr OperandDesc OpDesc_Offd = OperandDesc{Mask(16, 31), {0, true}}; |
| 68 | constexpr OperandDesc OpDesc_OffdPs = OperandDesc{Mask(20, 31), {0, true}}; |
| 69 | constexpr OperandDesc OpDesc_S = OperandDesc{Mask(6, 10), {21, false}}; |
| 70 | constexpr OperandDesc OpDesc_SH = OperandDesc{Mask(16, 20), {11, false}}; |
| 71 | constexpr OperandDesc OpDesc_SIMM = OperandDesc{Mask(16, 31), {0, true}}; |
| 72 | constexpr OperandDesc OpDesc_SPR = OperandDesc{Mask(11, 20), {11, false}}; |
| 73 | constexpr OperandDesc OpDesc_SR = OperandDesc{Mask(12, 15), {16, false}}; |
| 74 | constexpr OperandDesc OpDesc_TO = OperandDesc{Mask(6, 10), {21, false}}; |
| 75 | constexpr OperandDesc OpDesc_TPR = OperandDesc{Mask(11, 20), {11, false}}; |
| 76 | constexpr OperandDesc OpDesc_UIMM = OperandDesc{Mask(16, 31), {0, false}}; |
| 77 | constexpr OperandDesc OpDesc_I1 = OperandDesc{Mask(17, 19), {12, false}}; |
| 78 | constexpr OperandDesc OpDesc_I2 = OperandDesc{Mask(22, 24), {7, false}}; |
| 79 | } // namespace |
| 80 | |
| 81 | void OperandList::Insert(size_t before, u32 val) |
| 82 | { |
| 83 | overfill = count == MAX_OPERANDS; |
| 84 | for (size_t i = before + 1; i <= count && i < MAX_OPERANDS; i++) |
| 85 | { |
| 86 | std::swap(list[i], list[before]); |
| 87 | } |
| 88 | |
| 89 | list[before] = Tagged<Interval, u32>({0, 0}, val); |
| 90 | if (!overfill) |
| 91 | { |
| 92 | count++; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // OperandDesc holds the shift position for an operand, as well as the mask |
| 97 | // Whether the user provided a valid input for an operand can be determined by the mask |
| 98 | u32 OperandDesc::MaxVal() const |
| 99 | { |
| 100 | const u32 mask_sh = mask >> shift; |
| 101 | if (is_signed) |
| 102 | { |
| 103 | const u32 mask_hibit = (mask_sh & (mask_sh ^ (mask_sh >> 1))); |
| 104 | return mask_hibit - 1; |
| 105 | } |
| 106 | return mask_sh; |
| 107 | } |
| 108 | |
| 109 | u32 OperandDesc::MinVal() const |
| 110 | { |
| 111 | if (is_signed) |
| 112 | { |
| 113 | return ~MaxVal(); |
| 114 | } |
| 115 | return 0; |
| 116 | } |
| 117 | |
| 118 | u32 OperandDesc::TruncBits() const |
| 119 | { |
| 120 | const u32 mask_sh = mask >> shift; |
| 121 | const u32 mask_lobit = mask_sh & (mask_sh ^ (mask_sh << 1)); |
| 122 | return mask_lobit - 1; |
| 123 | } |
| 124 | |
| 125 | bool OperandDesc::Fits(u32 val) const |
| 126 | { |
| 127 | const u32 mask_sh = mask >> shift; |
| 128 | if (is_signed) |
| 129 | { |
| 130 | // Get high bit and low bit from a range mask |
| 131 | const u32 mask_hibit = mask_sh & (mask_sh ^ (mask_sh >> 1)); |
| 132 | const u32 mask_lobit = mask_sh & (mask_sh ^ (mask_sh << 1)); |
| 133 | // Positive max is (signbit - 1) |
| 134 | // Negative min is ~(Positive Max) |
| 135 | const u32 positive_max = mask_hibit - 1; |
| 136 | const u32 negative_max = ~positive_max; |
| 137 | // Truncated bits are any bits right of the mask that are 0 after shifting |
| 138 | const u32 truncate_bits = mask_lobit - 1; |
| 139 | return (val <= positive_max || val >= negative_max) && !(val & truncate_bits); |
| 140 | } |
| 141 | return (mask_sh & val) == val; |
| 142 | } |
| 143 | |
| 144 | u32 OperandDesc::Fit(u32 val) const |
| 145 | { |
| 146 | return (val << shift) & mask; |
| 147 | } |
| 148 | |
| 149 | /////////////////// |
| 150 | // PARSER TABLES // |
| 151 | /////////////////// |
| 152 | |
| 153 | extern const CaseInsensitiveDict<u32, '_'> sprg_map = { |
| 154 | {"xer", 1}, {"lr", 8}, {"ctr", 9}, {"dsisr", 18}, {"dar", 19}, |
| 155 | {"dec", 22}, {"sdr1", 25}, {"srr0", 26}, {"srr1", 27}, {"sprg0", 272}, |
| 156 | {"sprg1", 273}, {"sprg2", 274}, {"sprg3", 275}, {"ear", 282}, {"tbl", 284}, |
| 157 | {"tbu", 285}, {"ibat0u", 528}, {"ibat0l", 529}, {"ibat1u", 530}, {"ibat1l", 531}, |
| 158 | {"ibat2u", 532}, {"ibat2l", 533}, {"ibat3u", 534}, {"ibat3l", 535}, {"dbat0u", 536}, |
| 159 | {"dbat0l", 537}, {"dbat1u", 538}, {"dbat1l", 539}, {"dbat2u", 540}, {"dbat2l", 541}, |
| 160 | {"dbat3u", 542}, {"dbat3l", 543}, {"gqr0", 912}, {"gqr1", 913}, {"gqr2", 914}, |
| 161 | {"gqr3", 915}, {"gqr4", 916}, {"gqr5", 917}, {"gqr6", 918}, {"gqr7", 919}, |
| 162 | {"hid2", 920}, {"wpar", 921}, {"dma_u", 922}, {"dma_l", 923}, {"ummcr0", 936}, |
| 163 | {"upmc1", 937}, {"upmc2", 938}, {"usia", 939}, {"ummcr1", 940}, {"upmc3", 941}, |
| 164 | {"upmc4", 942}, {"usda", 943}, {"mmcr0", 952}, {"pmc1", 953}, {"pmc2", 954}, |
| 165 | {"sia", 955}, {"mmcr1", 956}, {"pmc3", 957}, {"pmc4", 958}, {"sda", 959}, |
| 166 | {"hid0", 1008}, {"hid1", 1009}, {"iabr", 1010}, {"dabr", 1013}, {"l2cr", 1017}, |
| 167 | {"ictc", 1019}, {"thrm1", 1020}, {"thrm2", 1021}, {"thrm3", 1022}}; |
| 168 | |
| 169 | extern const CaseInsensitiveDict<GekkoDirective> directives_map = { |
| 170 | {"byte", GekkoDirective::Byte}, {"2byte", GekkoDirective::_2byte}, |
| 171 | {"4byte", GekkoDirective::_4byte}, {"8byte", GekkoDirective::_8byte}, |
| 172 | {"float", GekkoDirective::Float}, {"double", GekkoDirective::Double}, |
| 173 | {"locate", GekkoDirective::Locate}, {"padalign", GekkoDirective::PadAlign}, |
| 174 | {"align", GekkoDirective::Align}, {"zeros", GekkoDirective::Zeros}, |
| 175 | {"skip", GekkoDirective::Skip}, {"defvar", GekkoDirective::DefVar}, |
| 176 | {"ascii", GekkoDirective::Ascii}, {"asciz", GekkoDirective::Asciz}, |
| 177 | }; |
| 178 | |
| 179 | #define MNEMONIC(mnemonic_str, mnemonic_enum, variant_bits, alg) \ |
| 180 | { \ |
| 181 | mnemonic_str, \ |
| 182 | { \ |
| 183 | static_cast<size_t>(mnemonic_enum) * VARIANT_PERMUTATIONS + (variant_bits), alg \ |
| 184 | } \ |
| 185 | } |
| 186 | #define PLAIN_MNEMONIC(mnemonic_str, mnemonic_enum, alg) \ |
| 187 | MNEMONIC(mnemonic_str, mnemonic_enum, PLAIN_MNEMONIC, alg) |
| 188 | #define RC_MNEMONIC(mnemonic_str, mnemonic_enum, alg) \ |
| 189 | MNEMONIC(mnemonic_str, mnemonic_enum, PLAIN_MNEMONIC, alg), \ |
| 190 | MNEMONIC(mnemonic_str ".", mnemonic_enum, RECORD_BIT, alg) |
| 191 | #define OERC_MNEMONIC(mnemonic_str, mnemonic_enum, alg) \ |
| 192 | MNEMONIC(mnemonic_str, mnemonic_enum, PLAIN_MNEMONIC, alg), \ |
| 193 | MNEMONIC(mnemonic_str ".", mnemonic_enum, RECORD_BIT, alg), \ |
| 194 | MNEMONIC(mnemonic_str "o", mnemonic_enum, OVERFLOW_EXCEPTION, alg), \ |
| 195 | MNEMONIC(mnemonic_str "o.", mnemonic_enum, (RECORD_BIT | OVERFLOW_EXCEPTION), alg) |
| 196 | #define LK_MNEMONIC(mnemonic_str, mnemonic_enum, alg) \ |
| 197 | MNEMONIC(mnemonic_str, mnemonic_enum, PLAIN_MNEMONIC, alg), \ |
| 198 | MNEMONIC(mnemonic_str "l", mnemonic_enum, LINK_BIT, alg) |
| 199 | #define AALK_MNEMONIC(mnemonic_str, mnemonic_enum, alg) \ |
| 200 | MNEMONIC(mnemonic_str, mnemonic_enum, PLAIN_MNEMONIC, alg), \ |
| 201 | MNEMONIC(mnemonic_str "l", mnemonic_enum, LINK_BIT, alg), \ |
| 202 | MNEMONIC(mnemonic_str "a", mnemonic_enum, ABSOLUTE_ADDRESS_BIT, alg), \ |
| 203 | MNEMONIC(mnemonic_str "la", mnemonic_enum, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), alg) |
| 204 | |
| 205 | extern const CaseInsensitiveDict<ParseInfo, '.', '_'> mnemonic_tokens = { |
| 206 | OERC_MNEMONIC("add", GekkoMnemonic::Add, ParseAlg::Op3), |
| 207 | OERC_MNEMONIC("addc", GekkoMnemonic::Addc, ParseAlg::Op3), |
| 208 | OERC_MNEMONIC("adde", GekkoMnemonic::Adde, ParseAlg::Op3), |
| 209 | PLAIN_MNEMONIC("addi", GekkoMnemonic::Addi, ParseAlg::Op3), |
| 210 | PLAIN_MNEMONIC("addic", GekkoMnemonic::Addic, ParseAlg::Op3), |
| 211 | PLAIN_MNEMONIC("addic.", GekkoMnemonic::AddicDot, ParseAlg::Op3), |
| 212 | PLAIN_MNEMONIC("addis", GekkoMnemonic::Addis, ParseAlg::Op3), |
| 213 | OERC_MNEMONIC("addme", GekkoMnemonic::Addme, ParseAlg::Op2), |
| 214 | OERC_MNEMONIC("addze", GekkoMnemonic::Addze, ParseAlg::Op2), |
| 215 | RC_MNEMONIC("and", GekkoMnemonic::And, ParseAlg::Op3), |
| 216 | RC_MNEMONIC("andc", GekkoMnemonic::Andc, ParseAlg::Op3), |
| 217 | PLAIN_MNEMONIC("andi.", GekkoMnemonic::AndiDot, ParseAlg::Op3), |
| 218 | PLAIN_MNEMONIC("andis.", GekkoMnemonic::AndisDot, ParseAlg::Op3), |
| 219 | AALK_MNEMONIC("b", GekkoMnemonic::B, ParseAlg::Op1), |
| 220 | AALK_MNEMONIC("bc", GekkoMnemonic::Bc, ParseAlg::Op3), |
| 221 | LK_MNEMONIC("bcctr", GekkoMnemonic::Bcctr, ParseAlg::Op2), |
| 222 | LK_MNEMONIC("bclr", GekkoMnemonic::Bclr, ParseAlg::Op2), |
| 223 | PLAIN_MNEMONIC("cmp", GekkoMnemonic::Cmp, ParseAlg::Op4), |
| 224 | PLAIN_MNEMONIC("cmpi", GekkoMnemonic::Cmpi, ParseAlg::Op4), |
| 225 | PLAIN_MNEMONIC("cmpl", GekkoMnemonic::Cmpl, ParseAlg::Op4), |
| 226 | PLAIN_MNEMONIC("cmpli", GekkoMnemonic::Cmpli, ParseAlg::Op4), |
| 227 | RC_MNEMONIC("cntlzw", GekkoMnemonic::Cntlzw, ParseAlg::Op2), |
| 228 | PLAIN_MNEMONIC("crand", GekkoMnemonic::Crand, ParseAlg::Op3), |
| 229 | PLAIN_MNEMONIC("crandc", GekkoMnemonic::Crandc, ParseAlg::Op3), |
| 230 | PLAIN_MNEMONIC("creqv", GekkoMnemonic::Creqv, ParseAlg::Op3), |
| 231 | PLAIN_MNEMONIC("crnand", GekkoMnemonic::Crnand, ParseAlg::Op3), |
| 232 | PLAIN_MNEMONIC("crnor", GekkoMnemonic::Crnor, ParseAlg::Op3), |
| 233 | PLAIN_MNEMONIC("cror", GekkoMnemonic::Cror, ParseAlg::Op3), |
| 234 | PLAIN_MNEMONIC("crorc", GekkoMnemonic::Crorc, ParseAlg::Op3), |
| 235 | PLAIN_MNEMONIC("crxor", GekkoMnemonic::Crxor, ParseAlg::Op3), |
| 236 | PLAIN_MNEMONIC("dcbf", GekkoMnemonic::Dcbf, ParseAlg::Op2), |
| 237 | PLAIN_MNEMONIC("dcbi", GekkoMnemonic::Dcbi, ParseAlg::Op2), |
| 238 | PLAIN_MNEMONIC("dcbst", GekkoMnemonic::Dcbst, ParseAlg::Op2), |
| 239 | PLAIN_MNEMONIC("dcbt", GekkoMnemonic::Dcbt, ParseAlg::Op2), |
| 240 | PLAIN_MNEMONIC("dcbtst", GekkoMnemonic::Dcbtst, ParseAlg::Op2), |
| 241 | PLAIN_MNEMONIC("dcbz", GekkoMnemonic::Dcbz, ParseAlg::Op2), |
| 242 | PLAIN_MNEMONIC("dcbz_l", GekkoMnemonic::Dcbz_l, ParseAlg::Op2), |
| 243 | OERC_MNEMONIC("divw", GekkoMnemonic::Divw, ParseAlg::Op3), |
| 244 | OERC_MNEMONIC("divwu", GekkoMnemonic::Divwu, ParseAlg::Op3), |
| 245 | PLAIN_MNEMONIC("eciwx", GekkoMnemonic::Eciwx, ParseAlg::Op3), |
| 246 | PLAIN_MNEMONIC("ecowx", GekkoMnemonic::Ecowx, ParseAlg::Op3), |
| 247 | PLAIN_MNEMONIC("eieio", GekkoMnemonic::Eieio, ParseAlg::None), |
| 248 | RC_MNEMONIC("eqv", GekkoMnemonic::Eqv, ParseAlg::Op3), |
| 249 | RC_MNEMONIC("extsb", GekkoMnemonic::Extsb, ParseAlg::Op2), |
| 250 | RC_MNEMONIC("extsh", GekkoMnemonic::Extsh, ParseAlg::Op2), |
| 251 | RC_MNEMONIC("fabs", GekkoMnemonic::Fabs, ParseAlg::Op2), |
| 252 | RC_MNEMONIC("fadd", GekkoMnemonic::Fadd, ParseAlg::Op3), |
| 253 | RC_MNEMONIC("fadds", GekkoMnemonic::Fadds, ParseAlg::Op3), |
| 254 | PLAIN_MNEMONIC("fcmpo", GekkoMnemonic::Fcmpo, ParseAlg::Op3), |
| 255 | PLAIN_MNEMONIC("fcmpu", GekkoMnemonic::Fcmpu, ParseAlg::Op3), |
| 256 | RC_MNEMONIC("fctiw", GekkoMnemonic::Fctiw, ParseAlg::Op2), |
| 257 | RC_MNEMONIC("fctiwz", GekkoMnemonic::Fctiwz, ParseAlg::Op2), |
| 258 | RC_MNEMONIC("fdiv", GekkoMnemonic::Fdiv, ParseAlg::Op3), |
| 259 | RC_MNEMONIC("fdivs", GekkoMnemonic::Fdivs, ParseAlg::Op3), |
| 260 | RC_MNEMONIC("fmadd", GekkoMnemonic::Fmadd, ParseAlg::Op4), |
| 261 | RC_MNEMONIC("fmadds", GekkoMnemonic::Fmadds, ParseAlg::Op4), |
| 262 | RC_MNEMONIC("fmr", GekkoMnemonic::Fmr, ParseAlg::Op2), |
| 263 | RC_MNEMONIC("fmsub", GekkoMnemonic::Fmsub, ParseAlg::Op4), |
| 264 | RC_MNEMONIC("fmsubs", GekkoMnemonic::Fmsubs, ParseAlg::Op4), |
| 265 | RC_MNEMONIC("fmul", GekkoMnemonic::Fmul, ParseAlg::Op3), |
| 266 | RC_MNEMONIC("fmuls", GekkoMnemonic::Fmuls, ParseAlg::Op3), |
| 267 | RC_MNEMONIC("fnabs", GekkoMnemonic::Fnabs, ParseAlg::Op2), |
| 268 | RC_MNEMONIC("fneg", GekkoMnemonic::Fneg, ParseAlg::Op2), |
| 269 | RC_MNEMONIC("fnmadd", GekkoMnemonic::Fnmadd, ParseAlg::Op4), |
| 270 | RC_MNEMONIC("fnmadds", GekkoMnemonic::Fnmadds, ParseAlg::Op4), |
| 271 | RC_MNEMONIC("fnmsub", GekkoMnemonic::Fnmsub, ParseAlg::Op4), |
| 272 | RC_MNEMONIC("fnmsubs", GekkoMnemonic::Fnmsubs, ParseAlg::Op4), |
| 273 | RC_MNEMONIC("fres", GekkoMnemonic::Fres, ParseAlg::Op2), |
| 274 | RC_MNEMONIC("frsp", GekkoMnemonic::Frsp, ParseAlg::Op2), |
| 275 | RC_MNEMONIC("frsqrte", GekkoMnemonic::Frsqrte, ParseAlg::Op2), |
| 276 | RC_MNEMONIC("fsel", GekkoMnemonic::Fsel, ParseAlg::Op4), |
| 277 | RC_MNEMONIC("fsub", GekkoMnemonic::Fsub, ParseAlg::Op3), |
| 278 | RC_MNEMONIC("fsubs", GekkoMnemonic::Fsubs, ParseAlg::Op3), |
| 279 | PLAIN_MNEMONIC("icbi", GekkoMnemonic::Icbi, ParseAlg::Op2), |
| 280 | PLAIN_MNEMONIC("isync", GekkoMnemonic::Isync, ParseAlg::None), |
| 281 | PLAIN_MNEMONIC("lbz", GekkoMnemonic::Lbz, ParseAlg::Op1Off1), |
| 282 | PLAIN_MNEMONIC("lbzu", GekkoMnemonic::Lbzu, ParseAlg::Op1Off1), |
| 283 | PLAIN_MNEMONIC("lbzux", GekkoMnemonic::Lbzux, ParseAlg::Op3), |
| 284 | PLAIN_MNEMONIC("lbzx", GekkoMnemonic::Lbzx, ParseAlg::Op3), |
| 285 | PLAIN_MNEMONIC("lfd", GekkoMnemonic::Lfd, ParseAlg::Op1Off1), |
| 286 | PLAIN_MNEMONIC("lfdu", GekkoMnemonic::Lfdu, ParseAlg::Op1Off1), |
| 287 | PLAIN_MNEMONIC("lfdux", GekkoMnemonic::Lfdux, ParseAlg::Op3), |
| 288 | PLAIN_MNEMONIC("lfdx", GekkoMnemonic::Lfdx, ParseAlg::Op3), |
| 289 | PLAIN_MNEMONIC("lfs", GekkoMnemonic::Lfs, ParseAlg::Op1Off1), |
| 290 | PLAIN_MNEMONIC("lfsu", GekkoMnemonic::Lfsu, ParseAlg::Op1Off1), |
| 291 | PLAIN_MNEMONIC("lfsux", GekkoMnemonic::Lfsux, ParseAlg::Op3), |
| 292 | PLAIN_MNEMONIC("lfsx", GekkoMnemonic::Lfsx, ParseAlg::Op3), |
| 293 | PLAIN_MNEMONIC("lha", GekkoMnemonic::Lha, ParseAlg::Op1Off1), |
| 294 | PLAIN_MNEMONIC("lhau", GekkoMnemonic::Lhau, ParseAlg::Op1Off1), |
| 295 | PLAIN_MNEMONIC("lhaux", GekkoMnemonic::Lhaux, ParseAlg::Op3), |
| 296 | PLAIN_MNEMONIC("lhax", GekkoMnemonic::Lhax, ParseAlg::Op3), |
| 297 | PLAIN_MNEMONIC("lhbrx", GekkoMnemonic::Lhbrx, ParseAlg::Op3), |
| 298 | PLAIN_MNEMONIC("lhz", GekkoMnemonic::Lhz, ParseAlg::Op1Off1), |
| 299 | PLAIN_MNEMONIC("lhzu", GekkoMnemonic::Lhzu, ParseAlg::Op1Off1), |
| 300 | PLAIN_MNEMONIC("lhzux", GekkoMnemonic::Lhzux, ParseAlg::Op3), |
| 301 | PLAIN_MNEMONIC("lhzx", GekkoMnemonic::Lhzx, ParseAlg::Op3), |
| 302 | PLAIN_MNEMONIC("lmw", GekkoMnemonic::Lmw, ParseAlg::Op1Off1), |
| 303 | PLAIN_MNEMONIC("lswi", GekkoMnemonic::Lswi, ParseAlg::Op3), |
| 304 | PLAIN_MNEMONIC("lswx", GekkoMnemonic::Lswx, ParseAlg::Op3), |
| 305 | PLAIN_MNEMONIC("lwarx", GekkoMnemonic::Lwarx, ParseAlg::Op3), |
| 306 | PLAIN_MNEMONIC("lwbrx", GekkoMnemonic::Lwbrx, ParseAlg::Op3), |
| 307 | PLAIN_MNEMONIC("lwz", GekkoMnemonic::Lwz, ParseAlg::Op1Off1), |
| 308 | PLAIN_MNEMONIC("lwzu", GekkoMnemonic::Lwzu, ParseAlg::Op1Off1), |
| 309 | PLAIN_MNEMONIC("lwzux", GekkoMnemonic::Lwzux, ParseAlg::Op3), |
| 310 | PLAIN_MNEMONIC("lwzx", GekkoMnemonic::Lwzx, ParseAlg::Op3), |
| 311 | PLAIN_MNEMONIC("mcrf", GekkoMnemonic::Mcrf, ParseAlg::Op2), |
| 312 | PLAIN_MNEMONIC("mcrfs", GekkoMnemonic::Mcrfs, ParseAlg::Op2), |
| 313 | PLAIN_MNEMONIC("mcrxr", GekkoMnemonic::Mcrxr, ParseAlg::Op1), |
| 314 | PLAIN_MNEMONIC("mfcr", GekkoMnemonic::Mfcr, ParseAlg::Op1), |
| 315 | RC_MNEMONIC("mffs", GekkoMnemonic::Mffs, ParseAlg::Op1), |
| 316 | PLAIN_MNEMONIC("mfmsr", GekkoMnemonic::Mfmsr, ParseAlg::Op1), |
| 317 | PLAIN_MNEMONIC("mfspr_nobitswap", GekkoMnemonic::Mfspr_nobitswap, ParseAlg::Op2), |
| 318 | PLAIN_MNEMONIC("mfsr", GekkoMnemonic::Mfsr, ParseAlg::Op2), |
| 319 | PLAIN_MNEMONIC("mfsrin", GekkoMnemonic::Mfsrin, ParseAlg::Op2), |
| 320 | PLAIN_MNEMONIC("mftb_nobitswap", GekkoMnemonic::Mftb_nobitswap, ParseAlg::Op2), |
| 321 | PLAIN_MNEMONIC("mtcrf", GekkoMnemonic::Mtcrf, ParseAlg::Op2), |
| 322 | RC_MNEMONIC("mtfsb0", GekkoMnemonic::Mtfsb0, ParseAlg::Op1), |
| 323 | RC_MNEMONIC("mtfsb1", GekkoMnemonic::Mtfsb1, ParseAlg::Op1), |
| 324 | RC_MNEMONIC("mtfsf", GekkoMnemonic::Mtfsf, ParseAlg::Op2), |
| 325 | RC_MNEMONIC("mtfsfi", GekkoMnemonic::Mtfsfi, ParseAlg::Op2), |
| 326 | PLAIN_MNEMONIC("mtmsr", GekkoMnemonic::Mtmsr, ParseAlg::Op1), |
| 327 | PLAIN_MNEMONIC("mtspr_nobitswap", GekkoMnemonic::Mtspr_nobitswap, ParseAlg::Op2), |
| 328 | PLAIN_MNEMONIC("mtsr", GekkoMnemonic::Mtsr, ParseAlg::Op2), |
| 329 | PLAIN_MNEMONIC("mtsrin", GekkoMnemonic::Mtsrin, ParseAlg::Op2), |
| 330 | RC_MNEMONIC("mulhw", GekkoMnemonic::Mulhw, ParseAlg::Op3), |
| 331 | RC_MNEMONIC("mulhwu", GekkoMnemonic::Mulhwu, ParseAlg::Op3), |
| 332 | PLAIN_MNEMONIC("mulli", GekkoMnemonic::Mulli, ParseAlg::Op3), |
| 333 | OERC_MNEMONIC("mullw", GekkoMnemonic::Mullw, ParseAlg::Op3), |
| 334 | RC_MNEMONIC("nand", GekkoMnemonic::Nand, ParseAlg::Op3), |
| 335 | OERC_MNEMONIC("neg", GekkoMnemonic::Neg, ParseAlg::Op2), |
| 336 | RC_MNEMONIC("nor", GekkoMnemonic::Nor, ParseAlg::Op3), |
| 337 | RC_MNEMONIC("or", GekkoMnemonic::Or, ParseAlg::Op3), |
| 338 | RC_MNEMONIC("orc", GekkoMnemonic::Orc, ParseAlg::Op3), |
| 339 | PLAIN_MNEMONIC("ori", GekkoMnemonic::Ori, ParseAlg::Op3), |
| 340 | PLAIN_MNEMONIC("oris", GekkoMnemonic::Oris, ParseAlg::Op3), |
| 341 | PLAIN_MNEMONIC("psq_l", GekkoMnemonic::Psq_l, ParseAlg::Op1Off1Op2), |
| 342 | PLAIN_MNEMONIC("psq_lu", GekkoMnemonic::Psq_lu, ParseAlg::Op1Off1Op2), |
| 343 | PLAIN_MNEMONIC("psq_lux", GekkoMnemonic::Psq_lux, ParseAlg::Op5), |
| 344 | PLAIN_MNEMONIC("psq_lx", GekkoMnemonic::Psq_lx, ParseAlg::Op5), |
| 345 | PLAIN_MNEMONIC("psq_st", GekkoMnemonic::Psq_st, ParseAlg::Op1Off1Op2), |
| 346 | PLAIN_MNEMONIC("psq_stu", GekkoMnemonic::Psq_stu, ParseAlg::Op1Off1Op2), |
| 347 | PLAIN_MNEMONIC("psq_stux", GekkoMnemonic::Psq_stux, ParseAlg::Op5), |
| 348 | PLAIN_MNEMONIC("psq_stx", GekkoMnemonic::Psq_stx, ParseAlg::Op5), |
| 349 | RC_MNEMONIC("ps_abs", GekkoMnemonic::Ps_abs, ParseAlg::Op2), |
| 350 | RC_MNEMONIC("ps_add", GekkoMnemonic::Ps_add, ParseAlg::Op3), |
| 351 | PLAIN_MNEMONIC("ps_cmpo0", GekkoMnemonic::Ps_cmpo0, ParseAlg::Op3), |
| 352 | PLAIN_MNEMONIC("ps_cmpo1", GekkoMnemonic::Ps_cmpo1, ParseAlg::Op3), |
| 353 | PLAIN_MNEMONIC("ps_cmpu0", GekkoMnemonic::Ps_cmpu0, ParseAlg::Op3), |
| 354 | PLAIN_MNEMONIC("ps_cmpu1", GekkoMnemonic::Ps_cmpu1, ParseAlg::Op3), |
| 355 | RC_MNEMONIC("ps_div", GekkoMnemonic::Ps_div, ParseAlg::Op3), |
| 356 | RC_MNEMONIC("ps_madd", GekkoMnemonic::Ps_madd, ParseAlg::Op4), |
| 357 | RC_MNEMONIC("ps_madds0", GekkoMnemonic::Ps_madds0, ParseAlg::Op4), |
| 358 | RC_MNEMONIC("ps_madds1", GekkoMnemonic::Ps_madds1, ParseAlg::Op4), |
| 359 | RC_MNEMONIC("ps_merge00", GekkoMnemonic::Ps_merge00, ParseAlg::Op3), |
| 360 | RC_MNEMONIC("ps_merge01", GekkoMnemonic::Ps_merge01, ParseAlg::Op3), |
| 361 | RC_MNEMONIC("ps_merge10", GekkoMnemonic::Ps_merge10, ParseAlg::Op3), |
| 362 | RC_MNEMONIC("ps_merge11", GekkoMnemonic::Ps_merge11, ParseAlg::Op3), |
| 363 | RC_MNEMONIC("ps_mr", GekkoMnemonic::Ps_mr, ParseAlg::Op2), |
| 364 | RC_MNEMONIC("ps_msub", GekkoMnemonic::Ps_msub, ParseAlg::Op4), |
| 365 | RC_MNEMONIC("ps_mul", GekkoMnemonic::Ps_mul, ParseAlg::Op3), |
| 366 | RC_MNEMONIC("ps_muls0", GekkoMnemonic::Ps_muls0, ParseAlg::Op3), |
| 367 | RC_MNEMONIC("ps_muls1", GekkoMnemonic::Ps_muls1, ParseAlg::Op3), |
| 368 | RC_MNEMONIC("ps_nabs", GekkoMnemonic::Ps_nabs, ParseAlg::Op2), |
| 369 | RC_MNEMONIC("ps_neg", GekkoMnemonic::Ps_neg, ParseAlg::Op2), |
| 370 | RC_MNEMONIC("ps_nmadd", GekkoMnemonic::Ps_nmadd, ParseAlg::Op4), |
| 371 | RC_MNEMONIC("ps_nmsub", GekkoMnemonic::Ps_nmsub, ParseAlg::Op4), |
| 372 | RC_MNEMONIC("ps_res", GekkoMnemonic::Ps_res, ParseAlg::Op2), |
| 373 | RC_MNEMONIC("ps_rsqrte", GekkoMnemonic::Ps_rsqrte, ParseAlg::Op2), |
| 374 | RC_MNEMONIC("ps_sel", GekkoMnemonic::Ps_sel, ParseAlg::Op4), |
| 375 | RC_MNEMONIC("ps_sub", GekkoMnemonic::Ps_sub, ParseAlg::Op3), |
| 376 | RC_MNEMONIC("ps_sum0", GekkoMnemonic::Ps_sum0, ParseAlg::Op4), |
| 377 | RC_MNEMONIC("ps_sum1", GekkoMnemonic::Ps_sum1, ParseAlg::Op4), |
| 378 | PLAIN_MNEMONIC("rfi", GekkoMnemonic::Rfi, ParseAlg::None), |
| 379 | RC_MNEMONIC("rlwimi", GekkoMnemonic::Rlwimi, ParseAlg::Op5), |
| 380 | RC_MNEMONIC("rlwinm", GekkoMnemonic::Rlwinm, ParseAlg::Op5), |
| 381 | RC_MNEMONIC("rlwnm", GekkoMnemonic::Rlwnm, ParseAlg::Op5), |
| 382 | PLAIN_MNEMONIC("sc", GekkoMnemonic::Sc, ParseAlg::None), |
| 383 | RC_MNEMONIC("slw", GekkoMnemonic::Slw, ParseAlg::Op3), |
| 384 | RC_MNEMONIC("sraw", GekkoMnemonic::Sraw, ParseAlg::Op3), |
| 385 | RC_MNEMONIC("srawi", GekkoMnemonic::Srawi, ParseAlg::Op3), |
| 386 | RC_MNEMONIC("srw", GekkoMnemonic::Srw, ParseAlg::Op3), |
| 387 | PLAIN_MNEMONIC("stb", GekkoMnemonic::Stb, ParseAlg::Op1Off1), |
| 388 | PLAIN_MNEMONIC("stbu", GekkoMnemonic::Stbu, ParseAlg::Op1Off1), |
| 389 | PLAIN_MNEMONIC("stbux", GekkoMnemonic::Stbux, ParseAlg::Op3), |
| 390 | PLAIN_MNEMONIC("stbx", GekkoMnemonic::Stbx, ParseAlg::Op3), |
| 391 | PLAIN_MNEMONIC("stfd", GekkoMnemonic::Stfd, ParseAlg::Op1Off1), |
| 392 | PLAIN_MNEMONIC("stfdu", GekkoMnemonic::Stfdu, ParseAlg::Op1Off1), |
| 393 | PLAIN_MNEMONIC("stfdux", GekkoMnemonic::Stfdux, ParseAlg::Op3), |
| 394 | PLAIN_MNEMONIC("stfdx", GekkoMnemonic::Stfdx, ParseAlg::Op3), |
| 395 | PLAIN_MNEMONIC("stfiwx", GekkoMnemonic::Stfiwx, ParseAlg::Op3), |
| 396 | PLAIN_MNEMONIC("stfs", GekkoMnemonic::Stfs, ParseAlg::Op1Off1), |
| 397 | PLAIN_MNEMONIC("stfsu", GekkoMnemonic::Stfsu, ParseAlg::Op1Off1), |
| 398 | PLAIN_MNEMONIC("stfsux", GekkoMnemonic::Stfsux, ParseAlg::Op3), |
| 399 | PLAIN_MNEMONIC("stfsx", GekkoMnemonic::Stfsx, ParseAlg::Op3), |
| 400 | PLAIN_MNEMONIC("sth", GekkoMnemonic::Sth, ParseAlg::Op1Off1), |
| 401 | PLAIN_MNEMONIC("sthbrx", GekkoMnemonic::Sthbrx, ParseAlg::Op3), |
| 402 | PLAIN_MNEMONIC("sthu", GekkoMnemonic::Sthu, ParseAlg::Op1Off1), |
| 403 | PLAIN_MNEMONIC("sthux", GekkoMnemonic::Sthux, ParseAlg::Op3), |
| 404 | PLAIN_MNEMONIC("sthx", GekkoMnemonic::Sthx, ParseAlg::Op3), |
| 405 | PLAIN_MNEMONIC("stmw", GekkoMnemonic::Stmw, ParseAlg::Op1Off1), |
| 406 | PLAIN_MNEMONIC("stswi", GekkoMnemonic::Stswi, ParseAlg::Op3), |
| 407 | PLAIN_MNEMONIC("stswx", GekkoMnemonic::Stswx, ParseAlg::Op3), |
| 408 | PLAIN_MNEMONIC("stw", GekkoMnemonic::Stw, ParseAlg::Op1Off1), |
| 409 | PLAIN_MNEMONIC("stwbrx", GekkoMnemonic::Stwbrx, ParseAlg::Op3), |
| 410 | PLAIN_MNEMONIC("stwcx.", GekkoMnemonic::StwcxDot, ParseAlg::Op3), |
| 411 | PLAIN_MNEMONIC("stwu", GekkoMnemonic::Stwu, ParseAlg::Op1Off1), |
| 412 | PLAIN_MNEMONIC("stwux", GekkoMnemonic::Stwux, ParseAlg::Op3), |
| 413 | PLAIN_MNEMONIC("stwx", GekkoMnemonic::Stwx, ParseAlg::Op3), |
| 414 | OERC_MNEMONIC("subf", GekkoMnemonic::Subf, ParseAlg::Op3), |
| 415 | OERC_MNEMONIC("subfc", GekkoMnemonic::Subfc, ParseAlg::Op3), |
| 416 | OERC_MNEMONIC("subfe", GekkoMnemonic::Subfe, ParseAlg::Op3), |
| 417 | PLAIN_MNEMONIC("subfic", GekkoMnemonic::Subfic, ParseAlg::Op3), |
| 418 | OERC_MNEMONIC("subfme", GekkoMnemonic::Subfme, ParseAlg::Op2), |
| 419 | OERC_MNEMONIC("subfze", GekkoMnemonic::Subfze, ParseAlg::Op2), |
| 420 | PLAIN_MNEMONIC("sync", GekkoMnemonic::Sync, ParseAlg::None), |
| 421 | PLAIN_MNEMONIC("tlbie", GekkoMnemonic::Tlbie, ParseAlg::Op1), |
| 422 | PLAIN_MNEMONIC("tlbsync", GekkoMnemonic::Tlbsync, ParseAlg::None), |
| 423 | PLAIN_MNEMONIC("tw", GekkoMnemonic::Tw, ParseAlg::Op3), |
| 424 | PLAIN_MNEMONIC("twi", GekkoMnemonic::Twi, ParseAlg::Op3), |
| 425 | RC_MNEMONIC("xor", GekkoMnemonic::Xor, ParseAlg::Op3), |
| 426 | PLAIN_MNEMONIC("xori", GekkoMnemonic::Xori, ParseAlg::Op3), |
| 427 | PLAIN_MNEMONIC("xoris", GekkoMnemonic::Xoris, ParseAlg::Op3), |
| 428 | }; |
| 429 | |
| 430 | #define PSEUDO(mnemonic, base, variant_bits, alg) \ |
| 431 | { \ |
| 432 | mnemonic, \ |
| 433 | { \ |
| 434 | static_cast<size_t>(base) * VARIANT_PERMUTATIONS + (variant_bits), alg \ |
| 435 | } \ |
| 436 | } |
| 437 | #define PLAIN_PSEUDO(mnemonic, base, alg) PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg) |
| 438 | #define RC_PSEUDO(mnemonic, base, alg) \ |
| 439 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic ".", base, RECORD_BIT, alg) |
| 440 | #define OERC_PSEUDO(mnemonic, base, alg) \ |
| 441 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic ".", base, RECORD_BIT, alg), \ |
| 442 | PSEUDO(mnemonic "o", base, OVERFLOW_EXCEPTION, alg), \ |
| 443 | PSEUDO(mnemonic "o.", base, (RECORD_BIT | OVERFLOW_EXCEPTION), alg) |
| 444 | #define LK_PSEUDO(mnemonic, base, alg) \ |
| 445 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l", base, LINK_BIT, alg) |
| 446 | #define LKAA_PSEUDO(mnemonic, base, alg) \ |
| 447 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l", base, LINK_BIT, alg), \ |
| 448 | PSEUDO(mnemonic "a", base, ABSOLUTE_ADDRESS_BIT, alg), \ |
| 449 | PSEUDO(mnemonic "la", base, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), alg) |
| 450 | #define LKPRED_PSEUDO(mnemonic, base, alg) \ |
| 451 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l", base, LINK_BIT, alg), \ |
| 452 | PSEUDO(mnemonic "-", base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l-", base, LINK_BIT, alg), \ |
| 453 | PSEUDO(mnemonic "+", base##Predict, PLAIN_MNEMONIC, alg), \ |
| 454 | PSEUDO(mnemonic "l+", base##Predict, LINK_BIT, alg) |
| 455 | #define LKAAPRED_PSEUDO(mnemonic, base, alg) \ |
| 456 | PSEUDO(mnemonic, base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l", base, LINK_BIT, alg), \ |
| 457 | PSEUDO(mnemonic "a", base, ABSOLUTE_ADDRESS_BIT, alg), \ |
| 458 | PSEUDO(mnemonic "la", base, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), alg), \ |
| 459 | PSEUDO(mnemonic "-", base, PLAIN_MNEMONIC, alg), PSEUDO(mnemonic "l-", base, LINK_BIT, alg), \ |
| 460 | PSEUDO(mnemonic "a-", base, ABSOLUTE_ADDRESS_BIT, alg), \ |
| 461 | PSEUDO(mnemonic "la-", base, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), alg), \ |
| 462 | PSEUDO(mnemonic "+", base##Predict, PLAIN_MNEMONIC, alg), \ |
| 463 | PSEUDO(mnemonic "l+", base##Predict, LINK_BIT, alg), \ |
| 464 | PSEUDO(mnemonic "a+", base##Predict, ABSOLUTE_ADDRESS_BIT, alg), \ |
| 465 | PSEUDO(mnemonic "la+", base##Predict, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), alg) |
| 466 | |
| 467 | extern const CaseInsensitiveDict<ParseInfo, '.', '_', '+', '-'> extended_mnemonic_tokens = { |
| 468 | PLAIN_PSEUDO("subi", ExtendedGekkoMnemonic::Subi, ParseAlg::Op3), |
| 469 | PLAIN_PSEUDO("subis", ExtendedGekkoMnemonic::Subis, ParseAlg::Op3), |
| 470 | PLAIN_PSEUDO("subic", ExtendedGekkoMnemonic::Subic, ParseAlg::Op3), |
| 471 | PLAIN_PSEUDO("subic.", ExtendedGekkoMnemonic::SubicDot, ParseAlg::Op3), |
| 472 | OERC_PSEUDO("sub", ExtendedGekkoMnemonic::Sub, ParseAlg::Op3), |
| 473 | OERC_PSEUDO("subc", ExtendedGekkoMnemonic::Subc, ParseAlg::Op3), |
| 474 | PLAIN_PSEUDO("cmpwi", ExtendedGekkoMnemonic::Cmpwi, ParseAlg::Op2Or3), |
| 475 | PLAIN_PSEUDO("cmpw", ExtendedGekkoMnemonic::Cmpw, ParseAlg::Op2Or3), |
| 476 | PLAIN_PSEUDO("cmplwi", ExtendedGekkoMnemonic::Cmplwi, ParseAlg::Op2Or3), |
| 477 | PLAIN_PSEUDO("cmplw", ExtendedGekkoMnemonic::Cmplw, ParseAlg::Op2Or3), |
| 478 | RC_PSEUDO("extlwi", ExtendedGekkoMnemonic::Extlwi, ParseAlg::Op4), |
| 479 | RC_PSEUDO("extrwi", ExtendedGekkoMnemonic::Extrwi, ParseAlg::Op4), |
| 480 | RC_PSEUDO("inslwi", ExtendedGekkoMnemonic::Inslwi, ParseAlg::Op4), |
| 481 | RC_PSEUDO("insrwi", ExtendedGekkoMnemonic::Insrwi, ParseAlg::Op4), |
| 482 | RC_PSEUDO("rotlwi", ExtendedGekkoMnemonic::Rotlwi, ParseAlg::Op3), |
| 483 | RC_PSEUDO("rotrwi", ExtendedGekkoMnemonic::Rotrwi, ParseAlg::Op3), |
| 484 | RC_PSEUDO("rotlw", ExtendedGekkoMnemonic::Rotlw, ParseAlg::Op3), |
| 485 | RC_PSEUDO("slwi", ExtendedGekkoMnemonic::Slwi, ParseAlg::Op3), |
| 486 | RC_PSEUDO("srwi", ExtendedGekkoMnemonic::Srwi, ParseAlg::Op3), |
| 487 | RC_PSEUDO("clrlwi", ExtendedGekkoMnemonic::Clrlwi, ParseAlg::Op3), |
| 488 | RC_PSEUDO("clrrwi", ExtendedGekkoMnemonic::Clrrwi, ParseAlg::Op3), |
| 489 | RC_PSEUDO("clrlslwi", ExtendedGekkoMnemonic::Clrlslwi, ParseAlg::Op4), |
| 490 | LKAAPRED_PSEUDO("bt", ExtendedGekkoMnemonic::Bt, ParseAlg::Op2), |
| 491 | LKAAPRED_PSEUDO("bf", ExtendedGekkoMnemonic::Bf, ParseAlg::Op2), |
| 492 | LKAAPRED_PSEUDO("bdnz", ExtendedGekkoMnemonic::Bdnz, ParseAlg::Op1), |
| 493 | LKAAPRED_PSEUDO("bdnzt", ExtendedGekkoMnemonic::Bdnzt, ParseAlg::Op2), |
| 494 | LKAAPRED_PSEUDO("bdnzf", ExtendedGekkoMnemonic::Bdnzf, ParseAlg::Op2), |
| 495 | LKAAPRED_PSEUDO("bdz", ExtendedGekkoMnemonic::Bdz, ParseAlg::Op1), |
| 496 | LKAAPRED_PSEUDO("bdzt", ExtendedGekkoMnemonic::Bdzt, ParseAlg::Op2), |
| 497 | LKAAPRED_PSEUDO("bdzf", ExtendedGekkoMnemonic::Bdzf, ParseAlg::Op2), |
| 498 | LK_PSEUDO("blr", ExtendedGekkoMnemonic::Blr, ParseAlg::None), |
| 499 | LK_PSEUDO("bctr", ExtendedGekkoMnemonic::Bctr, ParseAlg::None), |
| 500 | LKPRED_PSEUDO("btlr", ExtendedGekkoMnemonic::Btlr, ParseAlg::Op1), |
| 501 | LKPRED_PSEUDO("btctr", ExtendedGekkoMnemonic::Btctr, ParseAlg::Op1), |
| 502 | LKPRED_PSEUDO("bflr", ExtendedGekkoMnemonic::Bflr, ParseAlg::Op1), |
| 503 | LKPRED_PSEUDO("bfctr", ExtendedGekkoMnemonic::Bfctr, ParseAlg::Op1), |
| 504 | LKPRED_PSEUDO("bdnzlr", ExtendedGekkoMnemonic::Bdnzlr, ParseAlg::None), |
| 505 | LKPRED_PSEUDO("bdnztlr", ExtendedGekkoMnemonic::Bdnztlr, ParseAlg::Op1), |
| 506 | LKPRED_PSEUDO("bdnzflr", ExtendedGekkoMnemonic::Bdnzflr, ParseAlg::Op1), |
| 507 | LKPRED_PSEUDO("bdzlr", ExtendedGekkoMnemonic::Bdzlr, ParseAlg::None), |
| 508 | LKPRED_PSEUDO("bdztlr", ExtendedGekkoMnemonic::Bdztlr, ParseAlg::Op1), |
| 509 | LKPRED_PSEUDO("bdzflr", ExtendedGekkoMnemonic::Bdzflr, ParseAlg::Op1), |
| 510 | LKAAPRED_PSEUDO("blt", ExtendedGekkoMnemonic::Blt, ParseAlg::Op1Or2), |
| 511 | LKAAPRED_PSEUDO("ble", ExtendedGekkoMnemonic::Ble, ParseAlg::Op1Or2), |
| 512 | LKAAPRED_PSEUDO("beq", ExtendedGekkoMnemonic::Beq, ParseAlg::Op1Or2), |
| 513 | LKAAPRED_PSEUDO("bge", ExtendedGekkoMnemonic::Bge, ParseAlg::Op1Or2), |
| 514 | LKAAPRED_PSEUDO("bgt", ExtendedGekkoMnemonic::Bgt, ParseAlg::Op1Or2), |
| 515 | LKAAPRED_PSEUDO("bnl", ExtendedGekkoMnemonic::Bnl, ParseAlg::Op1Or2), |
| 516 | LKAAPRED_PSEUDO("bne", ExtendedGekkoMnemonic::Bne, ParseAlg::Op1Or2), |
| 517 | LKAAPRED_PSEUDO("bng", ExtendedGekkoMnemonic::Bng, ParseAlg::Op1Or2), |
| 518 | LKAAPRED_PSEUDO("bso", ExtendedGekkoMnemonic::Bso, ParseAlg::Op1Or2), |
| 519 | LKAAPRED_PSEUDO("bns", ExtendedGekkoMnemonic::Bns, ParseAlg::Op1Or2), |
| 520 | LKAAPRED_PSEUDO("bun", ExtendedGekkoMnemonic::Bun, ParseAlg::Op1Or2), |
| 521 | LKAAPRED_PSEUDO("bnu", ExtendedGekkoMnemonic::Bnu, ParseAlg::Op1Or2), |
| 522 | LKPRED_PSEUDO("bltlr", ExtendedGekkoMnemonic::Bltlr, ParseAlg::NoneOrOp1), |
| 523 | LKPRED_PSEUDO("bltctr", ExtendedGekkoMnemonic::Bltctr, ParseAlg::NoneOrOp1), |
| 524 | LKPRED_PSEUDO("blelr", ExtendedGekkoMnemonic::Blelr, ParseAlg::NoneOrOp1), |
| 525 | LKPRED_PSEUDO("blectr", ExtendedGekkoMnemonic::Blectr, ParseAlg::NoneOrOp1), |
| 526 | LKPRED_PSEUDO("beqlr", ExtendedGekkoMnemonic::Beqlr, ParseAlg::NoneOrOp1), |
| 527 | LKPRED_PSEUDO("beqctr", ExtendedGekkoMnemonic::Beqctr, ParseAlg::NoneOrOp1), |
| 528 | LKPRED_PSEUDO("bgelr", ExtendedGekkoMnemonic::Bgelr, ParseAlg::NoneOrOp1), |
| 529 | LKPRED_PSEUDO("bgectr", ExtendedGekkoMnemonic::Bgectr, ParseAlg::NoneOrOp1), |
| 530 | LKPRED_PSEUDO("bgtlr", ExtendedGekkoMnemonic::Bgtlr, ParseAlg::NoneOrOp1), |
| 531 | LKPRED_PSEUDO("bgtctr", ExtendedGekkoMnemonic::Bgtctr, ParseAlg::NoneOrOp1), |
| 532 | LKPRED_PSEUDO("bnllr", ExtendedGekkoMnemonic::Bnllr, ParseAlg::NoneOrOp1), |
| 533 | LKPRED_PSEUDO("bnlctr", ExtendedGekkoMnemonic::Bnlctr, ParseAlg::NoneOrOp1), |
| 534 | LKPRED_PSEUDO("bnelr", ExtendedGekkoMnemonic::Bnelr, ParseAlg::NoneOrOp1), |
| 535 | LKPRED_PSEUDO("bnectr", ExtendedGekkoMnemonic::Bnectr, ParseAlg::NoneOrOp1), |
| 536 | LKPRED_PSEUDO("bnglr", ExtendedGekkoMnemonic::Bnglr, ParseAlg::NoneOrOp1), |
| 537 | LKPRED_PSEUDO("bngctr", ExtendedGekkoMnemonic::Bngctr, ParseAlg::NoneOrOp1), |
| 538 | LKPRED_PSEUDO("bsolr", ExtendedGekkoMnemonic::Bsolr, ParseAlg::NoneOrOp1), |
| 539 | LKPRED_PSEUDO("bsoctr", ExtendedGekkoMnemonic::Bsoctr, ParseAlg::NoneOrOp1), |
| 540 | LKPRED_PSEUDO("bnslr", ExtendedGekkoMnemonic::Bnslr, ParseAlg::NoneOrOp1), |
| 541 | LKPRED_PSEUDO("bnsctr", ExtendedGekkoMnemonic::Bnsctr, ParseAlg::NoneOrOp1), |
| 542 | LKPRED_PSEUDO("bunlr", ExtendedGekkoMnemonic::Bunlr, ParseAlg::NoneOrOp1), |
| 543 | LKPRED_PSEUDO("bunctr", ExtendedGekkoMnemonic::Bunctr, ParseAlg::NoneOrOp1), |
| 544 | LKPRED_PSEUDO("bnulr", ExtendedGekkoMnemonic::Bnulr, ParseAlg::NoneOrOp1), |
| 545 | LKPRED_PSEUDO("bnuctr", ExtendedGekkoMnemonic::Bnuctr, ParseAlg::NoneOrOp1), |
| 546 | PLAIN_PSEUDO("crset", ExtendedGekkoMnemonic::Crset, ParseAlg::Op1), |
| 547 | PLAIN_PSEUDO("crclr", ExtendedGekkoMnemonic::Crclr, ParseAlg::Op1), |
| 548 | PLAIN_PSEUDO("crmove", ExtendedGekkoMnemonic::Crmove, ParseAlg::Op2), |
| 549 | PLAIN_PSEUDO("crnot", ExtendedGekkoMnemonic::Crnot, ParseAlg::Op2), |
| 550 | PLAIN_PSEUDO("twlt", ExtendedGekkoMnemonic::Twlt, ParseAlg::Op2), |
| 551 | PLAIN_PSEUDO("twlti", ExtendedGekkoMnemonic::Twlti, ParseAlg::Op2), |
| 552 | PLAIN_PSEUDO("twle", ExtendedGekkoMnemonic::Twle, ParseAlg::Op2), |
| 553 | PLAIN_PSEUDO("twlei", ExtendedGekkoMnemonic::Twlei, ParseAlg::Op2), |
| 554 | PLAIN_PSEUDO("tweq", ExtendedGekkoMnemonic::Tweq, ParseAlg::Op2), |
| 555 | PLAIN_PSEUDO("tweqi", ExtendedGekkoMnemonic::Tweqi, ParseAlg::Op2), |
| 556 | PLAIN_PSEUDO("twge", ExtendedGekkoMnemonic::Twge, ParseAlg::Op2), |
| 557 | PLAIN_PSEUDO("twgei", ExtendedGekkoMnemonic::Twgei, ParseAlg::Op2), |
| 558 | PLAIN_PSEUDO("twgt", ExtendedGekkoMnemonic::Twgt, ParseAlg::Op2), |
| 559 | PLAIN_PSEUDO("twgti", ExtendedGekkoMnemonic::Twgti, ParseAlg::Op2), |
| 560 | PLAIN_PSEUDO("twnl", ExtendedGekkoMnemonic::Twnl, ParseAlg::Op2), |
| 561 | PLAIN_PSEUDO("twnli", ExtendedGekkoMnemonic::Twnli, ParseAlg::Op2), |
| 562 | PLAIN_PSEUDO("twne", ExtendedGekkoMnemonic::Twne, ParseAlg::Op2), |
| 563 | PLAIN_PSEUDO("twnei", ExtendedGekkoMnemonic::Twnei, ParseAlg::Op2), |
| 564 | PLAIN_PSEUDO("twng", ExtendedGekkoMnemonic::Twng, ParseAlg::Op2), |
| 565 | PLAIN_PSEUDO("twngi", ExtendedGekkoMnemonic::Twngi, ParseAlg::Op2), |
| 566 | PLAIN_PSEUDO("twllt", ExtendedGekkoMnemonic::Twllt, ParseAlg::Op2), |
| 567 | PLAIN_PSEUDO("twllti", ExtendedGekkoMnemonic::Twllti, ParseAlg::Op2), |
| 568 | PLAIN_PSEUDO("twlle", ExtendedGekkoMnemonic::Twlle, ParseAlg::Op2), |
| 569 | PLAIN_PSEUDO("twllei", ExtendedGekkoMnemonic::Twllei, ParseAlg::Op2), |
| 570 | PLAIN_PSEUDO("twlge", ExtendedGekkoMnemonic::Twlge, ParseAlg::Op2), |
| 571 | PLAIN_PSEUDO("twlgei", ExtendedGekkoMnemonic::Twlgei, ParseAlg::Op2), |
| 572 | PLAIN_PSEUDO("twlgt", ExtendedGekkoMnemonic::Twlgt, ParseAlg::Op2), |
| 573 | PLAIN_PSEUDO("twlgti", ExtendedGekkoMnemonic::Twlgti, ParseAlg::Op2), |
| 574 | PLAIN_PSEUDO("twlnl", ExtendedGekkoMnemonic::Twlnl, ParseAlg::Op2), |
| 575 | PLAIN_PSEUDO("twlnli", ExtendedGekkoMnemonic::Twlnli, ParseAlg::Op2), |
| 576 | PLAIN_PSEUDO("twlng", ExtendedGekkoMnemonic::Twlng, ParseAlg::Op2), |
| 577 | PLAIN_PSEUDO("twlngi", ExtendedGekkoMnemonic::Twlngi, ParseAlg::Op2), |
| 578 | PLAIN_PSEUDO("trap", ExtendedGekkoMnemonic::Trap, ParseAlg::None), |
| 579 | PLAIN_PSEUDO("mtxer", ExtendedGekkoMnemonic::Mtxer, ParseAlg::Op1), |
| 580 | PLAIN_PSEUDO("mfxer", ExtendedGekkoMnemonic::Mfxer, ParseAlg::Op1), |
| 581 | PLAIN_PSEUDO("mtlr", ExtendedGekkoMnemonic::Mtlr, ParseAlg::Op1), |
| 582 | PLAIN_PSEUDO("mflr", ExtendedGekkoMnemonic::Mflr, ParseAlg::Op1), |
| 583 | PLAIN_PSEUDO("mtctr", ExtendedGekkoMnemonic::Mtctr, ParseAlg::Op1), |
| 584 | PLAIN_PSEUDO("mfctr", ExtendedGekkoMnemonic::Mfctr, ParseAlg::Op1), |
| 585 | PLAIN_PSEUDO("mtdsisr", ExtendedGekkoMnemonic::Mtdsisr, ParseAlg::Op1), |
| 586 | PLAIN_PSEUDO("mfdsisr", ExtendedGekkoMnemonic::Mfdsisr, ParseAlg::Op1), |
| 587 | PLAIN_PSEUDO("mtdar", ExtendedGekkoMnemonic::Mtdar, ParseAlg::Op1), |
| 588 | PLAIN_PSEUDO("mfdar", ExtendedGekkoMnemonic::Mfdar, ParseAlg::Op1), |
| 589 | PLAIN_PSEUDO("mtdec", ExtendedGekkoMnemonic::Mtdec, ParseAlg::Op1), |
| 590 | PLAIN_PSEUDO("mfdec", ExtendedGekkoMnemonic::Mfdec, ParseAlg::Op1), |
| 591 | PLAIN_PSEUDO("mtsdr1", ExtendedGekkoMnemonic::Mtsdr1, ParseAlg::Op1), |
| 592 | PLAIN_PSEUDO("mfsdr1", ExtendedGekkoMnemonic::Mfsdr1, ParseAlg::Op1), |
| 593 | PLAIN_PSEUDO("mtsrr0", ExtendedGekkoMnemonic::Mtsrr0, ParseAlg::Op1), |
| 594 | PLAIN_PSEUDO("mfsrr0", ExtendedGekkoMnemonic::Mfsrr0, ParseAlg::Op1), |
| 595 | PLAIN_PSEUDO("mtsrr1", ExtendedGekkoMnemonic::Mtsrr1, ParseAlg::Op1), |
| 596 | PLAIN_PSEUDO("mfsrr1", ExtendedGekkoMnemonic::Mfsrr1, ParseAlg::Op1), |
| 597 | PLAIN_PSEUDO("mtasr", ExtendedGekkoMnemonic::Mtasr, ParseAlg::Op1), |
| 598 | PLAIN_PSEUDO("mfasr", ExtendedGekkoMnemonic::Mfasr, ParseAlg::Op1), |
| 599 | PLAIN_PSEUDO("mtear", ExtendedGekkoMnemonic::Mtear, ParseAlg::Op1), |
| 600 | PLAIN_PSEUDO("mfear", ExtendedGekkoMnemonic::Mfear, ParseAlg::Op1), |
| 601 | PLAIN_PSEUDO("mttbl", ExtendedGekkoMnemonic::Mttbl, ParseAlg::Op1), |
| 602 | PLAIN_PSEUDO("mftbl", ExtendedGekkoMnemonic::Mftbl, ParseAlg::Op1), |
| 603 | PLAIN_PSEUDO("mttbu", ExtendedGekkoMnemonic::Mttbu, ParseAlg::Op1), |
| 604 | PLAIN_PSEUDO("mftbu", ExtendedGekkoMnemonic::Mftbu, ParseAlg::Op1), |
| 605 | PLAIN_PSEUDO("mtsprg", ExtendedGekkoMnemonic::Mtsprg, ParseAlg::Op2), |
| 606 | PLAIN_PSEUDO("mfsprg", ExtendedGekkoMnemonic::Mfsprg, ParseAlg::Op2), |
| 607 | PLAIN_PSEUDO("mtibatu", ExtendedGekkoMnemonic::Mtibatu, ParseAlg::Op2), |
| 608 | PLAIN_PSEUDO("mfibatu", ExtendedGekkoMnemonic::Mfibatu, ParseAlg::Op2), |
| 609 | PLAIN_PSEUDO("mtibatl", ExtendedGekkoMnemonic::Mtibatl, ParseAlg::Op2), |
| 610 | PLAIN_PSEUDO("mfibatl", ExtendedGekkoMnemonic::Mfibatl, ParseAlg::Op2), |
| 611 | PLAIN_PSEUDO("mtdbatu", ExtendedGekkoMnemonic::Mtdbatu, ParseAlg::Op2), |
| 612 | PLAIN_PSEUDO("mfdbatu", ExtendedGekkoMnemonic::Mfdbatu, ParseAlg::Op2), |
| 613 | PLAIN_PSEUDO("mtdbatl", ExtendedGekkoMnemonic::Mtdbatl, ParseAlg::Op2), |
| 614 | PLAIN_PSEUDO("mfdbatl", ExtendedGekkoMnemonic::Mfdbatl, ParseAlg::Op2), |
| 615 | PLAIN_PSEUDO("nop", ExtendedGekkoMnemonic::Nop, ParseAlg::None), |
| 616 | PLAIN_PSEUDO("li", ExtendedGekkoMnemonic::Li, ParseAlg::Op2), |
| 617 | PLAIN_PSEUDO("lis", ExtendedGekkoMnemonic::Lis, ParseAlg::Op2), |
| 618 | PLAIN_PSEUDO("la", ExtendedGekkoMnemonic::La, ParseAlg::Op1Off1), |
| 619 | RC_PSEUDO("mr", ExtendedGekkoMnemonic::Mr, ParseAlg::Op2), |
| 620 | RC_PSEUDO("not", ExtendedGekkoMnemonic::Not, ParseAlg::Op2), |
| 621 | PLAIN_PSEUDO("mtcr", ExtendedGekkoMnemonic::Mtcr, ParseAlg::Op1), |
| 622 | PLAIN_PSEUDO("mfspr", ExtendedGekkoMnemonic::Mfspr, ParseAlg::Op2), |
| 623 | PLAIN_PSEUDO("mftb", ExtendedGekkoMnemonic::Mftb, ParseAlg::Op2), |
| 624 | PLAIN_PSEUDO("mtspr", ExtendedGekkoMnemonic::Mtspr, ParseAlg::Op2), |
| 625 | }; |
| 626 | |
| 627 | #undef MNEMONIC |
| 628 | #undef PLAIN_MNEMONIC |
| 629 | #undef RC_MNEMONIC |
| 630 | #undef OERC_MNEMONIC |
| 631 | #undef LK_MNEMONIC |
| 632 | #undef AALK_MNEMONIC |
| 633 | #undef PSEUDO |
| 634 | #undef PLAIN_PSEUDO |
| 635 | #undef RC_PSEUDO |
| 636 | #undef OERC_PSEUDO |
| 637 | #undef LK_PSEUDO |
| 638 | #undef LKAA_PSEUDO |
| 639 | #undef LKPRED_PSEUDO |
| 640 | #undef LKAAPRED_PSEUDO |
| 641 | |
| 642 | ////////////////////// |
| 643 | // ASSEMBLER TABLES // |
| 644 | ////////////////////// |
| 645 | #define EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, ...) \ |
| 646 | MnemonicDesc \ |
| 647 | { \ |
| 648 | InsertOpcode(opcode_val) | (extra_bits), \ |
| 649 | static_cast<u32>(std::initializer_list<OperandDesc>{__VA_ARGS__}.size()), \ |
| 650 | { \ |
| 651 | __VA_ARGS__ \ |
| 652 | } \ |
| 653 | } |
| 654 | #define MNEMONIC(opcode_val, extra_bits, ...) \ |
| 655 | EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, __VA_ARGS__), INVALID_MNEMONIC, INVALID_MNEMONIC, \ |
| 656 | INVALID_MNEMONIC |
| 657 | #define BASIC_MNEMONIC(opcode_val, ...) MNEMONIC(opcode_val, 0, __VA_ARGS__) |
| 658 | #define RC_MNEMONIC(opcode_val, extra_bits, ...) \ |
| 659 | EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, __VA_ARGS__), \ |
| 660 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(1, 31, 31)), __VA_ARGS__), \ |
| 661 | INVALID_MNEMONIC, INVALID_MNEMONIC |
| 662 | #define OERC_MNEMONIC(opcode_val, extra_bits, ...) \ |
| 663 | EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, __VA_ARGS__), \ |
| 664 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(1, 31, 31)), __VA_ARGS__), \ |
| 665 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(1, 21, 21)), __VA_ARGS__), \ |
| 666 | EMIT_MNEMONIC_ENTRY( \ |
| 667 | opcode_val, ((extra_bits) | InsertVal(1, 31, 31) | InsertVal(1, 21, 21)), __VA_ARGS__) |
| 668 | #define LK_MNEMONIC(opcode_val, extra_bits, ...) \ |
| 669 | EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, __VA_ARGS__), \ |
| 670 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(1, 31, 31)), __VA_ARGS__), \ |
| 671 | INVALID_MNEMONIC, INVALID_MNEMONIC |
| 672 | #define AALK_MNEMONIC(opcode_val, extra_bits, ...) \ |
| 673 | EMIT_MNEMONIC_ENTRY(opcode_val, extra_bits, __VA_ARGS__), \ |
| 674 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(0b01, 30, 31)), __VA_ARGS__), \ |
| 675 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(0b10, 30, 31)), __VA_ARGS__), \ |
| 676 | EMIT_MNEMONIC_ENTRY(opcode_val, ((extra_bits) | InsertVal(0b11, 30, 31)), __VA_ARGS__) |
| 677 | |
| 678 | // Defines all basic mnemonics that Broadway/Gekko supports |
| 679 | extern const std::array<MnemonicDesc, NUM_MNEMONICS * VARIANT_PERMUTATIONS> mnemonics = { |
| 680 | // A-2 |
| 681 | OERC_MNEMONIC(31, InsertVal(266, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // add |
| 682 | OERC_MNEMONIC(31, InsertVal(10, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // addc |
| 683 | OERC_MNEMONIC(31, InsertVal(138, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // adde |
| 684 | BASIC_MNEMONIC(14, OpDesc_D, OpDesc_A, OpDesc_SIMM), // addi |
| 685 | BASIC_MNEMONIC(12, OpDesc_D, OpDesc_A, OpDesc_SIMM), // addic |
| 686 | BASIC_MNEMONIC(13, OpDesc_D, OpDesc_A, OpDesc_SIMM), // addic. |
| 687 | BASIC_MNEMONIC(15, OpDesc_D, OpDesc_A, OpDesc_SIMM), // addis |
| 688 | OERC_MNEMONIC(31, InsertVal(234, 22, 30), OpDesc_D, OpDesc_A), // addme |
| 689 | OERC_MNEMONIC(31, InsertVal(202, 22, 30), OpDesc_D, OpDesc_A), // addze |
| 690 | OERC_MNEMONIC(31, InsertVal(491, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // divw |
| 691 | OERC_MNEMONIC(31, InsertVal(459, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // divwu |
| 692 | RC_MNEMONIC(31, InsertVal(75, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // mulhw |
| 693 | RC_MNEMONIC(31, InsertVal(11, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // mulhwu |
| 694 | BASIC_MNEMONIC(7, OpDesc_D, OpDesc_A, OpDesc_SIMM), // mulli |
| 695 | OERC_MNEMONIC(31, InsertVal(235, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // mullw |
| 696 | OERC_MNEMONIC(31, InsertVal(104, 22, 30), OpDesc_D, OpDesc_A), // neg |
| 697 | OERC_MNEMONIC(31, InsertVal(40, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // subf |
| 698 | OERC_MNEMONIC(31, InsertVal(8, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // subfc |
| 699 | OERC_MNEMONIC(31, InsertVal(136, 22, 30), OpDesc_D, OpDesc_A, OpDesc_B), // subfe |
| 700 | BASIC_MNEMONIC(8, OpDesc_D, OpDesc_A, OpDesc_SIMM), // subfic |
| 701 | OERC_MNEMONIC(31, InsertVal(232, 22, 30), OpDesc_D, OpDesc_A), // subfme |
| 702 | OERC_MNEMONIC(31, InsertVal(200, 22, 30), OpDesc_D, OpDesc_A), // subfze |
| 703 | |
| 704 | // A-3 |
| 705 | MNEMONIC(31, InsertVal(0, 21, 30), OpDesc_Crfd, OpDesc_L, OpDesc_A, OpDesc_B), // cmp |
| 706 | BASIC_MNEMONIC(11, OpDesc_Crfd, OpDesc_L, OpDesc_A, OpDesc_SIMM), // cmpi |
| 707 | MNEMONIC(31, InsertVal(32, 21, 30), OpDesc_Crfd, OpDesc_L, OpDesc_A, OpDesc_B), // cmpl |
| 708 | BASIC_MNEMONIC(10, OpDesc_Crfd, OpDesc_L, OpDesc_A, OpDesc_UIMM), // cmpli |
| 709 | |
| 710 | // A-4 |
| 711 | RC_MNEMONIC(31, InsertVal(28, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // and |
| 712 | RC_MNEMONIC(31, InsertVal(60, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // andc |
| 713 | BASIC_MNEMONIC(28, OpDesc_A, OpDesc_S, OpDesc_UIMM), // andi. |
| 714 | BASIC_MNEMONIC(29, OpDesc_A, OpDesc_S, OpDesc_UIMM), // andis. |
| 715 | RC_MNEMONIC(31, InsertVal(26, 21, 30), OpDesc_A, OpDesc_S), // cntlzw |
| 716 | RC_MNEMONIC(31, InsertVal(284, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // eqv |
| 717 | RC_MNEMONIC(31, InsertVal(954, 21, 30), OpDesc_A, OpDesc_S), // extsb |
| 718 | RC_MNEMONIC(31, InsertVal(922, 21, 30), OpDesc_A, OpDesc_S), // extsh |
| 719 | RC_MNEMONIC(31, InsertVal(476, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // nand |
| 720 | RC_MNEMONIC(31, InsertVal(124, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // nor |
| 721 | RC_MNEMONIC(31, InsertVal(444, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // or |
| 722 | RC_MNEMONIC(31, InsertVal(412, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // orc |
| 723 | BASIC_MNEMONIC(24, OpDesc_A, OpDesc_S, OpDesc_UIMM), // ori |
| 724 | BASIC_MNEMONIC(25, OpDesc_A, OpDesc_S, OpDesc_UIMM), // oris |
| 725 | RC_MNEMONIC(31, InsertVal(316, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // xor |
| 726 | BASIC_MNEMONIC(26, OpDesc_A, OpDesc_S, OpDesc_UIMM), // xori |
| 727 | BASIC_MNEMONIC(27, OpDesc_A, OpDesc_S, OpDesc_UIMM), // xoris |
| 728 | |
| 729 | // A-5 |
| 730 | RC_MNEMONIC(20, 0, OpDesc_A, OpDesc_S, OpDesc_SH, OpDesc_MB, OpDesc_ME), // rlwimi |
| 731 | RC_MNEMONIC(21, 0, OpDesc_A, OpDesc_S, OpDesc_SH, OpDesc_MB, OpDesc_ME), // rlwinm |
| 732 | RC_MNEMONIC(23, 0, OpDesc_A, OpDesc_S, OpDesc_B, OpDesc_MB, OpDesc_ME), // rlwnm |
| 733 | |
| 734 | // A-6 |
| 735 | RC_MNEMONIC(31, InsertVal(24, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // slw |
| 736 | RC_MNEMONIC(31, InsertVal(792, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // sraw |
| 737 | RC_MNEMONIC(31, InsertVal(824, 21, 30), OpDesc_A, OpDesc_S, OpDesc_SH), // srawi |
| 738 | RC_MNEMONIC(31, InsertVal(536, 21, 30), OpDesc_A, OpDesc_S, OpDesc_B), // srw |
| 739 | |
| 740 | // A-7 |
| 741 | RC_MNEMONIC(63, InsertVal(21, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fadd |
| 742 | RC_MNEMONIC(59, InsertVal(21, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fadds |
| 743 | RC_MNEMONIC(63, InsertVal(18, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fdiv |
| 744 | RC_MNEMONIC(59, InsertVal(18, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fdivs |
| 745 | RC_MNEMONIC(63, InsertVal(25, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C), // fmul |
| 746 | RC_MNEMONIC(59, InsertVal(25, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C), // fmuls |
| 747 | RC_MNEMONIC(59, InsertVal(24, 26, 30), OpDesc_D, OpDesc_B), // fres |
| 748 | RC_MNEMONIC(63, InsertVal(26, 26, 30), OpDesc_D, OpDesc_B), // frsqrte |
| 749 | RC_MNEMONIC(63, InsertVal(20, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fsub |
| 750 | RC_MNEMONIC(59, InsertVal(20, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // fsubs |
| 751 | RC_MNEMONIC(63, InsertVal(23, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fsel |
| 752 | |
| 753 | // A-8 |
| 754 | RC_MNEMONIC(63, InsertVal(29, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fmadd |
| 755 | RC_MNEMONIC(59, InsertVal(29, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fmadds |
| 756 | RC_MNEMONIC(63, InsertVal(28, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fmsub |
| 757 | RC_MNEMONIC(59, InsertVal(28, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fmsubs |
| 758 | RC_MNEMONIC(63, InsertVal(31, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fnmadd |
| 759 | RC_MNEMONIC(59, InsertVal(31, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fnmadds |
| 760 | RC_MNEMONIC(63, InsertVal(30, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fnmsub |
| 761 | RC_MNEMONIC(59, InsertVal(30, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // fnmsubs |
| 762 | |
| 763 | // A-9 |
| 764 | RC_MNEMONIC(63, InsertVal(14, 21, 30), OpDesc_D, OpDesc_B), // fctiw |
| 765 | RC_MNEMONIC(63, InsertVal(15, 21, 30), OpDesc_D, OpDesc_B), // fctiwz |
| 766 | RC_MNEMONIC(63, InsertVal(12, 21, 30), OpDesc_D, OpDesc_B), // frsp |
| 767 | |
| 768 | // A-10 |
| 769 | MNEMONIC(63, InsertVal(32, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // fcmpo |
| 770 | MNEMONIC(63, InsertVal(0, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // fcmpu |
| 771 | |
| 772 | // A-11 |
| 773 | MNEMONIC(63, InsertVal(64, 21, 30), OpDesc_Crfd, OpDesc_Crfs), // mcrfs |
| 774 | RC_MNEMONIC(63, InsertVal(583, 21, 30), OpDesc_D), // mffs |
| 775 | RC_MNEMONIC(63, InsertVal(70, 21, 30), OpDesc_Crbd), // mtfsb0 |
| 776 | RC_MNEMONIC(63, InsertVal(38, 21, 30), OpDesc_Crbd), // mtfsb1 |
| 777 | RC_MNEMONIC(63, InsertVal(711, 21, 30), OpDesc_FM, OpDesc_B), // mtfsf |
| 778 | RC_MNEMONIC(63, InsertVal(134, 21, 30), OpDesc_Crfd, OpDesc_IMM), // mtfsfi |
| 779 | |
| 780 | // A-12 |
| 781 | BASIC_MNEMONIC(34, OpDesc_D, OpDesc_Offd, OpDesc_A), // lbz |
| 782 | BASIC_MNEMONIC(35, OpDesc_D, OpDesc_Offd, OpDesc_A), // lbzu |
| 783 | MNEMONIC(31, InsertVal(119, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lbzux |
| 784 | MNEMONIC(31, InsertVal(87, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lbzx |
| 785 | BASIC_MNEMONIC(42, OpDesc_D, OpDesc_Offd, OpDesc_A), // lha |
| 786 | BASIC_MNEMONIC(43, OpDesc_D, OpDesc_Offd, OpDesc_A), // lhau |
| 787 | MNEMONIC(31, InsertVal(375, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lhaux |
| 788 | MNEMONIC(31, InsertVal(343, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lhax |
| 789 | BASIC_MNEMONIC(40, OpDesc_D, OpDesc_Offd, OpDesc_A), // lhz |
| 790 | BASIC_MNEMONIC(41, OpDesc_D, OpDesc_Offd, OpDesc_A), // lhzu |
| 791 | MNEMONIC(31, InsertVal(311, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lhzux |
| 792 | MNEMONIC(31, InsertVal(279, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lhzx |
| 793 | BASIC_MNEMONIC(32, OpDesc_D, OpDesc_Offd, OpDesc_A), // lwz |
| 794 | BASIC_MNEMONIC(33, OpDesc_D, OpDesc_Offd, OpDesc_A), // lwzu |
| 795 | MNEMONIC(31, InsertVal(55, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lwzux |
| 796 | MNEMONIC(31, InsertVal(23, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lwzx |
| 797 | |
| 798 | // A-13 |
| 799 | BASIC_MNEMONIC(38, OpDesc_S, OpDesc_Offd, OpDesc_A), // stb |
| 800 | BASIC_MNEMONIC(39, OpDesc_S, OpDesc_Offd, OpDesc_A), // stbu |
| 801 | MNEMONIC(31, InsertVal(247, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stbux |
| 802 | MNEMONIC(31, InsertVal(215, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stbx |
| 803 | BASIC_MNEMONIC(44, OpDesc_S, OpDesc_Offd, OpDesc_A), // sth |
| 804 | BASIC_MNEMONIC(45, OpDesc_S, OpDesc_Offd, OpDesc_A), // sthu |
| 805 | MNEMONIC(31, InsertVal(439, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // sthux |
| 806 | MNEMONIC(31, InsertVal(407, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // sthx |
| 807 | BASIC_MNEMONIC(36, OpDesc_S, OpDesc_Offd, OpDesc_A), // stw |
| 808 | BASIC_MNEMONIC(37, OpDesc_S, OpDesc_Offd, OpDesc_A), // stwu |
| 809 | MNEMONIC(31, InsertVal(183, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stwux |
| 810 | MNEMONIC(31, InsertVal(151, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stwx |
| 811 | |
| 812 | // A-14 |
| 813 | MNEMONIC(31, InsertVal(790, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lhbrx |
| 814 | MNEMONIC(31, InsertVal(534, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lwbrx |
| 815 | MNEMONIC(31, InsertVal(918, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // sthbrx |
| 816 | MNEMONIC(31, InsertVal(662, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stwbrx |
| 817 | |
| 818 | // A-15 |
| 819 | BASIC_MNEMONIC(46, OpDesc_D, OpDesc_Offd, OpDesc_A), // lmw |
| 820 | BASIC_MNEMONIC(47, OpDesc_S, OpDesc_Offd, OpDesc_A), // stmw |
| 821 | |
| 822 | // A-16 |
| 823 | MNEMONIC(31, InsertVal(597, 21, 30), OpDesc_D, OpDesc_A, OpDesc_NB), // lswi |
| 824 | MNEMONIC(31, InsertVal(533, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lswx |
| 825 | MNEMONIC(31, InsertVal(725, 21, 30), OpDesc_S, OpDesc_A, OpDesc_NB), // stswi |
| 826 | MNEMONIC(31, InsertVal(661, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stswx |
| 827 | |
| 828 | // A-17 |
| 829 | MNEMONIC(31, InsertVal(854, 21, 30)), // eieio |
| 830 | MNEMONIC(19, InsertVal(150, 21, 30)), // isync |
| 831 | MNEMONIC(31, InsertVal(20, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lwarx |
| 832 | MNEMONIC(31, InsertVal(150, 21, 30) | InsertVal(1, 31, 31), OpDesc_S, OpDesc_A, |
| 833 | OpDesc_B), // stwcx. |
| 834 | MNEMONIC(31, InsertVal(598, 21, 30)), // sync |
| 835 | |
| 836 | // A-18 |
| 837 | BASIC_MNEMONIC(50, OpDesc_D, OpDesc_Offd, OpDesc_A), // lfd |
| 838 | BASIC_MNEMONIC(51, OpDesc_D, OpDesc_Offd, OpDesc_A), // lfdu |
| 839 | MNEMONIC(31, InsertVal(631, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lfdux |
| 840 | MNEMONIC(31, InsertVal(599, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lfdx |
| 841 | BASIC_MNEMONIC(48, OpDesc_D, OpDesc_Offd, OpDesc_A), // lfs |
| 842 | BASIC_MNEMONIC(49, OpDesc_D, OpDesc_Offd, OpDesc_A), // lfsu |
| 843 | MNEMONIC(31, InsertVal(567, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lfsux |
| 844 | MNEMONIC(31, InsertVal(535, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // lfsx |
| 845 | |
| 846 | // A-19 |
| 847 | BASIC_MNEMONIC(54, OpDesc_S, OpDesc_Offd, OpDesc_A), // stfd |
| 848 | BASIC_MNEMONIC(55, OpDesc_S, OpDesc_Offd, OpDesc_A), // stfdu |
| 849 | MNEMONIC(31, InsertVal(759, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stfdux |
| 850 | MNEMONIC(31, InsertVal(727, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stfdx |
| 851 | MNEMONIC(31, InsertVal(983, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stfiwx |
| 852 | BASIC_MNEMONIC(52, OpDesc_S, OpDesc_Offd, OpDesc_A), // stfs |
| 853 | BASIC_MNEMONIC(53, OpDesc_S, OpDesc_Offd, OpDesc_A), // stfsu |
| 854 | MNEMONIC(31, InsertVal(695, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stfsux |
| 855 | MNEMONIC(31, InsertVal(663, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // stfsx |
| 856 | |
| 857 | // A-20 |
| 858 | RC_MNEMONIC(63, InsertVal(264, 21, 30), OpDesc_D, OpDesc_B), // fabs |
| 859 | RC_MNEMONIC(63, InsertVal(72, 21, 30), OpDesc_D, OpDesc_B), // fmr |
| 860 | RC_MNEMONIC(63, InsertVal(136, 21, 30), OpDesc_D, OpDesc_B), // fnabs |
| 861 | RC_MNEMONIC(63, InsertVal(40, 21, 30), OpDesc_D, OpDesc_B), // fneg |
| 862 | |
| 863 | // A-21 |
| 864 | AALK_MNEMONIC(18, 0, OpDesc_LI), // b |
| 865 | AALK_MNEMONIC(16, 0, OpDesc_BO, OpDesc_BI, OpDesc_BD), // bc |
| 866 | LK_MNEMONIC(19, InsertVal(528, 21, 30), OpDesc_BO, OpDesc_BI), // bcctr |
| 867 | LK_MNEMONIC(19, InsertVal(16, 21, 30), OpDesc_BO, OpDesc_BI), // bclr |
| 868 | |
| 869 | // A-22 |
| 870 | MNEMONIC(19, InsertVal(257, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crand |
| 871 | MNEMONIC(19, InsertVal(129, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crandc |
| 872 | MNEMONIC(19, InsertVal(289, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // creqv |
| 873 | MNEMONIC(19, InsertVal(225, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crnand |
| 874 | MNEMONIC(19, InsertVal(33, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crnor |
| 875 | MNEMONIC(19, InsertVal(449, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // cror |
| 876 | MNEMONIC(19, InsertVal(417, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crorc |
| 877 | MNEMONIC(19, InsertVal(193, 21, 30), OpDesc_Crbd, OpDesc_Crba, OpDesc_Crbb), // crxor |
| 878 | MNEMONIC(19, InsertVal(0, 21, 30), OpDesc_Crfd, OpDesc_Crfs), // mcrf |
| 879 | |
| 880 | // A-23 |
| 881 | MNEMONIC(19, InsertVal(50, 21, 30)), // rfi |
| 882 | MNEMONIC(17, InsertVal(1, 30, 30)), // sc |
| 883 | |
| 884 | // A-24 |
| 885 | MNEMONIC(31, InsertVal(4, 21, 30), OpDesc_TO, OpDesc_A, OpDesc_B), // tw |
| 886 | BASIC_MNEMONIC(3, OpDesc_TO, OpDesc_A, OpDesc_SIMM), // twi |
| 887 | |
| 888 | // A-25 |
| 889 | MNEMONIC(31, InsertVal(512, 21, 30), OpDesc_Crfd), // mcrxr |
| 890 | MNEMONIC(31, InsertVal(19, 21, 30), OpDesc_D), // mfcr |
| 891 | MNEMONIC(31, InsertVal(83, 21, 30), OpDesc_D), // mfmsr |
| 892 | MNEMONIC(31, InsertVal(339, 21, 30), OpDesc_D, OpDesc_SPR), // mfspr |
| 893 | MNEMONIC(31, InsertVal(371, 21, 30), OpDesc_D, OpDesc_TPR), // mftb |
| 894 | MNEMONIC(31, InsertVal(144, 21, 30), OpDesc_CRM, OpDesc_S), // mtcrf |
| 895 | MNEMONIC(31, InsertVal(146, 21, 30), OpDesc_S), // mtmsr |
| 896 | MNEMONIC(31, InsertVal(467, 21, 30), OpDesc_SPR, OpDesc_D), // mtspr |
| 897 | |
| 898 | // A-26 |
| 899 | MNEMONIC(31, InsertVal(86, 21, 30), OpDesc_A, OpDesc_B), // dcbf |
| 900 | MNEMONIC(31, InsertVal(470, 21, 30), OpDesc_A, OpDesc_B), // dcbi |
| 901 | MNEMONIC(31, InsertVal(54, 21, 30), OpDesc_A, OpDesc_B), // dcbst |
| 902 | MNEMONIC(31, InsertVal(278, 21, 30), OpDesc_A, OpDesc_B), // dcbt |
| 903 | MNEMONIC(31, InsertVal(246, 21, 30), OpDesc_A, OpDesc_B), // dcbtst |
| 904 | MNEMONIC(31, InsertVal(1014, 21, 30), OpDesc_A, OpDesc_B), // dcbz |
| 905 | MNEMONIC(31, InsertVal(982, 21, 30), OpDesc_A, OpDesc_B), // icbi |
| 906 | |
| 907 | // A-27 |
| 908 | MNEMONIC(31, InsertVal(595, 21, 30), OpDesc_D, OpDesc_SR), // mfsr |
| 909 | MNEMONIC(31, InsertVal(659, 21, 30), OpDesc_D, OpDesc_B), // mfsrin |
| 910 | MNEMONIC(31, InsertVal(210, 21, 30), OpDesc_SR, OpDesc_S), // mtsr |
| 911 | MNEMONIC(31, InsertVal(242, 21, 30), OpDesc_S, OpDesc_B), // mtsrin |
| 912 | |
| 913 | // A-28 |
| 914 | MNEMONIC(31, InsertVal(306, 21, 30), OpDesc_B), // tlbie |
| 915 | MNEMONIC(31, InsertVal(566, 21, 30)), // tlbsync |
| 916 | |
| 917 | // A-29 |
| 918 | MNEMONIC(31, InsertVal(310, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // eciwx |
| 919 | MNEMONIC(31, InsertVal(438, 21, 30), OpDesc_S, OpDesc_A, OpDesc_B), // ecowx |
| 920 | |
| 921 | // A-30 |
| 922 | MNEMONIC(4, InsertVal(6, 25, 30), OpDesc_D, OpDesc_A, OpDesc_B, OpDesc_W2, |
| 923 | OpDesc_I2), // psq_lx |
| 924 | MNEMONIC(4, InsertVal(7, 25, 30), OpDesc_S, OpDesc_A, OpDesc_B, OpDesc_W2, |
| 925 | OpDesc_I2), // psq_stx |
| 926 | MNEMONIC(4, InsertVal(38, 25, 30), OpDesc_D, OpDesc_A, OpDesc_B, OpDesc_W2, |
| 927 | OpDesc_I2), // psq_lux |
| 928 | MNEMONIC(4, InsertVal(39, 25, 30), OpDesc_S, OpDesc_A, OpDesc_B, OpDesc_W2, |
| 929 | OpDesc_I2), // psq_stux |
| 930 | BASIC_MNEMONIC(56, OpDesc_D, OpDesc_OffdPs, OpDesc_A, OpDesc_W1, OpDesc_I1), // psq_l |
| 931 | BASIC_MNEMONIC(57, OpDesc_D, OpDesc_OffdPs, OpDesc_A, OpDesc_W1, OpDesc_I1), // psq_lu |
| 932 | BASIC_MNEMONIC(60, OpDesc_S, OpDesc_OffdPs, OpDesc_A, OpDesc_W1, OpDesc_I1), // psq_st |
| 933 | BASIC_MNEMONIC(61, OpDesc_S, OpDesc_OffdPs, OpDesc_A, OpDesc_W1, OpDesc_I1), // psq_stu |
| 934 | |
| 935 | // A-31 |
| 936 | RC_MNEMONIC(4, InsertVal(18, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_div |
| 937 | RC_MNEMONIC(4, InsertVal(20, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_sub |
| 938 | RC_MNEMONIC(4, InsertVal(21, 26, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_add |
| 939 | RC_MNEMONIC(4, InsertVal(23, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_sel |
| 940 | RC_MNEMONIC(4, InsertVal(24, 26, 30), OpDesc_D, OpDesc_B), // ps_res |
| 941 | RC_MNEMONIC(4, InsertVal(25, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C), // ps_mul |
| 942 | RC_MNEMONIC(4, InsertVal(26, 26, 30), OpDesc_D, OpDesc_B), // ps_rsqrte |
| 943 | RC_MNEMONIC(4, InsertVal(28, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_msub |
| 944 | RC_MNEMONIC(4, InsertVal(29, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_madd |
| 945 | RC_MNEMONIC(4, InsertVal(30, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_nmsub |
| 946 | RC_MNEMONIC(4, InsertVal(31, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_nmadd |
| 947 | RC_MNEMONIC(4, InsertVal(40, 21, 30), OpDesc_D, OpDesc_B), // ps_neg |
| 948 | RC_MNEMONIC(4, InsertVal(72, 21, 30), OpDesc_D, OpDesc_B), // ps_mr |
| 949 | RC_MNEMONIC(4, InsertVal(136, 21, 30), OpDesc_D, OpDesc_B), // ps_nabs |
| 950 | RC_MNEMONIC(4, InsertVal(264, 21, 30), OpDesc_D, OpDesc_B), // ps_abs |
| 951 | |
| 952 | // A-32 |
| 953 | RC_MNEMONIC(4, InsertVal(10, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_sum0 |
| 954 | RC_MNEMONIC(4, InsertVal(11, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_sum1 |
| 955 | RC_MNEMONIC(4, InsertVal(12, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C), // ps_muls0 |
| 956 | RC_MNEMONIC(4, InsertVal(13, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C), // ps_muls1 |
| 957 | RC_MNEMONIC(4, InsertVal(14, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_madds0 |
| 958 | RC_MNEMONIC(4, InsertVal(15, 26, 30), OpDesc_D, OpDesc_A, OpDesc_C, OpDesc_B), // ps_madds1 |
| 959 | MNEMONIC(4, InsertVal(0, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // ps_cmpu0 |
| 960 | MNEMONIC(4, InsertVal(32, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // ps_cmpo0 |
| 961 | MNEMONIC(4, InsertVal(64, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // ps_cmpu1 |
| 962 | MNEMONIC(4, InsertVal(96, 21, 30), OpDesc_Crfd, OpDesc_A, OpDesc_B), // ps_cmpo1 |
| 963 | RC_MNEMONIC(4, InsertVal(528, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_merge00 |
| 964 | RC_MNEMONIC(4, InsertVal(560, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_merge01 |
| 965 | RC_MNEMONIC(4, InsertVal(592, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_merge10 |
| 966 | RC_MNEMONIC(4, InsertVal(624, 21, 30), OpDesc_D, OpDesc_A, OpDesc_B), // ps_merge11 |
| 967 | MNEMONIC(4, InsertVal(1014, 21, 30), OpDesc_A, OpDesc_B), // dcbz_l |
| 968 | }; |
| 969 | |
| 970 | namespace |
| 971 | { |
| 972 | // Reused operand translators for extended mnemonics |
| 973 | void NegateSIMM(OperandList& operands) |
| 974 | { |
| 975 | operands[2] = static_cast<u32>(-static_cast<s32>(operands[2])); |
| 976 | } |
| 977 | |
| 978 | void SwapOps1And2(OperandList& operands) |
| 979 | { |
| 980 | std::swap(operands[1], operands[2]); |
| 981 | } |
| 982 | |
| 983 | void SetCompareWordMode(OperandList& operands) |
| 984 | { |
| 985 | if (operands.count == 2) |
| 986 | { |
| 987 | operands.Insert(0, 0); |
| 988 | } |
| 989 | operands.Insert(1, 0); |
| 990 | } |
| 991 | |
| 992 | template <u32 BO, u32 BI> |
| 993 | void FillBOBI(OperandList& operands) |
| 994 | { |
| 995 | operands.Insert(0, BO); |
| 996 | operands.Insert(1, BI); |
| 997 | } |
| 998 | |
| 999 | template <size_t Idx> |
| 1000 | void BitswapIdx(OperandList& operands) |
| 1001 | { |
| 1002 | operands[Idx] = SprBitswap(operands[Idx]); |
| 1003 | } |
| 1004 | |
| 1005 | template <u32 BO, u32 Cond, u32 ParamCount> |
| 1006 | void FillBOBICond(OperandList& operands) |
| 1007 | { |
| 1008 | if (operands.count < ParamCount) |
| 1009 | { |
| 1010 | operands.Insert(0, 0); |
| 1011 | } |
| 1012 | operands[0] = (operands[0] << 2) | Cond; |
| 1013 | operands.Insert(0, BO); |
| 1014 | } |
| 1015 | |
| 1016 | template <u32 BO> |
| 1017 | void FillBO(OperandList& operands) |
| 1018 | { |
| 1019 | operands.Insert(0, BO); |
| 1020 | } |
| 1021 | |
| 1022 | template <u32 TO> |
| 1023 | void TrapSetTO(OperandList& operands) |
| 1024 | { |
| 1025 | operands.Insert(0, TO); |
| 1026 | } |
| 1027 | |
| 1028 | template <u32 SPRG> |
| 1029 | void FillMtspr(OperandList& operands) |
| 1030 | { |
| 1031 | operands.Insert(0, SPRG); |
| 1032 | } |
| 1033 | |
| 1034 | template <u32 SPRG> |
| 1035 | void FillMfspr(OperandList& operands) |
| 1036 | { |
| 1037 | operands.Insert(1, SPRG); |
| 1038 | } |
| 1039 | |
| 1040 | template <u32 SPRG> |
| 1041 | void FillMtsprBatAndBitswap(OperandList& operands) |
| 1042 | { |
| 1043 | operands[0] = SprBitswap(2 * operands[0] + SPRG); |
| 1044 | } |
| 1045 | |
| 1046 | template <u32 SPRG> |
| 1047 | void FillMfsprBatAndBitswap(OperandList& operands) |
| 1048 | { |
| 1049 | operands[1] = SprBitswap(2 * operands[1] + SPRG); |
| 1050 | } |
| 1051 | } // namespace |
| 1052 | |
| 1053 | #define PSEUDO(base, variant_bits, cb) \ |
| 1054 | ExtendedMnemonicDesc \ |
| 1055 | { \ |
| 1056 | static_cast<size_t>(base) * VARIANT_PERMUTATIONS + variant_bits, cb \ |
| 1057 | } |
| 1058 | #define PLAIN_PSEUDO(base, cb) \ |
| 1059 | PSEUDO(base, PLAIN_MNEMONIC, cb), INVALID_EXT_MNEMONIC, INVALID_EXT_MNEMONIC, INVALID_EXT_MNEMONIC |
| 1060 | #define RC_PSEUDO(base, cb) \ |
| 1061 | PSEUDO(base, PLAIN_MNEMONIC, cb), PSEUDO(base, RECORD_BIT, cb), INVALID_EXT_MNEMONIC, \ |
| 1062 | INVALID_EXT_MNEMONIC |
| 1063 | #define OERC_PSEUDO(base, cb) \ |
| 1064 | PSEUDO(base, PLAIN_MNEMONIC, cb), PSEUDO(base, RECORD_BIT, cb), \ |
| 1065 | PSEUDO(base, OVERFLOW_EXCEPTION, cb), PSEUDO(base, (RECORD_BIT | OVERFLOW_EXCEPTION), cb) |
| 1066 | #define LK_PSEUDO(base, cb) \ |
| 1067 | PSEUDO(base, PLAIN_MNEMONIC, cb), PSEUDO(base, LINK_BIT, cb), INVALID_EXT_MNEMONIC, \ |
| 1068 | INVALID_EXT_MNEMONIC |
| 1069 | #define LKAA_PSEUDO(base, cb) \ |
| 1070 | PSEUDO(base, PLAIN_MNEMONIC, cb), PSEUDO(base, LINK_BIT, cb), \ |
| 1071 | PSEUDO(base, ABSOLUTE_ADDRESS_BIT, cb), PSEUDO(base, (LINK_BIT | ABSOLUTE_ADDRESS_BIT), cb) |
| 1072 | |
| 1073 | extern const std::array<ExtendedMnemonicDesc, NUM_EXT_MNEMONICS * VARIANT_PERMUTATIONS> |
| 1074 | extended_mnemonics = { |
| 1075 | // E.2.1 |
| 1076 | PLAIN_PSEUDO(GekkoMnemonic::Addi, NegateSIMM), // subi |
| 1077 | PLAIN_PSEUDO(GekkoMnemonic::Addis, NegateSIMM), // subis |
| 1078 | PLAIN_PSEUDO(GekkoMnemonic::Addic, NegateSIMM), // subic |
| 1079 | PLAIN_PSEUDO(GekkoMnemonic::AddicDot, NegateSIMM), // subic. |
| 1080 | |
| 1081 | // E.2.2 |
| 1082 | OERC_PSEUDO(GekkoMnemonic::Subf, SwapOps1And2), // sub |
| 1083 | OERC_PSEUDO(GekkoMnemonic::Subfc, SwapOps1And2), // subc |
| 1084 | |
| 1085 | // E.3.2 |
| 1086 | PLAIN_PSEUDO(GekkoMnemonic::Cmpi, SetCompareWordMode), // cmpwi |
| 1087 | PLAIN_PSEUDO(GekkoMnemonic::Cmp, SetCompareWordMode), // cmpw |
| 1088 | PLAIN_PSEUDO(GekkoMnemonic::Cmpli, SetCompareWordMode), // cmplwi |
| 1089 | PLAIN_PSEUDO(GekkoMnemonic::Cmpl, SetCompareWordMode), // cmplw |
| 1090 | |
| 1091 | // E.4.2 |
| 1092 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1093 | const u32 n = operands[2], b = operands[3]; |
| 1094 | operands[2] = b; |
| 1095 | operands[3] = 0; |
| 1096 | operands.Insert(4, n - 1); |
| 1097 | })), // extlwi |
| 1098 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1099 | const u32 n = operands[2], b = operands[3]; |
| 1100 | operands[2] = b + n; |
| 1101 | operands[3] = 32 - n; |
| 1102 | operands.Insert(4, 31); |
| 1103 | })), // extrwi |
| 1104 | RC_PSEUDO(GekkoMnemonic::Rlwimi, ([](OperandList& operands) { |
| 1105 | const u32 n = operands[2], b = operands[3]; |
| 1106 | operands[2] = 32 - b; |
| 1107 | operands[3] = b; |
| 1108 | operands.Insert(4, b + n - 1); |
| 1109 | })), // inslwi |
| 1110 | RC_PSEUDO(GekkoMnemonic::Rlwimi, ([](OperandList& operands) { |
| 1111 | const u32 n = operands[2], b = operands[3]; |
| 1112 | operands[2] = 32 - (b + n); |
| 1113 | operands[3] = b; |
| 1114 | operands.Insert(4, b + n - 1); |
| 1115 | })), // insrwi |
| 1116 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1117 | operands.Insert(3, 0); |
| 1118 | operands.Insert(4, 31); |
| 1119 | })), // rotlwi |
| 1120 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1121 | const u32 n = operands[2]; |
| 1122 | operands[2] = 32 - n; |
| 1123 | operands.Insert(3, 0); |
| 1124 | operands.Insert(4, 31); |
| 1125 | })), // rotrwi |
| 1126 | RC_PSEUDO(GekkoMnemonic::Rlwnm, ([](OperandList& operands) { |
| 1127 | operands.Insert(3, 0); |
| 1128 | operands.Insert(4, 31); |
| 1129 | })), // rotlw |
| 1130 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1131 | const u32 n = operands[2]; |
| 1132 | operands.Insert(3, 0); |
| 1133 | operands.Insert(4, 31 - n); |
| 1134 | })), // slwi |
| 1135 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1136 | const u32 n = operands[2]; |
| 1137 | operands[2] = 32 - n; |
| 1138 | operands.Insert(3, n); |
| 1139 | operands.Insert(4, 31); |
| 1140 | })), // srwi |
| 1141 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1142 | const u32 n = operands[2]; |
| 1143 | operands[2] = 0; |
| 1144 | operands.Insert(3, n); |
| 1145 | operands.Insert(4, 31); |
| 1146 | })), // clrlwi |
| 1147 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1148 | const u32 n = operands[2]; |
| 1149 | operands[2] = 0; |
| 1150 | operands.Insert(3, 0); |
| 1151 | operands.Insert(4, 31 - n); |
| 1152 | })), // clrrwi |
| 1153 | RC_PSEUDO(GekkoMnemonic::Rlwinm, ([](OperandList& operands) { |
| 1154 | const u32 b = operands[2], n = operands[3]; |
| 1155 | operands[2] = n; |
| 1156 | operands[3] = b - n; |
| 1157 | operands.Insert(4, 31 - n); |
| 1158 | })), // clrlslwi |
| 1159 | |
| 1160 | // E.5.2 |
| 1161 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<12>)), // bt |
| 1162 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<4>)), // bf |
| 1163 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBI<16, 0>)), // bdnz |
| 1164 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<8>)), // bdnzt |
| 1165 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<0>)), // bdnzf |
| 1166 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBI<18, 0>)), // bdz |
| 1167 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<10>)), // bdzt |
| 1168 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<2>)), // bdzf |
| 1169 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<13>)), // bt+ |
| 1170 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<5>)), // bf+ |
| 1171 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBI<17, 0>)), // bdnz+ |
| 1172 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<9>)), // bdnzt+ |
| 1173 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<1>)), // bdnzf+ |
| 1174 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBI<19, 0>)), // bdz+ |
| 1175 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<11>)), // bdzt+ |
| 1176 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBO<3>)), // bdzf+ |
| 1177 | |
| 1178 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBI<20, 0>)), // blr |
| 1179 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<12>)), // btlr |
| 1180 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<4>)), // bflr |
| 1181 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBI<16, 0>)), // bdnzlr |
| 1182 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<8>)), // bdnztlr |
| 1183 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<0>)), // bdnzflr |
| 1184 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBI<18, 0>)), // bdzlr |
| 1185 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<10>)), // bdztlr |
| 1186 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<2>)), // bdzflr |
| 1187 | |
| 1188 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<13>)), // btlr+ |
| 1189 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<5>)), // bflr+ |
| 1190 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBI<17, 0>)), // bdnzlr+ |
| 1191 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<9>)), // bdnztlr+ |
| 1192 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<1>)), // bdnzflr+ |
| 1193 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBI<19, 0>)), // bdzlr+ |
| 1194 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<11>)), // bdztlr+ |
| 1195 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBO<3>)), // bdzflr+ |
| 1196 | |
| 1197 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBI<20, 0>)), // bctr |
| 1198 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBO<12>)), // btctr |
| 1199 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBO<4>)), // bfctr |
| 1200 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBO<13>)), // btctr+ |
| 1201 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBO<5>)), // bfctr+ |
| 1202 | |
| 1203 | // E.5.3 |
| 1204 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<12, 0, 2>)), // blt |
| 1205 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 1, 2>)), // ble |
| 1206 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<12, 2, 2>)), // beq |
| 1207 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 0, 2>)), // bge |
| 1208 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<12, 1, 2>)), // bgt |
| 1209 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 0, 2>)), // bnl |
| 1210 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 2, 2>)), // bne |
| 1211 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 1, 2>)), // bng |
| 1212 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<12, 3, 2>)), // bso |
| 1213 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 3, 2>)), // bns |
| 1214 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<12, 3, 2>)), // bun |
| 1215 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<4, 3, 2>)), // bnu |
| 1216 | |
| 1217 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<13, 0, 2>)), // blt+ |
| 1218 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 1, 2>)), // ble+ |
| 1219 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<13, 2, 2>)), // beq+ |
| 1220 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 0, 2>)), // bge+ |
| 1221 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<13, 1, 2>)), // bgt+ |
| 1222 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 0, 2>)), // bnl+ |
| 1223 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 2, 2>)), // bne+ |
| 1224 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 1, 2>)), // bng+ |
| 1225 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<13, 3, 2>)), // bso+ |
| 1226 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 3, 2>)), // bns+ |
| 1227 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<13, 3, 2>)), // bun+ |
| 1228 | LKAA_PSEUDO(GekkoMnemonic::Bc, (FillBOBICond<5, 3, 2>)), // bnu+ |
| 1229 | |
| 1230 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<12, 0, 1>)), // bltlr |
| 1231 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 1, 1>)), // blelr |
| 1232 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<12, 2, 1>)), // beqlr |
| 1233 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 0, 1>)), // bgelr |
| 1234 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<12, 1, 1>)), // bgtlr |
| 1235 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 0, 1>)), // bnllr |
| 1236 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 2, 1>)), // bnelr |
| 1237 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 1, 1>)), // bnglr |
| 1238 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<12, 3, 1>)), // bsolr |
| 1239 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 3, 1>)), // bnslr |
| 1240 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<12, 3, 1>)), // bunlr |
| 1241 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<4, 3, 1>)), // bnulr |
| 1242 | |
| 1243 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<13, 0, 1>)), // bltlr+ |
| 1244 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 1, 1>)), // blelr+ |
| 1245 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<13, 2, 1>)), // beqlr+ |
| 1246 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 0, 1>)), // bgelr+ |
| 1247 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<13, 1, 1>)), // bgtlr+ |
| 1248 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 0, 1>)), // bnllr+ |
| 1249 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 2, 1>)), // bnelr+ |
| 1250 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 1, 1>)), // bnglr+ |
| 1251 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<13, 3, 1>)), // bsolr+ |
| 1252 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 3, 1>)), // bnslr+ |
| 1253 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<13, 3, 1>)), // bunlr+ |
| 1254 | LK_PSEUDO(GekkoMnemonic::Bclr, (FillBOBICond<5, 3, 1>)), // bnulr+ |
| 1255 | |
| 1256 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<12, 0, 1>)), // bltctr |
| 1257 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 1, 1>)), // blectr |
| 1258 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<12, 2, 1>)), // beqctr |
| 1259 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 0, 1>)), // bgectr |
| 1260 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<12, 1, 1>)), // bgtctr |
| 1261 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 0, 1>)), // bnlctr |
| 1262 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 2, 1>)), // bnectr |
| 1263 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 1, 1>)), // bngctr |
| 1264 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<12, 3, 1>)), // bsoctr |
| 1265 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 3, 1>)), // bnsctr |
| 1266 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<12, 3, 1>)), // bunctr |
| 1267 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<4, 3, 1>)), // bnuctr |
| 1268 | |
| 1269 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<13, 0, 1>)), // bltctr+ |
| 1270 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 1, 1>)), // blectr+ |
| 1271 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<13, 2, 1>)), // beqctr+ |
| 1272 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 0, 1>)), // bgectr+ |
| 1273 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<13, 1, 1>)), // bgtctr+ |
| 1274 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 0, 1>)), // bnlctr+ |
| 1275 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 2, 1>)), // bnectr+ |
| 1276 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 1, 1>)), // bngctr+ |
| 1277 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<13, 3, 1>)), // bsoctr+ |
| 1278 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 3, 1>)), // bnsctr+ |
| 1279 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<13, 3, 1>)), // bunctr+ |
| 1280 | LK_PSEUDO(GekkoMnemonic::Bcctr, (FillBOBICond<5, 3, 1>)), // bnuctr+ |
| 1281 | |
| 1282 | // E.6 |
| 1283 | PLAIN_PSEUDO(GekkoMnemonic::Creqv, |
| 1284 | [](OperandList& operands) { |
| 1285 | operands.Insert(1, operands[0]); |
| 1286 | operands.Insert(2, operands[0]); |
| 1287 | }), // crset |
| 1288 | PLAIN_PSEUDO(GekkoMnemonic::Crxor, |
| 1289 | [](OperandList& operands) { |
| 1290 | operands.Insert(1, operands[0]); |
| 1291 | operands.Insert(2, operands[0]); |
| 1292 | }), // crclr |
| 1293 | PLAIN_PSEUDO(GekkoMnemonic::Cror, |
| 1294 | [](OperandList& operands) { operands.Insert(2, operands[1]); }), // crmove |
| 1295 | PLAIN_PSEUDO(GekkoMnemonic::Crnor, |
| 1296 | [](OperandList& operands) { operands.Insert(2, operands[1]); }), // crnot |
| 1297 | |
| 1298 | // E.7 |
| 1299 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<16>), // twlt |
| 1300 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<16>), // twlti |
| 1301 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<20>), // twle |
| 1302 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<20>), // twlei |
| 1303 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<4>), // tweq |
| 1304 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<4>), // tweqi |
| 1305 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<12>), // twge |
| 1306 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<12>), // twgei |
| 1307 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<8>), // twgt |
| 1308 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<8>), // twgti |
| 1309 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<12>), // twnl |
| 1310 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<12>), // twnli |
| 1311 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<24>), // twne |
| 1312 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<24>), // twnei |
| 1313 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<20>), // twng |
| 1314 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<20>), // twngi |
| 1315 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<2>), // twllt |
| 1316 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<2>), // twllti |
| 1317 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<6>), // twlle |
| 1318 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<6>), // twllei |
| 1319 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<5>), // twlge |
| 1320 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<5>), // twlgei |
| 1321 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<1>), // twlgt |
| 1322 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<1>), // twlgti |
| 1323 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<5>), // twlnl |
| 1324 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<5>), // twlnli |
| 1325 | PLAIN_PSEUDO(GekkoMnemonic::Tw, TrapSetTO<6>), // twlng |
| 1326 | PLAIN_PSEUDO(GekkoMnemonic::Twi, TrapSetTO<6>), // twlngi |
| 1327 | PLAIN_PSEUDO(GekkoMnemonic::Tw, |
| 1328 | [](OperandList& operands) { |
| 1329 | operands.Insert(0, 31); |
| 1330 | operands.Insert(1, 0); |
| 1331 | operands.Insert(2, 0); |
| 1332 | }), // trap |
| 1333 | |
| 1334 | // E.8 |
| 1335 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(1)>), // mtxer |
| 1336 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(1)>), // mfxer |
| 1337 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(8)>), // mtlr |
| 1338 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(8)>), // mflr |
| 1339 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(9)>), // mtctr |
| 1340 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(9)>), // mfctr |
| 1341 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(18)>), // mtdsisr |
| 1342 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(18)>), // mfdsisr |
| 1343 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(19)>), // mtdar |
| 1344 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(19)>), // mfdar |
| 1345 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(22)>), // mtdec |
| 1346 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(22)>), // mfdec |
| 1347 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(25)>), // mtsdr1 |
| 1348 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(25)>), // mfsdr1 |
| 1349 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(26)>), // mtsrr0 |
| 1350 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(26)>), // mfsrr0 |
| 1351 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(27)>), // mtsrr1 |
| 1352 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(27)>), // mfsrr1 |
| 1353 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(280)>), // mtasr |
| 1354 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(280)>), // mfasr |
| 1355 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(282)>), // mtear |
| 1356 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfspr<SprBitswap(282)>), // mfear |
| 1357 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(284)>), // mttbl |
| 1358 | PLAIN_PSEUDO(GekkoMnemonic::Mftb_nobitswap, FillMfspr<SprBitswap(268)>), // mftbl |
| 1359 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtspr<SprBitswap(285)>), // mttbu |
| 1360 | PLAIN_PSEUDO(GekkoMnemonic::Mftb_nobitswap, FillMfspr<SprBitswap(269)>), // mftbu |
| 1361 | PLAIN_PSEUDO( |
| 1362 | GekkoMnemonic::Mtspr_nobitswap, |
| 1363 | [](OperandList& operands) { operands[0] = SprBitswap(operands[0] + 272); }), // mtsprg |
| 1364 | PLAIN_PSEUDO( |
| 1365 | GekkoMnemonic::Mfspr_nobitswap, |
| 1366 | [](OperandList& operands) { operands[1] = SprBitswap(operands[1] + 272); }), // mfsprg |
| 1367 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtsprBatAndBitswap<528>), // mtibatu |
| 1368 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfsprBatAndBitswap<528>), // mfibatu |
| 1369 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtsprBatAndBitswap<529>), // mtibatl |
| 1370 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfsprBatAndBitswap<529>), // mfibatl |
| 1371 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtsprBatAndBitswap<536>), // mtdbatu |
| 1372 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfsprBatAndBitswap<536>), // mfdbatu |
| 1373 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, FillMtsprBatAndBitswap<537>), // mtdbatl |
| 1374 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, FillMfsprBatAndBitswap<537>), // mfdbatl |
| 1375 | |
| 1376 | // E.9 |
| 1377 | PLAIN_PSEUDO(GekkoMnemonic::Ori, |
| 1378 | [](OperandList& operands) { |
| 1379 | operands.Insert(0, 0); |
| 1380 | operands.Insert(1, 0); |
| 1381 | operands.Insert(2, 0); |
| 1382 | }), // nop |
| 1383 | PLAIN_PSEUDO(GekkoMnemonic::Addi, |
| 1384 | [](OperandList& operands) { operands.Insert(1, 0); }), // li |
| 1385 | PLAIN_PSEUDO(GekkoMnemonic::Addis, |
| 1386 | [](OperandList& operands) { operands.Insert(1, 0); }), // lis |
| 1387 | PLAIN_PSEUDO(GekkoMnemonic::Addi, SwapOps1And2), // la |
| 1388 | RC_PSEUDO(GekkoMnemonic::Or, |
| 1389 | ([](OperandList& operands) { operands.Insert(2, operands[1]); })), // mr |
| 1390 | RC_PSEUDO(GekkoMnemonic::Nor, |
| 1391 | ([](OperandList& operands) { operands.Insert(2, operands[1]); })), // not |
| 1392 | PLAIN_PSEUDO(GekkoMnemonic::Mtcrf, |
| 1393 | [](OperandList& operands) { operands.Insert(0, 0xff); }), // mtcr |
| 1394 | |
| 1395 | // Additional mnemonics |
| 1396 | PLAIN_PSEUDO(GekkoMnemonic::Mfspr_nobitswap, BitswapIdx<1>), // mfspr |
| 1397 | PLAIN_PSEUDO(GekkoMnemonic::Mftb_nobitswap, BitswapIdx<1>), // mfspr |
| 1398 | PLAIN_PSEUDO(GekkoMnemonic::Mtspr_nobitswap, BitswapIdx<0>), // mtspr |
| 1399 | }; |
| 1400 | |
| 1401 | #undef EMIT_MNEMONIC_ENTRY |
| 1402 | #undef MNEMONIC |
| 1403 | #undef BASIC_MNEMONIC |
| 1404 | #undef RC_MNEMONIC |
| 1405 | #undef OERC_MNEMONIC |
| 1406 | #undef LK_MNEMONIC |
| 1407 | #undef AALK_MNEMONIC |
| 1408 | #undef PSEUDO |
| 1409 | #undef PLAIN_PSEUDO |
| 1410 | #undef RC_PSEUDO |
| 1411 | #undef OERC_PSEUDO |
| 1412 | #undef LK_PSEUDO |
| 1413 | #undef LKAA_PSEUDO |
| 1414 | |
| 1415 | ////////////////// |
| 1416 | // LEXER TABLES // |
| 1417 | ////////////////// |
| 1418 | |
| 1419 | namespace |
| 1420 | { |
| 1421 | constexpr TransitionF HasPlusOrMinus = [](char c) { return c == '+' || c == '-'; }; |
| 1422 | constexpr TransitionF HasDigit = [](char c) -> bool { return std::isdigit(c); }; |
| 1423 | constexpr TransitionF HasE = [](char c) { return c == 'e'; }; |
| 1424 | constexpr TransitionF HasDot = [](char c) { return c == '.'; }; |
| 1425 | |
| 1426 | // Normal string characters |
| 1427 | constexpr TransitionF HasNormal = [](char c) { return c != '\n' && c != '"' && c != '\\'; }; |
| 1428 | // Invalid characters in string |
| 1429 | constexpr TransitionF HasInvalid = [](char c) { return c == '\n'; }; |
| 1430 | // Octal digits |
| 1431 | constexpr TransitionF HasOctal = [](char c) { return c >= '0' && c <= '7'; }; |
| 1432 | // Hex digits |
| 1433 | constexpr TransitionF HasHex = [](char c) -> bool { return std::isxdigit(c); }; |
| 1434 | // Normal - octal |
| 1435 | constexpr TransitionF HasNormalMinusOctal = [](char c) { return HasNormal(c) && !HasOctal(c); }; |
| 1436 | // Normal - hex |
| 1437 | constexpr TransitionF HasNormalMinusHex = [](char c) { return HasNormal(c) && !HasHex(c); }; |
| 1438 | // Escape start |
| 1439 | constexpr TransitionF HasEscape = [](char c) { return c == '\\'; }; |
| 1440 | // All single-character escapes |
| 1441 | constexpr TransitionF HasSCE = [](char c) { return !HasOctal(c) && c != 'x' && c != '\n'; }; |
| 1442 | // Hex escape |
| 1443 | constexpr TransitionF HasHexStart = [](char c) { return c == 'x'; }; |
| 1444 | constexpr TransitionF HasQuote = [](char c) { return c == '"'; }; |
| 1445 | } // namespace |
| 1446 | |
| 1447 | extern const std::vector<DfaNode> float_dfa = { |
| 1448 | {{DfaEdge(HasPlusOrMinus, 1), DfaEdge(HasDigit, 2), DfaEdge(HasDot, 5)}, |
| 1449 | "Invalid float: No numeric value"}, |
| 1450 | |
| 1451 | {{DfaEdge(HasDigit, 2), DfaEdge(HasDot, 5)}, "Invalid float: No numeric value"}, |
| 1452 | |
| 1453 | {{DfaEdge(HasDigit, 2), DfaEdge(HasDot, 3), DfaEdge(HasE, 7)}, std::nullopt}, |
| 1454 | {{DfaEdge(HasDigit, 4)}, "Invalid float: No numeric value after decimal point"}, |
| 1455 | {{DfaEdge(HasDigit, 4), DfaEdge(HasE, 7)}, std::nullopt}, |
| 1456 | |
| 1457 | {{DfaEdge(HasDigit, 6)}, "Invalid float: No numeric value after decimal point"}, |
| 1458 | {{DfaEdge(HasDigit, 6), DfaEdge(HasE, 7)}, std::nullopt}, |
| 1459 | |
| 1460 | {{DfaEdge(HasDigit, 9), DfaEdge(HasPlusOrMinus, 8)}, |
| 1461 | "Invalid float: No numeric value following exponent signifier"}, |
| 1462 | {{DfaEdge(HasDigit, 9)}, "Invalid float: No numeric value following exponent signifier"}, |
| 1463 | {{DfaEdge(HasDigit, 9)}, std::nullopt}, |
| 1464 | }; |
| 1465 | |
| 1466 | extern const std::vector<DfaNode> string_dfa = { |
| 1467 | // Base character check |
| 1468 | {{DfaEdge(HasNormal, 0), DfaEdge(HasInvalid, 1), DfaEdge(HasQuote, 2), DfaEdge(HasEscape, 3)}, |
| 1469 | "Invalid string: No terminating \""}, |
| 1470 | |
| 1471 | // Invalid (unescaped newline) |
| 1472 | {{}, "Invalid string: No terminating \""}, |
| 1473 | // String end |
| 1474 | {{}, std::nullopt}, |
| 1475 | |
| 1476 | // Escape character breakout |
| 1477 | {{DfaEdge(HasSCE, 0), DfaEdge(HasInvalid, 1), DfaEdge(HasOctal, 4), DfaEdge(HasHexStart, 6)}, |
| 1478 | "Invalid string: No terminating \""}, |
| 1479 | |
| 1480 | // Octal characters, at most 3 |
| 1481 | {{DfaEdge(HasNormalMinusOctal, 0), DfaEdge(HasInvalid, 1), DfaEdge(HasQuote, 2), |
| 1482 | DfaEdge(HasEscape, 3), DfaEdge(HasOctal, 5)}, |
| 1483 | "Invalid string: No terminating \""}, |
| 1484 | {{DfaEdge(HasNormal, 0), DfaEdge(HasInvalid, 1), DfaEdge(HasQuote, 2), DfaEdge(HasEscape, 3)}, |
| 1485 | "Invalid string: No terminating \""}, |
| 1486 | |
| 1487 | // Hex characters, 1 or more |
| 1488 | {{DfaEdge(HasHex, 7)}, "Invalid string: bad hex escape"}, |
| 1489 | {{DfaEdge(HasNormalMinusHex, 0), DfaEdge(HasInvalid, 1), DfaEdge(HasQuote, 2), |
| 1490 | DfaEdge(HasEscape, 3), DfaEdge(HasHex, 7)}, |
| 1491 | "Invalid string: No terminating \""}, |
| 1492 | }; |
| 1493 | } // namespace Common::GekkoAssembler::detail |