@@ -1291,62 +1291,35 @@ bool PPCAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
1291
1291
llvm_unreachable (" Implement any new match types added!" );
1292
1292
}
1293
1293
1294
+ #define GET_REGISTER_MATCHER
1295
+ #include " PPCGenAsmMatcher.inc"
1296
+
1294
1297
MCRegister PPCAsmParser::matchRegisterName (int64_t &IntVal) {
1295
1298
if (getParser ().getTok ().is (AsmToken::Percent))
1296
1299
getParser ().Lex (); // Eat the '%'.
1297
1300
1298
1301
if (!getParser ().getTok ().is (AsmToken::Identifier))
1299
1302
return MCRegister ();
1300
1303
1301
- MCRegister RegNo;
1302
1304
StringRef Name = getParser ().getTok ().getString ();
1305
+ MCRegister RegNo = MatchRegisterName (Name);
1306
+ if (!RegNo)
1307
+ return RegNo;
1308
+
1309
+ Name.substr (Name.find_first_of (" 1234567890" )).getAsInteger (10 , IntVal);
1310
+
1311
+ // MatchRegisterName doesn't seem to have special handling for 64bit vs 32bit
1312
+ // register types.
1303
1313
if (Name.equals_insensitive (" lr" )) {
1304
1314
RegNo = isPPC64 () ? PPC::LR8 : PPC::LR;
1305
1315
IntVal = 8 ;
1306
1316
} else if (Name.equals_insensitive (" ctr" )) {
1307
1317
RegNo = isPPC64 () ? PPC::CTR8 : PPC::CTR;
1308
1318
IntVal = 9 ;
1309
- } else if (Name.equals_insensitive (" vrsave" )) {
1310
- RegNo = PPC::VRSAVE;
1319
+ } else if (Name.equals_insensitive (" vrsave" ))
1311
1320
IntVal = 256 ;
1312
- } else if (Name.starts_with_insensitive (" r" ) &&
1313
- !Name.substr (1 ).getAsInteger (10 , IntVal) && IntVal < 32 ) {
1321
+ else if (Name.starts_with_insensitive (" r" ))
1314
1322
RegNo = isPPC64 () ? XRegs[IntVal] : RRegs[IntVal];
1315
- } else if (Name.starts_with_insensitive (" f" ) &&
1316
- !Name.substr (1 ).getAsInteger (10 , IntVal) && IntVal < 32 ) {
1317
- RegNo = FRegs[IntVal];
1318
- } else if (Name.starts_with_insensitive (" vs" ) &&
1319
- !Name.substr (2 ).getAsInteger (10 , IntVal) && IntVal < 64 ) {
1320
- RegNo = VSRegs[IntVal];
1321
- } else if (Name.starts_with_insensitive (" v" ) &&
1322
- !Name.substr (1 ).getAsInteger (10 , IntVal) && IntVal < 32 ) {
1323
- RegNo = VRegs[IntVal];
1324
- } else if (Name.starts_with_insensitive (" cr" ) &&
1325
- !Name.substr (2 ).getAsInteger (10 , IntVal) && IntVal < 8 ) {
1326
- RegNo = CRRegs[IntVal];
1327
- } else if (Name.starts_with_insensitive (" acc" ) &&
1328
- !Name.substr (3 ).getAsInteger (10 , IntVal) && IntVal < 8 ) {
1329
- RegNo = ACCRegs[IntVal];
1330
- } else if (Name.starts_with_insensitive (" wacc_hi" ) &&
1331
- !Name.substr (7 ).getAsInteger (10 , IntVal) && IntVal < 8 ) {
1332
- RegNo = ACCRegs[IntVal];
1333
- } else if (Name.starts_with_insensitive (" wacc" ) &&
1334
- !Name.substr (4 ).getAsInteger (10 , IntVal) && IntVal < 8 ) {
1335
- RegNo = WACCRegs[IntVal];
1336
- } else if (Name.starts_with_insensitive (" dmrrowp" ) &&
1337
- !Name.substr (7 ).getAsInteger (10 , IntVal) && IntVal < 32 ) {
1338
- RegNo = DMRROWpRegs[IntVal];
1339
- } else if (Name.starts_with_insensitive (" dmrrow" ) &&
1340
- !Name.substr (6 ).getAsInteger (10 , IntVal) && IntVal < 64 ) {
1341
- RegNo = DMRROWRegs[IntVal];
1342
- } else if (Name.starts_with_insensitive (" dmrp" ) &&
1343
- !Name.substr (4 ).getAsInteger (10 , IntVal) && IntVal < 4 ) {
1344
- RegNo = DMRROWpRegs[IntVal];
1345
- } else if (Name.starts_with_insensitive (" dmr" ) &&
1346
- !Name.substr (3 ).getAsInteger (10 , IntVal) && IntVal < 8 ) {
1347
- RegNo = DMRRegs[IntVal];
1348
- } else
1349
- return MCRegister ();
1350
1323
1351
1324
getParser ().Lex ();
1352
1325
return RegNo;
@@ -1874,7 +1847,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmParser() {
1874
1847
RegisterMCAsmParser<PPCAsmParser> D (getThePPC64LETarget ());
1875
1848
}
1876
1849
1877
- #define GET_REGISTER_MATCHER
1878
1850
#define GET_MATCHER_IMPLEMENTATION
1879
1851
#define GET_MNEMONIC_SPELL_CHECKER
1880
1852
#include " PPCGenAsmMatcher.inc"
0 commit comments