/*-------------------------------------------------------------------------*/ /* Prolog To Wam Compiler INRIA Rocquencourt - CLoE Project */ /* C Run-time Daniel Diaz - 1994 */ /* */ /* GCC and WAM Configuration */ /* */ /* configure.c */ /*-------------------------------------------------------------------------*/ #include #include #include #include #include #define CONFIGURE #include "bool.h" #include "machine.h" /*---------------------------------*/ /* Constants */ /*---------------------------------*/ #define ARITY_SIZE 8 /* also in atom_prd.h */ #define WORD_SIZE (sizeof(long)*8) /*---------------------------------*/ /* Type Definitions */ /*---------------------------------*/ typedef struct { char type[32]; char name[32]; }RegInf; typedef enum { INTEGER, UNSIGNED, STACK, MALLOC }TypTag; typedef struct { char name[32]; TypTag type; char cast[32]; }TagInf; typedef struct { char name[32]; int def_size; char top_macro[128]; }StackInf; /*---------------------------------*/ /* Global Variables */ /*---------------------------------*/ char save_str[256]; /*---------------------------------*/ /* Function Prototypes */ /*---------------------------------*/ void Generate_Gcc (int nb_of_used_regs); int Generate_Archi (void); char *Read_Identifier (char *s,Bool fail_if_error,char **end); int Read_Integer (char *s,char **end); int Generate_Regs (FILE *f,FILE *g); void Generate_Tags (FILE *f,FILE *g); void Generate_Stacks (FILE *f,FILE *g); void Fatal_Error (char *format,...); /*-------------------------------------------------------------------------*/ /* MAIN */ /* */ /*-------------------------------------------------------------------------*/ main() { #ifndef M_MACHINE printf("Error: unsupported machine\n"); exit(-1); #else char *used_regs[]=M_USED_REGS; int nb_of_used_regs; int i; printf("\t-------------------------------\n"); printf("Configuring %s for %s\n",COMPILER,M_MACHINE); nb_of_used_regs=Generate_Archi(); Generate_Gcc(nb_of_used_regs); printf("size of machine words : %d bits\n",WORD_SIZE); printf("register used : "); for(i=0;itype,dp->name,*p++); if (!*p) fprintf(g,"\n\n"); } else fprintf(g,"#define %s\t\t\t((%s)\t (reg_bank[%s%d]))\n", dp->name,dp->type,offset,nb_not_alloc++); } fprintf(g,"\n\n"); fprintf(g,"#define NB_OF_REGS \t%d\n",total_nb_reg); fprintf(g,"#define NB_OF_ALLOC_REGS \t%d\n",total_nb_reg-nb_not_alloc); fprintf(g,"#define NB_OF_NOT_ALLOC_REGS\t%d\n",nb_not_alloc); fprintf(g,"#define REG_BANK_SIZE \t(%sNB_OF_NOT_ALLOC_REGS)\n",offset); fprintf(g,"\n\n"); fprintf(g,"#define Reg(i)\t\t\t("); k=0; for(i=0;i<10;i++) for(j=0;jname); else fprintf(g," (WamWord) %s)\n",dp->name); } fprintf(g,"\n"); fprintf(g,"#ifdef WAM_ENGINE\n\n"); fprintf(g," char *reg_tbl[]=\t{"); k=0; for(i=0;i<10;i++) for(j=0;jname,k> %d)))\n", tag_size); fprintf(g,"#define UnTag_Unsigned(w)\t((unsigned) (((unsigned long) (w) >> %d)))\n", tag_size); fprintf(g,"#define UnTag_Stack(w) \t((WamWord *) (((unsigned long) (w) >> %d) | STACK_MASK))\n", tag_size); fprintf(g,"#define UnTag_Malloc(w) \t((unsigned long) (((unsigned long) (w) >> %d) | MALLOC_MASK))\n", tag_size); fprintf(g,"\n"); fprintf(g,"#define NB_OF_TAGS \t%d\n\n",nb_tag); for(i=0;i