llvm.org GIT mirror llvm / 08f689e
[AArch64] Cleanup AsmParser: no need to use dyn_cast + assert. cast does it for us. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213296 91177308-0d34-0410-b5e6-96231b3b80d8 Arnaud A. de Grandmaison 6 years ago
1 changed file(s) with 76 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
12521252
12531253 void addSImm9Operands(MCInst &Inst, unsigned N) const {
12541254 assert(N == 1 && "Invalid number of operands!");
1255 const MCConstantExpr *MCE = dyn_cast(getImm());
1255 const MCConstantExpr *MCE = cast(getImm());
1256 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1257 }
1258
1259 void addSImm7s4Operands(MCInst &Inst, unsigned N) const {
1260 assert(N == 1 && "Invalid number of operands!");
1261 const MCConstantExpr *MCE = cast(getImm());
1262 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 4));
1263 }
1264
1265 void addSImm7s8Operands(MCInst &Inst, unsigned N) const {
1266 assert(N == 1 && "Invalid number of operands!");
1267 const MCConstantExpr *MCE = cast(getImm());
1268 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 8));
1269 }
1270
1271 void addSImm7s16Operands(MCInst &Inst, unsigned N) const {
1272 assert(N == 1 && "Invalid number of operands!");
1273 const MCConstantExpr *MCE = cast(getImm());
1274 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 16));
1275 }
1276
1277 void addImm0_7Operands(MCInst &Inst, unsigned N) const {
1278 assert(N == 1 && "Invalid number of operands!");
1279 const MCConstantExpr *MCE = cast(getImm());
1280 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1281 }
1282
1283 void addImm1_8Operands(MCInst &Inst, unsigned N) const {
1284 assert(N == 1 && "Invalid number of operands!");
1285 const MCConstantExpr *MCE = cast(getImm());
1286 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1287 }
1288
1289 void addImm0_15Operands(MCInst &Inst, unsigned N) const {
1290 assert(N == 1 && "Invalid number of operands!");
1291 const MCConstantExpr *MCE = cast(getImm());
1292 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1293 }
1294
1295 void addImm1_16Operands(MCInst &Inst, unsigned N) const {
1296 assert(N == 1 && "Invalid number of operands!");
1297 const MCConstantExpr *MCE = cast(getImm());
12561298 assert(MCE && "Invalid constant immediate operand!");
12571299 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
12581300 }
12591301
1260 void addSImm7s4Operands(MCInst &Inst, unsigned N) const {
1261 assert(N == 1 && "Invalid number of operands!");
1262 const MCConstantExpr *MCE = dyn_cast(getImm());
1263 assert(MCE && "Invalid constant immediate operand!");
1264 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 4));
1265 }
1266
1267 void addSImm7s8Operands(MCInst &Inst, unsigned N) const {
1268 assert(N == 1 && "Invalid number of operands!");
1269 const MCConstantExpr *MCE = dyn_cast(getImm());
1270 assert(MCE && "Invalid constant immediate operand!");
1271 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 8));
1272 }
1273
1274 void addSImm7s16Operands(MCInst &Inst, unsigned N) const {
1275 assert(N == 1 && "Invalid number of operands!");
1276 const MCConstantExpr *MCE = dyn_cast(getImm());
1277 assert(MCE && "Invalid constant immediate operand!");
1278 Inst.addOperand(MCOperand::CreateImm(MCE->getValue() / 16));
1279 }
1280
1281 void addImm0_7Operands(MCInst &Inst, unsigned N) const {
1282 assert(N == 1 && "Invalid number of operands!");
1283 const MCConstantExpr *MCE = dyn_cast(getImm());
1284 assert(MCE && "Invalid constant immediate operand!");
1302 void addImm0_31Operands(MCInst &Inst, unsigned N) const {
1303 assert(N == 1 && "Invalid number of operands!");
1304 const MCConstantExpr *MCE = cast(getImm());
12851305 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
12861306 }
12871307
1288 void addImm1_8Operands(MCInst &Inst, unsigned N) const {
1289 assert(N == 1 && "Invalid number of operands!");
1290 const MCConstantExpr *MCE = dyn_cast(getImm());
1291 assert(MCE && "Invalid constant immediate operand!");
1308 void addImm1_31Operands(MCInst &Inst, unsigned N) const {
1309 assert(N == 1 && "Invalid number of operands!");
1310 const MCConstantExpr *MCE = cast(getImm());
12921311 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
12931312 }
12941313
1295 void addImm0_15Operands(MCInst &Inst, unsigned N) const {
1296 assert(N == 1 && "Invalid number of operands!");
1297 const MCConstantExpr *MCE = dyn_cast(getImm());
1298 assert(MCE && "Invalid constant immediate operand!");
1314 void addImm1_32Operands(MCInst &Inst, unsigned N) const {
1315 assert(N == 1 && "Invalid number of operands!");
1316 const MCConstantExpr *MCE = cast(getImm());
12991317 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13001318 }
13011319
1302 void addImm1_16Operands(MCInst &Inst, unsigned N) const {
1303 assert(N == 1 && "Invalid number of operands!");
1304 const MCConstantExpr *MCE = dyn_cast(getImm());
1305 assert(MCE && "Invalid constant immediate operand!");
1320 void addImm0_63Operands(MCInst &Inst, unsigned N) const {
1321 assert(N == 1 && "Invalid number of operands!");
1322 const MCConstantExpr *MCE = cast(getImm());
13061323 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13071324 }
13081325
1309 void addImm0_31Operands(MCInst &Inst, unsigned N) const {
1310 assert(N == 1 && "Invalid number of operands!");
1311 const MCConstantExpr *MCE = dyn_cast(getImm());
1312 assert(MCE && "Invalid constant immediate operand!");
1326 void addImm1_63Operands(MCInst &Inst, unsigned N) const {
1327 assert(N == 1 && "Invalid number of operands!");
1328 const MCConstantExpr *MCE = cast(getImm());
13131329 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13141330 }
13151331
1316 void addImm1_31Operands(MCInst &Inst, unsigned N) const {
1317 assert(N == 1 && "Invalid number of operands!");
1318 const MCConstantExpr *MCE = dyn_cast(getImm());
1319 assert(MCE && "Invalid constant immediate operand!");
1332 void addImm1_64Operands(MCInst &Inst, unsigned N) const {
1333 assert(N == 1 && "Invalid number of operands!");
1334 const MCConstantExpr *MCE = cast(getImm());
13201335 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13211336 }
13221337
1323 void addImm1_32Operands(MCInst &Inst, unsigned N) const {
1324 assert(N == 1 && "Invalid number of operands!");
1325 const MCConstantExpr *MCE = dyn_cast(getImm());
1326 assert(MCE && "Invalid constant immediate operand!");
1338 void addImm0_127Operands(MCInst &Inst, unsigned N) const {
1339 assert(N == 1 && "Invalid number of operands!");
1340 const MCConstantExpr *MCE = cast(getImm());
13271341 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13281342 }
13291343
1330 void addImm0_63Operands(MCInst &Inst, unsigned N) const {
1331 assert(N == 1 && "Invalid number of operands!");
1332 const MCConstantExpr *MCE = dyn_cast(getImm());
1333 assert(MCE && "Invalid constant immediate operand!");
1344 void addImm0_255Operands(MCInst &Inst, unsigned N) const {
1345 assert(N == 1 && "Invalid number of operands!");
1346 const MCConstantExpr *MCE = cast(getImm());
13341347 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13351348 }
13361349
1337 void addImm1_63Operands(MCInst &Inst, unsigned N) const {
1338 assert(N == 1 && "Invalid number of operands!");
1339 const MCConstantExpr *MCE = dyn_cast(getImm());
1340 assert(MCE && "Invalid constant immediate operand!");
1350 void addImm0_65535Operands(MCInst &Inst, unsigned N) const {
1351 assert(N == 1 && "Invalid number of operands!");
1352 const MCConstantExpr *MCE = cast(getImm());
13411353 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13421354 }
13431355
1344 void addImm1_64Operands(MCInst &Inst, unsigned N) const {
1345 assert(N == 1 && "Invalid number of operands!");
1346 const MCConstantExpr *MCE = dyn_cast(getImm());
1347 assert(MCE && "Invalid constant immediate operand!");
1356 void addImm32_63Operands(MCInst &Inst, unsigned N) const {
1357 assert(N == 1 && "Invalid number of operands!");
1358 const MCConstantExpr *MCE = cast(getImm());
13481359 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
13491360 }
13501361
1351 void addImm0_127Operands(MCInst &Inst, unsigned N) const {
1352 assert(N == 1 && "Invalid number of operands!");
1353 const MCConstantExpr *MCE = dyn_cast(getImm());
1354 assert(MCE && "Invalid constant immediate operand!");
1355 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1356 }
1357
1358 void addImm0_255Operands(MCInst &Inst, unsigned N) const {
1359 assert(N == 1 && "Invalid number of operands!");
1360 const MCConstantExpr *MCE = dyn_cast(getImm());
1361 assert(MCE && "Invalid constant immediate operand!");
1362 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1363 }
1364
1365 void addImm0_65535Operands(MCInst &Inst, unsigned N) const {
1366 assert(N == 1 && "Invalid number of operands!");
1367 const MCConstantExpr *MCE = dyn_cast(getImm());
1368 assert(MCE && "Invalid constant immediate operand!");
1369 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1370 }
1371
1372 void addImm32_63Operands(MCInst &Inst, unsigned N) const {
1373 assert(N == 1 && "Invalid number of operands!");
1374 const MCConstantExpr *MCE = dyn_cast(getImm());
1375 assert(MCE && "Invalid constant immediate operand!");
1376 Inst.addOperand(MCOperand::CreateImm(MCE->getValue()));
1377 }
1378
13791362 void addLogicalImm32Operands(MCInst &Inst, unsigned N) const {
13801363 assert(N == 1 && "Invalid number of operands!");
1381 const MCConstantExpr *MCE = dyn_cast(getImm());
1382 assert(MCE && "Invalid logical immediate operand!");
1364 const MCConstantExpr *MCE = cast(getImm());
13831365 uint64_t encoding =
13841366 AArch64_AM::encodeLogicalImmediate(MCE->getValue() & 0xFFFFFFFF, 32);
13851367 Inst.addOperand(MCOperand::CreateImm(encoding));
13871369
13881370 void addLogicalImm64Operands(MCInst &Inst, unsigned N) const {
13891371 assert(N == 1 && "Invalid number of operands!");
1390 const MCConstantExpr *MCE = dyn_cast(getImm());
1391 assert(MCE && "Invalid logical immediate operand!");
1372 const MCConstantExpr *MCE = cast(getImm());
13921373 uint64_t encoding = AArch64_AM::encodeLogicalImmediate(MCE->getValue(), 64);
13931374 Inst.addOperand(MCOperand::CreateImm(encoding));
13941375 }
14111392
14121393 void addSIMDImmType10Operands(MCInst &Inst, unsigned N) const {
14131394 assert(N == 1 && "Invalid number of operands!");
1414 const MCConstantExpr *MCE = dyn_cast(getImm());
1415 assert(MCE && "Invalid immediate operand!");
1395 const MCConstantExpr *MCE = cast(getImm());
14161396 uint64_t encoding = AArch64_AM::encodeAdvSIMDModImmType10(MCE->getValue());
14171397 Inst.addOperand(MCOperand::CreateImm(encoding));
14181398 }