1473
1502
#define FM_DF 2 /* v9 */
1474
1503
#define FM_QF 3 /* v9 */
1476
#define fmovicc(opcode, fpsize, cond, flags) /* v9 */ \
1477
{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z,f,g", flags, v9 }, \
1478
{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z,f,g", flags, v9 }
1505
#define fmoviccx(opcode, fpsize, args, cond, flags) /* v9 */ \
1506
{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z," args, flags, v9 }, \
1507
{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z," args, flags, v9 }
1480
#define fmovfcc(opcode, fpsize, fcond, flags) /* v9 */ \
1481
{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6,f,g", flags, v9 }, \
1482
{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7,f,g", flags, v9 }, \
1483
{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8,f,g", flags, v9 }, \
1484
{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9,f,g", flags, v9 }
1509
#define fmovfccx(opcode, fpsize, args, fcond, flags) /* v9 */ \
1510
{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6," args, flags, v9 }, \
1511
{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7," args, flags, v9 }, \
1512
{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8," args, flags, v9 }, \
1513
{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9," args, flags, v9 }
1486
1515
/* FIXME: use fmovicc/fmovfcc? */ /* v9 */
1487
#define fmovcc(opcode, fpsize, cond, fcond, flags) /* v9 */ \
1488
{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z,f,g", flags | F_FLOAT, v9 }, \
1489
{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6,f,g", flags | F_FLOAT, v9 }, \
1490
{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z,f,g", flags | F_FLOAT, v9 }, \
1491
{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7,f,g", flags | F_FLOAT, v9 }, \
1492
{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8,f,g", flags | F_FLOAT, v9 }, \
1493
{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9,f,g", flags | F_FLOAT, v9 }
1495
/* v9 */ fmovcc ("fmovda", FM_DF, CONDA, FCONDA, 0),
1496
/* v9 */ fmovcc ("fmovqa", FM_QF, CONDA, FCONDA, 0),
1497
/* v9 */ fmovcc ("fmovsa", FM_SF, CONDA, FCONDA, 0),
1498
/* v9 */ fmovicc ("fmovdcc", FM_DF, CONDCC, 0),
1499
/* v9 */ fmovicc ("fmovqcc", FM_QF, CONDCC, 0),
1500
/* v9 */ fmovicc ("fmovscc", FM_SF, CONDCC, 0),
1501
/* v9 */ fmovicc ("fmovdcs", FM_DF, CONDCS, 0),
1502
/* v9 */ fmovicc ("fmovqcs", FM_QF, CONDCS, 0),
1503
/* v9 */ fmovicc ("fmovscs", FM_SF, CONDCS, 0),
1504
/* v9 */ fmovcc ("fmovde", FM_DF, CONDE, FCONDE, 0),
1505
/* v9 */ fmovcc ("fmovqe", FM_QF, CONDE, FCONDE, 0),
1506
/* v9 */ fmovcc ("fmovse", FM_SF, CONDE, FCONDE, 0),
1507
/* v9 */ fmovcc ("fmovdg", FM_DF, CONDG, FCONDG, 0),
1508
/* v9 */ fmovcc ("fmovqg", FM_QF, CONDG, FCONDG, 0),
1509
/* v9 */ fmovcc ("fmovsg", FM_SF, CONDG, FCONDG, 0),
1510
/* v9 */ fmovcc ("fmovdge", FM_DF, CONDGE, FCONDGE, 0),
1511
/* v9 */ fmovcc ("fmovqge", FM_QF, CONDGE, FCONDGE, 0),
1512
/* v9 */ fmovcc ("fmovsge", FM_SF, CONDGE, FCONDGE, 0),
1513
/* v9 */ fmovicc ("fmovdgeu", FM_DF, CONDGEU, F_ALIAS),
1514
/* v9 */ fmovicc ("fmovqgeu", FM_QF, CONDGEU, F_ALIAS),
1515
/* v9 */ fmovicc ("fmovsgeu", FM_SF, CONDGEU, F_ALIAS),
1516
/* v9 */ fmovicc ("fmovdgu", FM_DF, CONDGU, 0),
1517
/* v9 */ fmovicc ("fmovqgu", FM_QF, CONDGU, 0),
1518
/* v9 */ fmovicc ("fmovsgu", FM_SF, CONDGU, 0),
1519
/* v9 */ fmovcc ("fmovdl", FM_DF, CONDL, FCONDL, 0),
1520
/* v9 */ fmovcc ("fmovql", FM_QF, CONDL, FCONDL, 0),
1521
/* v9 */ fmovcc ("fmovsl", FM_SF, CONDL, FCONDL, 0),
1522
/* v9 */ fmovcc ("fmovdle", FM_DF, CONDLE, FCONDLE, 0),
1523
/* v9 */ fmovcc ("fmovqle", FM_QF, CONDLE, FCONDLE, 0),
1524
/* v9 */ fmovcc ("fmovsle", FM_SF, CONDLE, FCONDLE, 0),
1525
/* v9 */ fmovicc ("fmovdleu", FM_DF, CONDLEU, 0),
1526
/* v9 */ fmovicc ("fmovqleu", FM_QF, CONDLEU, 0),
1527
/* v9 */ fmovicc ("fmovsleu", FM_SF, CONDLEU, 0),
1528
/* v9 */ fmovfcc ("fmovdlg", FM_DF, FCONDLG, 0),
1529
/* v9 */ fmovfcc ("fmovqlg", FM_QF, FCONDLG, 0),
1530
/* v9 */ fmovfcc ("fmovslg", FM_SF, FCONDLG, 0),
1531
/* v9 */ fmovicc ("fmovdlu", FM_DF, CONDLU, F_ALIAS),
1532
/* v9 */ fmovicc ("fmovqlu", FM_QF, CONDLU, F_ALIAS),
1533
/* v9 */ fmovicc ("fmovslu", FM_SF, CONDLU, F_ALIAS),
1534
/* v9 */ fmovcc ("fmovdn", FM_DF, CONDN, FCONDN, 0),
1535
/* v9 */ fmovcc ("fmovqn", FM_QF, CONDN, FCONDN, 0),
1536
/* v9 */ fmovcc ("fmovsn", FM_SF, CONDN, FCONDN, 0),
1537
/* v9 */ fmovcc ("fmovdne", FM_DF, CONDNE, FCONDNE, 0),
1538
/* v9 */ fmovcc ("fmovqne", FM_QF, CONDNE, FCONDNE, 0),
1539
/* v9 */ fmovcc ("fmovsne", FM_SF, CONDNE, FCONDNE, 0),
1540
/* v9 */ fmovicc ("fmovdneg", FM_DF, CONDNEG, 0),
1541
/* v9 */ fmovicc ("fmovqneg", FM_QF, CONDNEG, 0),
1542
/* v9 */ fmovicc ("fmovsneg", FM_SF, CONDNEG, 0),
1543
/* v9 */ fmovcc ("fmovdnz", FM_DF, CONDNZ, FCONDNZ, F_ALIAS),
1544
/* v9 */ fmovcc ("fmovqnz", FM_QF, CONDNZ, FCONDNZ, F_ALIAS),
1545
/* v9 */ fmovcc ("fmovsnz", FM_SF, CONDNZ, FCONDNZ, F_ALIAS),
1546
/* v9 */ fmovfcc ("fmovdo", FM_DF, FCONDO, 0),
1547
/* v9 */ fmovfcc ("fmovqo", FM_QF, FCONDO, 0),
1548
/* v9 */ fmovfcc ("fmovso", FM_SF, FCONDO, 0),
1549
/* v9 */ fmovicc ("fmovdpos", FM_DF, CONDPOS, 0),
1550
/* v9 */ fmovicc ("fmovqpos", FM_QF, CONDPOS, 0),
1551
/* v9 */ fmovicc ("fmovspos", FM_SF, CONDPOS, 0),
1552
/* v9 */ fmovfcc ("fmovdu", FM_DF, FCONDU, 0),
1553
/* v9 */ fmovfcc ("fmovqu", FM_QF, FCONDU, 0),
1554
/* v9 */ fmovfcc ("fmovsu", FM_SF, FCONDU, 0),
1555
/* v9 */ fmovfcc ("fmovdue", FM_DF, FCONDUE, 0),
1556
/* v9 */ fmovfcc ("fmovque", FM_QF, FCONDUE, 0),
1557
/* v9 */ fmovfcc ("fmovsue", FM_SF, FCONDUE, 0),
1558
/* v9 */ fmovfcc ("fmovdug", FM_DF, FCONDUG, 0),
1559
/* v9 */ fmovfcc ("fmovqug", FM_QF, FCONDUG, 0),
1560
/* v9 */ fmovfcc ("fmovsug", FM_SF, FCONDUG, 0),
1561
/* v9 */ fmovfcc ("fmovduge", FM_DF, FCONDUGE, 0),
1562
/* v9 */ fmovfcc ("fmovquge", FM_QF, FCONDUGE, 0),
1563
/* v9 */ fmovfcc ("fmovsuge", FM_SF, FCONDUGE, 0),
1564
/* v9 */ fmovfcc ("fmovdul", FM_DF, FCONDUL, 0),
1565
/* v9 */ fmovfcc ("fmovqul", FM_QF, FCONDUL, 0),
1566
/* v9 */ fmovfcc ("fmovsul", FM_SF, FCONDUL, 0),
1567
/* v9 */ fmovfcc ("fmovdule", FM_DF, FCONDULE, 0),
1568
/* v9 */ fmovfcc ("fmovqule", FM_QF, FCONDULE, 0),
1569
/* v9 */ fmovfcc ("fmovsule", FM_SF, FCONDULE, 0),
1570
/* v9 */ fmovicc ("fmovdvc", FM_DF, CONDVC, 0),
1571
/* v9 */ fmovicc ("fmovqvc", FM_QF, CONDVC, 0),
1572
/* v9 */ fmovicc ("fmovsvc", FM_SF, CONDVC, 0),
1573
/* v9 */ fmovicc ("fmovdvs", FM_DF, CONDVS, 0),
1574
/* v9 */ fmovicc ("fmovqvs", FM_QF, CONDVS, 0),
1575
/* v9 */ fmovicc ("fmovsvs", FM_SF, CONDVS, 0),
1576
/* v9 */ fmovcc ("fmovdz", FM_DF, CONDZ, FCONDZ, F_ALIAS),
1577
/* v9 */ fmovcc ("fmovqz", FM_QF, CONDZ, FCONDZ, F_ALIAS),
1578
/* v9 */ fmovcc ("fmovsz", FM_SF, CONDZ, FCONDZ, F_ALIAS),
1516
#define fmovccx(opcode, fpsize, args, cond, fcond, flags) /* v9 */ \
1517
{ opcode, F3F(2, 0x35, 0x100+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x100+fpsize))|MCOND(~cond,~0), "z," args, flags | F_FLOAT, v9 }, \
1518
{ opcode, F3F(2, 0x35, 0x000+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x000+fpsize))|MCOND(~fcond,~0), "6," args, flags | F_FLOAT, v9 }, \
1519
{ opcode, F3F(2, 0x35, 0x180+fpsize)|MCOND(cond,0), F3F(~2, ~0x35, ~(0x180+fpsize))|MCOND(~cond,~0), "Z," args, flags | F_FLOAT, v9 }, \
1520
{ opcode, F3F(2, 0x35, 0x040+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x040+fpsize))|MCOND(~fcond,~0), "7," args, flags | F_FLOAT, v9 }, \
1521
{ opcode, F3F(2, 0x35, 0x080+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x080+fpsize))|MCOND(~fcond,~0), "8," args, flags | F_FLOAT, v9 }, \
1522
{ opcode, F3F(2, 0x35, 0x0c0+fpsize)|MCOND(fcond,0), F3F(~2, ~0x35, ~(0x0c0+fpsize))|MCOND(~fcond,~0), "9," args, flags | F_FLOAT, v9 }
1524
#define fmovicc(suffix, cond, flags) /* v9 */ \
1525
fmoviccx("fmovd" suffix, FM_DF, "B,H", cond, flags), \
1526
fmoviccx("fmovq" suffix, FM_QF, "R,J", cond, flags), \
1527
fmoviccx("fmovs" suffix, FM_SF, "f,g", cond, flags)
1529
#define fmovfcc(suffix, fcond, flags) /* v9 */ \
1530
fmovfccx("fmovd" suffix, FM_DF, "B,H", fcond, flags), \
1531
fmovfccx("fmovq" suffix, FM_QF, "R,J", fcond, flags), \
1532
fmovfccx("fmovs" suffix, FM_SF, "f,g", fcond, flags)
1534
#define fmovcc(suffix, cond, fcond, flags) /* v9 */ \
1535
fmovccx("fmovd" suffix, FM_DF, "B,H", cond, fcond, flags), \
1536
fmovccx("fmovq" suffix, FM_QF, "R,J", cond, fcond, flags), \
1537
fmovccx("fmovs" suffix, FM_SF, "f,g", cond, fcond, flags)
1539
/* v9 */ fmovcc ("a", CONDA, FCONDA, 0),
1540
/* v9 */ fmovicc ("cc", CONDCC, 0),
1541
/* v9 */ fmovicc ("cs", CONDCS, 0),
1542
/* v9 */ fmovcc ("e", CONDE, FCONDE, 0),
1543
/* v9 */ fmovcc ("g", CONDG, FCONDG, 0),
1544
/* v9 */ fmovcc ("ge", CONDGE, FCONDGE, 0),
1545
/* v9 */ fmovicc ("geu", CONDGEU, F_ALIAS),
1546
/* v9 */ fmovicc ("gu", CONDGU, 0),
1547
/* v9 */ fmovcc ("l", CONDL, FCONDL, 0),
1548
/* v9 */ fmovcc ("le", CONDLE, FCONDLE, 0),
1549
/* v9 */ fmovicc ("leu", CONDLEU, 0),
1550
/* v9 */ fmovfcc ("lg", FCONDLG, 0),
1551
/* v9 */ fmovicc ("lu", CONDLU, F_ALIAS),
1552
/* v9 */ fmovcc ("n", CONDN, FCONDN, 0),
1553
/* v9 */ fmovcc ("ne", CONDNE, FCONDNE, 0),
1554
/* v9 */ fmovicc ("neg", CONDNEG, 0),
1555
/* v9 */ fmovcc ("nz", CONDNZ, FCONDNZ, F_ALIAS),
1556
/* v9 */ fmovfcc ("o", FCONDO, 0),
1557
/* v9 */ fmovicc ("pos", CONDPOS, 0),
1558
/* v9 */ fmovfcc ("u", FCONDU, 0),
1559
/* v9 */ fmovfcc ("ue", FCONDUE, 0),
1560
/* v9 */ fmovfcc ("ug", FCONDUG, 0),
1561
/* v9 */ fmovfcc ("uge", FCONDUGE, 0),
1562
/* v9 */ fmovfcc ("ul", FCONDUL, 0),
1563
/* v9 */ fmovfcc ("ule", FCONDULE, 0),
1564
/* v9 */ fmovicc ("vc", CONDVC, 0),
1565
/* v9 */ fmovicc ("vs", CONDVS, 0),
1566
/* v9 */ fmovcc ("z", CONDZ, FCONDZ, F_ALIAS),
1568
#undef fmoviccx /* v9 */
1569
#undef fmovfccx /* v9 */
1570
#undef fmovccx /* v9 */
1580
1571
#undef fmovicc /* v9 */
1581
1572
#undef fmovfcc /* v9 */
1582
1573
#undef fmovcc /* v9 */
1725
1716
{ "fstoi", F3F(2, 0x34, 0x0d1), F3F(~2, ~0x34, ~0x0d1)|RS1_G0, "f,g", F_FLOAT, v6 },
1726
1717
{ "fqtoi", F3F(2, 0x34, 0x0d3), F3F(~2, ~0x34, ~0x0d3)|RS1_G0, "R,g", F_FLOAT, v8 },
1728
{ "fdtox", F3F(2, 0x34, 0x082), F3F(~2, ~0x34, ~0x082)|RS1_G0, "B,g", F_FLOAT, v9 },
1729
{ "fstox", F3F(2, 0x34, 0x081), F3F(~2, ~0x34, ~0x081)|RS1_G0, "f,g", F_FLOAT, v9 },
1730
{ "fqtox", F3F(2, 0x34, 0x083), F3F(~2, ~0x34, ~0x083)|RS1_G0, "R,g", F_FLOAT, v9 },
1719
{ "fdtox", F3F(2, 0x34, 0x082), F3F(~2, ~0x34, ~0x082)|RS1_G0, "B,H", F_FLOAT, v9 },
1720
{ "fstox", F3F(2, 0x34, 0x081), F3F(~2, ~0x34, ~0x081)|RS1_G0, "f,H", F_FLOAT, v9 },
1721
{ "fqtox", F3F(2, 0x34, 0x083), F3F(~2, ~0x34, ~0x083)|RS1_G0, "R,H", F_FLOAT, v9 },
1732
1723
{ "fitod", F3F(2, 0x34, 0x0c8), F3F(~2, ~0x34, ~0x0c8)|RS1_G0, "f,H", F_FLOAT, v6 },
1733
1724
{ "fitos", F3F(2, 0x34, 0x0c4), F3F(~2, ~0x34, ~0x0c4)|RS1_G0, "f,g", F_FLOAT, v6 },
1734
1725
{ "fitoq", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,J", F_FLOAT, v8 },
1736
{ "fxtod", F3F(2, 0x34, 0x088), F3F(~2, ~0x34, ~0x088)|RS1_G0, "f,H", F_FLOAT, v9 },
1737
{ "fxtos", F3F(2, 0x34, 0x084), F3F(~2, ~0x34, ~0x084)|RS1_G0, "f,g", F_FLOAT, v9 },
1738
{ "fxtoq", F3F(2, 0x34, 0x08c), F3F(~2, ~0x34, ~0x08c)|RS1_G0, "f,J", F_FLOAT, v9 },
1727
{ "fxtod", F3F(2, 0x34, 0x088), F3F(~2, ~0x34, ~0x088)|RS1_G0, "B,H", F_FLOAT, v9 },
1728
{ "fxtos", F3F(2, 0x34, 0x084), F3F(~2, ~0x34, ~0x084)|RS1_G0, "B,g", F_FLOAT, v9 },
1729
{ "fxtoq", F3F(2, 0x34, 0x08c), F3F(~2, ~0x34, ~0x08c)|RS1_G0, "B,J", F_FLOAT, v9 },
1740
1731
{ "fdtoq", F3F(2, 0x34, 0x0ce), F3F(~2, ~0x34, ~0x0ce)|RS1_G0, "B,J", F_FLOAT, v8 },
1741
1732
{ "fdtos", F3F(2, 0x34, 0x0c6), F3F(~2, ~0x34, ~0x0c6)|RS1_G0, "B,g", F_FLOAT, v6 },
2479
2446
to compare_opcodes. */
2480
2447
static unsigned int current_arch_mask;
2449
/* Given BFD mach number, return a mask of SPARC_OPCODE_ARCH_FOO values. */
2452
compute_arch_mask (unsigned long mach)
2457
case bfd_mach_sparc :
2458
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8);
2459
case bfd_mach_sparc_sparclet :
2460
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLET);
2461
case bfd_mach_sparc_sparclite :
2462
case bfd_mach_sparc_sparclite_le :
2463
/* sparclites insns are recognized by default (because that's how
2464
they've always been treated, for better or worse). Kludge this by
2465
indicating generic v8 is also selected. */
2466
return (SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLITE)
2467
| SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8));
2468
case bfd_mach_sparc_v8plus :
2469
case bfd_mach_sparc_v9 :
2470
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9);
2471
case bfd_mach_sparc_v8plusa :
2472
case bfd_mach_sparc_v9a :
2473
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9A);
2474
case bfd_mach_sparc_v8plusb :
2475
case bfd_mach_sparc_v9b :
2476
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9B);
2481
/* Compare opcodes A and B. */
2484
compare_opcodes (const void * a, const void * b)
2486
sparc_opcode *op0 = * (sparc_opcode **) a;
2487
sparc_opcode *op1 = * (sparc_opcode **) b;
2488
unsigned long int match0 = op0->match, match1 = op1->match;
2489
unsigned long int lose0 = op0->lose, lose1 = op1->lose;
2490
register unsigned int i;
2492
/* If one (and only one) insn isn't supported by the current architecture,
2493
prefer the one that is. If neither are supported, but they're both for
2494
the same architecture, continue processing. Otherwise (both unsupported
2495
and for different architectures), prefer lower numbered arch's (fudged
2496
by comparing the bitmasks). */
2497
if (op0->architecture & current_arch_mask)
2499
if (! (op1->architecture & current_arch_mask))
2504
if (op1->architecture & current_arch_mask)
2506
else if (op0->architecture != op1->architecture)
2507
return op0->architecture - op1->architecture;
2510
/* If a bit is set in both match and lose, there is something
2511
wrong with the opcode table. */
2516
/* xgettext:c-format */
2517
_("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
2518
op0->name, match0, lose0);
2519
op0->lose &= ~op0->match;
2527
/* xgettext:c-format */
2528
_("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
2529
op1->name, match1, lose1);
2530
op1->lose &= ~op1->match;
2534
/* Because the bits that are variable in one opcode are constant in
2535
another, it is important to order the opcodes in the right order. */
2536
for (i = 0; i < 32; ++i)
2538
unsigned long int x = 1 << i;
2539
int x0 = (match0 & x) != 0;
2540
int x1 = (match1 & x) != 0;
2546
for (i = 0; i < 32; ++i)
2548
unsigned long int x = 1 << i;
2549
int x0 = (lose0 & x) != 0;
2550
int x1 = (lose1 & x) != 0;
2556
/* They are functionally equal. So as long as the opcode table is
2557
valid, we can put whichever one first we want, on aesthetic grounds. */
2559
/* Our first aesthetic ground is that aliases defer to real insns. */
2561
int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS);
2563
if (alias_diff != 0)
2564
/* Put the one that isn't an alias first. */
2568
/* Except for aliases, two "identical" instructions had
2569
better have the same opcode. This is a sanity check on the table. */
2570
i = strcmp (op0->name, op1->name);
2573
if (op0->flags & F_ALIAS) /* If they're both aliases, be arbitrary. */
2577
/* xgettext:c-format */
2578
_("Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"),
2579
op0->name, op1->name);
2582
/* Fewer arguments are preferred. */
2584
int length_diff = strlen (op0->args) - strlen (op1->args);
2586
if (length_diff != 0)
2587
/* Put the one with fewer arguments first. */
2591
/* Put 1+i before i+1. */
2593
char *p0 = (char *) strchr (op0->args, '+');
2594
char *p1 = (char *) strchr (op1->args, '+');
2598
/* There is a plus in both operands. Note that a plus
2599
sign cannot be the first character in args,
2600
so the following [-1]'s are valid. */
2601
if (p0[-1] == 'i' && p1[1] == 'i')
2602
/* op0 is i+1 and op1 is 1+i, so op1 goes first. */
2604
if (p0[1] == 'i' && p1[-1] == 'i')
2605
/* op0 is 1+i and op1 is i+1, so op0 goes first. */
2610
/* Put 1,i before i,1. */
2612
int i0 = strncmp (op0->args, "i,1", 3) == 0;
2613
int i1 = strncmp (op1->args, "i,1", 3) == 0;
2619
/* They are, as far as we can tell, identical.
2620
Since qsort may have rearranged the table partially, there is
2621
no way to tell which one was first in the opcode table as
2622
written, so just say there are equal. */
2623
/* ??? This is no longer true now that we sort a vector of pointers,
2624
not the table itself. */
2628
/* Build a hash table from the opcode table.
2629
OPCODE_TABLE is a sorted list of pointers into the opcode table. */
2632
build_hash_table (const sparc_opcode **opcode_table,
2633
sparc_opcode_hash **hash_table,
2637
int hash_count[HASH_SIZE];
2638
static sparc_opcode_hash *hash_buf = NULL;
2640
/* Start at the end of the table and work backwards so that each
2643
memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
2644
memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
2645
if (hash_buf != NULL)
2647
hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
2648
for (i = num_opcodes - 1; i >= 0; --i)
2650
int hash = HASH_INSN (opcode_table[i]->match);
2651
sparc_opcode_hash *h = &hash_buf[i];
2653
h->next = hash_table[hash];
2654
h->opcode = opcode_table[i];
2655
hash_table[hash] = h;
2659
#if 0 /* for debugging */
2661
int min_count = num_opcodes, max_count = 0;
2664
for (i = 0; i < HASH_SIZE; ++i)
2666
if (hash_count[i] < min_count)
2667
min_count = hash_count[i];
2668
if (hash_count[i] > max_count)
2669
max_count = hash_count[i];
2670
total += hash_count[i];
2673
printf ("Opcode hash table stats: min %d, max %d, ave %f\n",
2674
min_count, max_count, (double) total / HASH_SIZE);
2482
2679
/* Print one instruction from MEMADDR on INFO->STREAM.
2484
2681
We suffix the instruction with a comment that gives the absolute
3033
info->insn_type = dis_noninsn; /* Mark as non-valid instruction */
3254
info->insn_type = dis_noninsn; /* Mark as non-valid instruction. */
3034
3255
(*info->fprintf_func) (stream, _("unknown"));
3035
3256
return sizeof (buffer);
3038
/* Given BFD mach number, return a mask of SPARC_OPCODE_ARCH_FOO values. */
3041
compute_arch_mask (mach)
3047
case bfd_mach_sparc :
3048
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8);
3049
case bfd_mach_sparc_sparclet :
3050
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLET);
3051
case bfd_mach_sparc_sparclite :
3052
case bfd_mach_sparc_sparclite_le :
3053
/* sparclites insns are recognized by default (because that's how
3054
they've always been treated, for better or worse). Kludge this by
3055
indicating generic v8 is also selected. */
3056
return (SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_SPARCLITE)
3057
| SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V8));
3058
case bfd_mach_sparc_v8plus :
3059
case bfd_mach_sparc_v9 :
3060
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9);
3061
case bfd_mach_sparc_v8plusa :
3062
case bfd_mach_sparc_v9a :
3063
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9A);
3064
case bfd_mach_sparc_v8plusb :
3065
case bfd_mach_sparc_v9b :
3066
return SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9B);
3071
/* Compare opcodes A and B. */
3074
compare_opcodes (const void *a, const void *b)
3076
struct sparc_opcode *op0 = * (struct sparc_opcode **) a;
3077
struct sparc_opcode *op1 = * (struct sparc_opcode **) b;
3078
unsigned long int match0 = op0->match, match1 = op1->match;
3079
unsigned long int lose0 = op0->lose, lose1 = op1->lose;
3080
register unsigned int i;
3082
/* If one (and only one) insn isn't supported by the current architecture,
3083
prefer the one that is. If neither are supported, but they're both for
3084
the same architecture, continue processing. Otherwise (both unsupported
3085
and for different architectures), prefer lower numbered arch's (fudged
3086
by comparing the bitmasks). */
3087
if (op0->architecture & current_arch_mask)
3089
if (! (op1->architecture & current_arch_mask))
3094
if (op1->architecture & current_arch_mask)
3096
else if (op0->architecture != op1->architecture)
3097
return op0->architecture - op1->architecture;
3100
/* If a bit is set in both match and lose, there is something
3101
wrong with the opcode table. */
3106
/* xgettext:c-format */
3107
_("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
3108
op0->name, match0, lose0);
3109
op0->lose &= ~op0->match;
3117
/* xgettext:c-format */
3118
_("Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"),
3119
op1->name, match1, lose1);
3120
op1->lose &= ~op1->match;
3124
/* Because the bits that are variable in one opcode are constant in
3125
another, it is important to order the opcodes in the right order. */
3126
for (i = 0; i < 32; ++i)
3128
unsigned long int x = 1 << i;
3129
int x0 = (match0 & x) != 0;
3130
int x1 = (match1 & x) != 0;
3136
for (i = 0; i < 32; ++i)
3138
unsigned long int x = 1 << i;
3139
int x0 = (lose0 & x) != 0;
3140
int x1 = (lose1 & x) != 0;
3146
/* They are functionally equal. So as long as the opcode table is
3147
valid, we can put whichever one first we want, on aesthetic grounds. */
3149
/* Our first aesthetic ground is that aliases defer to real insns. */
3151
int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS);
3152
if (alias_diff != 0)
3153
/* Put the one that isn't an alias first. */
3157
/* Except for aliases, two "identical" instructions had
3158
better have the same opcode. This is a sanity check on the table. */
3159
i = strcmp (op0->name, op1->name);
3162
if (op0->flags & F_ALIAS) /* If they're both aliases, be arbitrary. */
3166
/* xgettext:c-format */
3167
_("Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"),
3168
op0->name, op1->name);
3171
/* Fewer arguments are preferred. */
3173
int length_diff = strlen (op0->args) - strlen (op1->args);
3174
if (length_diff != 0)
3175
/* Put the one with fewer arguments first. */
3179
/* Put 1+i before i+1. */
3181
char *p0 = (char *) strchr (op0->args, '+');
3182
char *p1 = (char *) strchr (op1->args, '+');
3186
/* There is a plus in both operands. Note that a plus
3187
sign cannot be the first character in args,
3188
so the following [-1]'s are valid. */
3189
if (p0[-1] == 'i' && p1[1] == 'i')
3190
/* op0 is i+1 and op1 is 1+i, so op1 goes first. */
3192
if (p0[1] == 'i' && p1[-1] == 'i')
3193
/* op0 is 1+i and op1 is i+1, so op0 goes first. */
3198
/* Put 1,i before i,1. */
3200
int i0 = strncmp (op0->args, "i,1", 3) == 0;
3201
int i1 = strncmp (op1->args, "i,1", 3) == 0;
3207
/* They are, as far as we can tell, identical.
3208
Since qsort may have rearranged the table partially, there is
3209
no way to tell which one was first in the opcode table as
3210
written, so just say there are equal. */
3211
/* ??? This is no longer true now that we sort a vector of pointers,
3212
not the table itself. */
3216
/* Build a hash table from the opcode table.
3217
OPCODE_TABLE is a sorted list of pointers into the opcode table. */
3220
build_hash_table (opcode_table, hash_table, num_opcodes)
3221
const struct sparc_opcode **opcode_table;
3222
struct opcode_hash **hash_table;
3226
int hash_count[HASH_SIZE];
3227
static struct opcode_hash *hash_buf = NULL;
3229
/* Start at the end of the table and work backwards so that each
3232
memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
3233
memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
3234
if (hash_buf != NULL)
3236
hash_buf = (struct opcode_hash *) malloc (sizeof (struct opcode_hash) * num_opcodes);
3237
for (i = num_opcodes - 1; i >= 0; --i)
3239
register int hash = HASH_INSN (opcode_table[i]->match);
3240
register struct opcode_hash *h = &hash_buf[i];
3241
h->next = hash_table[hash];
3242
h->opcode = opcode_table[i];
3243
hash_table[hash] = h;
3247
#if 0 /* for debugging */
3249
int min_count = num_opcodes, max_count = 0;
3252
for (i = 0; i < HASH_SIZE; ++i)
3254
if (hash_count[i] < min_count)
3255
min_count = hash_count[i];
3256
if (hash_count[i] > max_count)
3257
max_count = hash_count[i];
3258
total += hash_count[i];
3261
printf ("Opcode hash table stats: min %d, max %d, ave %f\n",
3262
min_count, max_count, (double) total / HASH_SIZE);