Line 60... |
Line 60... |
#define MT_BURST 0x08 /* burst start & end markers */
|
#define MT_BURST 0x08 /* burst start & end markers */
|
#define MT_BURSTE 0x10
|
#define MT_BURSTE 0x10
|
#define MT_WRITE 0x20 /* This memory access does a write */
|
#define MT_WRITE 0x20 /* This memory access does a write */
|
#define MT_SIGNED 0x40 /* Signed memory access */
|
#define MT_SIGNED 0x40 /* Signed memory access */
|
|
|
|
#define MO_NONE 0 /* different memory ordering, even if there are dependencies,
|
|
burst can be made, width can change */
|
|
#define MO_WEAK 1 /* different memory ordering, if there cannot be dependencies,
|
|
burst can be made, width can change */
|
|
#define MO_STRONG 2 /* Same memory ordering, burst can be made, width can change */
|
|
#define MO_EXACT 3 /* Exacltly the same memory ordering and widths */
|
|
|
#define BB_INLOOP 0x01 /* This block is inside a loop */
|
#define BB_INLOOP 0x01 /* This block is inside a loop */
|
#define BB_OPTIONAL 0x02
|
#define BB_OPTIONAL 0x02
|
#define BB_END 0x04 /* Last block in a function */
|
#define BB_END 0x04 /* Last block in a function */
|
#define BB_DEAD 0x08 /* This block is unaccessible -> to be removed */
|
#define BB_DEAD 0x08 /* This block is unaccessible -> to be removed */
|
|
|
Line 78... |
Line 85... |
#define cucdebug(x,s...) {if ((x) <= cuc_debug) printf (s);}
|
#define cucdebug(x,s...) {if ((x) <= cuc_debug) printf (s);}
|
|
|
/* Options */
|
/* Options */
|
/* Whether we are debugging cuc (0-9) */
|
/* Whether we are debugging cuc (0-9) */
|
extern int cuc_debug;
|
extern int cuc_debug;
|
static const int calling_convention = 1;
|
|
static const int memory_order = 2;
|
|
static const int enable_bursts = 1;
|
|
static const int no_multicycle = 1;
|
|
|
|
/* Temporary registers by software convention */
|
/* Temporary registers by software convention */
|
extern const int call_saved[MAX_REGS];
|
extern const int call_saved[MAX_REGS];
|
|
|
typedef struct _dep_list_t {
|
typedef struct _dep_list_t {
|
Line 102... |
Line 105... |
int cmatch;
|
int cmatch;
|
int dead;
|
int dead;
|
int ninsn; /* Number of associated instructions */
|
int ninsn; /* Number of associated instructions */
|
struct _csm_list *from;
|
struct _csm_list *from;
|
struct _csm_list *next;
|
struct _csm_list *next;
|
} cuc_shared;
|
} cuc_shared_list;
|
|
|
|
/* Shared resource item definition */
|
|
typedef struct {
|
|
int ref;
|
|
int cmatch;
|
|
} cuc_shared_item;
|
|
|
/* Implementation specific timings */
|
/* Implementation specific timings */
|
typedef struct {
|
typedef struct {
|
int b; /* Basic block # this timing is referring to */
|
int b; /* Basic block # this timing is referring to */
|
int preroll; /* How many times was this BB pre/unrolled */
|
int preroll; /* How many times was this BB pre/unrolled */
|
int unroll;
|
int unroll;
|
int nshared;
|
int nshared;
|
int *shared; /* List of shared resources */
|
cuc_shared_item *shared; /* List of shared resources */
|
int new_time;
|
int new_time;
|
double size;
|
double size;
|
} cuc_timings;
|
} cuc_timings;
|
|
|
/* Instructionn entity */
|
/* Instructionn entity */
|
Line 140... |
Line 149... |
int last_used_reg[MAX_REGS];
|
int last_used_reg[MAX_REGS];
|
dep_list *mdep; /* Last memory access dependencies */
|
dep_list *mdep; /* Last memory access dependencies */
|
int nmemory;
|
int nmemory;
|
int cnt; /* how many times was this block executed */
|
int cnt; /* how many times was this block executed */
|
int unrolled; /* how many times has been this block unrolled */
|
int unrolled; /* how many times has been this block unrolled */
|
|
|
int ntim; /* Basic block options */
|
int ntim; /* Basic block options */
|
cuc_timings *tim;
|
cuc_timings *tim;
|
|
int selected_tim; /* Selected option, -1 if none */
|
} cuc_bb;
|
} cuc_bb;
|
|
|
/* Function entity */
|
/* Function entity */
|
typedef struct {
|
typedef struct {
|
/* Basic blocks */
|
/* Basic blocks */
|
Line 166... |
Line 177... |
int orig_time; /* time in cyc required for SW implementation */
|
int orig_time; /* time in cyc required for SW implementation */
|
int num_runs; /* Number times this function was run */
|
int num_runs; /* Number times this function was run */
|
cuc_timings timings; /* Base timings */
|
cuc_timings timings; /* Base timings */
|
unsigned long start_addr; /* Address of first instruction inn function */
|
unsigned long start_addr; /* Address of first instruction inn function */
|
unsigned long end_addr; /* Address of last instruction inn function */
|
unsigned long end_addr; /* Address of last instruction inn function */
|
|
int memory_order; /* Memory order */
|
} cuc_func;
|
} cuc_func;
|
|
|
/* Instructions from function */
|
/* Instructions from function */
|
extern cuc_insn insn[MAX_INSNS];
|
extern cuc_insn insn[MAX_INSNS];
|
extern int num_insn;
|
extern int num_insn;
|
extern int reloc[MAX_INSNS];
|
extern int reloc[MAX_INSNS];
|
extern FILE *flog;
|
extern FILE *flog;
|
|
|
/* Loads from file into global array insn */
|
/* Loads from file into global array insn */
|
void cuc_load (char *in_fn);
|
int cuc_load (char *in_fn);
|
|
|
/* Scans sequence of BBs and set bb[].cnt */
|
/* Scans sequence of BBs and set bb[].cnt */
|
void generate_bb_seq (cuc_func *f, char *mp_filename, char *bb_filename);
|
void generate_bb_seq (cuc_func *f, char *mp_filename, char *bb_filename);
|
|
|
/* Prints out instructions */
|
/* Prints out instructions */
|
Line 195... |
Line 207... |
void free_func (cuc_func *f);
|
void free_func (cuc_func *f);
|
|
|
/* Common subexpression elimination */
|
/* Common subexpression elimination */
|
void cse (cuc_func *f);
|
void cse (cuc_func *f);
|
|
|
/* Common subexpression matching -- resource sharing */
|
/* Common subexpression matching -- resource sharing, analysis pass */
|
void csm (cuc_func *f);
|
void csm (cuc_func *f);
|
|
|
|
/* Common subexpression matching -- resource sharing, generation pass */
|
|
void csm_gen (cuc_func *f, cuc_func *rf, cuc_shared_item *shared, int nshared);
|
|
|
/* Set the BB limits */
|
/* Set the BB limits */
|
void detect_bb (cuc_func *func);
|
void detect_bb (cuc_func *func);
|
|
|
/* Optimize basic blocks */
|
/* Optimize basic blocks */
|
void optimize_bb (cuc_func *func);
|
void optimize_bb (cuc_func *func);
|