5 typedef unsigned long long u64
;
17 u64 ic_fetch_failed
: 1;
35 u64 d2_stopped_out
: 1;
42 u64 e1_write_enable
: 1;
83 #define FLAG(i, y) (log.i? y: ' ')
84 #define FLGA(i, y, z) (log.i? y: z)
85 #define PNIA(f) (full_nia[log.f] & 0xff)
87 const char *units
[4] = { "--", "al", "ls", "fp" };
90 "illegal", "nop ", "add ", "and ", "attn ", "b ", "bc ", "bcreg ",
91 "bperm ", "cmp ", "cmpb ", "cmpeqb ", "cmprb ", "cntz ", "crop ", "darn ",
92 "dcbf ", "dcbst ", "dcbt ", "dcbtst ", "dcbz ", "div ", "dive ", "exts ",
93 "extswsl", "fpop ", "fpopi ", "icbi ", "icbt ", "isel ", "isync ", "ld ",
94 "st ", "mcrxrx ", "mfcr ", "mfmsr ", "mfspr ", "mod ", "mtcrf ", "mtmsr ",
95 "mtspr ", "mull64 ", "mulh64 ", "mulh32 ", "or ", "popcnt ", "prty ", "rfid ",
96 "rlc ", "rlcl ", "rlcr ", "sc ", "setb ", "shl ", "shr ", "sync ",
97 "tlbie ", "trap ", "xor ", "bcd ", "addg6s ", "ffail ", "?62 ", "?63 "
100 const char *spr_names
[13] =
102 "lr ", "ctr", "sr0", "sr1", "hr0", "hr1", "sg0", "sg1",
103 "sg2", "sg3", "hg0", "hg1", "xer"
106 int main(int ac
, char **av
)
108 struct log_entry log
;
112 const char *filename
;
116 if (ac
!= 1 && ac
!= 2) {
117 fprintf(stderr
, "Usage: %s [filename]\n", av
[0]);
123 f
= fopen(filename
, "rb");
130 for (i
= 0; i
< 15; ++i
)
131 full_nia
[i
] = i
<< 2;
133 while (fread(&log
, sizeof(log
), 1, f
) == 1) {
134 full_nia
[log
.nia_lo
& 0xf] = (log
.nia_hi
? 0xc000000000000000: 0) |
136 if (lineno
% 20 == 1) {
137 printf(" fetch1 NIA icache decode1 decode2 execute1 loadstore dcache CR GSPR\n");
138 printf(" ---------------- TAHW S -WB-- pN --insn-- pN un op pN byp FR IIE MSR WC SD MM CE SRTO DE -WB-- c ms reg val\n");
139 printf(" LdMy t csnSa IA IA it IA abc le srx EPID em tw rd mx tAwp vr csnSa 0 k\n");
141 printf("%4ld %c0000%.11llx %c ", lineno
,
142 (log
.nia_hi
? 'c': '0'),
143 (unsigned long long)log
.nia_lo
<< 2,
144 FLAG(ic_stall_out
, '|'));
145 printf("%c%c%c%d %c %c%c%d%c%c %.2llx ",
146 FLGA(ic_ra_valid
, ' ', 'T'),
147 FLGA(ic_access_ok
, ' ', 'X'),
148 FLGA(ic_is_hit
, 'H', FLGA(ic_is_miss
, 'M', ' ')),
151 FLAG(ic_wb_cyc
, 'c'),
152 FLAG(ic_wb_stb
, 's'),
154 FLAG(ic_wb_stall
, 'S'),
155 FLAG(ic_wb_ack
, 'a'),
158 printf("%.8x", log
.ic_insn
);
159 else if (log
.ic_fetch_failed
)
163 printf(" %c%c %.2llx ",
165 FLAG(d2_stall_out
, '|'),
170 ops
[log
.d1_insn_type
]);
172 printf("-- -------");
175 FLAG(d2_stall_out
, '|'));
176 printf("%.2llx %c%c%c %c%c ",
178 FLAG(d2_bypass_a
, 'a'),
179 FLAG(d2_bypass_b
, 'b'),
180 FLAG(d2_bypass_c
, 'c'),
182 FLAG(e1_stall_out
, '|'));
183 printf("%c%c %c%c%c %c%c%c%c %c%c ",
184 FLAG(e1_flush_out
, 'F'),
185 FLAG(e1_redirect
, 'R'),
186 FLAG(e1_irq_state
, 'w'),
188 FLAG(e1_exception
, 'X'),
189 FLAG(e1_msr_ee
, 'E'),
190 FLGA(e1_msr_pr
, 'u', 's'),
191 FLAG(e1_msr_ir
, 'I'),
192 FLAG(e1_msr_dr
, 'D'),
193 FLAG(e1_write_enable
, 'W'),
194 FLAG(e1_valid
, 'C'));
195 printf("%c %d%d %c%c %c%c %c ",
196 FLAG(ls_stall_out
, '|'),
199 FLAG(ls_mo_valid
, 'M'),
200 FLAG(ls_min_done
, 'm'),
201 FLAG(ls_lo_valid
, 'C'),
202 FLAG(ls_eo_except
, 'X'),
203 FLAG(ls_do_valid
, '>'));
204 printf("%d%c%d%d %c%c %c%c%d%c%c ",
206 FLAG(dc_ra_valid
, 'R'),
209 FLAG(dc_do_valid
, 'V'),
210 FLAG(dc_do_error
, 'E'),
211 FLAG(dc_wb_cyc
, 'c'),
212 FLAG(dc_wb_stb
, 's'),
214 FLAG(dc_wb_stall
, 'S'),
215 FLAG(dc_wb_ack
, 'a'));
216 if (log
.cr_wr_enable
)
217 printf("%x>%.2x ", log
.cr_wr_data
, log
.cr_wr_mask
);
220 if (log
.reg_wr_enable
) {
221 if (log
.reg_wr_reg
< 32 || log
.reg_wr_reg
> 44)
222 printf("r%02d", log
.reg_wr_reg
);
224 printf("%s", spr_names
[log
.reg_wr_reg
- 32]);
225 printf("=%.16llx", log
.reg_wr_data
);
229 if (log
.ls_lo_valid
|| log
.e1_valid
)
232 printf("%ld instructions completed, %.2f CPI\n", ncompl
,
233 (double)(lineno
- 1) / ncompl
);