Line 1... |
Line 1... |
/* cuc.h -- OpenRISC Custom Unit Compiler, main header file
|
/* cuc.h -- OpenRISC Custom Unit Compiler, main header file
|
* Copyright (C) 2002 Marko Mlinar, markom@opencores.org
|
|
*
|
|
* This file is part of OpenRISC 1000 Architectural Simulator.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
#ifndef __DATAF_H__
|
Copyright (C) 2002 Marko Mlinar, markom@opencores.org
|
#define __DATAF_H__
|
Copyright (C) 2008 Embecosm Limited
|
|
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
|
This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
/* This program is commented throughout in a fashion suitable for processing
|
|
with Doxygen. */
|
|
|
|
|
|
#ifndef CUC__H
|
|
#define CUC__H
|
|
|
|
/* Package includes */
|
|
#include "abstract.h"
|
|
|
|
|
/* Maximum number of instructions per function */
|
/* Maximum number of instructions per function */
|
#define MAX_INSNS 0x10000
|
#define MAX_INSNS 0x10000
|
#define MAX_BB 0x1000
|
#define MAX_BB 0x1000
|
#define MAX_REGS 34
|
#define MAX_REGS 34
|
Line 102... |
Line 113... |
extern int cuc_debug;
|
extern int cuc_debug;
|
|
|
/* Temporary registers by software convention */
|
/* Temporary registers by software convention */
|
extern const int caller_saved[MAX_REGS];
|
extern const int caller_saved[MAX_REGS];
|
|
|
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 */
|
/* Shared list, if marked dead, entry is not used */
|
typedef struct _csm_list {
|
typedef struct _csm_list
|
|
{
|
int ref;
|
int ref;
|
int cnt;
|
int cnt;
|
int cmovs;
|
int cmovs;
|
double size, osize;
|
double size, osize;
|
int cmatch;
|
int cmatch;
|
Line 121... |
Line 134... |
struct _csm_list *from;
|
struct _csm_list *from;
|
struct _csm_list *next;
|
struct _csm_list *next;
|
} cuc_shared_list;
|
} cuc_shared_list;
|
|
|
/* Shared resource item definition */
|
/* Shared resource item definition */
|
typedef struct {
|
typedef struct
|
|
{
|
int ref;
|
int ref;
|
int cmatch;
|
int cmatch;
|
} cuc_shared_item;
|
} 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;
|
cuc_shared_item *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 */
|
typedef struct {
|
typedef struct
|
|
{
|
int type; /* type of the instruction */
|
int type; /* type of the instruction */
|
int index; /* Instruction index */
|
int index; /* Instruction index */
|
int opt[MAX_OPERANDS]; /* operand types */
|
int opt[MAX_OPERANDS]; /* operand types */
|
unsigned long op[MAX_OPERANDS]; /* operand values */
|
unsigned long op[MAX_OPERANDS]; /* operand values */
|
dep_list *dep; /* instruction dependencies */
|
dep_list *dep; /* instruction dependencies */
|
Line 151... |
Line 167... |
unsigned long max; /* max result value */
|
unsigned long max; /* max result value */
|
int tmp;
|
int tmp;
|
} cuc_insn;
|
} cuc_insn;
|
|
|
/* Basic block entity */
|
/* Basic block entity */
|
typedef struct {
|
typedef struct
|
|
{
|
unsigned long type; /* Type of the bb */
|
unsigned long type; /* Type of the bb */
|
int first, last; /* Where this block lies */
|
int first, last; /* Where this block lies */
|
int prev[2], next[2];
|
int prev[2], next[2];
|
int tmp;
|
int tmp;
|
cuc_insn *insn; /* Instructions lie here */
|
cuc_insn *insn; /* Instructions lie here */
|
Line 170... |
Line 187... |
cuc_timings *tim;
|
cuc_timings *tim;
|
int selected_tim; /* Selected option, -1 if none */
|
int selected_tim; /* Selected option, -1 if none */
|
} cuc_bb;
|
} cuc_bb;
|
|
|
/* Function entity */
|
/* Function entity */
|
typedef struct _cuc_func {
|
typedef struct _cuc_func
|
|
{
|
/* 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];/* Whether this register was saved */
|
int saved_regs[MAX_REGS];/* Whether this register was saved */
|
int lur[MAX_REGS]; /* Location of last use */
|
int lur[MAX_REGS]; /* Location of last use */
|
Line 233... |
Line 251... |
|
|
/* Common subexpression matching -- resource sharing, analysis pass */
|
/* Common subexpression matching -- resource sharing, analysis pass */
|
void csm (cuc_func *f);
|
void csm (cuc_func *f);
|
|
|
/* Common subexpression matching -- resource sharing, generation pass */
|
/* Common subexpression matching -- resource sharing, generation pass */
|
void csm_gen (cuc_func *f, cuc_func *rf, cuc_shared_item *shared, int nshared);
|
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 */
|
Line 273... |
Line 292... |
/* Cuts the tree and marks registers */
|
/* Cuts the tree and marks registers */
|
void mark_cut (cuc_func *f);
|
void mark_cut (cuc_func *f);
|
|
|
/* Unroll loop b times times and return new function. Original
|
/* Unroll loop b times times and return new function. Original
|
function is unmodified. */
|
function is unmodified. */
|
cuc_func *preunroll_loop (cuc_func *func, int b, int preroll, int unroll, char *bb_filename);
|
cuc_func *preunroll_loop (cuc_func * func, int b, int preroll, int unroll,
|
|
char *bb_filename);
|
|
|
/* Clean memory and data dependencies */
|
/* Clean memory and data dependencies */
|
void clean_deps (cuc_func *func);
|
void clean_deps (cuc_func *func);
|
|
|
/* Schedule memory accesses
|
/* Schedule memory accesses
|
0 - exact; 1 - strong; 2 - weak; 3 - none */
|
0 - exact; 1 - strong; 2 - weak; 3 - none */
|
int schedule_memory (cuc_func *func, int otype);
|
int schedule_memory (cuc_func *func, int otype);
|
|
|
/* Generates verilog file out of insn dataflow */
|
|
void output_verilog (cuc_func *func, char *filename, char *funcname);
|
|
|
|
/* Recalculates bb[].cnt values, based on generated profile file */
|
/* Recalculates bb[].cnt values, based on generated profile file */
|
void recalc_cnts (cuc_func *f, char *bb_filename);
|
void recalc_cnts (cuc_func *f, char *bb_filename);
|
|
|
/* Calculate timings */
|
/* Calculate timings */
|
void analyse_timings (cuc_func *func, cuc_timings *timings);
|
void analyse_timings (cuc_func *func, cuc_timings *timings);
|
Line 318... |
Line 335... |
void add_latches(cuc_func *f);
|
void add_latches(cuc_func *f);
|
|
|
/* split the BB, based on the group numbers in .tmp */
|
/* split the BB, based on the group numbers in .tmp */
|
void expand_bb (cuc_func *f, int b);
|
void expand_bb (cuc_func *f, int b);
|
|
|
void generate_main(int nfuncs, cuc_func **f, char *filename);
|
|
|
|
void add_dep(dep_list **list, int dep);
|
void add_dep(dep_list **list, int dep);
|
|
|
void dispose_list(dep_list **list);
|
void dispose_list(dep_list **list);
|
|
|
void main_cuc(char *filename);
|
void main_cuc(char *filename);
|
|
|
void add_data_dep(cuc_func *f);
|
void add_data_dep(cuc_func *f);
|
#endif /* __DATAF_H__ */
|
|
|
void reg_cuc_sec ();
|
|
|
|
#endif /* CUC__H */
|
|
|
No newline at end of file
|
No newline at end of file
|