00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LMDES_H
00019 #define LMDES_H
00020
00021 #include <stdio.h>
00022 #include "dynamic_symbol.h"
00023 #include "md.h"
00024
00025
00026
00027
00028 #define TAKE_MDES_STATS 0
00029
00030
00031 #define MDES_INFO(oper) ((Mdes_Info *)(oper->mdes_info))
00032
00033
00034 #define MDES_PRED 0
00035 #define MDES_DEST 1
00036 #define MDES_SRC 2
00037 #define MDES_SYNC_IN 3
00038 #define MDES_SYNC_OUT 4
00039
00040
00041 #define MDES_SUPERSCALAR 0
00042 #define MDES_VLIW 1
00043
00044
00045 #define MDES_OVERLAPPING_REQUEST 0x00000001
00046
00047 typedef struct mdes_IO_set_st
00048 {
00049 int id;
00050 int external_id;
00051 char *name;
00052 int *mask;
00053 } Mdes_IO_Set;
00054
00055 typedef struct mdes_IO_item_st
00056 {
00057 int id;
00058 char *name;
00059 Mdes_IO_Set **operand_type;
00060 } Mdes_IO_Item;
00061
00062 typedef struct mdes_resource_st
00063 {
00064 int id;
00065 char *name;
00066 } Mdes_Resource;
00067
00068 typedef struct mdes_rmask_st
00069 {
00070 int *uncond;
00071 int *pred;
00072 } Mdes_Rmask;
00073
00074 typedef struct mdes_Rused
00075 {
00076 int flags;
00077 int start_usage;
00078 int end_usage;
00079 int num_options;
00080 Mdes_Rmask *option;
00081 } Mdes_Rused;
00082
00083 typedef struct mdes_reslist_st
00084 {
00085 int id;
00086 char *name;
00087 int num_used;
00088 Mdes_Rused *used;
00089 int num_slot_options;
00090 int *slot_options;
00091 int num_RU_entries_required;
00092 } Mdes_ResList;
00093
00094 typedef struct mdes_latency_st
00095 {
00096 int id;
00097 char *name;
00098 int exception;
00099 int *operand_latency;
00100 } Mdes_Latency;
00101
00102 typedef struct mdes_alt_st
00103 {
00104 int id;
00105 char *asm_name;
00106 int alt_flags;
00107 struct mdes_operation_st *operation;
00108 Mdes_IO_Item *IO_item;
00109 Mdes_ResList *reslist;
00110 struct SM_Table *table;
00111 Mdes_Latency *latency;
00112 } Mdes_Alt;
00113
00114 typedef struct Mdes_Stats
00115 {
00116 double num_oper_checks;
00117 double num_oper_checks_failed;
00118 double num_table_checks;
00119 double num_table_checks_failed;
00120 double num_option_checks;
00121 double num_option_checks_failed;
00122 double num_usage_checks;
00123 double num_usage_checks_failed;
00124 double num_slot_checks;
00125 double num_slot_checks_failed;
00126 INT_Symbol_Table *first_choice_dist;
00127 INT_Symbol_Table *num_choice_dist;
00128 INT_Symbol_Table *succeed_first_choice_dist;
00129 INT_Symbol_Table *succeed_num_choice_dist;
00130 INT_Symbol_Table *succeed_option_check_dist;
00131 INT_Symbol_Table *fail_option_check_dist;
00132 INT_Symbol_Table *succeed_usage_check_dist;
00133 INT_Symbol_Table *fail_usage_check_dist;
00134 } Mdes_Stats;
00135
00136 typedef struct mdes_operation_st
00137 {
00138 int id;
00139 int opcode;
00140 char *external_name;
00141 int num_alts;
00142 Mdes_Alt *alt;
00143 int op_flags;
00144 int heuristic_alt;
00145
00146 #if TAKE_MDES_STATS
00147
00148 Mdes_Stats sched_prepass;
00149 Mdes_Stats sched_postpass;
00150 #endif
00151 } Mdes_Operation;
00152
00153 typedef struct mdes_st
00154 {
00155 char *file_name;
00156 int processor_model;
00157 int number[5];
00158 int offset[5];
00159 char *name[5];
00160 int operand_count;
00161 int latency_count;
00162 int num_slots;
00163 int max_slot;
00164 int IOmask_width;
00165 int num_reg_files;
00166 int max_IO_set_id;
00167 int null_external_id;
00168 Mdes_IO_Set **IO_set_table;
00169 int num_IO_sets;
00170 Mdes_IO_Set *IO_set;
00171 int num_IO_items;
00172 Mdes_IO_Item *IO_item;
00173 int num_resources;
00174 Mdes_Resource *resource;
00175 int num_reslists;
00176 int Rmask_width;
00177 Mdes_ResList *reslist;
00178 int num_latencies;
00179 Mdes_Latency *latency;
00180 int num_operations;
00181 Mdes_Operation *operation;
00182 int max_opcode;
00183 Mdes_Operation **op_table;
00184 Mdes_IO_Set **operand_type_buf;
00185 int *index_type;
00186 int *index_number;
00187
00188
00189 struct Mdes2 *mdes2;
00190
00191
00192
00193
00194
00195
00196
00197
00198 int check_resources_for_only_one_alt;
00199 } Mdes;
00200
00201 typedef struct mdes_compatable_alt_st
00202 {
00203 Mdes_Alt *alt;
00204 struct mdes_compatable_alt_st *next;
00205 } Mdes_Compatable_Alt;
00206
00207 typedef struct Mdes_Info
00208 {
00209 int opcode;
00210 int num_compatable_alts;
00211 Mdes_Compatable_Alt *compatable_alts;
00212 } Mdes_Info;
00213
00214
00215 #define mdes_processor_model() lmdes->processor_model
00216 #define mdes_total_slots() lmdes->num_slots
00217
00218 #ifdef __cplusplus
00219 extern "C" {
00220 #endif
00221
00222
00223 extern Mdes *lmdes;
00224
00225
00226 extern void L_init_lmdes (char *mdes_file_name, int num_pred, int num_dest,
00227 int num_src, int num_sync);
00228 extern void print_mdes ( FILE *out, Mdes *mdes );
00229 extern int lmdes_initialized (void);
00230
00231 extern Mdes_Info *build_mdes_info (unsigned int opcode, int *io_list);
00232 extern void free_mdes_info (Mdes_Info *info);
00233
00234 extern void print_mdes_operand_name ( FILE *out, Mdes *mdes, unsigned int index );
00235 extern void mdes_print_IO_set (FILE *out, unsigned int id);
00236
00237 extern int mdes_defined_opcode (unsigned int opcode);
00238
00239 extern int op_flag_set (unsigned int opcode, int mask);
00240 extern int alt_flag_set (unsigned int opcode, unsigned int alt_no, int mask);
00241 extern int any_alt_flag_set (Mdes_Info *mdes_info, int mask);
00242
00243 extern int mdes_max_opcode (void);
00244 extern int mdes_operand_count (void);
00245 extern int mdes_latency_count (void);
00246 extern int mdes_num_operands (unsigned int operand_type);
00247 extern int mdes_null_operand ( void );
00248
00249
00250
00251 extern int operand_index (unsigned int operand_type, unsigned int operand_number);
00252
00253 extern int operand_type (unsigned int operand_index);
00254 extern int operand_number (unsigned int operand_index);
00255
00256 extern int max_operand_time (Mdes_Info *mdes_info, int operand_index);
00257 extern int min_operand_time (Mdes_Info *mdes_info, int operand_index);
00258
00259 extern int mdes_calc_min_ready_time (Mdes_Info *mdes_info, int *ready_time);
00260
00261 extern int mdes_operand_latency (unsigned int opcode, unsigned int alt_no,
00262 unsigned int operand_index);
00263
00264 extern int mdes_max_completion_time (int opcode, int alt_no);
00265 extern int mdes_heuristic_alt_id (int opcode);
00266
00267 extern Mdes *load_lmdes_from_version2 (char *mdes_file_name, int num_pred,
00268 int num_dest, int num_src,
00269 int num_sync);
00270 extern void Malloc_struct (void **ptr, int size);
00271 extern void Malloc_name (char **ptr, char *name);
00272 extern void M_punt (char *format, ...);
00273 extern void print_mdes_stats (FILE *out, int prepass);
00274 extern void increment_check_history (INT_Symbol_Table *table, int num_checks,
00275 int inc);
00276 extern int get_int_parm (MD *md, char *parm_name);
00277 #ifdef __cplusplus
00278 }
00279 #endif
00280
00281 #endif