int main(void) { while (moreinput()) { parse(); optimize(); addable(); generate(); peephole(); writeout(); } return 0; }
void LIR_Assembler::emit_lir_list(LIR_List* list) { peephole(list); int n = list->length(); for (int i = 0; i < n; i++) { LIR_Op* op = list->at(i); check_codespace(); CHECK_BAILOUT(); #ifndef PRODUCT if (CommentedAssembly) { // Don't record out every op since that's too verbose. Print // branches since they include block and stub names. Also print // patching moves since they generate funny looking code. if (op->code() == lir_branch || (op->code() == lir_move && op->as_Op1()->patch_code() != lir_patch_none)) { stringStream st; op->print_on(&st); _masm->block_comment(st.as_string()); } } if (PrintLIRWithAssembly) { // print out the LIR operation followed by the resulting assembly list->at(i)->print(); tty->cr(); } #endif /* PRODUCT */ op->emit_code(this); if (compilation()->debug_info_recorder()->recording_non_safepoints()) { process_debug_info(op); } #ifndef PRODUCT if (PrintLIRWithAssembly) { _masm->code()->decode(); } #endif /* PRODUCT */ } }
void LIR_Assembler::emit_lir_list(LIR_List* list) { peephole(list); int n = list->length(); for (int i = 0; i < n; i++) { LIR_Op* op = list->at(i); check_codespace(); CHECK_BAILOUT(); #ifndef PRODUCT // Don't record out every op since that's too verbose. Print // branches since they include block and stub names. Also print // patching moves since they generate funny looking code. if (op->code() == lir_branch || (op->code() == lir_move && op->as_Op1()->patch_code() != lir_patch_none)) { stringStream st; op->print_on(&st); _masm->block_comment(st.as_string()); } int start_relpc = _masm->rel_pc(); if (PrintLIRWithAssembly) { // print out the LIR operation followed by the resulting assembly list->at(i)->print(C1OUT);C1OUT->cr(); } #endif /* PRODUCT */ op->emit_code(this); #ifndef PRODUCT if (PrintLIRWithAssembly) { address code = (address)_masm->blob(); Disassembler::decode(code+start_relpc, code+_masm->rel_pc(), C1OUT); } #endif /* PRODUCT */ } #ifndef PRODUCT if (PrintLIRWithAssembly) { C1OUT->flush(); } #endif }
static struct icode *generate_function(function f, bool toplevel, fncode fn) { /* make help string; must be allocated before code (immutability restriction) */ struct string *help = NULL; if (f->help.len) help = make_readonly(alloc_string_length(f->help.str, f->help.len)); struct string *varname = NULL, *filename = NULL, *nicename = NULL; struct vector *arg_types = NULL; GCPRO5(help, varname, filename, nicename, arg_types); /* Make variable name (if present) */ if (f->varname) varname = make_readonly(alloc_string(f->varname)); else varname = NULL; /* Make filename string */ filename = make_filename(f->filename); nicename = make_filename(f->nicename); arg_types = make_arg_types(f); fncode newfn = new_fncode(toplevel); set_lineno(f->lineno, newfn); if (f->varargs) /* varargs makes a vector from the first nargs entries of the stack and stores it in local value 0 */ ins0(op_varargs, newfn); else { /* First, generate code to check the argument types & count */ /* argcheck copies the arguments into the local variables, assuming that the last argument (on top of the stack) is local value 0, the next to last local value 1, and so on. It then discards all the parameters */ int nargs = 0; for (vlist argument = f->args; argument; argument = argument->next) nargs++; ins1(op_argcheck, nargs, newfn); nargs = 0; for (vlist argument = f->args; argument; argument = argument->next) { generate_typeset_check(argument->typeset, nargs, newfn); nargs++; } ins1(op_pop_n, nargs, newfn); } /* Generate code of function */ env_push(f->args, newfn); start_block("function", newfn); generate_component(f->value, newfn); end_block(newfn); generate_typeset_check(f->typeset, 0, newfn); ins0(op_return, newfn); peephole(newfn); struct icode *c = generate_fncode( newfn, help, varname, filename, nicename, f->lineno, arg_types, f->typeset, compile_level); varlist closure = env_pop(&c->nb_locals); UNGCPRO(); /* Generate code for creating closure */ /* Count length of closure */ int clen = 0; for (varlist cvar = closure; cvar; cvar = cvar->next) clen++; /* Generate closure */ ins1(op_closure, clen, fn); /* Add variables to it */ for (varlist cvar = closure; cvar; cvar = cvar->next) ins1(op_closure_var + cvar->vclass, cvar->offset, fn); delete_fncode(newfn); return c; }