1 ;/* SDCCglobl.h - global macros etc required by all files */
13 # include "sdccconf.h"
19 # define NATIVE_WIN32 1
23 #define NATIVE_WIN32 1
27 #define NATIVE_WIN32 1
33 #define MAX_FNAME_LEN 128
34 #define MAX_REG_PARMS 1
38 #define max(a,b) (a > b ? a : b)
42 #define min(a,b) (a < b ? a : b)
54 #define CHARSIZE port->s.char_size
55 #define SHORTSIZE port->s.short_size
56 #define INTSIZE port->s.int_size
57 #define LONGSIZE port->s.long_size
58 #define PTRSIZE port->s.ptr_size
59 #define FPTRSIZE port->s.fptr_size
60 #define GPTRSIZE port->s.gptr_size
61 #define BITSIZE port->s.bit_size
62 #define FLOATSIZE port->s.float_size
63 #define MAXBASESIZE port->s.max_base_size
66 #define PRAGMA_SAVE "SAVE"
67 #define PRAGMA_RESTORE "RESTORE"
68 #define PRAGMA_NOINDUCTION "NOINDUCTION"
69 #define PRAGMA_NOINVARIANT "NOINVARIANT"
70 #define PRAGMA_NOLOOPREV "NOLOOPREVERSE"
71 #define PRAGMA_INDUCTION "INDUCTION"
72 #define PRAGMA_STACKAUTO "STACKAUTO"
73 #define PRAGMA_NOJTBOUND "NOJTBOUND"
74 #define PRAGMA_NOGCSE "NOGCSE"
75 #define PRAGMA_NOOVERLAY "NOOVERLAY"
76 #define PRAGMA_CALLEESAVES "CALLEE-SAVES"
77 #define PRAGMA_EXCLUDE "EXCLUDE"
78 #define PRAGMA_NOREGPARMS "NOREGPARMS"
85 #define MAX_INLINEASM 4*1024
86 #define DEFPOOLSTACK(type,size) \
88 type *type##FreeStack [size] ; \
89 int type##StackPtr = 0 ;
91 #define ALLOC(x,sz) if (!(x = calloc(1, sz))) \
93 werror(E_OUT_OF_MEM,__FILE__,(long) sz);\
98 #define ALLOCTYPE(type,size) if (!(type##Pool = calloc(1, size*sizeof(type))))\
100 werror(E_OUT_OF_MEM,__FILE__,(long) size); \
104 #define PUSH(x,y) x##FreeStack[x##StackPtr++] = y
105 #define PEEK(x) x##FreeStack[x##StackPtr-1]
106 #define POP(type) type##FreeStack[--type##StackPtr]
107 /* #define POP(x) (x##StackPtr ? x##FreeStack[--x##StackPtr] : \
108 (assert(x##StackPtr),0)) */
110 #define EMPTY(x) (x##StackPtr <= 1 ? 1 : 0)
112 #define EMPTY(x) (x##StackPtr == 0 ? 1 : 0)
116 #define COPYTYPE(start,end,from) (end = getSpec (start = from))
119 /* generalpurpose stack related macros */
120 #define STACK_DCL(stack,type,size) \
121 typedef type t_##stack ; \
122 t_##stack stack[size] ; \
123 t_##stack (*p_##stack) = stack + (size); \
125 /* define extern stack */
126 #define EXTERN_STACK_DCL(stack,type,size) \
127 typedef type t_##stack ; \
128 extern t_##stack stack[size] ; \
129 extern t_##stack *p_##stack;
131 #define STACK_FULL(stack) ((p_##stack) <= stack )
132 #define STACK_EMPTY(stack) ((p_##stack) >= (stack + \
133 sizeof(stack)/sizeof(*stack)) )
135 #define STACK_PUSH_(stack,x) (*--p_##stack = (x))
136 #define STACK_POP_(stack) (*p_##stack++)
138 #define STACK_PUSH(stack,x) (STACK_FULL(stack) \
139 ?((t_##stack)(long)(STACK_ERR(1))) \
140 : STACK_PUSH_(stack,x) )
142 #define STACK_POP(stack) (STACK_EMPTY(stack) \
143 ?((t_##stack)(long)(STACK_ERR(0))) \
144 : STACK_POP_(stack) )
146 #define STACK_PEEK(stack) (STACK_EMPTY(stack) \
147 ?((t_##stack) NULL) \
150 #define STACK_ERR(o) ( o \
151 ? fprintf(stderr,"stack Overflow\n")\
152 : fprintf(stderr,"stack underflow\n"))
154 /* optimization options */
156 unsigned global_cse : 1 ;
157 unsigned ptrArithmetic :1;
158 unsigned label1 : 1 ;
159 unsigned label2 : 1 ;
160 unsigned label3 : 1 ;
161 unsigned label4 : 1 ;
162 unsigned loopInvariant: 1;
163 unsigned loopInduction: 1;
164 unsigned noJTabBoundary:1;
165 unsigned noLoopReverse :1;
169 Used in options.model.A bit each as port.supported_models is an OR
180 /* other command line options */
182 int model; /* see MODEL_* defines above */
183 int stackAuto : 3 ; /* Stack Automatic */
184 int useXstack : 3 ; /* use Xternal Stack */
185 int stack10bit : 3; /* use 10 bit stack (flat24 model only) */
186 int genericPtr: 1 ; /* use generic pointers */
187 int regExtend : 1 ; /* don't use extended registers */
188 int dump_raw : 1 ; /* dump after intermediate code generation */
189 int dump_gcse : 1 ; /* dump after gcse */
190 int dump_loop : 1 ; /* dump after loop optimizations */
191 int dump_kill : 1 ; /* dump after dead code elimination */
192 int dump_range: 1 ; /* dump after live range analysis */
193 int dump_pack : 1 ; /* dump after register packing */
194 int dump_rassgn:1 ; /* dump after register assignment */
195 int cc_only : 1 ; /* compile only flag */
196 int intlong_rent:1 ; /* integer & long support routines reentrant */
197 int float_rent: 1 ; /* floating point routines are reentrant */
198 int out_fmt : 1 ; /* 1 = motorola S19 format 0 = intel Hex format */
199 int cyclomatic: 1 ; /* print cyclomatic information */
200 int noOverlay : 1 ; /* don't overlay local variables & parameters */
201 int mainreturn: 1 ; /* issue a return after main */
202 int nopeep : 1 ; /* no peep hole optimization */
203 int asmpeep : 1 ; /* pass inline assembler thru peep hole */
204 int debug : 1 ; /* generate extra debug info */
205 int nodebug : 1 ; /* Generate no debug info. */
206 int stackOnData:1 ; /* stack after data segment */
207 int noregparms: 1 ; /* do not pass parameters in registers */
208 int c1mode : 1 ; /* Act like c1 - no pre-proc, asm or link */
209 char *peep_file ; /* additional rules for peep hole */
210 char *out_name ; /* Asm output name for c1 mode */
211 int nostdlib : 1 ; /* Don't use standard lib files */
212 int nostdinc : 1 ; /* Don't use standard include files */
213 int verbose : 1 ; /* Show what the compiler is doing */
214 int ANSIint : 1 ; /* Use ANSI integer promotion rules in expressions. */
216 char *calleeSaves[128]; /* list of functions using callee save */
217 char *excludeRegs[32] ; /* registers excluded from saving */
219 /* starting address of the segments */
220 int xstack_loc ; /* initial location of external stack */
221 int stack_loc ; /* initial value of internal stack pointer */
222 int xdata_loc ; /* xternal ram starts at address */
223 int data_loc ; /* interram start location */
224 int idata_loc ; /* indirect address space */
225 int code_loc ; /* code location start */
226 int iram_size ; /* internal ram size (used only for error checking) */
229 /* forward definition for variables accessed globally */
230 extern char *currFname ;
231 extern char *srcFileName; /* source file name without the extenstion */
232 extern char *moduleName ; /* source file name without path & extension */
233 extern int currLineno ; /* current line number */
234 extern int yylineno ; /* line number of the current file SDCC.lex */
235 extern FILE *yyin ; /* */
236 extern FILE *asmFile ; /* assembly output file */
237 extern FILE *cdbFile ; /* debugger symbol file */
238 extern int NestLevel ; /* NestLevel SDCC.y */
239 extern int stackPtr ; /* stack pointer SDCC.y */
240 extern int xstackPtr ; /* external stack pointer SDCC.y */
241 extern int reentrant ; /* /X flag has been sent SDCC.y */
242 extern char buffer[] ;/* general buffer SDCCgen.c */
243 extern int currRegBank; /* register bank being used SDCCgens.c */
244 extern struct symbol *currFunc; /* current function SDCCgens.c */
245 extern int cNestLevel; /* block nest level SDCCval.c */
246 extern int currBlockno; /* sequentail block number */
247 extern struct optimize optimize ;
248 extern struct options options;
249 extern int maxInterrupts;
251 /* Visible from SDCCmain.c */
252 extern int nrelFiles;
253 extern char *relFiles[128];
254 extern char *libFiles[128] ;
255 extern int nlibFiles;
256 void buildCmdLine(char *into, char **args, const char **cmds,
257 const char *p1, const char *p2,
258 const char *p3, const char **list);
259 int my_system (const char *cmd, char **cmd_argv);
261 void parseWithComma (char **,char *) ;
263 /** Creates a temporary file a'la tmpfile which avoids the bugs
264 in cygwin wrt c:\tmp.
265 Scans, in order: TMP, TEMP, TMPDIR, else uses tmpfile().
267 FILE *tempfile(void);
269 /** Creates a duplicate of the string 'sz' a'la strdup but using
272 char *gc_strdup(const char *sz);
274 /** An assert() macro that will go out through sdcc's error
277 #define wassertl(a,s) ((a) ? 0 : \
278 (werror (E_INTERNAL_ERROR,__FILE__,__LINE__, s), 0))
280 #define wassert(a) wassertl(a,"code generator internal error")