35using namespace PowerISA;
41 bool printDest =
true;
42 bool printSrcs =
true;
43 bool printSecondSrc =
true;
49 if (myMnemonic ==
"mtcrf" ||
50 myMnemonic ==
"mtxer" ||
51 myMnemonic ==
"mtlr" ||
52 myMnemonic ==
"mtctr" ||
53 myMnemonic ==
"mttar" ||
54 myMnemonic ==
"mttb" ||
55 myMnemonic ==
"mttbu") {
57 }
else if (myMnemonic ==
"mfcr" ||
58 myMnemonic ==
"mfxer" ||
59 myMnemonic ==
"mflr" ||
60 myMnemonic ==
"mfctr" ||
61 myMnemonic ==
"mftar" ||
62 myMnemonic ==
"mftb" ||
63 myMnemonic ==
"mftbu") {
69 myMnemonic = myMnemonic +
"o";
71 myMnemonic = myMnemonic +
".";
112 ss <<
", " << (int32_t)
si;
122 std::stringstream
ss;
123 bool printSecondSrc =
true;
124 bool printThirdSrc =
false;
130 if (myMnemonic ==
"addme" ||
131 myMnemonic ==
"addze" ||
132 myMnemonic ==
"subfme" ||
133 myMnemonic ==
"subfze" ||
134 myMnemonic ==
"neg") {
135 printSecondSrc =
false;
136 }
else if (myMnemonic ==
"maddhd" ||
137 myMnemonic ==
"maddhdu" ||
138 myMnemonic ==
"maddld") {
139 printThirdSrc =
true;
144 myMnemonic = myMnemonic +
"o";
146 myMnemonic = myMnemonic +
".";
180 std::stringstream
ss;
181 bool negateImm =
false;
187 if (myMnemonic ==
"addi") {
194 }
else if (myMnemonic ==
"addis") {
198 myMnemonic =
"subis";
201 }
else if (myMnemonic ==
"addic" &&
si < 0) {
202 myMnemonic =
"subic";
204 }
else if (myMnemonic ==
"addic_") {
206 myMnemonic =
"subic.";
209 myMnemonic =
"addic.";
240 std::stringstream
ss;
241 bool printSrcs =
true;
242 bool printDisp =
true;
243 bool negateDisp =
false;
249 if (myMnemonic ==
"addpcis") {
255 myMnemonic =
"subpcis";
275 ss <<
", " << (negateDisp ? -
d :
d);
285 std::stringstream
ss;
286 bool printSecondSrc =
true;
294 printSecondSrc =
false;
295 }
else if (myMnemonic ==
"extsb" ||
296 myMnemonic ==
"extsh" ||
297 myMnemonic ==
"extsw" ||
298 myMnemonic ==
"cntlzw" ||
299 myMnemonic ==
"cntlzd" ||
300 myMnemonic ==
"cnttzw" ||
301 myMnemonic ==
"cnttzd") {
302 printSecondSrc =
false;
307 myMnemonic = myMnemonic +
".";
321 if (printSecondSrc) {
349 std::stringstream
ss;
350 bool printRegs =
true;
356 if (myMnemonic ==
"ori" &&
360 }
else if (myMnemonic ==
"xori" &&
364 }
else if (myMnemonic ==
"andi_") {
365 myMnemonic =
"andi.";
366 }
else if (myMnemonic ==
"andis_") {
367 myMnemonic =
"andis.";
397 std::stringstream
ss;
398 bool printFieldPrefix =
false;
399 bool printLength =
true;
405 if (myMnemonic ==
"cmp" ||
406 myMnemonic ==
"cmpl") {
407 myMnemonic +=
l ?
"d" :
"w";
408 printFieldPrefix =
true;
415 if (printFieldPrefix) {
417 ss <<
"cr" << (int)
bf;
424 if (!printFieldPrefix ||
bf > 0)
431 if (!printFieldPrefix ||
bf > 0 || printLength)
450 std::stringstream
ss;
451 bool printFieldPrefix =
false;
452 bool printLength =
true;
458 if (myMnemonic ==
"cmpi") {
459 myMnemonic =
l ?
"cmpdi" :
"cmpwi";
460 printFieldPrefix =
true;
467 if (printFieldPrefix) {
469 ss <<
"cr" << (int)
bf;
476 if (!printFieldPrefix ||
bf > 0)
483 if (!printFieldPrefix ||
bf > 0 || printLength)
499 std::stringstream
ss;
500 bool printFieldPrefix =
false;
501 bool printLength =
true;
507 if (myMnemonic ==
"cmpli") {
508 myMnemonic =
l ?
"cmpldi" :
"cmplwi";
509 printFieldPrefix =
true;
516 if (printFieldPrefix) {
518 ss <<
"cr" << (int)
bf;
525 if (!printFieldPrefix ||
bf > 0)
532 if (!printFieldPrefix ||
bf > 0 || printLength)
548 std::stringstream
ss;
549 bool printSecondSrc =
true;
550 bool printShift =
false;
556 if (myMnemonic ==
"srawi") {
557 printSecondSrc =
false;
563 myMnemonic = myMnemonic +
".";
577 if (printSecondSrc) {
599 ss <<
", " << (int)
sh;
609 std::stringstream
ss;
610 bool printSecondSrc =
true;
611 bool printShift =
false;
617 if (myMnemonic ==
"sradi" ||
618 myMnemonic ==
"extswsli") {
619 printSecondSrc =
false;
625 myMnemonic = myMnemonic +
".";
639 if (printSecondSrc) {
661 ss <<
", " << (int)
sh;
671 std::stringstream
ss;
672 bool printSecondSrc =
true;
673 bool printShift =
true;
674 bool printMaskBeg =
true;
675 bool printMaskEnd =
true;
681 if (myMnemonic ==
"rlwinm") {
682 if (
mb == 0 &&
me == 31) {
683 myMnemonic =
"rotlwi";
684 printMaskBeg =
false;
685 printMaskEnd =
false;
686 }
else if (
sh == 0 &&
me == 31) {
687 myMnemonic =
"clrlwi";
689 printMaskEnd =
false;
691 printSecondSrc =
false;
692 }
else if (myMnemonic ==
"rlwnm") {
693 if (
mb == 0 &&
me == 31) {
694 myMnemonic =
"rotlw";
695 printMaskBeg =
false;
696 printMaskEnd =
false;
699 }
else if (myMnemonic ==
"rlwimi") {
700 printSecondSrc =
false;
705 myMnemonic = myMnemonic +
".";
719 if (printSecondSrc) {
741 ss <<
", " << (int)
sh;
745 ss <<
", " << (int)
mb;
747 ss <<
", " << (int)
me;
756 std::stringstream
ss;
757 bool printSecondSrc =
false;
758 bool printShift =
true;
759 bool printMaskBeg =
true;
765 if (myMnemonic ==
"rldicl") {
767 myMnemonic =
"rotldi";
768 printMaskBeg =
false;
769 }
else if (
sh == 0) {
770 myMnemonic =
"clrldi";
773 }
else if (myMnemonic ==
"rldcl") {
775 myMnemonic =
"rotld";
776 printMaskBeg =
false;
778 printSecondSrc =
true;
780 }
else if (myMnemonic ==
"rldcr") {
781 printSecondSrc =
true;
787 myMnemonic = myMnemonic +
".";
801 if (printSecondSrc) {
823 ss <<
", " << (int)
sh;
827 ss <<
", " << (int)
mb;
838 std::stringstream
ss;
839 bool printSrcs =
true;
840 bool printCond =
false;
846 if (myMnemonic ==
"tw" &&
853 (myMnemonic ==
"tw" || myMnemonic ==
"td")) {
889 std::stringstream
ss;
890 bool printCond =
false;
898 if (myMnemonic ==
"twi") {
899 myMnemonic =
"tw" +
ext +
"i";
900 }
else if (myMnemonic ==
"tdi") {
901 myMnemonic =
"td" +
ext +
"i";
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
std::string suffix() const
void printReg(std::ostream &os, RegId reg) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
uint8_t _numSrcRegs
See numSrcRegs().
uint8_t _numDestRegs
See numDestRegs().
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
const char * mnemonic
Base mnemonic (e.g., "add").
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void ccprintf(cp::Print &print)