Line 18... |
Line 18... |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
#ifndef __DATAF_H__
|
#ifndef __DATAF_H__
|
#define __DATAF_H__
|
#define __DATAF_H__
|
|
|
#define DEBUG 0
|
|
|
|
/* Maximum number of instructions per function */
|
/* Maximum number of instructions per function */
|
#define MAX_INSNS 0x10000
|
#define MAX_INSNS 0x10000
|
#define MAX_OPERANDS 4
|
#define MAX_OPERANDS 4
|
#define MAX_BB 0x100
|
#define MAX_BB 0x100
|
#define MAX_REGS 34
|
#define MAX_REGS 34
|
Line 75... |
Line 73... |
#define REF_I(r) ((r) % MAX_INSNS)
|
#define REF_I(r) ((r) % MAX_INSNS)
|
#define INSN(ref) bb[REF_BB(ref)].insn[REF_I(ref)]
|
#define INSN(ref) bb[REF_BB(ref)].insn[REF_I(ref)]
|
|
|
#define log(x...) fprintf (flog, x)
|
#define log(x...) fprintf (flog, x)
|
|
|
|
#define cucdebug(x,s...) {if ((x) <= cuc_debug) printf (s);}
|
|
|
/* Options */
|
/* Options */
|
|
/* Whether we are debugging cuc (0-9) */
|
|
extern int cuc_debug;
|
static const int calling_convention = 1;
|
static const int calling_convention = 1;
|
static const int memory_order = 2;
|
static const int memory_order = 2;
|
static const int enable_bursts = 1;
|
static const int enable_bursts = 1;
|
static const int no_multicycle = 1;
|
static const int no_multicycle = 1;
|
|
|
Line 89... |
Line 91... |
typedef struct _dep_list_t {
|
typedef struct _dep_list_t {
|
unsigned long ref;
|
unsigned long ref;
|
struct _dep_list_t *next;
|
struct _dep_list_t *next;
|
} dep_list;
|
} dep_list;
|
|
|
|
/* Shared list, if marked dead, entry is not used */
|
|
typedef struct _csm_list {
|
|
int ref;
|
|
int cnt;
|
|
int cmovs;
|
|
double size, osize;
|
|
int cmatch;
|
|
int dead;
|
|
int ninsn; /* Number of associated instructions */
|
|
struct _csm_list *from;
|
|
struct _csm_list *next;
|
|
} cuc_shared;
|
|
|
/* 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 *shared; /* List of shared resources */
|
int new_time;
|
int new_time;
|
int old_time;
|
|
double size;
|
double size;
|
} cuc_timings;
|
} cuc_timings;
|
|
|
/* Instructionn entity */
|
/* Instructionn entity */
|
typedef struct {
|
typedef struct {
|
Line 133... |
Line 149... |
/* Function entity */
|
/* Function entity */
|
typedef struct {
|
typedef struct {
|
/* Basic blocks */
|
/* Basic blocks */
|
int num_bb;
|
int num_bb;
|
cuc_bb bb[MAX_BB];
|
cuc_bb bb[MAX_BB];
|
int saved_regs[MAX_REGS];
|
int saved_regs[MAX_REGS];/* Whether this register was saved */
|
|
int lur[MAX_REGS]; /* Location of last use */
|
|
int used_regs[MAX_REGS]; /* Nonzero if it was used */
|
|
|
/* Schedule of memory instructions */
|
/* Schedule of memory instructions */
|
int nmsched;
|
int nmsched;
|
int msched[MAX_INSNS];
|
int msched[MAX_INSNS];
|
int mtype[MAX_INSNS];
|
int mtype[MAX_INSNS];
|
|
|
/* initial bb and their relocations to new block numbers */
|
/* initial bb and their relocations to new block numbers */
|
int num_init_bb;
|
int num_init_bb;
|
int *init_bb_reloc;
|
int *init_bb_reloc;
|
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 */
|
|
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 */
|
} cuc_func;
|
} cuc_func;
|
|
|
/* Instructions from function */
|
/* Instructions from function */
|
Line 172... |
Line 192... |
cuc_func *dup_func (cuc_func *f);
|
cuc_func *dup_func (cuc_func *f);
|
|
|
/* Releases memory allocated by function */
|
/* Releases memory allocated by function */
|
void free_func (cuc_func *f);
|
void free_func (cuc_func *f);
|
|
|
|
/* Common subexpression elimination */
|
|
void cse (cuc_func *f);
|
|
|
|
/* Common subexpression matching -- resource sharing */
|
|
void csm (cuc_func *f);
|
|
|
/* 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);
|