void SCCP::analyzeSSA(Instr* instr) { if (numDefs(instr) == 0) { if (isBlockEnd(instr)) analyzeBranch((BlockEndInstr*)instr); return; } // dev: save current types for later check int i = 0; for (ArrayRange<Def> d = defRange(instr); !d.empty(); d.popFront(), ++i) old_types[i] = type(d.front()); // compute types eval_counts[instr->id]++; analyzer.computeTypes(instr); // dev: check computation result bool changed2 = false; i = 0; for (ArrayRange<Def> d = defRange(instr); !d.empty(); d.popFront(), ++i) { AvmAssert(subtypeof(old_types[i], type(d.front())) && "illegal type narrowing"); changed2 |= *type(d.front()) != *old_types[i]; } if (changed2) { if (enable_typecheck) { printInstr(instr); } addInstrUsers(instr); } }
void printIList(tIlist * L){ listFirst(L); while (L->active != NULL){ printf("%p: ", (void *) L->active); printInstr(&L->active->instr); listNext(L); } }
void printBlocks(const Func* func, const Graph* g) { const Unit* unit = func->unit(); func->prettyPrint(std::cout); printFPI(func); for (LinearBlocks i(g->first_linear, 0); !i.empty(); i.popFront()) { const Block* b = i.front(); std::cout << blockToString(b, g, unit) << std::endl; for (InstrRange j(b->start, b->end); !j.empty(); ) { printInstr(unit, j.popFront()); } } std::cout << std::endl; }
void print(std::ostream& ostream, const IRInstruction* inst, const RegAllocInfo* regs, const GuardConstraints* guards) { if (!inst->isTransient()) { ostream << color(ANSI_COLOR_YELLOW); ostream << folly::format("({:02d}) ", inst->id()); ostream << color(ANSI_COLOR_END); } printInstr(ostream, inst, regs, guards); if (Block* taken = inst->taken()) { ostream << punc(" -> "); printLabel(ostream, taken); } }
void Vxls::print(const char* caption) { std::ostringstream str; str << "Intervals " << caption << "\n"; forEachInterval(intervals, [&] (Interval* ivl) { if (ivl->fixed()) { if (ignore_reserved && !abi.unreserved().contains(ivl->vreg)) { return; } if (collapse_fixed) { return; } } str << folly::format(" {: <2}", size_t(ivl->vreg)); }); str << " FX\n"; for (auto b : blocks) { printInstr(str, nullptr, block_ranges[b].start, b); for (auto& inst : unit.blocks[b].code) { printInstr(str, &inst, inst.pos, b); } } HPHP::Trace::traceRelease("%s\n", str.str().c_str()); }
void run(struct Instruction *code) { machine.reg[PC] = 0; // Start at first instruction machine.reg[SP] = MEM_SIZE; while (code[machine.reg[PC]].op!=HLT) { if(DEBUG_MODE){ printf("\n******************************************************\n"); printf("Instruction:\t"); printInstr(code[machine.reg[PC]]); printf("PC:\t\t%d\n", machine.reg[PC]); runIns(code[machine.reg[PC]]); dumpMachine(); }else runIns(code[machine.reg[PC]]); // If not a jump, continue with next instruction machine.reg[PC]++; } }
int main(int argc, char *argv[]) { yyin = fopen(argv[1], "r"); int i; yyparse(); processLabels(); printf("Running the following code:\n"); printf("***************\n"); for (i=0;i<count; i++) { printf("%d: ",i); printInstr(code[i]); } printf("***************\n\n"); run(code); return 0; }
int main(int argc,char **argv) { int i; char* file = NULL; char* line = NULL; int execute = 0; init_signal(); o_stream = stdout; while((i = getopt_long(argc, argv, "svhxo:", long_options, NULL)) > 0) { switch(i) { case 's': suppress_error = 1; break; case 'v': die(VPRINT); case 'o': file = strdup(optarg); break; case 'x': execute = 1; break; case '?': case 'h': default: die(USAGE,argv[0]); break; } } banner(); if(optind >= argc) die(USAGE,argv[0]); if(!(i_stream = fopen(argv[optind],"r"))) xdie("fopen"); i_file = argv[optind]; if(file && !(o_stream = fopen(file,"w"))) xdie("fopen"); if(o_stream != stdout) { printf("Output redirected to %s...\n",file); close(1); if(dup(fileno(o_stream)) < 0) xdie("dup"); } hexmne.symbols = malloc(sizeof(struct hexmne_sym)); hexmne.syms_len = 1; hexmne.symbols[0].name = strdup("$$"); hexmne.symbols[0].offset = 0; line = xmalloc(256); hexmne.instr = xmalloc(sizeof(struct hexmne_instr)); hexmne.instr_len = i = 0; while(fgets(line,256,i_stream)) { line[strlen(line)-1] = '\0'; #ifdef _DEBUG printf("[DEBUG] %d:%s\n",nline,line); #endif if(line[0] == '#' || line[0] == '\0') continue; if(stroff(line,'#') != -1) line[stroff(line,'#')] = '\0'; if(line[0] == '@') { hexmne_preprocess( line ); continue; } hexmne_parse_all( line ); } #ifdef _DEBUG dump_symbols(); #endif relocateAllSymbols(); putchar('\n'); printInstr(); if(execute) lxs_execute(); free(hexmne.symbols); free(hexmne.instr); free(line); if(file) free(file); if(o_stream != stdout) fclose(o_stream); return 0; }