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 "proc_gen_new.h"
00043
00044 static const char* const description[]= {
00045 "/* ====================================================================",
00046 " * ====================================================================",
00047 " *",
00048 " * Description:",
00049 " *",
00050 " * A description of the PROC (actually just an enum of all the processors).",
00051 " * The description exports the following:",
00052 " *",
00053 " * typedef (enum) PROCESSOR",
00054 " * Contains all the target processors. Their names have the form",
00055 " * PROCESSOR_<name>.",
00056 " *",
00057 " * const PROCESSOR PROCESSOR_UNDEFINED",
00058 " * Useful value guaranteed not to be a valid PROCESSOR.",
00059 " *",
00060 " * const int PROCESSOR_count",
00061 " * Gives the number of processors.",
00062 " *",
00063 " * PROCESSOR PROCESSOR_Value",
00064 " * The current processor.",
00065 " *",
00066 " * const char* PROCESSOR_Name(PROCESSOR topcode)",
00067 " * Returns a name for the given PROCESSOR.",
00068 " *",
00069 " * ====================================================================",
00070 " * ====================================================================",
00071 " */", NULL};
00072
00073 void Proc_Generator(void *pknobs, GEN_MODE mode)
00074 {
00075 FILE *c_file, *h_file, *export_file;
00076 int op_index;
00077
00078 Init_Module_Files(mode, "targ_proc", &c_file, &h_file, &export_file);
00079 Emit_Header(h_file, "targ_proc", description);
00080 fprintf(c_file, "#include \"targ_proc.h\"\n\n");
00081
00082 fprintf(h_file, "typedef enum processor {\n");
00083 fprintf(c_file, "static const char* const processor_names[] = {\n");
00084 char * buf = EKAPI_ProcessName(pknobs);
00085 fprintf(c_file, " \"%s\",\n", buf);
00086 fprintf(h_file, " PROCESSOR_%s,\n", buf);
00087 fprintf(c_file, " \"UNDEFINED\"\n};\n\n");
00088 fprintf(h_file, " PROCESSOR_UNDEFINED\n} PROCESSOR;\n\n");
00089 fprintf(h_file, "#define PROCESSOR_count %d\n\n", 1);
00090 fprintf(c_file,
00091 "PROCESSOR PROCESSOR_Value = PROCESSOR_UNDEFINED;\n\n"
00092 "const char* PROCESSOR_Name(PROCESSOR proc)\n"
00093 "{\n"
00094 " return processor_names[(int)proc];\n"
00095 "}\n");
00096 fprintf(h_file,
00097 "extern PROCESSOR PROCESSOR_Value;\n\n"
00098 "extern const char* PROCESSOR_Name(PROCESSOR proc);\n");
00099 fprintf(export_file, "PROCESSOR_Name\n");
00100
00101 Emit_Tailer(h_file);
00102 Close_Module_Files(mode, &c_file, &h_file, &export_file);
00103 }
00104