00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "properties_gen.h"
00043
00044 static const char * const description[] = {
00045 " /* ====================================================================\n\
00046 * ====================================================================\n\
00047 *\n\
00048 * Description:\n\
00049 *\n\
00050 * A description of the properties (attributes) for the instructions\n\
00051 * in the ISA. The description exports the following:\n\
00052 *\n\
00053 * BOOL TOP_is_xxx(TOP topcode)\n\
00054 * Return true/false if 'topcode' has/does-not-have the property\n\
00055 * 'xxx'.\n\
00056 *\n\
00057 * ====================================================================\n\
00058 * ====================================================================\n\
00059 */", NULL};
00060
00061 void Properties_Generator(void *pknobs, GEN_MODE mode)
00062 {
00063 int prop_index, prop_count, false_prop_count;
00064 int op_index, op_count;
00065 FILE *c_file, *h_file, *export_file;
00066 char *prop_name;
00067 UINT64 prop_value;
00068 char suffix_UINT64[10] = "ULL";
00069
00070 #ifdef TARG_WIN
00071 strcpy(suffix_UINT64, "mUI64");
00072 #endif
00073 Init_Module_Files(mode, "targ_isa_properties", &c_file, &h_file, &export_file);
00074 Emit_Header(h_file, "targ_isa_properties", description);
00075 fprintf(c_file, "#include \"targ_isa_properties.h\"\n");
00076
00077 fprintf(h_file, "extern const mUINT64 ISA_PROPERTIES_flags[];\n\n");
00078 fprintf(c_file, "\nconst mUINT64 ISA_PROPERTIES_flags[] = {\n");
00079 fprintf(export_file, "ISA_PROPERTIES_flags\n");
00080
00081 prop_count = EKAPI_OppCount(pknobs);
00082
00083 for(prop_index=0; prop_index<prop_count; prop_index++ )
00084 {
00085 char *buf = EKAPI_Oppid2Name(pknobs, prop_index);
00086 Is_True(buf, ("op prop name return NULL"));
00087
00088 if (strstr(buf, "OPP_")) {
00089 prop_name =buf + strlen("OPP_");
00090 }
00091 prop_value = 1ULL << prop_index;
00092 fprintf(h_file, "#define PROP_%-16s 0x%llx%s\n",
00093 prop_name,
00094 prop_value,
00095 suffix_UINT64
00096 );
00097 free(buf);
00098 }
00099 fprintf(h_file, "\n\n");
00100
00101
00102 for(prop_index=0; prop_index<prop_count; prop_index++ )
00103 {
00104 char *buf = EKAPI_Oppid2Name(pknobs, prop_index);
00105 Is_True(buf, ("op properties name return NULL"));
00106
00107 if (strstr(buf, "OPP_")) {
00108 prop_name =buf + strlen("OPP_");
00109 }
00110
00111 fprintf(h_file, "#define TOP_is_%s(t) (ISA_PROPERTIES_flags[(INT)t] & PROP_%s)\n",
00112 prop_name,
00113 prop_name
00114 );
00115
00116 free(buf);
00117 }
00118 fprintf(h_file, "\n");
00119
00120
00121 false_prop_count = EKAPI_FalseOppCount(pknobs);
00122 for(prop_index=0; prop_index<false_prop_count; prop_index++ )
00123 {
00124 char *buf = EKAPI_FalseOppid2Name(pknobs, prop_index);
00125 Is_True(buf, ("op flase properties name return NULL"));
00126
00127 if (strstr(buf, "OPP_")) {
00128 prop_name =buf + strlen("OPP_");
00129 }
00130
00131 fprintf(h_file, "#define TOP_is_%s(t) (FALSE)\n",
00132 prop_name
00133 );
00134 free(buf);
00135 }
00136
00137
00138
00139 op_count = EKAPI_OpCount(pknobs);
00140 for (op_index=0; op_index<op_count; op_index++)
00141 {
00142 char comment[200]="";
00143 UINT64 flag = EKAPI_OppMask4op(pknobs, op_index);
00144
00145
00146 sprintf(comment, "/* %s:", EKAPI_OpName4id(pknobs, op_index));
00147 for(prop_index=0; prop_index<prop_count; prop_index++)
00148 {
00149
00150 if (flag & (1 << prop_index)) {
00151 char *buf = EKAPI_Oppid2Name(pknobs, prop_index);
00152 Is_True(buf, ("Op name return NULL"));
00153
00154 if (strstr(buf, "OPP_")) {
00155 prop_name =buf + strlen("OPP_");
00156 }
00157 strcat(comment, " ");
00158 strcat(comment, prop_name);
00159 free(buf);
00160 }
00161
00162 }
00163 strcat(comment," */" );
00164 fprintf(c_file," 0x%016llx%s, %s\n", flag, suffix_UINT64, comment);
00165 }
00166 fprintf(c_file, "};\n");
00167
00168 Emit_Tailer(h_file);
00169 Close_Module_Files(mode, &c_file, &h_file, &export_file);
00170 }