Lines Matching defs:fp_cpp
184 void ArchDesc::build_register_masks(FILE *fp_cpp) {
189 fprintf(fp_cpp,"\n");
190 fprintf(fp_cpp,"// Register masks, one for each register class.\n");
203 fprintf(fp_cpp, "const RegMask _%s%s_mask(", prefix, rc_name_to_upper);
208 fprintf(fp_cpp," 0x%x,", reg_class->regs_in_word(i, false));
210 fprintf(fp_cpp," 0x%x );\n", reg_class->regs_in_word(i, false));
215 fprintf(fp_cpp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, rc_name_to_upper);
217 fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i, true));
219 fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i, true));
227 static int pipeline_reads_initializer(FILE *fp_cpp, NameList &pipeline_reads, PipeClassForm *pipeclass)
287 fprintf(fp_cpp, "static const enum machPipelineStages pipeline_reads_%03d[%d] = {\n%s};\n\n",
298 FILE *fp_cpp,
362 fprintf(fp_cpp, "static const enum machPipelineStages pipeline_res_stages_%03d[%d] = {\n%s};\n\n",
375 FILE *fp_cpp,
433 fprintf(fp_cpp, "static const uint pipeline_res_cycles_%03d[%d] = {\n%s};\n\n",
448 FILE *fp_cpp,
580 fprintf(fp_cpp, "static const Pipeline_Use_Element pipeline_res_mask_%03d[%d] = {\n%s};\n\n",
601 void ArchDesc::build_pipe_classes(FILE *fp_cpp) {
615 fprintf(fp_cpp, "uint Node::latency(uint i) const {\n");
616 fprintf(fp_cpp, " // assert(false, \"pipeline functionality is not defined\");\n");
617 fprintf(fp_cpp, " return %d;\n", non_operand_latency);
618 fprintf(fp_cpp, "}\n");
622 fprintf(fp_cpp, "\n");
623 fprintf(fp_cpp, "//------------------Pipeline Methods-----------------------------------------\n");
624 fprintf(fp_cpp, "#ifndef PRODUCT\n");
625 fprintf(fp_cpp, "const char * Pipeline::stageName(uint s) {\n");
626 fprintf(fp_cpp, " static const char * const _stage_names[] = {\n");
627 fprintf(fp_cpp, " \"undefined\"");
630 fprintf(fp_cpp, ", \"%s\"", _pipeline->_stages.name(s));
632 fprintf(fp_cpp, "\n };\n\n");
633 fprintf(fp_cpp, " return (s <= %d ? _stage_names[s] : \"???\");\n",
635 fprintf(fp_cpp, "}\n");
636 fprintf(fp_cpp, "#endif\n\n");
638 fprintf(fp_cpp, "uint Pipeline::functional_unit_latency(uint start, const Pipeline *pred) const {\n");
639 fprintf(fp_cpp, " // See if the functional units overlap\n");
641 fprintf(fp_cpp, "\n#ifndef PRODUCT\n");
642 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
643 fprintf(fp_cpp, " tty->print(\"# functional_unit_latency: start == %%d, this->exclusively == 0x%%03x, pred->exclusively == 0x%%03x\\n\", start, resourcesUsedExclusively(), pred->resourcesUsedExclusively());\n");
644 fprintf(fp_cpp, " }\n");
645 fprintf(fp_cpp, "#endif\n\n");
647 fprintf(fp_cpp, " uint mask = resourcesUsedExclusively() & pred->resourcesUsedExclusively();\n");
648 fprintf(fp_cpp, " if (mask == 0)\n return (start);\n\n");
650 fprintf(fp_cpp, "\n#ifndef PRODUCT\n");
651 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
652 fprintf(fp_cpp, " tty->print(\"# functional_unit_latency: mask == 0x%%x\\n\", mask);\n");
653 fprintf(fp_cpp, " }\n");
654 fprintf(fp_cpp, "#endif\n\n");
656 fprintf(fp_cpp, " for (uint i = 0; i < pred->resourceUseCount(); i++) {\n");
657 fprintf(fp_cpp, " const Pipeline_Use_Element *predUse = pred->resourceUseElement(i);\n");
658 fprintf(fp_cpp, " if (predUse->multiple())\n");
659 fprintf(fp_cpp, " continue;\n\n");
660 fprintf(fp_cpp, " for (uint j = 0; j < resourceUseCount(); j++) {\n");
661 fprintf(fp_cpp, " const Pipeline_Use_Element *currUse = resourceUseElement(j);\n");
662 fprintf(fp_cpp, " if (currUse->multiple())\n");
663 fprintf(fp_cpp, " continue;\n\n");
664 fprintf(fp_cpp, " if (predUse->used() & currUse->used()) {\n");
665 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask x = predUse->mask();\n");
666 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask y = currUse->mask();\n\n");
667 fprintf(fp_cpp, " for ( y <<= start; x.overlaps(y); start++ )\n");
668 fprintf(fp_cpp, " y <<= 1;\n");
669 fprintf(fp_cpp, " }\n");
670 fprintf(fp_cpp, " }\n");
671 fprintf(fp_cpp, " }\n\n");
672 fprintf(fp_cpp, " // There is the potential for overlap\n");
673 fprintf(fp_cpp, " return (start);\n");
674 fprintf(fp_cpp, "}\n\n");
675 fprintf(fp_cpp, "// The following two routines assume that the root Pipeline_Use entity\n");
676 fprintf(fp_cpp, "// consists of exactly 1 element for each functional unit\n");
677 fprintf(fp_cpp, "// start is relative to the current cycle; used for latency-based info\n");
678 fprintf(fp_cpp, "uint Pipeline_Use::full_latency(uint delay, const Pipeline_Use &pred) const {\n");
679 fprintf(fp_cpp, " for (uint i = 0; i < pred._count; i++) {\n");
680 fprintf(fp_cpp, " const Pipeline_Use_Element *predUse = pred.element(i);\n");
681 fprintf(fp_cpp, " if (predUse->_multiple) {\n");
682 fprintf(fp_cpp, " uint min_delay = %d;\n",
684 fprintf(fp_cpp, " // Multiple possible functional units, choose first unused one\n");
685 fprintf(fp_cpp, " for (uint j = predUse->_lb; j <= predUse->_ub; j++) {\n");
686 fprintf(fp_cpp, " const Pipeline_Use_Element *currUse = element(j);\n");
687 fprintf(fp_cpp, " uint curr_delay = delay;\n");
688 fprintf(fp_cpp, " if (predUse->_used & currUse->_used) {\n");
689 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask x = predUse->_mask;\n");
690 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask y = currUse->_mask;\n\n");
691 fprintf(fp_cpp, " for ( y <<= curr_delay; x.overlaps(y); curr_delay++ )\n");
692 fprintf(fp_cpp, " y <<= 1;\n");
693 fprintf(fp_cpp, " }\n");
694 fprintf(fp_cpp, " if (min_delay > curr_delay)\n min_delay = curr_delay;\n");
695 fprintf(fp_cpp, " }\n");
696 fprintf(fp_cpp, " if (delay < min_delay)\n delay = min_delay;\n");
697 fprintf(fp_cpp, " }\n");
698 fprintf(fp_cpp, " else {\n");
699 fprintf(fp_cpp, " for (uint j = predUse->_lb; j <= predUse->_ub; j++) {\n");
700 fprintf(fp_cpp, " const Pipeline_Use_Element *currUse = element(j);\n");
701 fprintf(fp_cpp, " if (predUse->_used & currUse->_used) {\n");
702 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask x = predUse->_mask;\n");
703 fprintf(fp_cpp, " Pipeline_Use_Cycle_Mask y = currUse->_mask;\n\n");
704 fprintf(fp_cpp, " for ( y <<= delay; x.overlaps(y); delay++ )\n");
705 fprintf(fp_cpp, " y <<= 1;\n");
706 fprintf(fp_cpp, " }\n");
707 fprintf(fp_cpp, " }\n");
708 fprintf(fp_cpp, " }\n");
709 fprintf(fp_cpp, " }\n\n");
710 fprintf(fp_cpp, " return (delay);\n");
711 fprintf(fp_cpp, "}\n\n");
712 fprintf(fp_cpp, "void Pipeline_Use::add_usage(const Pipeline_Use &pred) {\n");
713 fprintf(fp_cpp, " for (uint i = 0; i < pred._count; i++) {\n");
714 fprintf(fp_cpp, " const Pipeline_Use_Element *predUse = pred.element(i);\n");
715 fprintf(fp_cpp, " if (predUse->_multiple) {\n");
716 fprintf(fp_cpp, " // Multiple possible functional units, choose first unused one\n");
717 fprintf(fp_cpp, " for (uint j = predUse->_lb; j <= predUse->_ub; j++) {\n");
718 fprintf(fp_cpp, " Pipeline_Use_Element *currUse = element(j);\n");
719 fprintf(fp_cpp, " if ( !predUse->_mask.overlaps(currUse->_mask) ) {\n");
720 fprintf(fp_cpp, " currUse->_used |= (1 << j);\n");
721 fprintf(fp_cpp, " _resources_used |= (1 << j);\n");
722 fprintf(fp_cpp, " currUse->_mask.Or(predUse->_mask);\n");
723 fprintf(fp_cpp, " break;\n");
724 fprintf(fp_cpp, " }\n");
725 fprintf(fp_cpp, " }\n");
726 fprintf(fp_cpp, " }\n");
727 fprintf(fp_cpp, " else {\n");
728 fprintf(fp_cpp, " for (uint j = predUse->_lb; j <= predUse->_ub; j++) {\n");
729 fprintf(fp_cpp, " Pipeline_Use_Element *currUse = element(j);\n");
730 fprintf(fp_cpp, " currUse->_used |= (1 << j);\n");
731 fprintf(fp_cpp, " _resources_used |= (1 << j);\n");
732 fprintf(fp_cpp, " currUse->_mask.Or(predUse->_mask);\n");
733 fprintf(fp_cpp, " }\n");
734 fprintf(fp_cpp, " }\n");
735 fprintf(fp_cpp, " }\n");
736 fprintf(fp_cpp, "}\n\n");
738 fprintf(fp_cpp, "uint Pipeline::operand_latency(uint opnd, const Pipeline *pred) const {\n");
739 fprintf(fp_cpp, " int const default_latency = 1;\n");
740 fprintf(fp_cpp, "\n");
742 fprintf(fp_cpp, "#ifndef PRODUCT\n");
743 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
744 fprintf(fp_cpp, " tty->print(\"# operand_latency(%%d), _read_stage_count = %%d\\n\", opnd, _read_stage_count);\n");
745 fprintf(fp_cpp, " }\n");
746 fprintf(fp_cpp, "#endif\n\n");
748 fprintf(fp_cpp, " assert(this, \"NULL pipeline info\");\n");
749 fprintf(fp_cpp, " assert(pred, \"NULL predecessor pipline info\");\n\n");
750 fprintf(fp_cpp, " if (pred->hasFixedLatency())\n return (pred->fixedLatency());\n\n");
751 fprintf(fp_cpp, " // If this is not an operand, then assume a dependence with 0 latency\n");
752 fprintf(fp_cpp, " if (opnd > _read_stage_count)\n return (0);\n\n");
753 fprintf(fp_cpp, " uint writeStage = pred->_write_stage;\n");
754 fprintf(fp_cpp, " uint readStage = _read_stages[opnd-1];\n");
756 fprintf(fp_cpp, "\n#ifndef PRODUCT\n");
757 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
758 fprintf(fp_cpp, " tty->print(\"# operand_latency: writeStage=%%s readStage=%%s, opnd=%%d\\n\", stageName(writeStage), stageName(readStage), opnd);\n");
759 fprintf(fp_cpp, " }\n");
760 fprintf(fp_cpp, "#endif\n\n");
762 fprintf(fp_cpp, "\n");
763 fprintf(fp_cpp, " if (writeStage == stage_undefined || readStage == stage_undefined)\n");
764 fprintf(fp_cpp, " return (default_latency);\n");
765 fprintf(fp_cpp, "\n");
766 fprintf(fp_cpp, " int delta = writeStage - readStage;\n");
767 fprintf(fp_cpp, " if (delta < 0) delta = 0;\n\n");
769 fprintf(fp_cpp, "\n#ifndef PRODUCT\n");
770 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
771 fprintf(fp_cpp, " tty->print(\"# operand_latency: delta=%%d\\n\", delta);\n");
772 fprintf(fp_cpp, " }\n");
773 fprintf(fp_cpp, "#endif\n\n");
775 fprintf(fp_cpp, " return (delta);\n");
776 fprintf(fp_cpp, "}\n\n");
788 fprintf(fp_cpp, "Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &in1, const Pipeline_Use_Cycle_Mask &in2) {\n");
789 fprintf(fp_cpp, " return Pipeline_Use_Cycle_Mask(in1._mask & in2._mask);\n");
790 fprintf(fp_cpp, "}\n\n");
791 fprintf(fp_cpp, "Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &in1, const Pipeline_Use_Cycle_Mask &in2) {\n");
792 fprintf(fp_cpp, " return Pipeline_Use_Cycle_Mask(in1._mask | in2._mask);\n");
793 fprintf(fp_cpp, "}\n\n");
798 fprintf(fp_cpp, "Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &in1, const Pipeline_Use_Cycle_Mask &in2) {\n");
799 fprintf(fp_cpp, " return Pipeline_Use_Cycle_Mask(");
801 fprintf(fp_cpp, "in1._mask%d & in2._mask%d%s\n", l, l, l < masklen ? ", " : "");
802 fprintf(fp_cpp, ");\n");
803 fprintf(fp_cpp, "}\n\n");
804 fprintf(fp_cpp, "Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &in1, const Pipeline_Use_Cycle_Mask &in2) {\n");
805 fprintf(fp_cpp, " return Pipeline_Use_Cycle_Mask(");
807 fprintf(fp_cpp, "in1._mask%d | in2._mask%d%s", l, l, l < masklen ? ", " : "");
808 fprintf(fp_cpp, ");\n");
809 fprintf(fp_cpp, "}\n\n");
810 fprintf(fp_cpp, "void Pipeline_Use_Cycle_Mask::Or(const Pipeline_Use_Cycle_Mask &in2) {\n ");
812 fprintf(fp_cpp, " _mask%d |= in2._mask%d;", l, l);
813 fprintf(fp_cpp, "\n}\n\n");
823 fprintf(fp_cpp, "static const Pipeline pipeline_class_Zero_Instructions(0, 0, true, 0, 0, false, false, false, false, NULL, NULL, NULL, Pipeline_Use(0, 0, 0, NULL));\n\n");
824 fprintf(fp_cpp, "static const Pipeline pipeline_class_Unknown_Instructions(0, 0, true, 0, 0, false, true, true, false, NULL, NULL, NULL, Pipeline_Use(0, 0, 0, NULL));\n\n");
826 fprintf(fp_cpp, "const Pipeline_Use_Element Pipeline_Use::elaborated_elements[%d] = {\n", _pipeline->_rescount);
828 fprintf(fp_cpp, " Pipeline_Use_Element(0, %d, %d, false, Pipeline_Use_Cycle_Mask(", i1, i1);
831 fprintf(fp_cpp, "0%s", i2 > 0 ? ", " : "");
832 fprintf(fp_cpp, "))%s\n", i1 < (_pipeline->_rescount-1) ? "," : "");
834 fprintf(fp_cpp, "};\n\n");
836 fprintf(fp_cpp, "const Pipeline_Use Pipeline_Use::elaborated_use(0, 0, %d, (Pipeline_Use_Element *)&elaborated_elements[0]);\n\n",
840 fprintf(fp_cpp, "\n");
841 fprintf(fp_cpp, "// Pipeline Class \"%s\"\n", classname);
872 int pipeline_reads_index = pipeline_reads_initializer(fp_cpp, pipeline_reads, pipeclass);
875 fp_cpp, _pipeline, pipeline_res_stages, pipeclass);
878 fp_cpp, _pipeline, pipeline_res_cycles, pipeclass);
881 fp_cpp, _pipeline, pipeline_res_masks, pipeline_res_args, pipeclass);
901 fprintf(fp_cpp, "static const uint pipeline_res_or_masks_%03d[%d] = {",
908 fprintf(fp_cpp, " 0x%0*x%c", resource_count, used_mask, i < (int)resource_groups ? ',' : ' ');
911 fprintf(fp_cpp, "};\n\n");
916 fprintf(fp_cpp, "static const Pipeline pipeline_class_%03d(",
919 fprintf(fp_cpp, "(uint)stage_undefined");
921 fprintf(fp_cpp, "(uint)stage_%s", _pipeline->_stages.name(maxWriteStage));
923 fprintf(fp_cpp, "((uint)stage_%s)+%d", _pipeline->_stages.name(maxWriteStage), maxMoreInstrs);
924 fprintf(fp_cpp, ", %d, %s, %d, %d, %s, %s, %s, %s,\n",
934 fprintf(fp_cpp, "\n (enum machPipelineStages * const) pipeline_reads_%03d,\n ",
938 fprintf(fp_cpp, " NULL,");
939 fprintf(fp_cpp, " (enum machPipelineStages * const) pipeline_res_stages_%03d,\n",
941 fprintf(fp_cpp, " (uint * const) pipeline_res_cycles_%03d,\n",
943 fprintf(fp_cpp, " Pipeline_Use(%s, (Pipeline_Use_Element *)",
946 fprintf(fp_cpp, "&pipeline_res_mask_%03d[0]",
949 fprintf(fp_cpp, "NULL");
950 fprintf(fp_cpp, "));\n");
954 fprintf(fp_cpp, "\n");
955 fprintf(fp_cpp, "//------------------Inter-Instruction Latency--------------------------------\n");
956 fprintf(fp_cpp, "uint Node::latency(uint i) {\n");
959 fprintf(fp_cpp, "#ifndef PRODUCT\n");
960 fprintf(fp_cpp, " if (TraceOptoOutput) {\n");
961 fprintf(fp_cpp, " tty->print(\"# %%4d->latency(%%d)\\n\", _idx, i);\n");
962 fprintf(fp_cpp, " }\n");
963 fprintf(fp_cpp, "#endif\n");
965 fprintf(fp_cpp, " uint j;\n");
966 fprintf(fp_cpp, " // verify in legal range for inputs\n");
967 fprintf(fp_cpp, " assert(i < len(), \"index not in range\");\n\n");
968 fprintf(fp_cpp, " // verify input is not null\n");
969 fprintf(fp_cpp, " Node *pred = in(i);\n");
970 fprintf(fp_cpp, " if (!pred)\n return %d;\n\n",
972 fprintf(fp_cpp, " if (pred->is_Proj())\n pred = pred->in(0);\n\n");
973 fprintf(fp_cpp, " // if either node does not have pipeline info, use default\n");
974 fprintf(fp_cpp, " const Pipeline *predpipe = pred->pipeline();\n");
975 fprintf(fp_cpp, " assert(predpipe, \"no predecessor pipeline info\");\n\n");
976 fprintf(fp_cpp, " if (predpipe->hasFixedLatency())\n return predpipe->fixedLatency();\n\n");
977 fprintf(fp_cpp, " const Pipeline *currpipe = pipeline();\n");
978 fprintf(fp_cpp, " assert(currpipe, \"no pipeline info\");\n\n");
979 fprintf(fp_cpp, " if (!is_Mach())\n return %d;\n\n",
981 fprintf(fp_cpp, " const MachNode *m = as_Mach();\n");
982 fprintf(fp_cpp, " j = m->oper_input_base();\n");
983 fprintf(fp_cpp, " if (i < j)\n return currpipe->functional_unit_latency(%d, predpipe);\n\n",
985 fprintf(fp_cpp, " // determine which operand this is in\n");
986 fprintf(fp_cpp, " uint n = m->num_opnds();\n");
987 fprintf(fp_cpp, " int delta = %d;\n\n",
989 fprintf(fp_cpp, " uint k;\n");
990 fprintf(fp_cpp, " for (k = 1; k < n; k++) {\n");
991 fprintf(fp_cpp, " j += m->_opnds[k]->num_edges();\n");
992 fprintf(fp_cpp, " if (i < j)\n");
993 fprintf(fp_cpp, " break;\n");
994 fprintf(fp_cpp, " }\n");
995 fprintf(fp_cpp, " if (k < n)\n");
996 fprintf(fp_cpp, " delta = currpipe->operand_latency(k,predpipe);\n\n");
997 fprintf(fp_cpp, " return currpipe->functional_unit_latency(delta, predpipe);\n");
1000 fprintf(fp_cpp, " // assert(false, \"pipeline functionality is not defined\");\n");
1001 fprintf(fp_cpp, " return %d;\n",
1004 fprintf(fp_cpp, "}\n\n");
1007 fprintf(fp_cpp, "// Descriptions for emitting different functional unit nops\n");
1012 fprintf(fp_cpp, "void Bundle::initialize_nops(MachNode * nop_list[%d], Compile *C) {\n", nopcnt);
1015 fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new (C) %sNode();\n", i, nop);
1017 fprintf(fp_cpp, "};\n\n");
1018 fprintf(fp_cpp, "#ifndef PRODUCT\n");
1019 fprintf(fp_cpp, "void Bundle::dump(outputStream *st) const {\n");
1020 fprintf(fp_cpp, " static const char * bundle_flags[] = {\n");
1021 fprintf(fp_cpp, " \"\",\n");
1022 fprintf(fp_cpp, " \"use nop delay\",\n");
1023 fprintf(fp_cpp, " \"use unconditional delay\",\n");
1024 fprintf(fp_cpp, " \"use conditional delay\",\n");
1025 fprintf(fp_cpp, " \"used in conditional delay\",\n");
1026 fprintf(fp_cpp, " \"used in unconditional delay\",\n");
1027 fprintf(fp_cpp, " \"used in all conditional delays\",\n");
1028 fprintf(fp_cpp, " };\n\n");
1030 fprintf(fp_cpp, " static const char *resource_names[%d] = {", _pipeline->_rescount);
1032 fprintf(fp_cpp, " \"%s\"%c", _pipeline->_reslist.name(i), i < _pipeline->_rescount-1 ? ',' : ' ');
1033 fprintf(fp_cpp, "};\n\n");
1036 fprintf(fp_cpp, " bool needs_comma = false;\n\n");
1037 fprintf(fp_cpp, " if (_flags) {\n");
1038 fprintf(fp_cpp, " st->print(\"%%s\", bundle_flags[_flags]);\n");
1039 fprintf(fp_cpp, " needs_comma = true;\n");
1040 fprintf(fp_cpp, " };\n");
1041 fprintf(fp_cpp, " if (instr_count()) {\n");
1042 fprintf(fp_cpp, " st->print(\"%%s%%d instr%%s\", needs_comma ? \", \" : \"\", instr_count(), instr_count() != 1 ? \"s\" : \"\");\n");
1043 fprintf(fp_cpp, " needs_comma = true;\n");
1044 fprintf(fp_cpp, " };\n");
1045 fprintf(fp_cpp, " uint r = resources_used();\n");
1046 fprintf(fp_cpp, " if (r) {\n");
1047 fprintf(fp_cpp, " st->print(\"%%sresource%%s:\", needs_comma ? \", \" : \"\", (r & (r-1)) != 0 ? \"s\" : \"\");\n");
1048 fprintf(fp_cpp, " for (uint i = 0; i < %d; i++)\n", _pipeline->_rescount);
1049 fprintf(fp_cpp, " if ((r & (1 << i)) != 0)\n");
1050 fprintf(fp_cpp, " st->print(\" %%s\", resource_names[i]);\n");
1051 fprintf(fp_cpp, " needs_comma = true;\n");
1052 fprintf(fp_cpp, " };\n");
1053 fprintf(fp_cpp, " st->print(\"\\n\");\n");
1054 fprintf(fp_cpp, "}\n");
1055 fprintf(fp_cpp, "#endif\n");
2926 static void define_fill_new_machnode(bool used, FILE *fp_cpp) {
2927 fprintf(fp_cpp, "\n");
2928 fprintf(fp_cpp, "// Copy _idx, inputs and operands to new node\n");
2929 fprintf(fp_cpp, "void MachNode::fill_new_machnode( MachNode* node, Compile* C) const {\n");
2931 fprintf(fp_cpp, " // This architecture does not have cisc or short branch instructions\n");
2932 fprintf(fp_cpp, " ShouldNotCallThis();\n");
2933 fprintf(fp_cpp, "}\n");
2936 fprintf(fp_cpp, " // New node must use same node index\n");
2937 fprintf(fp_cpp, " node->set_idx( _idx );\n");
2939 fprintf(fp_cpp, " // Copy machine-independent inputs\n");
2940 fprintf(fp_cpp, " for( uint j = 0; j < req(); j++ ) {\n");
2941 fprintf(fp_cpp, " node->add_req(in(j));\n");
2942 fprintf(fp_cpp, " }\n");
2944 fprintf(fp_cpp, " // Copy my operands, except for cisc position\n");
2945 fprintf(fp_cpp, " int nopnds = num_opnds();\n");
2946 fprintf(fp_cpp, " assert( node->num_opnds() == (uint)nopnds, \"Must have same number of operands\");\n");
2947 fprintf(fp_cpp, " MachOper **to = node->_opnds;\n");
2948 fprintf(fp_cpp, " for( int i = 0; i < nopnds; i++ ) {\n");
2949 fprintf(fp_cpp, " if( i != cisc_operand() ) \n");
2950 fprintf(fp_cpp, " to[i] = _opnds[i]->clone(C);\n");
2951 fprintf(fp_cpp, " }\n");
2952 fprintf(fp_cpp, "}\n");
2954 fprintf(fp_cpp, "\n");
3393 FILE *fp_cpp = map.def_file();
3401 fprintf(fp_cpp,"\n");
3412 fprintf(fp_cpp, " /* %4d */", idx); map.map(*op); fprintf(fp_cpp, ",\n");
3415 fprintf(fp_cpp, " // last operand\n");
3421 fprintf(fp_cpp, " /* %4d */", idx); map.map(*opc); fprintf(fp_cpp, ",\n");
3424 fprintf(fp_cpp, " // last operand class\n");
3431 fprintf(fp_cpp, " /* %4d */", idx); map.map(name); fprintf(fp_cpp, ",\n");
3434 fprintf(fp_cpp, " // last internally defined operand\n");
3449 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3460 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3474 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3485 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3489 fprintf(fp_cpp, " // last instruction\n");
3511 void ArchDesc::generate_adlc_verification(FILE *fp_cpp) {
3512 fprintf(fp_cpp, "\n");
3514 fprintf(fp_cpp, "#ifndef PRODUCT\n");
3515 fprintf(fp_cpp, "void Compile::adlc_verification() {\n");
3516 globalDefs().print_asserts(fp_cpp);
3517 fprintf(fp_cpp, "}\n");
3518 fprintf(fp_cpp, "#endif\n");
3519 fprintf(fp_cpp, "\n");
3523 void ArchDesc::addSourceBlocks(FILE *fp_cpp) {
3525 _source.output(fp_cpp);
3527 generate_adlc_verification(fp_cpp);
3546 void ArchDesc::buildReduceMaps(FILE *fp_hpp, FILE *fp_cpp) {
3560 fprintf(fp_cpp, "// Map from machine-independent register number to register_save_policy\n");
3561 fprintf(fp_cpp, "const char register_save_policy[] = {\n");
3567 fprintf(fp_cpp, " '%c'%s // %s\n", policy, comma, rdef->_regname);
3569 fprintf(fp_cpp, "};\n\n");
3572 fprintf(fp_cpp, "// Map from machine-independent register number to c_reg_save_policy\n");
3573 fprintf(fp_cpp, "const char c_reg_save_policy[] = {\n");
3579 fprintf(fp_cpp, " '%c'%s // %s\n", policy, comma, rdef->_regname);
3581 fprintf(fp_cpp, "};\n\n");
3584 fprintf(fp_cpp, "// Map from machine-independent register number to register_save_type\n");
3585 fprintf(fp_cpp, "const int register_save_type[] = {\n");
3590 fprintf(fp_cpp, " %s%s\n", rdef->_idealtype, comma);
3592 fprintf(fp_cpp, "};\n\n");
3595 OutputReduceOp output_reduce_op(fp_hpp, fp_cpp, _globalNames, *this);
3598 OutputLeftOp output_left_op(fp_hpp, fp_cpp, _globalNames, *this);
3601 OutputRightOp output_right_op(fp_hpp, fp_cpp, _globalNames, *this);
3604 OutputRuleName output_rule_name(fp_hpp, fp_cpp, _globalNames, *this);
3607 OutputSwallowed output_swallowed(fp_hpp, fp_cpp, _globalNames, *this);
3611 //OutputInstChainRule output_inst_chain(fp_hpp, fp_cpp, _globalNames, *this);
3702 void ArchDesc::buildMachOperGenerator(FILE *fp_cpp) {
3706 fprintf(fp_cpp, "\n");
3707 fprintf(fp_cpp, "\n");
3708 fprintf(fp_cpp,
3710 fprintf(fp_cpp,
3713 fprintf(fp_cpp, "\n");
3714 fprintf(fp_cpp, "MachOper *State::MachOperGenerator");
3715 fprintf(fp_cpp, "(int opcode, Compile* C)");
3716 fprintf(fp_cpp, "{\n");
3717 fprintf(fp_cpp, "\n");
3718 fprintf(fp_cpp, " switch(opcode) {\n");
3728 genMachOperCase(fp_cpp, _globalNames, *this, *op);
3739 fprintf(fp_cpp, " case %s:", opEnumName);
3740 fprintf(fp_cpp, " return NULL;\n");
3744 fprintf(fp_cpp, " \n");
3745 fprintf(fp_cpp, " default:\n");
3746 fprintf(fp_cpp, " fprintf(stderr, \"Default MachOper Generator invoked for: \\n\");\n");
3747 fprintf(fp_cpp, " fprintf(stderr, \" opcode = %cd\\n\", opcode);\n", '%');
3748 fprintf(fp_cpp, " break;\n");
3749 fprintf(fp_cpp, " }\n");
3752 fprintf(fp_cpp, " return NULL;\n");
3753 fprintf(fp_cpp, "};\n");
3759 void ArchDesc::buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *indent) {
3764 fprintf(fp_cpp, "%s %sNode *node = new (C) %sNode();\n",indent, opClass,opClass);
3790 fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index);
3791 fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode);
3800 fprintf(fp_cpp, "%s node->_opnd_array[%d] = ", indent,
3806 fprintf(fp_cpp, "new (C) %sOper(", opName);
3813 path_to_constant(fp_cpp, _globalNames, op->_matrule, i);
3815 fprintf(fp_cpp, ", ");
3816 path_to_constant(fp_cpp, _globalNames, op->_matrule, i);
3819 fprintf(fp_cpp, " );\n");
3825 fprintf(fp_cpp, "%s node->_bottom_type = _leaf->bottom_type();\n", indent);
3828 fprintf(fp_cpp, "%s node->_prob = _leaf->as_If()->_prob;\n", indent);
3829 fprintf(fp_cpp, "%s node->_fcnt = _leaf->as_If()->_fcnt;\n", indent);
3832 fprintf(fp_cpp, "%s node->_counters = _leaf->as_FastLock()->counters();\n", indent);
3853 bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) {
3864 fprintf(fp_cpp, "\n");
3865 fprintf(fp_cpp, "void %sNode::use_cisc_RegMask() {\n", this->_ident);
3868 fprintf(fp_cpp, " _cisc_RegMask = &STACK_OR_%s;\n", reg_mask_name);
3869 fprintf(fp_cpp, "}\n");
3872 fprintf(fp_cpp, "\n");
3873 fprintf(fp_cpp, "// Build CISC version of this instruction\n");
3874 fprintf(fp_cpp, "MachNode *%sNode::cisc_version( int offset, Compile* C ) {\n", this->_ident);
3876 fprintf(fp_cpp, " %sNode *node = new (C) %sNode();\n", name, name);
3879 fprintf(fp_cpp, " node->_bottom_type = bottom_type();\n");
3884 fprintf(fp_cpp," node->_num_opnds = %d;\n", num_unique_opnds());
3887 fprintf(fp_cpp, "\n");
3888 fprintf(fp_cpp, " // Copy _idx, inputs and operands to new node\n");
3889 fprintf(fp_cpp, " fill_new_machnode(node, C);\n");
3891 fprintf(fp_cpp, " // Construct operand to access [stack_pointer + offset]\n");
3892 fprintf(fp_cpp, " node->set_opnd_array(cisc_operand(), new (C) %sOper(offset));\n", cisc_oper_name);
3893 fprintf(fp_cpp, "\n");
3896 fprintf(fp_cpp, " return node;\n");
3897 fprintf(fp_cpp, "}\n");
3898 fprintf(fp_cpp, "\n");
3914 bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) {
3920 fprintf(fp_cpp, "// Build short branch version of this instruction\n");
3921 fprintf(fp_cpp, "MachNode *%sNode::short_branch_version(Compile* C) {\n", this->_ident);
3923 fprintf(fp_cpp, " %sNode *node = new (C) %sNode();\n", name, name);
3925 fprintf(fp_cpp, " node->_prob = _prob;\n");
3926 fprintf(fp_cpp, " node->_fcnt = _fcnt;\n");
3930 fprintf(fp_cpp, " node->_bottom_type = bottom_type();\n");
3933 fprintf(fp_cpp, "\n");
3936 fprintf(fp_cpp, " // Copy _idx, inputs and operands to new node\n");
3937 fprintf(fp_cpp, " fill_new_machnode(node, C);\n");
3940 fprintf(fp_cpp, " return node;\n");
3941 fprintf(fp_cpp, "}\n");
3942 fprintf(fp_cpp,"\n");
3951 void ArchDesc::buildMachNodeGenerator(FILE *fp_cpp) {
3954 fprintf(fp_cpp, "\n");
3955 fprintf(fp_cpp, "\n");
3956 fprintf(fp_cpp,
3958 fprintf(fp_cpp,
3961 fprintf(fp_cpp, "\n");
3962 fprintf(fp_cpp, "MachNode *State::MachNodeGenerator");
3963 fprintf(fp_cpp, "(int opcode, Compile* C)");
3964 fprintf(fp_cpp, "{\n");
3965 fprintf(fp_cpp, " switch(opcode) {\n");
3980 fprintf(fp_cpp, " case %s_rule:", opClass);
3983 fprintf(fp_cpp, " {\n");
3985 buildMachNode(fp_cpp, inst, " ");
3987 fprintf(fp_cpp, " return node;\n");
3988 fprintf(fp_cpp, " }\n");
3992 fprintf(fp_cpp, " \n");
3993 fprintf(fp_cpp, " default:\n");
3994 fprintf(fp_cpp, " fprintf(stderr, \"Default MachNode Generator invoked for: \\n\");\n");
3995 fprintf(fp_cpp, " fprintf(stderr, \" opcode = %cd\\n\", opcode);\n", '%');
3996 fprintf(fp_cpp, " break;\n");
3997 fprintf(fp_cpp, " };\n");
4000 fprintf(fp_cpp, " return NULL;\n");
4001 fprintf(fp_cpp, "}\n");
4008 void ArchDesc::buildInstructMatchCheck(FILE *fp_cpp) const {
4009 fprintf(fp_cpp, "\n\n");
4010 fprintf(fp_cpp, "const bool Matcher::has_match_rule(int opcode) {\n");
4011 fprintf(fp_cpp, " assert(_last_machine_leaf < opcode && opcode < _last_opcode, \"opcode in range\");\n");
4012 fprintf(fp_cpp, " return _hasMatchRule[opcode];\n");
4013 fprintf(fp_cpp, "}\n\n");
4015 fprintf(fp_cpp, "const bool Matcher::_hasMatchRule[_last_opcode] = {\n");
4018 fprintf(fp_cpp, " %-5s, // %s\n",
4022 fprintf(fp_cpp, " %-5s // %s\n",
4025 fprintf(fp_cpp, "};\n");
4030 void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
4031 fprintf(fp_cpp,"\n\n");
4033 fprintf(fp_cpp,"bool Matcher::stack_direction() const { return %s; }\n\n",
4036 fprintf(fp_cpp,"int Compile::sync_stack_slots() const { return %s; }\n\n",
4039 fprintf(fp_cpp,"uint Matcher::stack_alignment_in_bytes() { return %s; }\n\n",
4042 fprintf(fp_cpp,"OptoReg::Name Matcher::return_addr() const {");
4044 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4048 fprintf(fp_cpp," return OptoReg::stack2reg(%s); }\n\n",
4052 fprintf(fp_cpp,"uint Compile::in_preserve_stack_slots() ");
4053 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_in_preserve_slots);
4055 fprintf(fp_cpp,"uint Compile::out_preserve_stack_slots() ");
4056 fprintf(fp_cpp,"{ return SharedRuntime::out_preserve_stack_slots(); }\n\n");
4058 fprintf(fp_cpp,"uint Compile::varargs_C_out_slots_killed() const ");
4059 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_varargs_C_out_slots_killed);
4061 fprintf(fp_cpp,"void Matcher::calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length, bool is_outgoing) {\n");
4062 fprintf(fp_cpp,"%s\n", _frame->_calling_convention);
4063 fprintf(fp_cpp,"}\n\n");
4065 fprintf(fp_cpp,"void Matcher::c_calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length) {\n");
4066 fprintf(fp_cpp,"%s\n", _frame->_c_calling_convention);
4067 fprintf(fp_cpp,"}\n\n");
4069 fprintf(fp_cpp,"OptoRegPair Matcher::return_value(int ideal_reg, bool is_outgoing) {\n");
4070 fprintf(fp_cpp,"%s\n", _frame->_return_value);
4071 fprintf(fp_cpp,"}\n\n");
4073 fprintf(fp_cpp,"OptoRegPair Matcher::c_return_value(int ideal_reg, bool is_outgoing) {\n");
4074 fprintf(fp_cpp,"%s\n", _frame->_c_return_value);
4075 fprintf(fp_cpp,"}\n\n");
4078 fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {");
4079 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4081 fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {");
4082 fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n");
4085 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {");
4086 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4088 fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {");
4089 fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n");
4092 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {");
4094 fprintf(fp_cpp," return OptoReg::Bad; }\n\n");
4096 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4102 fprintf(fp_cpp,"OptoReg::Name Matcher::frame_pointer() const {");
4103 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4107 fprintf(fp_cpp,"OptoReg::Name Matcher::c_frame_pointer() const {");
4108 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4112 fprintf(fp_cpp, "// Number of callee-save + always-save registers\n");
4113 fprintf(fp_cpp, "int Matcher::number_of_saved_registers() {\n");
4121 fprintf(fp_cpp, " return %d;\n", nof_saved_registers);
4122 fprintf(fp_cpp, "};\n\n");
4206 void ArchDesc::build_cisc_spill_instructions(FILE *fp_hpp, FILE *fp_cpp) {
4208 fprintf(fp_cpp, "// The following instructions can cisc-spill\n");
4218 fprintf(fp_cpp, "// %s can cisc-spill operand %d to %s\n", inst->_ident, operand, inst2->_ident);
4221 fprintf(fp_cpp, "\n\n");