//Dump all IR expressions of region and its used MDs. void IR_EXPR_TAB::dump_ir_expr_tab() { if (g_tfile == NULL) return; fprintf(g_tfile, "\n==---- DUMP IR_EXPR_TAB ----=="); IR_DU_MGR * du_mgr = m_ru->get_du_mgr(); INT last = m_ir_expr_vec.get_last_idx(); for (INT i = 0; i <= last; i++) { ExpRep * ie = m_ir_expr_vec.get(i); if (ie == NULL) { continue; } ASSERT0(EXPR_id(ie) == (UINT)i); fprintf(g_tfile, "\n\n----------- ExpRep(%d)", i); dump_ir(EXPR_ir(ie), m_dm); fprintf(g_tfile, "\n\tOCC:"); for (IR * occ = EXPR_occ_list(ie).get_head(); occ != NULL; occ = EXPR_occ_list(ie).get_next()) { fprintf(g_tfile, "IR%d", IR_id(occ)); MDSet const* use_mds = du_mgr->get_may_use(occ); if (use_mds != NULL) { fprintf(g_tfile, "(use:"); use_mds->dump(m_ru->get_md_sys()); fprintf(g_tfile, ")"); } fprintf(g_tfile, ","); } } fflush(g_tfile); }
void IRBB::dump(Region * ru) { if (g_tfile == NULL) { return; } g_indent = 0; fprintf(g_tfile, "\n----- BB%d ------", BB_id(this)); if (get_lab_list().get_elem_count() > 0) { fprintf(g_tfile, "\nLABEL:"); dumpBBLabel(get_lab_list(), g_tfile); } //Attributes fprintf(g_tfile, "\nATTR:"); if (BB_is_entry(this)) { fprintf(g_tfile, "entry_bb "); } //if (BB_is_exit(this)) { // fprintf(g_tfile, "exit_bb "); //} if (BB_is_fallthrough(this)) { fprintf(g_tfile, "fall_through "); } if (BB_is_target(this)) { fprintf(g_tfile, "branch_target "); } //IR list fprintf(g_tfile, "\nSTMT NUM:%d", getNumOfIR()); g_indent += 3; TypeMgr * dm = ru->get_type_mgr(); for (IR * ir = BB_first_ir(this); ir != NULL; ir = BB_irlist(this).get_next()) { ASSERT0(IR_next(ir) == NULL && IR_prev(ir) == NULL); ASSERT0(ir->get_bb() == this); dump_ir(ir, dm, NULL, true, true, false); } g_indent -= 3; fprintf(g_tfile, "\n"); fflush(g_tfile); }
int main(int argc, char **argv) { uint8_t eeprom[0xFF]; int16_t ir_data[16][4]; struct mlx_conv_s conv_tbl; double temp[16][4]; uint16_t cfg, ptat, trim; int16_t v_cp; double ptat_f; SDL_Surface *screen; int fd; #ifdef TEST int i; #endif int quit = 0; assert(argc > 1); fd = open(argv[1], O_RDWR); assert(fd >= 0); read_eeprom(fd, eeprom); hexdump(eeprom, 255); #ifdef TEST eeprom[0xda] = 0x78; eeprom[0xdb] = 0x1a; eeprom[0xdc] = 0x33; eeprom[0xdd] = 0x5b; eeprom[0xde] = 0xcc; eeprom[0xdf] = 0xed; eeprom[0xd4] = 0xd0; eeprom[0xd5] = 0xca; eeprom[0xd6] = 0x00; eeprom[0xd7] = 0x00; eeprom[0xd8] = 0x23; eeprom[0xd9] = 0x08; eeprom[0xe0] = 0xe4; eeprom[0xe1] = 0xd5; eeprom[0xe2] = 0x2a; eeprom[0xe3] = 0x21; eeprom[0xe4] = 0x99; eeprom[0xe5] = 0x79; for (i = 0; i < 64; i++) { eeprom[i] = 0xd6; eeprom[i + 64] = 0xc1; eeprom[i + 128] = 0x8f; } #endif prepare_conv(eeprom, &conv_tbl); assert(ioctl(fd, I2C_SLAVE, 0x60) >= 0); do { config_mlx(fd, eeprom); mlx_read_ram(fd, MLX_RAM_CONFIG, &cfg, 1); #ifdef DEBUG printf("cfg: %04x\n", cfg); #endif } while (!(cfg & (1 << 10))); mlx_read_ram(fd, MLX_RAM_TRIM, &trim, 1); #ifdef DEBUG printf("osc: %04x\n", trim); #endif screen = sdl_init(); while (!quit) { SDL_Event evt; mlx_read_ram(fd, MLX_RAM_TGC, (uint16_t *) & v_cp, 1); #ifdef DEBUG printf("tgc: %04x\n", (uint16_t) v_cp); #endif mlx_read_ram(fd, MLX_RAM_PTAT, &ptat, 1); ptat_f = ptat_to_kelvin(ptat, &conv_tbl); #ifdef DEBUG printf("ptat: %04x (%.1f)\n", ptat, kelvin_to_celsius(ptat_f)); #endif mlx_read_ram(fd, MLX_RAM_IR, (uint16_t *) ir_data, 16 * 4); #ifdef TEST v_cp = 0xffd8; ptat_f = 28.16 + 273.15; ir_data[0][0] = 0x0090; #endif convert_ir(ir_data, temp, &conv_tbl, ptat_f, v_cp); #ifdef DEBUG dump_ir(ir_data); dump_temps(temp); #endif draw_picture(screen, temp, kelvin_to_celsius(ptat_f)); while (SDL_PollEvent(&evt)) { if (evt.type == SDL_KEYDOWN) { switch (evt.key.keysym.sym) { case SDLK_q: case SDLK_ESCAPE: quit = 1; break; default: break; } } } } close(fd); return 0; }
void IR_GVN::dump_bb(UINT bbid) { if (g_tfile == NULL) { return; } IR_BB * bb = m_ru->get_bb(bbid); IS_TRUE0(bb); CIR_ITER ii; fprintf(g_tfile, "\n-- BB%d ", IR_BB_id(bb)); dump_bb_labs(IR_BB_lab_list(bb)); fprintf(g_tfile, "\n"); for (IR * ir = IR_BB_first_ir(bb); ir != NULL; ir = IR_BB_next_ir(bb)) { dump_ir(ir, m_ru->get_dm()); fprintf(g_tfile, "\n"); VN * x = m_ir2vn.get(IR_id(ir)); if (x != NULL) { fprintf(g_tfile, "vn%d", VN_id(x)); } fprintf(g_tfile, " <- {"); switch (IR_type(ir)) { case IR_ST: ii.clean(); for (IR const* k = ir_iter_init_c(ST_rhs(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_STPR: ii.clean(); for (IR const* k = ir_iter_init_c(STPR_rhs(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_IST: ii.clean(); for (IR const* k = ir_iter_init_c(IST_rhs(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } ii.clean(); for (IR const* k = ir_iter_init_c(IST_base(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_CALL: case IR_ICALL: { ii.clean(); for (IR const* k = ir_iter_init_c(CALL_param_list(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } } break; case IR_TRUEBR: case IR_FALSEBR: ii.clean(); for (IR const* k = ir_iter_init_c(BR_det(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_SWITCH: ii.clean(); for (IR const* k = ir_iter_init_c(SWITCH_vexp(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_IGOTO: ii.clean(); for (IR const* k = ir_iter_init_c(IGOTO_vexp(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_RETURN: ii.clean(); for (IR const* k = ir_iter_init_c(RET_exp(ir), ii); k != NULL; k = ir_iter_next_c(ii)) { VN * x = m_ir2vn.get(IR_id(k)); dump_h1(k, x); } break; case IR_GOTO: break; case IR_REGION: IS_TRUE0(0); //TODO break; default: IS_TRUE0(0); } fprintf(g_tfile, " }"); } fflush(g_tfile); }