Lines Matching refs:fp

117 static void cost_check(FILE *fp, const char *spaces,
129 if( debug_output ) { fprintf(fp, "// Previous rule with lower cost than: %s === %s_rule costs %s\n", arrayIdx, rule, cost->as_string()); }
137 if( debug_output ) { fprintf(fp, "// Previous rule with higher cost\n"); }
145 fprintf(fp, "%sif (STATE__NOT_YET_VALID(%s) || _cost[%s] > %s) {\n", spaces, arrayIdx, arrayIdx, cost->as_string());
150 if( debug_output ) { fprintf(fp, "%s// %s KNOWN_INVALID \n", spaces, arrayIdx); }
159 fprintf(fp, "%sif ( /* %s KNOWN_VALID || */ _cost[%s] > %s) {\n", spaces, arrayIdx, arrayIdx, cost->as_string());
167 fprintf(fp, "%s %s(%s, %s_rule, %s)", spaces, production, arrayIdx, rule, cost->as_string() );
169 if( cost_is_below_lower_bound ) { fprintf(fp, "\t // overwrites higher cost rule"); }
171 fprintf(fp, "\n");
175 fprintf(fp, "%s}\n", spaces);
193 static void child_test(FILE *fp, MatchList &mList) {
196 fprintf(fp, "STATE__VALID_CHILD(_kids[0], %s)", lchild_to_upper);
200 fprintf(fp, " && ");
204 fprintf(fp, "STATE__VALID_CHILD(_kids[1], %s)", rchild_to_upper);
213 Expr *ArchDesc::calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status) {
214 fprintf(fp, "%sunsigned int c = ", spaces);
232 fprintf(fp, "%s;\n", c->as_string());
239 void ArchDesc::gen_match(FILE *fp, MatchList &mList, ProductionState &status, Dict &operands_chained_from) {
243 fprintf(fp, "%s", spaces4);
249 fprintf(fp, "if( ");
251 child_test(fp, mList);
255 fprintf(fp," &&\n");
257 fprintf(fp, "%s %s", spaces6, predicate_test);
260 fprintf(fp," ) ");
267 fprintf(fp,"{\n");
270 const Expr *cost = calc_cost(fp, spaces6, mList, status);
272 cost_check(fp, spaces6, ArchDesc::getMachOperEnum(mList._resultStr), cost, mList._opcode, status);
275 expand_opclass( fp, spaces6, cost, mList._resultStr, status);
283 chain_rule(fp, spaces6, mList._resultStr, cost, rule, operands_chained_from, status);
286 fprintf(fp, " }\n");
293 void ArchDesc::expand_opclass(FILE *fp, const char *indent, const Expr *cost,
298 if( debug_output ) { fprintf(fp, "// expand operand classes for operand: %s \n", (char *)op->_ident ); } // %%%%% Explanation
305 cost_check(fp, indent, ArchDesc::getMachOperEnum(oclass), cost, result_type, status);
311 void ArchDesc::chain_rule(FILE *fp, const char *indent, const char *operand,
320 if( debug_output ) { fprintf(fp, "// chain rules starting from: %s and %s \n", (char *)operand, (char *)irule); } // %%%%% Explanation
342 cost_check(fp, indent, ArchDesc::getMachOperEnum(result), total_cost, reduce_rule, status);
343 chain_rule(fp, indent, result, total_cost, irule, operands_chained_from, status);
347 cost_check(fp, indent, ArchDesc::getMachOperEnum(result), total_cost, rule, status);
348 chain_rule(fp, indent, result, total_cost, rule, operands_chained_from, status);
352 expand_opclass( fp, indent, total_cost, result, status );
373 void ArchDesc::buildDFA(FILE* fp) {
389 fprintf(fp, "\n");
390 fprintf(fp, "//------------------------- Source -----------------------------------------\n");
393 // _source.output(fp);
394 fprintf(fp, "\n");
395 fprintf(fp, "//------------------------- Attributes -------------------------------------\n");
396 _attributes.output(fp);
397 fprintf(fp, "\n");
398 fprintf(fp, "//------------------------- Macros -----------------------------------------\n");
401 fprintf(fp, "#define %s(result, rule, cost)\\\n", dfa_production);
402 fprintf(fp, " _cost[ (result) ] = cost; _rule[ (result) ] = rule;\n");
403 fprintf(fp, "\n");
407 fprintf(fp, "#define %s(result, rule, cost)\\\n", dfa_production_set_valid);
408 fprintf(fp, " %s( (result), (rule), (cost) ); STATE__SET_VALID( (result) );\n", dfa_production);
409 fprintf(fp, "\n");
411 fprintf(fp, "//------------------------- DFA --------------------------------------------\n");
413 fprintf(fp,
422 fprintf(fp, "\n");
423 fprintf(fp, "\n");
430 fprintf(fp, "void State::_sub_Op_%s(const Node *n){\n", NodeClassNames[i]);
432 gen_dfa_state_body(fp, minimize, status, operands_chained_from, i);
434 fprintf(fp, "}\n");
437 fprintf(fp, "bool State::DFA");
438 fprintf(fp, "(int opcode, const Node *n) {\n");
439 fprintf(fp, " switch(opcode) {\n");
446 fprintf(fp, " case Op_%s: { _sub_Op_%s(n);\n", NodeClassNames[i], NodeClassNames[i]);
448 fprintf(fp, " case Op_%s: {\n", NodeClassNames[i]);
450 gen_dfa_state_body(fp, minimize, status, operands_chained_from, i);
453 fprintf(fp, " break;\n");
454 fprintf(fp, " }\n");
458 fprintf(fp, " \n");
459 fprintf(fp, " default:\n");
460 fprintf(fp, " tty->print(\"Default case invoked for: \\n\");\n");
461 fprintf(fp, " tty->print(\" opcode = %cd, \\\"%cs\\\"\\n\", opcode, NodeClassNames[opcode]);\n", '%', '%');
462 fprintf(fp, " return false;\n");
463 fprintf(fp, " }\n");
466 fprintf(fp, " return true;\n");
468 fprintf(fp, "}\n");
571 static void generate_cse(FILE *fp) {
577 fprintf(fp, " %s %s = %s;\n", shared_pred_type, shared_pred_var, shared_pred);
593 void ArchDesc::gen_dfa_state_body(FILE* fp, Dict &minimize, ProductionState &status, Dict &operands_chained_from, int i) {
611 dfa_shared_preds::generate_cse(fp);
619 gen_match(fp, *mList, status, operands_chained_from);
625 if( debug_output1 ) { fprintf(fp, "// top level chain rules for: %s \n", (char *)NodeClassNames[i]); } // %%%%% Explanation
627 chain_rule(fp, " ", (char *)NodeClassNames[i], zeroCost, "Invalid",
783 void Expr::print_define(FILE *fp) const {
786 fprintf(fp, "#define %s (%s) \n", _external_name, _expr);
787 fprintf(fp, "// value == %d \n", _min_value);
790 void Expr::print_assert(FILE *fp) const {
793 fprintf(fp, " assert( %s == %d, \"Expect (%s) to equal %d\");\n", _external_name, _min_value, _expr, _min_value);
865 void ExprDict::print_defines(FILE *fp) {
866 fprintf(fp, "\n");
871 expr->print_define(fp);
874 void ExprDict::print_asserts(FILE *fp) {
875 fprintf(fp, "\n");
876 fprintf(fp, " // Following assertions generated from definition section\n");
881 expr->print_assert(fp);