[llvm-commits] CVS: llvm/lib/Reoptimizer/BinInterface/sparc.cpp
Misha Brukman
brukman at neo.cs.uiuc.edu
Tue Nov 12 20:39:03 PST 2002
Changes in directory llvm/lib/Reoptimizer/BinInterface:
sparc.cpp updated: 1.2 -> 1.3
---
Log message:
* Fixed code layout to not go past 80 chars per line
* Removed Windows end-of-line ^M and converted tabs to spaces
* Include sparc9.h not sparc9.hp, since I manually preprocessed it
* Changed comments at the top to match the rest of LLVM standard
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/BinInterface/sparc.cpp
diff -u llvm/lib/Reoptimizer/BinInterface/sparc.cpp:1.2 llvm/lib/Reoptimizer/BinInterface/sparc.cpp:1.3
--- llvm/lib/Reoptimizer/BinInterface/sparc.cpp:1.2 Fri Aug 9 14:35:15 2002
+++ llvm/lib/Reoptimizer/BinInterface/sparc.cpp Tue Nov 12 20:38:36 2002
@@ -1,892 +1,1108 @@
+//===-----------------------------------------------------------*- C++ -*--===//
+//
+// SPARC Disassembler Library
+//
+// For debugging purposes only:
+//
+// * some deprecated instructions not supported
+//
+// This was an insane amount of.. inocous small crud to
+// implement.
+// Multimedia instructions NOT supported
//===----------------------------------------------------------------------===//
-//
-// SPARC Disassembler Library
-//
-// For debugging purposes only:
-//
-// * some deprecated instructions not supported
-//
-// This was an insane amount of.. inocous small crud to
-// implement.
-// Multimedia instrctions NOT supported
-//===----------------------------------------------------------------------===//
-
+
+#include <stdio.h>
+#include <stdlib.h>
#include "sparc9.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-
-void sparc_printbr(unsigned instr)
-{
- // look at the OP2 field
- if (RD_FLD(instr,INSTR_OP2)==OP2_ILLTRAP)
- printf("ILLTRAP .. ");
- else if (RD_FLD(instr, INSTR_OP2)==OP2_NOP)
- printf("NOP ... ");
- else if (RD_FLD(instr, INSTR_OP2)==OP2_SETHI)
- printf("SETHI ... ");
- else if (RD_FLD(instr, INSTR_OP2)==OP2_BICC)
- {
- printf("%s (Dep) disp:%08X",icond_names[RD_FLD(instr, INSTR_COND_H)], RD_FLD(instr,INSTR_DISP22));
- }
- else if (RD_FLD(instr, INSTR_OP2)==OP2_BPR)
- {
- //A, RCOND_H, D16HI, P, RS1, D16LO
- printf("P%s r%d " , rcond_names[RD_FLD(instr, INSTR_RCOND_H)], RD_FLD(instr, INSTR_RS1));
- }
- else{
- printf("Unknown:OP=0b00 OP2 = 0x%04X", RD_FLD(instr, INSTR_OP2));
- }
-}
-
-void sparc_printalu(char * basename , unsigned instr)
-{
- // OP=OP_2 : RD, OP3, RS1: {I=0 -> RS2 I=1->SIMM13}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("%s r%d <- r%d ,r%d",basename, RD_FLD(instr, INSTR_RD),RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("%s r%d <- r%d ,%d",basename, RD_FLD(instr, INSTR_RD),RD_FLD(instr, INSTR_RS1), SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
-}
-
-void sparc_printshf(char * basename, unsigned instr)
-{
- //OP=OP_2: RD, OP_3 RS1: {I=0 -> X & RS2 ,I=1 -> {X=0 -> SHCNT32 X=1->SHCNT64 }}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("%s%d r%d <- r%d, by r%d ",(RD_FLD(instr, INSTR_X)==0 ? 32 : 64), basename, RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("%s%d r%d <- r%d, by 0x%04X ", basename,(RD_FLD(instr, INSTR_X)==0 ? 32 : 64), RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1), (RD_FLD(instr, INSTR_X)==0 ? RD_FLD(instr, INSTR_SHCNT32) : RD_FLD(instr, INSTR_SHCNT64)) );
-
-}
-
-
-///////////////////////////////////
-// Floating point instructions //
-// * complete //
-///////////////////////////////////
-void sparc_printfpu(unsigned instr)
-{
- //OP=OP_2: RD, OP3 RS1, OPF, RS2
- bool rs1 = true;
- switch(CC_FLD(RD_FLD(instr, INSTR_OPF), OPF_TYPE_ON))
- {
- case OPF_FADDn:
- rs1 = true;
- printf("FADD%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FSUBn:
- rs1 = true;
- printf("FSUB%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FMOVn: //RS1 not valid
- rs1 = false;
- printf("FMOV%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FNEGn: //RS1 not valid
- rs1 = false;
- printf("FNEG%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FABSn: //RS1 not valid
- rs1 = false;
- printf("FABS%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FMULn:
- rs1 = true;
- printf("FMUL%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FDIVn:
- rs1 = true;
- printf("FDIV%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- case OPF_FSQRTn:
- rs1 = true;
- printf("FSQRT%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
- break;
- }
- switch (CC_FLD(RD_FLD(instr, INSTR_OPF),OPF_TYPE_TO))
- {
- case OPF_FxTOt: // RS1 not valid
- rs1 = false;
- printf("FxTO%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_TO)]);
- break;
- case OPF_FiTOt: // RS1 not valid
- rs1 = false;
- printf("FxTO%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_TO)]);
- break;
- }
-
- switch(RD_FLD(instr, INSTR_OPF))
- {
- case OPF_FsMULd:
- rs1 = true;
- printf("FsMULd ");
- break;
- case OPF_FdMULq:
- rs1 = true;
- printf("FdMULq ");
- break;
- case OPF_FsTOx: // RS1 not valid
- rs1 = false;
- printf("FsTOx ");
- break;
- case OPF_FsTOi: // RS1 not valid
- rs1 = false;
- printf("FsTOi ");
- break;
- case OPF_FsTOd: // RS1 not valid
- rs1 = false;
- printf("FsTOd ");
- break;
- case OPF_FsTOq: // RS1 not valid
- rs1 = false;
- printf("FsTOq ");
- break;
- case OPF_FdTOx: // RS1 not valid
- rs1 = false;
- printf("FdTOx ");
- break;
- case OPF_FdTOi: // RS1 not valid
- rs1 = false;
- printf("FdTOi ");
- break;
- case OPF_FdTOs: // RS1 not valid
- rs1 = false;
- printf("FdTOs ");
- break;
- case OPF_FdTOq: // RS1 not valid
- rs1 = false;
- printf("FdTOq ");
- break;
- case OPF_FqTOx: // RS1 not valid
- rs1 = false;
- printf("FqTOx ");
- break;
- case OPF_FqTOi: // RS1 not valid
- rs1 = false;
- printf("FqTOi ");
- break;
- case OPF_FqTOs: // RS1 not valid
- rs1 = false;
- printf("FqTOs ");
- break;
- case OPF_FqTOd: // RS1 not valid
- rs1 = false;
- printf("FqTOd ");
- break;
- }
- //OP=OP_2: RD, OP3 RS1, OPF, RS2
- if (rs1)
- printf("rd=r%d rs1=r%d rs2=r%d ", RD_FLD(instr, INSTR_RD),RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("rd=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS2));
-}
-
-void sparc_print2(unsigned instr)
-{
- switch(RD_FLD(instr, INSTR_OP3))
- {
- case OP3_ADD:
- sparc_printalu("ADD", instr);
- return;
-
- case OP3_ADDcc:
- sparc_printalu("ADDcc", instr);
- return;
-
- case OP3_ADDC:
- sparc_printalu("ADDC", instr);
- return;
-
- case OP3_ADDCcc:
- sparc_printalu("ADDCcc", instr);
- return;
-
- case OP3_AND:
- sparc_printalu("AND", instr);
- return;
-
- case OP3_ANDcc:
- sparc_printalu("ANDcc", instr);
- return;
-
- case OP3_OR:
- sparc_printalu("OR", instr);
- return;
-
- case OP3_ORcc:
- sparc_printalu("ORcc", instr);
- return;
-
- case OP3_XOR:
- sparc_printalu("XOR", instr);
- return;
-
- case OP3_XORcc:
- sparc_printalu("XORcc", instr);
- return;
-
- case OP3_SUB:
- sparc_printalu("SUB", instr);
- return;
-
- case OP3_SUBcc:
- sparc_printalu("SUBcc", instr);
- return;
-
- case OP3_ANDN:
- sparc_printalu("ANDN", instr);
- return;
-
- case OP3_ANDNcc:
- sparc_printalu("ANDNcc", instr);
- return;
-
- case OP3_ORN:
- sparc_printalu("ORN", instr);
- return;
-
- case OP3_ORNcc:
- sparc_printalu("ORNcc", instr);
- return;
-
- case OP3_XNOR:
- sparc_printalu("XNOR", instr);
- return;
-
- case OP3_XNORcc:
- sparc_printalu("XNORcc", instr);
- return;
-
- case OP3_SUBC:
- sparc_printalu("SUBC", instr);
- return;
-
- case OP3_SUBCcc:
- sparc_printalu("SUBCcc", instr);
- return;
-
- case OP3_MULX:
- sparc_printalu("MULX", instr);
- return;
-
- case OP3_SDIVX:
- sparc_printalu("SDIVX", instr);
- return;
-
- case OP3_UDIVX:
- sparc_printalu("UDIVX", instr);
- return;
-
- case OP3_SLL:
- sparc_printshf("SLL",instr);
- return;
- case OP3_SRL:
- sparc_printshf("SRL",instr);
- return;
- case OP3_SRA:
- sparc_printshf("SRA",instr);
- return;
-
- case OP3_DONERETRY:
- {
- if (RD_FLD(instr, INSTR_FCN)==FCN_DONE)
- printf("DONE");
- else if (RD_FLD(instr, INSTR_FCN)==FCN_RETRY)
- printf("RETRY");
- return;
- }
-
- case OP3_FCMP: //OP=OP_2: CC1_H, CC0_H, RS1, OPF, RS2
- {
- unsigned fop_n = CC_FLD(RD_FLD(instr, INSTR_OPF),OPF_TYPE_ON);
- if (fop_n==OPF_FCMPn)
- printf("FCMP ");
- else if (fop_n==OPF_FCMPEn)
- printf("FCMPE ");
-
- //which floating point condition register
- unsigned fcc = (RD_FLD(instr, INSTR_CC1_H) << 1) |
- RD_FLD(instr, INSTR_CC0_H);
-
- printf (" fcc=%d rs1=r%d rs2=r%d", fcc, RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
-
- return;
- }
-
- case OP3_FPU:
- sparc_printfpu(instr);
- return;
-
- case OP3_FLUSH: //OP=OP_2 RS1 {I=0 -> rs2, I=1->simm13}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("FLUSH rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("FLUSH rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1), SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- case OP3_FLUSHW: //OP=OP_2 I = 0
- printf("FLUSHW");
- return;
- case OP3_JMPL: //OP=OP_2 RD, RS1 {I=0-> RS2, I=1->SIMM13}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("JMPL link:r%d, to: r%d+r%d", RD_FLD(instr, INSTR_RD),RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2) );
- else
- printf("JMPL link:r%d, to: r%d+%d", RD_FLD(instr, INSTR_RD),RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)) );
- return;
-
- case OP3_POPC: //OP=OP_2, RD, RS1=0, {I=0->RS2, I=1->SIMM13}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("POPC rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("POPC rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
-
- case OP3_MEMBAR: //OP=OP_2 FCN = 0 RS1=0b01111 CMASK MMASK
- printf("MEMBAR cmask=0x%X mmask=0x%X", RD_FLD(instr, INSTR_CMASK), RD_FLD(instr, INSTR_MMASK));
- return;
-
- case OP3_Tcc: //integer trap COND_HI RS1, CC1/CC0 {I=0->RS2, I=1->SW_TRAP_#}
- if (RD_FLD(instr, INSTR_I)==0)
- printf("T%s Xcc?=%d rs1=r%d rs2=r%d", icond_names[RD_FLD(instr, INSTR_COND_H)],
- RD_FLD(instr, INSTR_CC1),
- RD_FLD(instr, INSTR_RS1),
- RD_FLD(instr, INSTR_RS2));
- else
- printf("T%s Xcc?=%d rs1=r%d trap#=%d", icond_names[RD_FLD(instr, INSTR_COND_H)],
- RD_FLD(instr, INSTR_CC1),
- RD_FLD(instr, INSTR_RS1),
- RD_FLD(instr, INSTR_SWTRAP));
-
- // guess what? a REALLY twisted special case..
- // FMOVcc and FRMOVcc share the same opcode.. you have to test if OPF_LOW_S makes
- // sense.. if so, it is a RMOVcc.. else FMOVcc..
- case OP3_FMOVcc: //OP=OP_2 RD, COND, bit18=0, OPF_CC, OPF_LOW_B, RS2
- //case OP3_FRMOVcc: //OP=OP_2 RD, RS1, bit13=0, RCOND,OPF_LOW_S, RS2
- {
- unsigned opflows = RD_FLD(instr, INSTR_OPF_LOW_S);
- unsigned opflowb = RD_FLD(instr, INSTR_OPF_LOW_B);
- if (opflows == OPF_FRMOVS || opflows == OPF_FRMOVD || opflows == OPF_FRMOVQ)
- {
- // Oh.. its a FRMOVcc
- char * basename;
- if (opflows == OPF_FRMOVS)
- basename = "FRMOVS";
- else if (opflows == OPF_FRMOVD)
- basename = "FRMOVD";
- else if (opflows == OPF_FRMOVQ)
- basename = "FRMOVQ";
-
- printf("%s%s rd=r%d rs1=r%d rs2=r%d", basename, rcond_names[RD_FLD(instr, INSTR_ECOND)],
- RD_FLD(instr, INSTR_RD),
- RD_FLD(instr, INSTR_RS1),
- RD_FLD(instr, INSTR_RS2));
-
- }
- else
- {
- char * basename;
-
- if (opflowb == OPF_FMOVS)
- basename = "FMOVS";
- else if (opflowb == OPF_FMOVD)
- basename = "FMOVD";
- else if (opflowb == OPF_FMOVQ)
- basename = "FMOVQ";
- else
- basename = "FMOV?";
-
- // Must be a FMOVcc
- printf("%s%s rd=r%d rs2=r%d %s", basename, fcond_names[RD_FLD(instr, INSTR_COND_H)],
- RD_FLD(instr, INSTR_RD),
- RD_FLD(instr, INSTR_RS2),
- cc_names[RD_FLD(instr, INSTR_OPFCC)]);
-
- }
- return;
- }
- case OP3_MOVcc: //OP=OP_2, Rd, OP3, CC2-CC1-CC0, COND, {I=0->RS2, I=1->SIMM13}
- {
- unsigned ccc = (RD_FLD(instr, INSTR_CC2) << 2) |
- (RD_FLD(instr, INSTR_CC1_H) << 1) |
- RD_FLD(instr, INSTR_CC0_H);
-
- if (RD_FLD(instr, INSTR_I) == 0)
- printf("MOV%s rd=r%d rs2=r%d %s", icond_names[RD_FLD(instr, INSTR_COND)],
- RD_FLD(instr, INSTR_RD),
- RD_FLD(instr, INSTR_RS2),
- cc_names[ccc]);
- else
- printf("MOV%s rd=r%d simm13=%d %s", icond_names[RD_FLD(instr, INSTR_COND)],
- RD_FLD(instr, INSTR_RD),
- SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)),
- cc_names[ccc]);
- return;
-
-
- }
- case OP3_RMOVcc: //OP=OP_2, Rd, RS1,RCOND, {I=0->RS2 -> I=1->SIMM10}
- {
- if (RD_FLD(instr, INSTR_I) == 0)
- printf("RMOV%s rd=r%d rs1=r%d rs2=r%d", rcond_names[RD_FLD(instr, INSTR_RCOND)],
- RD_FLD(instr, INSTR_RS1),
- RD_FLD(instr, INSTR_RS2));
- else
- printf("RMOV%s rd=r%d rs1=r%d simm10=%d", rcond_names[RD_FLD(instr, INSTR_RCOND)],
- RD_FLD(instr, INSTR_RS1),
- SIGN_EXTEND(RD_FLD(instr, INSTR_SIMM10),10));
- return;
- }
-
- case OP3_RETURN:
- if (RD_FLD(instr, INSTR_I) == 0)
- printf("RETURN r%d + r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
- else
- printf("RETURN r%d + %d", RD_FLD(instr, INSTR_RS1), SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
-
- case OP3_SAVE:
- if (RD_FLD(instr, INSTR_I) == 0)
- printf("SAVE r%d , r%d, r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_RD));
- else
- printf("SAVE r%d , %d, r%d", RD_FLD(instr, INSTR_RS1), SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)), RD_FLD(instr, INSTR_RD));
- return;
-
- case OP3_RESTORE:
- if (RD_FLD(instr, INSTR_I) == 0)
- printf("RESTORE r%d , r%d, r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_RD));
- else
- printf("RESTORE r%d , %d, r%d", RD_FLD(instr, INSTR_RS1), SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)), RD_FLD(instr, INSTR_RD));
- return;
-
-
- }
-
- printf("Unknown:OP=0b10 OP3 = 0x%04X", RD_FLD(instr, INSTR_OP3));
-}
-
-
-//
-// Decodes OP_3 = 3 family instructions
-// * complete
-// * instructions need pseudo-code translation =p
-// * STQFA for example has special register packing
-// that need decoded
-
-void sparc_print3(unsigned instr)
-{
- switch(RD_FLD(instr, INSTR_OP3))
- {
- case OP3_LDFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDDFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDQFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDQFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDQFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 0->31
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDDF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD ? spec? 5.1.4.1
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDQF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD ? spec?
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDQF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDQF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- // **SPECIAL case these 2 instructions have same OP3 field.. RD field determines which **
- case OP3_LDFSR: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 0
- //case OP3_LDXFSR: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 1
- {
- if (RD_FLD(instr, INSTR_RD)==0)
- printf("LDFSR ");
- else if (RD_FLD(instr, INSTR_RD)==1)
- printf("LDXFSR ");
-
- if (RD_FLD(instr, INSTR_I)==0)
- printf("rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
-
- return;
- }
-
- case OP3_LDSTUBA: //OP=OP_3 RD, RS1 {I=0->RS2, IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSTUBA rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDSTUBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSTUB: //OP=OP_3 RD, Rs1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSTUB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDSTUB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STB: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STBA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STH: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STHA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STW: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STWA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STX: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STX rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STX rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STXA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STXA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STXA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STDF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STDFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STQF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STQF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("STQF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_STQFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("STQFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("STQFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
-
- // ** SPECIAL CASE ** These 2 opcodes have same OP3 field.. RD determines
- case OP3_STFSR: //OP=OP_3 RD=0 RS1 {I=0->RS2, I=1->SIMM13}
- //case OP3_STXFSR: //OP=OP_3 RD=1 RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_RD)==0)
- printf("STFSR ");
- else if (RD_FLD(instr, INSTR_RD)==1)
- printf("STXFSR ");
-
- if (RD_FLD(instr, INSTR_I)==0)
- printf("rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
-
- return;
- }
-
- case OP3_LDSB: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDSB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSH: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDSH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSW: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDSW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUB: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDUB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUH: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDUH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUW: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDUW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDX: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDX rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("LDX rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSBA: //OP=OP_3,RD RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDSBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSHA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDSHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDSWA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDSWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDSWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUBA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDUBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUHA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDUHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDUWA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDUWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDUWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDXA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDXA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDXA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_LDDA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("LDDA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("LDDA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_PREFETCH: //OP=OP_3 FCN, RS1 {I=0->RS2, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("PREFETCH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
- else
- printf("PREFETCH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_PREFETCHA: //OP=OP_3 FCN, RS1 {I=0->RS2+IMM_ASI, I=1->SIMM13}
- {
- if (RD_FLD(instr, INSTR_I)==0)
- printf("PREFETCHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
- else
- printf("PREFETCHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
- return;
- }
- case OP3_CASA: //OP=OP_3 RD RS1 RS2{I=0->IMM_ASI, I=1->*}
- {
- printf("CASA rs1=r%d rs2=r%d rd=r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RD));
- if (RD_FLD(instr, INSTR_I)==0)
- printf("imm=0x%04X", RD_FLD(instr, INSTR_IMMASI));
- return;
- }
- case OP3_CASXA: //OP=OP_3 RD RS1 RS2{I=0->IMM_ASI, I=1->*}
- {
- printf("CASXA rs1=r%d rs2=r%d rd=r%d", RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RD));
- if (RD_FLD(instr, INSTR_I)==0)
- printf("imm=0x%04X", RD_FLD(instr, INSTR_IMMASI));
- return;
- }
- }
-
- printf("Unknown OP_3: OP3 = %08X", RD_FLD(instr, INSTR_OP3));
-}
-
-#define FLIP_ENDIAN(x) (((x & 255) << 24) | (((x >> 8) & 255) << 16) | (((x >> 16) & 255) << 8) | ((x >> 24) & 255))
-
-void sparc_print(unsigned instr)
-{
- printf("%08X: ", instr);
- if (RD_FLD(instr,INSTR_OP)==OP_CALL)
- printf("CALL disp:+%08X", instr & 0x3FFFFFFF);
- else if (RD_FLD(instr,INSTR_OP)==OP_BRANCH)
- sparc_printbr(instr);
- else if (RD_FLD(instr,INSTR_OP)==OP_2)
- sparc_print2(instr);
- else if (RD_FLD(instr,INSTR_OP)==OP_3)
- sparc_print3(instr);
- printf("\n");
-}
-
-
-void main()
-{
-sparc_print(0x9DE3BF88);
-sparc_print(0xF027A044);
-sparc_print(0xF227A048);
-sparc_print(0xD007A044);
-sparc_print(0xD027BFEC);
-sparc_print(0xD007BFEC);
-sparc_print(0x933A2001);
-sparc_print(0xD227BFEC);
-sparc_print(0xD007BFEC);
-sparc_print(0x932A2001);
-sparc_print(0xD227BFEC);
-sparc_print(0xD007BFEC);
-sparc_print(0x80A22000);
-sparc_print(0x02800005);
-sparc_print(0x01000000);
-sparc_print(0xD007BFEC);
-sparc_print(0x92022001);
-sparc_print(0xD227BFEC);
-sparc_print(0xD007BFEC);
-sparc_print(0x9202200A);
-sparc_print(0xD227BFEC);
-sparc_print(0xD007BFEC);
-sparc_print(0x94100008);
-sparc_print(0x932AA002);
-sparc_print(0x92024008);
-sparc_print(0x912A6001);
-sparc_print(0xD027BFEC);
-sparc_print(0xD007A044);
-sparc_print(0xD207BFEC);
- getchar();
-}
+
+void sparc_printbr(unsigned instr)
+{
+ // look at the OP2 field
+ if (RD_FLD(instr,INSTR_OP2)==OP2_ILLTRAP) {
+ printf("ILLTRAP .. ");
+ } else if (RD_FLD(instr, INSTR_OP2)==OP2_NOP) {
+ printf("NOP ... ");
+ } else if (RD_FLD(instr, INSTR_OP2)==OP2_SETHI) {
+ printf("SETHI ... ");
+ } else if (RD_FLD(instr, INSTR_OP2)==OP2_BICC) {
+ printf("%s (Dep) disp:%08X", icond_names[RD_FLD(instr, INSTR_COND_H)],
+ RD_FLD(instr,INSTR_DISP22));
+ } else if (RD_FLD(instr, INSTR_OP2)==OP2_BPR) {
+ //A, RCOND_H, D16HI, P, RS1, D16LO
+ printf("P%s r%d " , rcond_names[RD_FLD(instr, INSTR_RCOND_H)],
+ RD_FLD(instr, INSTR_RS1));
+ } else {
+ printf("Unknown:OP=0b00 OP2 = 0x%04X", RD_FLD(instr, INSTR_OP2));
+ }
+}
+
+void sparc_printalu(char * basename , unsigned instr)
+{
+ // OP=OP_2 : RD, OP3, RS1: {I=0 -> RS2 I=1->SIMM13}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("%s r%d <- r%d ,r%d",basename, RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("%s r%d <- r%d ,%d",basename, RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+}
+
+void sparc_printshf(char * basename, unsigned instr)
+{
+ // OP=OP_2: RD, OP_3 RS1:
+ // {I=0 -> X & RS2 ,I=1 -> {X=0 -> SHCNT32 X=1->SHCNT64 }}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("%s%d r%d <- r%d, by r%d ", (RD_FLD(instr, INSTR_X)==0 ? 32 : 64),
+ basename, RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("%s%d r%d <- r%d, by 0x%04X ", basename,
+ (RD_FLD(instr, INSTR_X)==0 ? 32 : 64),
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ (RD_FLD(instr, INSTR_X)==0 ? RD_FLD(instr, INSTR_SHCNT32)
+ : RD_FLD(instr, INSTR_SHCNT64)) );
+ }
+}
+
+
+///////////////////////////////////
+// Floating point instructions //
+// * complete //
+///////////////////////////////////
+void sparc_printfpu(unsigned instr)
+{
+ //OP=OP_2: RD, OP3 RS1, OPF, RS2
+ bool rs1 = true;
+ switch(CC_FLD(RD_FLD(instr, INSTR_OPF), OPF_TYPE_ON))
+ {
+ case OPF_FADDn:
+ rs1 = true;
+ printf("FADD%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FSUBn:
+ rs1 = true;
+ printf("FSUB%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FMOVn: //RS1 not valid
+ rs1 = false;
+ printf("FMOV%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FNEGn: //RS1 not valid
+ rs1 = false;
+ printf("FNEG%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FABSn: //RS1 not valid
+ rs1 = false;
+ printf("FABS%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FMULn:
+ rs1 = true;
+ printf("FMUL%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FDIVn:
+ rs1 = true;
+ printf("FDIV%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ case OPF_FSQRTn:
+ rs1 = true;
+ printf("FSQRT%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_ON)]);
+ break;
+ }
+ switch (CC_FLD(RD_FLD(instr, INSTR_OPF),OPF_TYPE_TO))
+ {
+ case OPF_FxTOt: // RS1 not valid
+ rs1 = false;
+ printf("FxTO%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_TO)]);
+ break;
+ case OPF_FiTOt: // RS1 not valid
+ rs1 = false;
+ printf("FxTO%s ", opf_type_name[RD_FLD(instr,OPF_TYPE_TO)]);
+ break;
+ }
+
+ switch(RD_FLD(instr, INSTR_OPF))
+ {
+ case OPF_FsMULd:
+ rs1 = true;
+ printf("FsMULd ");
+ break;
+ case OPF_FdMULq:
+ rs1 = true;
+ printf("FdMULq ");
+ break;
+ case OPF_FsTOx: // RS1 not valid
+ rs1 = false;
+ printf("FsTOx ");
+ break;
+ case OPF_FsTOi: // RS1 not valid
+ rs1 = false;
+ printf("FsTOi ");
+ break;
+ case OPF_FsTOd: // RS1 not valid
+ rs1 = false;
+ printf("FsTOd ");
+ break;
+ case OPF_FsTOq: // RS1 not valid
+ rs1 = false;
+ printf("FsTOq ");
+ break;
+ case OPF_FdTOx: // RS1 not valid
+ rs1 = false;
+ printf("FdTOx ");
+ break;
+ case OPF_FdTOi: // RS1 not valid
+ rs1 = false;
+ printf("FdTOi ");
+ break;
+ case OPF_FdTOs: // RS1 not valid
+ rs1 = false;
+ printf("FdTOs ");
+ break;
+ case OPF_FdTOq: // RS1 not valid
+ rs1 = false;
+ printf("FdTOq ");
+ break;
+ case OPF_FqTOx: // RS1 not valid
+ rs1 = false;
+ printf("FqTOx ");
+ break;
+ case OPF_FqTOi: // RS1 not valid
+ rs1 = false;
+ printf("FqTOi ");
+ break;
+ case OPF_FqTOs: // RS1 not valid
+ rs1 = false;
+ printf("FqTOs ");
+ break;
+ case OPF_FqTOd: // RS1 not valid
+ rs1 = false;
+ printf("FqTOd ");
+ break;
+ }
+ //OP=OP_2: RD, OP3 RS1, OPF, RS2
+ if (rs1) {
+ printf("rd=r%d rs1=r%d rs2=r%d ", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("rd=r%d rs2=r%d", RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS2));
+ }
+}
+
+void sparc_print2(unsigned instr)
+{
+ switch(RD_FLD(instr, INSTR_OP3))
+ {
+ case OP3_ADD:
+ sparc_printalu("ADD", instr);
+ return;
+
+ case OP3_ADDcc:
+ sparc_printalu("ADDcc", instr);
+ return;
+
+ case OP3_ADDC:
+ sparc_printalu("ADDC", instr);
+ return;
+
+ case OP3_ADDCcc:
+ sparc_printalu("ADDCcc", instr);
+ return;
+
+ case OP3_AND:
+ sparc_printalu("AND", instr);
+ return;
+
+ case OP3_ANDcc:
+ sparc_printalu("ANDcc", instr);
+ return;
+
+ case OP3_OR:
+ sparc_printalu("OR", instr);
+ return;
+
+ case OP3_ORcc:
+ sparc_printalu("ORcc", instr);
+ return;
+
+ case OP3_XOR:
+ sparc_printalu("XOR", instr);
+ return;
+
+ case OP3_XORcc:
+ sparc_printalu("XORcc", instr);
+ return;
+
+ case OP3_SUB:
+ sparc_printalu("SUB", instr);
+ return;
+
+ case OP3_SUBcc:
+ sparc_printalu("SUBcc", instr);
+ return;
+
+ case OP3_ANDN:
+ sparc_printalu("ANDN", instr);
+ return;
+
+ case OP3_ANDNcc:
+ sparc_printalu("ANDNcc", instr);
+ return;
+
+ case OP3_ORN:
+ sparc_printalu("ORN", instr);
+ return;
+
+ case OP3_ORNcc:
+ sparc_printalu("ORNcc", instr);
+ return;
+
+ case OP3_XNOR:
+ sparc_printalu("XNOR", instr);
+ return;
+
+ case OP3_XNORcc:
+ sparc_printalu("XNORcc", instr);
+ return;
+
+ case OP3_SUBC:
+ sparc_printalu("SUBC", instr);
+ return;
+
+ case OP3_SUBCcc:
+ sparc_printalu("SUBCcc", instr);
+ return;
+
+ case OP3_MULX:
+ sparc_printalu("MULX", instr);
+ return;
+
+ case OP3_SDIVX:
+ sparc_printalu("SDIVX", instr);
+ return;
+
+ case OP3_UDIVX:
+ sparc_printalu("UDIVX", instr);
+ return;
+
+ case OP3_SLL:
+ sparc_printshf("SLL",instr);
+ return;
+ case OP3_SRL:
+ sparc_printshf("SRL",instr);
+ return;
+ case OP3_SRA:
+ sparc_printshf("SRA",instr);
+ return;
+
+ case OP3_DONERETRY:
+ {
+ if (RD_FLD(instr, INSTR_FCN)==FCN_DONE)
+ printf("DONE");
+ else if (RD_FLD(instr, INSTR_FCN)==FCN_RETRY)
+ printf("RETRY");
+ return;
+ }
+
+ case OP3_FCMP: //OP=OP_2: CC1_H, CC0_H, RS1, OPF, RS2
+ {
+ unsigned fop_n = CC_FLD(RD_FLD(instr, INSTR_OPF),OPF_TYPE_ON);
+ if (fop_n==OPF_FCMPn)
+ printf("FCMP ");
+ else if (fop_n==OPF_FCMPEn)
+ printf("FCMPE ");
+
+ //which floating point condition register
+ unsigned fcc = (RD_FLD(instr, INSTR_CC1_H) << 1) |
+ RD_FLD(instr, INSTR_CC0_H);
+
+ printf (" fcc=%d rs1=r%d rs2=r%d", fcc, RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+
+ return;
+ }
+
+ case OP3_FPU:
+ sparc_printfpu(instr);
+ return;
+
+ case OP3_FLUSH: //OP=OP_2 RS1 {I=0 -> rs2, I=1->simm13}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("FLUSH rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("FLUSH rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ case OP3_FLUSHW: //OP=OP_2 I = 0
+ printf("FLUSHW");
+ return;
+ case OP3_JMPL: //OP=OP_2 RD, RS1 {I=0-> RS2, I=1->SIMM13}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("JMPL link:r%d, to: r%d+r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2) );
+ } else {
+ printf("JMPL link:r%d, to: r%d+%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)) );
+ }
+ return;
+ case OP3_POPC: //OP=OP_2, RD, RS1=0, {I=0->RS2, I=1->SIMM13}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("POPC rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("POPC rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ case OP3_MEMBAR: //OP=OP_2 FCN = 0 RS1=0b01111 CMASK MMASK
+ printf("MEMBAR cmask=0x%X mmask=0x%X", RD_FLD(instr, INSTR_CMASK),
+ RD_FLD(instr, INSTR_MMASK));
+ return;
+ case OP3_Tcc: //integer trap COND_HI RS1, CC1/CC0 {I=0->RS2, I=1->SW_TRAP_#}
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("T%s Xcc?=%d rs1=r%d rs2=r%d",
+ icond_names[RD_FLD(instr, INSTR_COND_H)],
+ RD_FLD(instr, INSTR_CC1),
+ RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("T%s Xcc?=%d rs1=r%d trap#=%d",
+ icond_names[RD_FLD(instr, INSTR_COND_H)],
+ RD_FLD(instr, INSTR_CC1),
+ RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_SWTRAP));
+ }
+ // guess what? a REALLY twisted special case..
+ // FMOVcc and FRMOVcc share the same opcode..
+ // you have to test if OPF_LOW_S makes sense..
+ // if so, it is a RMOVcc.. else FMOVcc..
+ case OP3_FMOVcc: //OP=OP_2 RD, COND, bit18=0, OPF_CC, OPF_LOW_B, RS2
+ //case OP3_FRMOVcc: //OP=OP_2 RD, RS1, bit13=0, RCOND,OPF_LOW_S, RS2
+ {
+ unsigned opflows = RD_FLD(instr, INSTR_OPF_LOW_S);
+ unsigned opflowb = RD_FLD(instr, INSTR_OPF_LOW_B);
+ if (opflows == OPF_FRMOVS || opflows == OPF_FRMOVD ||
+ opflows == OPF_FRMOVQ)
+ {
+ // Oh.. its a FRMOVcc
+ char * basename;
+ if (opflows == OPF_FRMOVS)
+ basename = "FRMOVS";
+ else if (opflows == OPF_FRMOVD)
+ basename = "FRMOVD";
+ else if (opflows == OPF_FRMOVQ)
+ basename = "FRMOVQ";
+
+ printf("%s%s rd=r%d rs1=r%d rs2=r%d", basename,
+ rcond_names[RD_FLD(instr, INSTR_ECOND)],
+ RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+
+ } else {
+ char *basename;
+ if (opflowb == OPF_FMOVS)
+ basename = "FMOVS";
+ else if (opflowb == OPF_FMOVD)
+ basename = "FMOVD";
+ else if (opflowb == OPF_FMOVQ)
+ basename = "FMOVQ";
+ else
+ basename = "FMOV?";
+
+ // Must be a FMOVcc
+ printf("%s%s rd=r%d rs2=r%d %s", basename,
+ fcond_names[RD_FLD(instr, INSTR_COND_H)],
+ RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS2),
+ cc_names[RD_FLD(instr, INSTR_OPFCC)]);
+ }
+ return;
+ }
+ case OP3_MOVcc: //OP=OP_2, Rd, OP3, CC2-CC1-CC0, COND, {I=0->RS2, I=1->SIMM13}
+ {
+ unsigned ccc = (RD_FLD(instr, INSTR_CC2) << 2) |
+ (RD_FLD(instr, INSTR_CC1_H) << 1) |
+ RD_FLD(instr, INSTR_CC0_H);
+
+ if (RD_FLD(instr, INSTR_I) == 0) {
+ printf("MOV%s rd=r%d rs2=r%d %s",
+ icond_names[RD_FLD(instr, INSTR_COND)],
+ RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS2),
+ cc_names[ccc]);
+ } else {
+ printf("MOV%s rd=r%d simm13=%d %s",
+ icond_names[RD_FLD(instr, INSTR_COND)],
+ RD_FLD(instr, INSTR_RD),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)),
+ cc_names[ccc]);
+ }
+ return;
+ }
+ case OP3_RMOVcc: //OP=OP_2, Rd, RS1,RCOND, {I=0->RS2 -> I=1->SIMM10}
+ {
+ if (RD_FLD(instr, INSTR_I) == 0) {
+ printf("RMOV%s rd=r%d rs1=r%d rs2=r%d",
+ rcond_names[RD_FLD(instr, INSTR_RCOND)],
+ RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("RMOV%s rd=r%d rs1=r%d simm10=%d",
+ rcond_names[RD_FLD(instr, INSTR_RCOND)],
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND(RD_FLD(instr, INSTR_SIMM10),10));
+ }
+ return;
+ }
+
+ case OP3_RETURN:
+ if (RD_FLD(instr, INSTR_I) == 0) {
+ printf("RETURN r%d + r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("RETURN r%d + %d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ case OP3_SAVE:
+ if (RD_FLD(instr, INSTR_I) == 0) {
+ printf("SAVE r%d , r%d, r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_RD));
+ } else {
+ printf("SAVE r%d , %d, r%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)),
+ RD_FLD(instr, INSTR_RD));
+ }
+ return;
+ case OP3_RESTORE:
+ if (RD_FLD(instr, INSTR_I) == 0) {
+ printf("RESTORE r%d , r%d, r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_RD));
+ } else {
+ printf("RESTORE r%d , %d, r%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)),
+ RD_FLD(instr, INSTR_RD));
+ }
+ return;
+ }
+
+ printf("Unknown:OP=0b10 OP3 = 0x%04X", RD_FLD(instr, INSTR_OP3));
+}
+
+
+//
+// Decodes OP_3 = 3 family instructions
+// * complete
+// * instructions need pseudo-code translation =p
+// * STQFA for example has special register packing
+// that need decoded
+
+void sparc_print3(unsigned instr)
+{
+ switch(RD_FLD(instr, INSTR_OP3))
+ {
+ case OP3_LDFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDDFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDQFA: //OP=OP_3 RD, Rs1, {I=0->IMM_ASI, RS2 I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDQFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDQFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ return;
+ }
+ case OP3_LDF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 0->31
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDDF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD ? spec? 5.1.4.1
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDQF: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD ? spec?
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDQF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDQF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ // **SPECIAL case these 2 instructions have same OP3 field
+ // RD field determines which **
+ case OP3_LDFSR: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 0
+ //case OP3_LDXFSR: //OP=OP_3 RD, RS1, {I=0->RS2, I=1->SIMM13} RD = 1
+ {
+ if (RD_FLD(instr, INSTR_RD)==0)
+ printf("LDFSR ");
+ else if (RD_FLD(instr, INSTR_RD)==1)
+ printf("LDXFSR ");
+
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+
+ case OP3_LDSTUBA: //OP=OP_3 RD, RS1 {I=0->RS2, IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSTUBA rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDSTUBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSTUB: //OP=OP_3 RD, Rs1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSTUB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDSTUB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STB: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STBA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STH: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STHA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STW: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STWA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STX: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STX rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STX rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STXA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STXA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STXA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STDF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STDF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STDF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STDFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STDFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STDFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STQF: //OP=OP_3 RD RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STQF rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("STQF rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_STQFA: //OP=OP_3 RD RS1 {I=0->RS2 IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("STQFA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("STQFA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+
+ // ** SPECIAL CASE ** These 2 opcodes have same OP3 field.. RD determines
+ case OP3_STFSR: //OP=OP_3 RD=0 RS1 {I=0->RS2, I=1->SIMM13}
+ //case OP3_STXFSR: //OP=OP_3 RD=1 RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_RD)==0)
+ printf("STFSR ");
+ else if (RD_FLD(instr, INSTR_RD)==1)
+ printf("STXFSR ");
+
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+
+ return;
+ }
+
+ case OP3_LDSB: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDSB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSH: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDSH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSW: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDSW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUB: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUB rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDUB rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUH: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDUH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUW: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUW rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDUW rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDX: //OP=OP_3,RD RS1, {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0)
+ printf("LDX rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("LDX rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSBA: //OP=OP_3,RD RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDSBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSHA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDSHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDSWA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDSWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDSWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUBA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUBA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDUBA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUHA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDUHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDUWA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDUWA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDUWA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDXA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDXA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDXA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_LDDA: //OP=OP_3, RS1, {I=0->RS2,IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("LDDA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("LDDA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_PREFETCH: //OP=OP_3 FCN, RS1 {I=0->RS2, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("PREFETCH rd=r%d rs1=r%d rs2=r%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),RD_FLD(instr, INSTR_RS2));
+ } else {
+ printf("PREFETCH rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ }
+ return;
+ }
+ case OP3_PREFETCHA: //OP=OP_3 FCN, RS1 {I=0->RS2+IMM_ASI, I=1->SIMM13}
+ {
+ if (RD_FLD(instr, INSTR_I)==0) {
+ printf("PREFETCHA rd=r%d rs1=r%d rs2=r%d immasi=0x%04X",
+ RD_FLD(instr, INSTR_RD), RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS2), RD_FLD(instr, INSTR_IMMASI));
+ } else {
+ printf("PREFETCHA rd=r%d rs1=r%d simm13=%d", RD_FLD(instr, INSTR_RD),
+ RD_FLD(instr, INSTR_RS1),
+ SIGN_EXTEND13(RD_FLD(instr, INSTR_SIMM13)));
+ return;
+ }
+ case OP3_CASA: //OP=OP_3 RD RS1 RS2{I=0->IMM_ASI, I=1->*}
+ {
+ printf("CASA rs1=r%d rs2=r%d rd=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RD));
+ if (RD_FLD(instr, INSTR_I)==0)
+ printf("imm=0x%04X", RD_FLD(instr, INSTR_IMMASI));
+ return;
+ }
+ case OP3_CASXA: //OP=OP_3 RD RS1 RS2{I=0->IMM_ASI, I=1->*}
+ {
+ printf("CASXA rs1=r%d rs2=r%d rd=r%d", RD_FLD(instr, INSTR_RS1),
+ RD_FLD(instr, INSTR_RS1), RD_FLD(instr, INSTR_RD));
+ if (RD_FLD(instr, INSTR_I)==0)
+ printf("imm=0x%04X", RD_FLD(instr, INSTR_IMMASI));
+ return;
+ }
+ }
+
+ printf("Unknown OP_3: OP3 = %08X", RD_FLD(instr, INSTR_OP3));
+}
+
+#define FLIP_ENDIAN(x) (((x & 255) << 24) \
+ | (((x >> 8) & 255) << 16) \
+ | (((x >> 16) & 255) << 8) \
+ | ((x >> 24) & 255))
+
+
+void sparc_print(unsigned instr)
+{
+ printf("%08X: ", instr);
+ if (RD_FLD(instr,INSTR_OP)==OP_CALL)
+ printf("CALL disp:+%08X", instr & 0x3FFFFFFF);
+ else if (RD_FLD(instr,INSTR_OP)==OP_BRANCH)
+ sparc_printbr(instr);
+ else if (RD_FLD(instr,INSTR_OP)==OP_2)
+ sparc_print2(instr);
+ else if (RD_FLD(instr,INSTR_OP)==OP_3)
+ sparc_print3(instr);
+ printf("\n");
+}
+
+
+void main()
+{
+ sparc_print(0x9DE3BF88);
+ sparc_print(0xF027A044);
+ sparc_print(0xF227A048);
+ sparc_print(0xD007A044);
+ sparc_print(0xD027BFEC);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x933A2001);
+ sparc_print(0xD227BFEC);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x932A2001);
+ sparc_print(0xD227BFEC);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x80A22000);
+ sparc_print(0x02800005);
+ sparc_print(0x01000000);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x92022001);
+ sparc_print(0xD227BFEC);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x9202200A);
+ sparc_print(0xD227BFEC);
+ sparc_print(0xD007BFEC);
+ sparc_print(0x94100008);
+ sparc_print(0x932AA002);
+ sparc_print(0x92024008);
+ sparc_print(0x912A6001);
+ sparc_print(0xD027BFEC);
+ sparc_print(0xD007A044);
+ sparc_print(0xD207BFEC);
+ getchar();
+}
More information about the llvm-commits
mailing list