PulkoMandy | 17fc759 | 2022-07-28 18:27:54 +0200 | [diff] [blame] | 1 | /* $VER: vbcc (supp.h) $Revision: 1.58 $ */ |
| 2 | |
| 3 | |
| 4 | #ifndef SUPP_H |
| 5 | #define SUPP_H 1 |
| 6 | #include <stdlib.h> |
| 7 | #include <stdio.h> |
| 8 | #include <limits.h> |
| 9 | #include <string.h> |
| 10 | #include <stddef.h> |
| 11 | #include <stdarg.h> |
| 12 | #include <ctype.h> |
| 13 | /* typenames */ |
| 14 | #define CHAR 1 |
| 15 | #define SHORT 2 |
| 16 | #define INT 3 |
| 17 | #define LONG 4 |
| 18 | #define LLONG 5 |
| 19 | #define FLOAT 6 |
| 20 | #define DOUBLE 7 |
| 21 | #define LDOUBLE 8 |
| 22 | #define VOID 9 |
| 23 | #define POINTER 10 |
| 24 | #define ARRAY 11 |
| 25 | #define STRUCT 12 |
| 26 | #define UNION 13 |
| 27 | #define ENUM 14 |
| 28 | #define FUNKT 15 |
| 29 | #define BOOL 16 |
| 30 | #define MAXINT 17 /* should not be accessible to application */ |
| 31 | #define MAX_TYPE MAXINT |
| 32 | #define MAXVECDIM 16 |
| 33 | #define VECBOOL (MAXINT+1) |
| 34 | #define VECCHAR (VECBOOL+MAXVECDIM) |
| 35 | #define VECSHORT (VECCHAR+MAXVECDIM) |
| 36 | #define VECINT (VECSHORT+MAXVECDIM) |
| 37 | #define VECLONG (VECINT+MAXVECDIM) |
| 38 | #define VECFLOAT (VECLONG+MAXVECDIM) |
| 39 | #define VECLAST (VECFLOAT+MAXVECDIM) |
| 40 | #define NQ 255 /* f&NQ gives type without any qualifiers */ |
| 41 | #define NU 511 /* f&NU gives type without any qualifiers but UNSIGNED */ |
| 42 | #define q1typ(p) ((p->code==ADDI2P||p->code==SUBIFP||p->code==CONVERT||p->code==SUBPFP)?p->typf2:p->typf) |
| 43 | #define q2typ(p) ((p->code==SUBPFP||p->code==LSHIFT||p->code==RSHIFT)?p->typf2:p->typf) |
| 44 | #define ztyp(p) ((p->code==ADDI2P||p->code==SUBIFP||p->code==ADDRESS)?p->typf2:p->typf) |
| 45 | #define iclabel(p) (p->typf) |
| 46 | #define opsize(p) (p->q2.val.vmax) |
| 47 | #define pushsize(p) (p->z.val.vmax) |
| 48 | #define pushedargsize(p) (p->q2.val.vmax) |
| 49 | #define isstatic(x) ((x)==STATIC) |
| 50 | #define isextern(x) ((x)==EXTERN) |
| 51 | #define isauto(x) ((x)==AUTO||(x)==REGISTER) |
| 52 | /* operations on bit-vectors */ |
| 53 | typedef unsigned int bvtype; |
| 54 | #define BVBITS (sizeof(bvtype)*CHAR_BIT) |
| 55 | #define BVSIZE(x) ((((x)+BVBITS-1)/BVBITS)*sizeof(bvtype)) |
| 56 | #define BSET(array,bit) (array)[(bit)/BVBITS]|=1<<((bit)%BVBITS) |
| 57 | #define BCLR(array,bit) (array)[(bit)/BVBITS]&=~(1<<((bit)%BVBITS)) |
| 58 | #define BTST(array,bit) ((array)[(bit)/BVBITS]&(1<<((bit)%BVBITS))) |
| 59 | /* type-qualifiers */ |
| 60 | #define UNSIGNED (NQ+1) |
| 61 | #define CONST (UNSIGNED<<1) |
| 62 | #define VOLATILE (CONST<<1) |
| 63 | #define RESTRICT (VOLATILE<<1) |
| 64 | #define UNCOMPLETE (RESTRICT<<1) |
| 65 | #define STRINGCONST (UNCOMPLETE<<1) |
| 66 | #define BOOLEAN (STRINGCONST<<1) |
| 67 | #define SIGNED_CHARACTER (BOOLEAN<<1) |
| 68 | #define PVOLATILE (SIGNED_CHARACTER<<1) |
| 69 | #ifdef HAVE_ECPP |
| 70 | /* removed */ |
| 71 | /* removed */ |
| 72 | /* removed */ |
| 73 | /* removed */ |
| 74 | /* removed */ |
| 75 | /* removed */ |
| 76 | /* removed */ |
| 77 | /* removed */ |
| 78 | /* removed */ |
| 79 | /* removed */ |
| 80 | /* removed */ |
| 81 | #endif |
| 82 | #define t_min(x) (((x)&UNSIGNED)?l2zm(0L):t_min[(x)&NQ]) |
| 83 | #define t_max(x) (((x)&UNSIGNED)?tu_max[(x)&NQ]:t_max[(x)&NQ]) |
| 84 | /* macro for internal errors */ |
| 85 | #define ierror(a) error(-1,(a),__LINE__,FILE_) |
| 86 | /* macros for target errors */ |
| 87 | #define twarning(x) error(323,x); |
| 88 | #define terror(x) error(324,x); |
| 89 | /* this header is provided by the code generator */ |
| 90 | #include "machine.h" |
| 91 | #define Z0 l2zm(0L) |
| 92 | #define Z1 l2zm(1L) |
| 93 | #define ZU0 ul2zum(0UL) |
| 94 | #define ZU1 ul2zum(1UL) |
| 95 | |
| 96 | #ifndef HAVE_EXT_TYPES |
| 97 | typedef zllong zmax; |
| 98 | typedef zullong zumax; |
| 99 | #endif |
| 100 | #ifndef ISPOINTER |
| 101 | #define ISPOINTER(x) ((x&NQ)==POINTER) |
| 102 | #endif |
| 103 | #ifndef ISINT |
| 104 | #define ISINT(x) ((x&NQ)>=CHAR&&(x&NQ)<=LLONG) |
| 105 | #endif |
| 106 | #ifndef ISFLOAT |
| 107 | #define ISFLOAT(x) ((x&NQ)>=FLOAT&&(x&NQ)<=LDOUBLE) |
| 108 | #endif |
| 109 | #ifndef ISFUNC |
| 110 | #define ISFUNC(x) ((x&NQ)==FUNKT) |
| 111 | #endif |
| 112 | #ifndef ISSTRUCT |
| 113 | #define ISSTRUCT(x) ((x&NQ)==STRUCT) |
| 114 | #endif |
| 115 | #ifndef ISUNION |
| 116 | #define ISUNION(x) ((x&NQ)==UNION) |
| 117 | #endif |
| 118 | #ifndef ISARRAY |
| 119 | #define ISARRAY(x) ((x&NQ)==ARRAY) |
| 120 | #endif |
| 121 | #ifndef ISVECTOR |
| 122 | #define ISVECTOR(x) ((x&NQ)>=VECBOOL&&(x&NQ)<=VECLAST) |
| 123 | #endif |
| 124 | #ifndef VECDIM |
| 125 | #define VECDIM(x) ((((x&NQ)-VECBOOL)&15)+1) |
| 126 | #endif |
| 127 | #ifndef ISSCALAR |
| 128 | #define ISSCALAR(x) ((x&NQ)>=CHAR&&(x&NQ)<=POINTER) |
| 129 | #endif |
| 130 | #ifndef ISARITH |
| 131 | #define ISARITH(x) (ISINT(x)||ISFLOAT(x)) |
| 132 | #endif |
| 133 | #ifndef POINTER_TYPE |
| 134 | #define POINTER_TYPE(x) POINTER |
| 135 | #endif |
| 136 | #ifndef MAXINT |
| 137 | #define MAXINT LLONG |
| 138 | #endif |
| 139 | #ifndef HAVE_INT_SIZET |
| 140 | #define HAVE_INT_SIZET 0 |
| 141 | #endif |
| 142 | #ifndef PTRDIFF_T |
| 143 | #define PTRDIFF_T(x) INT |
| 144 | #endif |
| 145 | #ifndef MAXADDI2P |
| 146 | #define MAXADDI2P LLONG |
| 147 | #endif |
| 148 | #ifndef MINADDUI2P |
| 149 | #define MINADDUI2P (MINADDI2P|UNSIGNED) |
| 150 | #endif |
| 151 | #ifndef MAXADDUI2P |
| 152 | #define MAXADDUI2P (MAXADDI2P|UNSIGNED) |
| 153 | #endif |
| 154 | #ifndef BESTCOPYT |
| 155 | #define BESTCOPYT INT |
| 156 | #endif |
| 157 | #define RSIZE BVSIZE(MAXR+1) |
| 158 | #define ALL_CALLS 1 |
| 159 | #define ALL_REGS 2 |
| 160 | #define ALL_USES 4 |
| 161 | #define ALL_MODS 8 |
| 162 | #define ALL_STACK 16 |
| 163 | #define ALWAYS_RETURNS 32 |
| 164 | #define NEVER_RETURNS 64 |
| 165 | #define NOSIDEFX 128 |
| 166 | #define WARNED_STACK 256 |
| 167 | #define WARNED_REGS 512 |
| 168 | #define USES_VLA 1024 |
| 169 | #define NO_INLINE 2048 |
| 170 | #define FULL_INLINE 4096 |
| 171 | typedef struct reg_handle treg_handle; |
| 172 | typedef struct tunit{ |
| 173 | struct Var *statics; |
| 174 | struct tunit *next; |
| 175 | } tunit; |
| 176 | /* additional information for functions; used by the optimizer */ |
| 177 | typedef struct function_info{ |
| 178 | struct IC *first_ic; /* inline copy of function starts here */ |
| 179 | struct IC *last_ic; /* " " " ends here */ |
| 180 | struct IC *opt_ic; /* code after optimizing */ |
| 181 | struct Var *vars; /* pointer to list of vars of that function */ |
| 182 | struct Var *statics; /* static variables of translation-unit */ |
| 183 | char *inline_asm; /* pointer to code for inline assembler */ |
| 184 | unsigned long flags; /* misc flags, see above */ |
| 185 | /* functions called, variables used and changed */ |
| 186 | int call_cnt,use_cnt,change_cnt; |
| 187 | struct varlist *call_list; |
| 188 | struct varlist *use_list; |
| 189 | struct varlist *change_list; |
| 190 | zmax max_offset; |
| 191 | /* registers used and modified by that function */ |
| 192 | bvtype regs_modified[RSIZE/sizeof(bvtype)]; |
| 193 | #if HAVE_OSEK |
| 194 | /* removed */ |
| 195 | /* removed */ |
| 196 | /* removed */ |
| 197 | #endif |
| 198 | zumax stack1; |
| 199 | zumax stack2; |
| 200 | long inline_size; /* size after inlining/optimizing for cross-module */ |
| 201 | int inline_depth; /* minimum depth for cross-module-inlining */ |
| 202 | } function_info; |
| 203 | typedef int typfl; |
| 204 | #if PVOLATILE >= INT_MAX |
| 205 | #error "need host with larger int size" |
| 206 | #endif |
| 207 | /* struct for types. */ |
| 208 | typedef struct Typ{ |
| 209 | typfl flags; /* see above */ |
| 210 | struct Typ *next; |
| 211 | struct struct_declaration *exact; /* used for STRUCT/UNION/FUNKT */ |
| 212 | zmax size; /* used for ARRAY */ |
| 213 | struct Var *dsize; /* used for variable-length arrays */ |
| 214 | char *attr; |
| 215 | int reg; |
| 216 | #ifdef HAVE_ECPP |
| 217 | /* removed */ |
| 218 | #endif |
| 219 | } type; |
| 220 | #define TYPS sizeof(type) |
| 221 | #ifndef HAVE_EXT_TYPES |
| 222 | typedef union atyps{ |
| 223 | zchar vchar; |
| 224 | zuchar vuchar; |
| 225 | zshort vshort; |
| 226 | zushort vushort; |
| 227 | zint vint; |
| 228 | zuint vuint; |
| 229 | zlong vlong; |
| 230 | zulong vulong; |
| 231 | zllong vllong; |
| 232 | zullong vullong; |
| 233 | zmax vmax; |
| 234 | zumax vumax; |
| 235 | zfloat vfloat; |
| 236 | zdouble vdouble; |
| 237 | zldouble vldouble; |
| 238 | } atyps; |
| 239 | #endif |
| 240 | /* This struct represents objects in the intermediate code. */ |
| 241 | typedef struct obj{ |
| 242 | int flags; /* see below */ |
| 243 | int reg; /* number of reg if flags® */ |
| 244 | int dtyp; /* type of pointer for DREFOBJ */ |
| 245 | struct Var *v; |
| 246 | struct AddressingMode *am; |
| 247 | union atyps val; |
| 248 | } obj; |
| 249 | /* Available flags in struct obj. */ |
| 250 | /* KONST muss immer am kleinsten sein, um beim Swappen */ |
| 251 | /* fuer available_expressions und Konstanten nach */ |
| 252 | /* rechts nicht in eine Endlosschleife zu kommen. */ |
| 253 | #define KONST 1 /* The object is a constant. Its value is stored in */ |
| 254 | /* val. */ |
| 255 | #define VAR 2 /* The object is a variable (stored in v). */ |
| 256 | #define SCRATCH 8 /* The object is a temporary. */ |
| 257 | #define STACK 16 /* obsolete */ |
| 258 | #define DREFOBJ 32 /* The object must be dereferenced. */ |
| 259 | #define REG 64 /* The object is contained in a hardware register. */ |
| 260 | #define VARADR 128 /* The object is the address of a static variable. */ |
| 261 | #define DONTREGISTERIZE 256 /* Do not put this object into a register. */ |
| 262 | #define VKONST 512 /* Variable containing a constant (for reg-alloc). */ |
| 263 | typedef struct Var{ |
| 264 | int storage_class; /* see below */ |
| 265 | int reg; /* Var is assigned to this hard-reg */ |
| 266 | int priority; /* Priority to be used in simple_regs() */ |
| 267 | long flags; /* see below */ |
| 268 | char *identifier; /* name of the variable */ |
| 269 | int nesting; /* can be freely used by the frontend */ |
| 270 | int index; /* used by the optimizer */ |
| 271 | int inr; /* counter for num_vars */ |
| 272 | zmax offset; /* offset relative to the stack frame */ |
| 273 | int line; /* line number of first declaration */ |
| 274 | char *filename; /* filename of first declaration */ |
| 275 | int dline; /* line number of definition */ |
| 276 | char *dfilename; /* filename of definition */ |
| 277 | type *vtyp; /* type of the variable */ |
| 278 | struct const_list *clist; /* initialized? */ |
| 279 | struct Var *next; /* pointer to next variable */ |
| 280 | struct function_info *fi; /* used by the optimizer */ |
| 281 | struct Var *inline_copy; /* used for function-inlining */ |
| 282 | struct tunit *tunit; /* translation unit the variable belongs to */ |
| 283 | char *vattr; /* extended variable attributes */ |
| 284 | char *description; /* description of variable meaning */ |
| 285 | struct obj cobj; /* used for register-allocation of constants */ |
| 286 | int ctyp; /* ----------------- " ----------------- */ |
| 287 | #ifdef HAVE_TARGET_ATTRIBUTES |
| 288 | unsigned long tattr; /* target-specific attributes */ |
| 289 | #endif |
| 290 | #ifdef ALEX_REG |
| 291 | int iRegCopyNr; |
| 292 | int iRegCopyNrHc12V; |
| 293 | #endif |
| 294 | } Var; |
| 295 | /* available storage-classes */ |
| 296 | #define AUTO 1 /* var is allocated on the stack */ |
| 297 | #define REGISTER 2 /* basically the same as AUTO (C-only) */ |
| 298 | #define STATIC 3 /* var is static but has no external linkage */ |
| 299 | #define EXTERN 4 /* var is static and has external linkage */ |
| 300 | #define TYPEDEF 5 /* C-only */ |
| 301 | /* available flags in struct Var */ |
| 302 | #define USEDASSOURCE 1 /* the var has been read */ |
| 303 | #define USEDASDEST 2 /* the var has been written */ |
| 304 | #define DEFINED 4 /* the var has been defined (i.e. storage will |
| 305 | be allocated in the current file) */ |
| 306 | #define USEDASADR 8 /* the address of the var has been taken */ |
| 307 | #define GENERATED 16 /* code for static vars has been generated */ |
| 308 | #define CONVPARAMETER 32 |
| 309 | #define TENTATIVE 64 /* C-only */ |
| 310 | #define USEDBEFORE 128 /* used by the optimizer */ |
| 311 | #define INLINEV 256 /* " " */ |
| 312 | #define PRINTFLIKE 512 /* C-only */ |
| 313 | #define SCANFLIKE 1024 /* C-only */ |
| 314 | #define NOTTYPESAFE 2048 /* used by the optimizer */ |
| 315 | #define DNOTTYPESAFE 4096 /* " " */ |
| 316 | #define REGPARM 8192 /* the var is a register parameter */ |
| 317 | #define DBLPUSH 16384 /* parameter is also on the stack */ |
| 318 | #define NOTINTU 32768 /* variable not (yet) defined in this translation-unit */ |
| 319 | #define REFERENCED 65536 /* variable referenced */ |
| 320 | #define STATICAUTO 131072 /* auto variable converted to static */ |
| 321 | #define INLINEFUNC (STATICAUTO*2) |
| 322 | #define INLINEEXT (INLINEFUNC*2) |
| 323 | #define BUILTIN (INLINEEXT*2) |
| 324 | #define NEEDS (BUILTIN*2) |
| 325 | |
| 326 | /* C-only */ |
| 327 | typedef struct struct_list{ |
| 328 | char *identifier; /* name of the struct/union-tag */ |
| 329 | type *styp; /* type of the member/parameter */ |
| 330 | zmax align; /* alignment of struct-member */ |
| 331 | int bfoffset; /* bitfield-offset */ |
| 332 | int bfsize; /* bitfield-size */ |
| 333 | int storage_class; /* storage-class of function-parameter */ |
| 334 | int reg; /* register to pass function-parameter */ |
| 335 | #ifdef HAVE_ECPP |
| 336 | /* removed */ |
| 337 | #endif |
| 338 | } struct_list; |
| 339 | |
| 340 | #define SLSIZE 32 /* realloc struct_lists in those steps */ |
| 341 | /* These structs are used to describe members of STRUCT/UNION or */ |
| 342 | /* parameters of FUNKT. Some of the entries in struct_list are not */ |
| 343 | /* relevant for both alternatives. */ |
| 344 | typedef struct struct_declaration{ |
| 345 | int count; /* number of members/parameters */ |
| 346 | int label; /* used for debug output */ |
| 347 | int typ; |
| 348 | struct tunit *tunit; |
| 349 | struct struct_declaration *next; |
| 350 | struct struct_list (*sl)[]; |
| 351 | char *identifier; |
| 352 | #ifdef HAVE_ECPP |
| 353 | /* removed */ |
| 354 | /* removed */ |
| 355 | /* removed */ |
| 356 | /* removed */ |
| 357 | /* removed */ |
| 358 | /* removed */ |
| 359 | /* removed */ |
| 360 | /* removed */ |
| 361 | /* removed */ |
| 362 | #endif |
| 363 | } struct_declaration; |
| 364 | |
| 365 | /* The quads in the intermediate code. */ |
| 366 | typedef struct IC{ |
| 367 | struct IC *prev; /* pointer to the next IC */ |
| 368 | struct IC *next; /* pointer to the previous IC */ |
| 369 | int code; /* see below */ |
| 370 | int typf; /* usually type of the operands, see interface.doc */ |
| 371 | int typf2; /* used for CONVERT,ADDI2P,SUBIFP,SUBPFP */ |
| 372 | int defindex; /* used by optimizer */ |
| 373 | int expindex; |
| 374 | int copyindex; |
| 375 | int change_cnt; |
| 376 | int use_cnt; |
| 377 | int call_cnt; |
| 378 | int line; /* corresponding line in source file (or 0) */ |
| 379 | struct varlist *change_list; /* used by optimizer */ |
| 380 | struct varlist *use_list; |
| 381 | struct varlist *call_list; |
| 382 | struct obj q1; /* source 1 */ |
| 383 | struct obj q2; /* source 2 */ |
| 384 | struct obj z; /* target */ |
| 385 | char *file; /* filename of the source file */ |
| 386 | int arg_cnt; |
| 387 | struct IC **arg_list; /* pointers to function argument ICs (only for code==CALL) */ |
| 388 | struct IC *copy; /* for copying/inlining */ |
| 389 | type *ityp; |
| 390 | long flags; |
| 391 | struct Var *savedsp; /* only for branch instructions and vlas */ |
| 392 | #ifdef HAVE_EXT_IC |
| 393 | struct ext_ic ext; |
| 394 | #endif |
| 395 | #ifdef ALEX_REG |
| 396 | int iZWebIndex; /* web for z in case z is a pointer and its value is defed*/ |
| 397 | int iQ1WebIndex; /* web for argument q1 */ |
| 398 | int iQ2WebIndex; /* web for argument q2 */ |
| 399 | void *pFlow; /* flowgraph reverse lookup */ |
| 400 | #endif |
| 401 | } IC; |
| 402 | #define ICS sizeof(struct IC) |
| 403 | /* flags for ICs */ |
| 404 | #define LOOP_COND_TRUE 1 /* loop condition is true at first iteration */ |
| 405 | #define EFF_IC 2 /* do not transform IC with doubtful optimizations */ |
| 406 | #define ORDERED_PUSH_COPY 4 /* mark a copy of an ordered push */ |
| 407 | |
| 408 | /* Available codes for struct IC. See interface.doc. */ |
| 409 | #define KOMMA 1 |
| 410 | #define ASSIGN 2 |
| 411 | #define ASSIGNOP 3 |
| 412 | |
| 413 | #if 0 |
| 414 | /* obsolete */ |
| 415 | #define ASSIGNADD 3 |
| 416 | #define ASSIGNSUB 4 |
| 417 | #define ASSIGNMULT 5 |
| 418 | #define ASSIGNDIV 6 |
| 419 | #define ASSIGNMOD 7 |
| 420 | #define ASSIGNAND 8 |
| 421 | #define ASSIGNXOR 9 |
| 422 | #define ASSIGNOR 10 |
| 423 | #define ASSIGNLSHIFT 11 |
| 424 | #define ASSIGNRSHIFT 12 |
| 425 | #endif |
| 426 | |
| 427 | #define COND 13 |
| 428 | #define LOR 14 |
| 429 | #define LAND 15 |
| 430 | #define OR 16 |
| 431 | #define XOR 17 |
| 432 | #define AND 18 |
| 433 | #define EQUAL 19 |
| 434 | #define INEQUAL 20 |
| 435 | #define LESS 21 |
| 436 | #define LESSEQ 22 |
| 437 | #define GREATER 23 |
| 438 | #define GREATEREQ 24 |
| 439 | #define LSHIFT 25 |
| 440 | #define RSHIFT 26 |
| 441 | #define ADD 27 |
| 442 | #define SUB 28 |
| 443 | #define MULT 29 |
| 444 | #define DIV 30 |
| 445 | #define MOD 31 |
| 446 | #define NEGATION 32 |
| 447 | #define KOMPLEMENT 33 |
| 448 | #define PREINC 34 |
| 449 | #define POSTINC 35 |
| 450 | #define PREDEC 36 |
| 451 | #define POSTDEC 37 |
| 452 | #define MINUS 38 |
| 453 | #define CONTENT 39 |
| 454 | #define ADDRESS 40 |
| 455 | #define CAST 41 |
| 456 | #define CALL 42 |
| 457 | #define INDEX 43 |
| 458 | #define DPSTRUCT 44 |
| 459 | #define DSTRUCT 45 |
| 460 | #define IDENTIFIER 46 |
| 461 | #define CEXPR 47 |
| 462 | #define STRING 48 |
| 463 | #define MEMBER 49 |
| 464 | #define CONVERT 50 |
| 465 | #if 0 |
| 466 | #define CONVCHAR 50 |
| 467 | #define CONVSHORT 51 |
| 468 | #define CONVINT 52 |
| 469 | #define CONVLONG 53 |
| 470 | #define CONVFLOAT 54 |
| 471 | #define CONVDOUBLE 55 |
| 472 | #define CONVVOID 56 |
| 473 | #define CONVPOINTER 57 |
| 474 | #define CONVUCHAR 58 |
| 475 | #define CONVUSHORT 59 |
| 476 | #define CONVUINT 60 |
| 477 | #define CONVULONG 61 |
| 478 | #endif |
| 479 | #define ADDRESSA 62 |
| 480 | #define FIRSTELEMENT 63 |
| 481 | #define PMULT 64 |
| 482 | #define ALLOCREG 65 |
| 483 | #define FREEREG 66 |
| 484 | #define PCEXPR 67 |
| 485 | #define TEST 68 |
| 486 | #define LABEL 69 |
| 487 | #define BEQ 70 |
| 488 | #define BNE 71 |
| 489 | #define BLT 72 |
| 490 | #define BGE 73 |
| 491 | #define BLE 74 |
| 492 | #define BGT 75 |
| 493 | #define BRA 76 |
| 494 | #define COMPARE 77 |
| 495 | #define PUSH 78 |
| 496 | #define POP 79 |
| 497 | #define ADDRESSS 80 |
| 498 | #define ADDI2P 81 |
| 499 | #define SUBIFP 82 |
| 500 | #define SUBPFP 83 |
| 501 | #define PUSHREG 84 |
| 502 | #define POPREG 85 |
| 503 | #define POPARGS 86 |
| 504 | #define SAVEREGS 87 |
| 505 | #define RESTOREREGS 88 |
| 506 | #define ILABEL 89 |
| 507 | #define DC 90 |
| 508 | #define ALIGN 91 |
| 509 | #define COLON 92 |
| 510 | #define GETRETURN 93 |
| 511 | #define SETRETURN 94 |
| 512 | #define MOVEFROMREG 95 |
| 513 | #define MOVETOREG 96 |
| 514 | #define NOP 97 |
| 515 | #define BITFIELD 98 |
| 516 | #define LITERAL 99 |
| 517 | #define REINTERPRET 100 |
| 518 | extern char *typname[]; |
| 519 | extern zmax sizetab[]; |
| 520 | extern char *storage_class_name[]; |
| 521 | extern char *ename[]; |
| 522 | extern int align_arguments; /* arguments correctly aligned on stack or |
| 523 | just stackalign? */ |
| 524 | extern zmax align[],maxalign,stackalign; |
| 525 | /* an empty string */ |
| 526 | extern char *empty; |
| 527 | extern zchar vchar; extern zuchar vuchar; |
| 528 | extern zshort vshort; extern zushort vushort; |
| 529 | extern zint vint; extern zuint vuint; |
| 530 | extern zlong vlong; extern zulong vulong; |
| 531 | extern zllong vllong; extern zullong vullong; |
| 532 | extern zmax vmax; extern zumax vumax; |
| 533 | extern zfloat vfloat; extern zdouble vdouble; |
| 534 | extern zldouble vldouble; |
| 535 | extern union atyps gval; |
| 536 | #ifndef DEBUG |
| 537 | extern int DEBUG; |
| 538 | #endif |
| 539 | #ifdef HAVE_MISRA |
| 540 | /* removed */ |
| 541 | #endif |
| 542 | /* used by the optimizer */ |
| 543 | /* for lists in ICs flags may be DREFOBJ to mark dereferences */ |
| 544 | /* for lists in function infos flags is the type of access */ |
| 545 | typedef struct varlist{ |
| 546 | struct Var *v; |
| 547 | int flags; |
| 548 | } varlist; |
| 549 | #define VLS sizeof(struct varlist) |
| 550 | extern struct IC *first_ic,*last_ic; |
| 551 | #define REGSA_NEVER 1 |
| 552 | #define REGSA_TEMPS 2 |
| 553 | extern int regs[MAXR+1],regsa[MAXR+1],regused[MAXR+1],simple_scratch[MAXR+1]; |
| 554 | extern int sregsa[MAXR+1]; |
| 555 | extern int reg_prio[MAXR+1],regscratch[MAXR+1]; |
| 556 | extern zmax regsize[MAXR+1]; |
| 557 | extern type *regtype[MAXR+1]; |
| 558 | extern struct Var *regsv[MAXR+1]; |
| 559 | extern char *regnames[]; |
| 560 | extern bvtype regs_modified[RSIZE/sizeof(bvtype)]; |
| 561 | extern int optspeed,optsize,unroll_all,stack_check; |
| 562 | extern int cross_module,final,no_emit; |
| 563 | extern int debug_info; |
| 564 | extern int label,return_label; |
| 565 | /* The structures used for available options of the code generator. */ |
| 566 | union ppi {char *p;long l;void (*f)(char *);}; |
| 567 | #define USEDFLAG 1 |
| 568 | #define STRINGFLAG 2 |
| 569 | #define VALFLAG 4 |
| 570 | #define FUNCFLAG 8 |
| 571 | extern int g_flags[MAXGF]; |
| 572 | extern char *g_flags_name[MAXGF]; |
| 573 | extern union ppi g_flags_val[MAXGF]; |
| 574 | extern zmax max_offset; |
| 575 | extern int function_calls,vlas; |
| 576 | extern int coloring; |
| 577 | extern int dmalloc; |
| 578 | extern int sec_per_obj; |
| 579 | extern int disable; |
| 580 | extern int misracheck,misraversion,misracomma,misratok; |
| 581 | extern int pack_align; |
| 582 | extern int short_push; |
| 583 | extern int static_cse,dref_cse; |
| 584 | extern int no_eff_ics,early_eff_ics; |
| 585 | extern int force_statics,prefer_statics; |
| 586 | extern int range_opt; |
| 587 | extern int default_unsigned; |
| 588 | extern Var *add_attr_haddecl; |
| 589 | |
| 590 | /* Das haette ich gern woanders */ |
| 591 | extern struct struct_declaration *add_sd(struct struct_declaration *,int); |
| 592 | typedef struct node{ |
| 593 | int flags,lvalue,sidefx; |
| 594 | int bfs,bfo; |
| 595 | type *ntyp; |
| 596 | struct node *left; |
| 597 | struct node *right; |
| 598 | struct argument_list *alist; |
| 599 | char *identifier; |
| 600 | struct const_list *cl; |
| 601 | struct Var *dsize; |
| 602 | union atyps val; |
| 603 | struct obj o; |
| 604 | } node; |
| 605 | typedef node *np; |
| 606 | #define NODES sizeof(struct node) |
| 607 | typedef struct const_list{ |
| 608 | union atyps val; |
| 609 | np tree; |
| 610 | zmax idx; |
| 611 | struct const_list *other,*next; |
| 612 | } const_list; |
| 613 | #define CLS sizeof(struct const_list) |
| 614 | typedef struct case_table{ |
| 615 | int num,typf; |
| 616 | struct IC *next_ic; |
| 617 | double density; |
| 618 | union atyps *vals; |
| 619 | int *labels; |
| 620 | union atyps min,max; |
| 621 | zumax diff; |
| 622 | } case_table; |
| 623 | extern zmax t_min[]; |
| 624 | extern zumax t_max[]; |
| 625 | extern zumax tu_max[]; |
| 626 | extern zmax char_bit; |
| 627 | extern char cg_copyright[]; |
| 628 | #ifdef HAVE_TARGET_ATTRIBUTES |
| 629 | extern char *g_attr_name[]; |
| 630 | #endif |
| 631 | extern char **target_macros; |
| 632 | extern int goto_used; |
| 633 | extern int ic_count; |
| 634 | extern int only_inline; |
| 635 | extern int multiple_ccs; |
| 636 | extern int float_used; |
| 637 | extern IC *err_ic; |
| 638 | extern long maxoptpasses,optflags,inline_size,unroll_size,inline_depth; |
| 639 | extern long clist_copy_stack; |
| 640 | extern long clist_copy_static; |
| 641 | extern long clist_copy_pointer; |
| 642 | extern long inline_memcpy_sz; |
| 643 | extern int noaliasopt,fp_assoc,noitra; |
| 644 | extern Var *vl0,*vl1,*vl2,*vl3; |
| 645 | extern char *filename; |
| 646 | extern char *emit_buffer[EMIT_BUF_DEPTH]; |
| 647 | extern char *emit_p; |
| 648 | extern int emit_f,emit_l; |
| 649 | extern int no_inline_peephole; |
| 650 | extern int ecpp; |
| 651 | /* functions which must be provided by the frontend */ |
| 652 | extern void add_IC(IC *); |
| 653 | extern void error(int,...); |
| 654 | #ifdef HAVE_MISRA |
| 655 | /* removed */ |
| 656 | /* removed */ |
| 657 | #endif |
| 658 | extern Var *add_tmp_var(type *); |
| 659 | extern void free_var(Var *); |
| 660 | extern void raus(void); |
| 661 | /* functions provided by supp.c */ |
| 662 | #define printtype prd |
| 663 | #define printobj probj |
| 664 | #define printic pric2 |
| 665 | #define printiclist pric |
| 666 | extern void free_IC(IC *); |
| 667 | extern void insert_IC(IC *,IC *); |
| 668 | extern void move_IC(IC *,IC *); |
| 669 | extern void pric(FILE *,IC *); |
| 670 | extern void pric2(FILE *,IC *); |
| 671 | extern void probj(FILE *,obj *,int); |
| 672 | extern void emit(FILE *,const char *,...); |
| 673 | extern void emit_char(FILE *,int); |
| 674 | void emit_flush(FILE *); |
| 675 | void remove_asm(void); |
| 676 | #if HAVE_TARGET_PEEPHOLE |
| 677 | extern int emit_peephole(void); |
| 678 | #endif |
| 679 | extern void emit_remove(void); |
| 680 | extern void emit_inline_asm(FILE *,char *); |
| 681 | extern void emitzm(FILE *,zmax); |
| 682 | extern void emitzum(FILE *,zumax); |
| 683 | extern void emitzld(FILE *,zldouble); |
| 684 | extern void emitval(FILE *,union atyps *,int); |
| 685 | extern void printzm(FILE *,zmax); |
| 686 | extern void printzum(FILE *,zumax); |
| 687 | extern void printzld(FILE *,zldouble); |
| 688 | extern void printval(FILE *,union atyps *,int); |
| 689 | extern void insert_const(union atyps *,int); |
| 690 | extern void prd(FILE *,type *); |
| 691 | extern void print_var(FILE *,Var *); |
| 692 | extern void freetyp(type *); |
| 693 | extern type *new_typ(void); |
| 694 | extern type *clone_typ(type *); |
| 695 | #ifdef HAVE_EXT_TYPES |
| 696 | extern void conv_typ(type *); |
| 697 | #endif |
| 698 | extern int VECTYPE(int); |
| 699 | extern int mkvec(int,int); |
| 700 | extern zmax szof(type *); |
| 701 | extern int is_vlength(type *); |
| 702 | extern Var *vlength_szof(type *); |
| 703 | extern zmax struct_offset(struct_declaration *,const char *); |
| 704 | extern zmax falign(type *); |
| 705 | int get_first_base_type(type *); |
| 706 | extern int objs_equal(obj *,obj *,int); |
| 707 | extern void eval_const(union atyps *,int); |
| 708 | extern int get_clist_byte(type *,const_list *, zmax, zuchar *); |
| 709 | extern zumax get_clist_int(type *, const_list *, zmax, int, int *); |
| 710 | extern function_info *new_fi(void); |
| 711 | extern void free_fi(function_info *); |
| 712 | extern void print_fi(FILE *,function_info *); |
| 713 | extern void static_stack_check(Var *); |
| 714 | #ifdef HAVE_REGPARMS |
| 715 | extern zmax va_offset(Var *); |
| 716 | #endif |
| 717 | extern void print_varlist(FILE *f,varlist *,int); |
| 718 | extern void add_attr(char **,char *); |
| 719 | extern int switch_IC(IC *); |
| 720 | extern int collides(obj *,obj *); |
| 721 | extern int is_const(type *); |
| 722 | extern int is_volatile_obj(obj *); |
| 723 | extern int is_volatile_ic(IC *); |
| 724 | extern case_table *calc_case_table(IC *,double); |
| 725 | int calc_regs(IC *,int); |
| 726 | Var *declare_builtin(char *name,int ztyp,int q1typ,int q1reg,int q2typ,int q2reg,int nosidefx,char *asm); |
| 727 | extern void emit_jump_table(FILE *,case_table *,char *,char *,int); |
| 728 | extern void optimize(long, Var *); |
| 729 | int bvcmp(bvtype *dest,bvtype *src,size_t len); |
| 730 | int bvdointersect(bvtype *,bvtype *,size_t len); |
| 731 | void bvunite(bvtype *dest,bvtype *src,size_t len); |
| 732 | void bvintersect(bvtype *dest,bvtype *src,size_t len); |
| 733 | void bvdiff(bvtype *dest,bvtype *src,size_t len); |
| 734 | void vqsort (void *,size_t,size_t,int (*)(const void *,const void *)); |
| 735 | #define bvcopy(dest,src,len) memcpy(dest,src,len) |
| 736 | #define bvclear(dest,len) memset(dest,0,len) |
| 737 | #define bvsetall(dest,len) memset(dest,-1,len) |
| 738 | extern void remove_IC(IC *); |
| 739 | extern IC *clone_ic(IC *); |
| 740 | extern IC *new_IC(void); |
| 741 | extern Var *new_var(void); |
| 742 | extern void insert_bitfield(obj *,obj *,obj *,int,int,int,int); |
| 743 | extern void *mymalloc(size_t); |
| 744 | extern void *myrealloc(void *,size_t); |
| 745 | extern void myfree(void *p); |
| 746 | #define free(x) myfree(x) |
| 747 | extern char *mystrdup(char *); |
| 748 | extern void simple_regs(void); |
| 749 | extern int bflayout(int,int,int); |
| 750 | /* functions provided by the code generator */ |
| 751 | extern int regok(int,int,int); |
| 752 | typedef struct rpair {int r1,r2;} rpair; |
| 753 | int reg_pair(int,rpair *); |
| 754 | extern rpair rp; |
| 755 | extern int freturn(type *); |
| 756 | #define ffreturn(x) ((x)->reg?(x)->reg:freturn(x)) |
| 757 | extern void gen_code(FILE *,IC *,Var *,zmax); |
| 758 | extern int init_cg(void); |
| 759 | extern void cleanup_cg(FILE *); |
| 760 | extern void init_db(FILE *); |
| 761 | void cleanup_db(FILE *); |
| 762 | extern int dangerous_IC(IC *); |
| 763 | extern void gen_dc(FILE *,int,const_list *); |
| 764 | extern void gen_ds(FILE *,zmax,type *); |
| 765 | extern void gen_var_head(FILE *,Var *); |
| 766 | extern void gen_align(FILE *,zmax); |
| 767 | extern int shortcut(int, int); |
| 768 | extern int must_convert(int,int,int); |
| 769 | long get_pof2(zumax); |
| 770 | int is_varargs(type *); |
| 771 | |
| 772 | typedef void *hashdata; |
| 773 | |
| 774 | typedef struct hashentry { |
| 775 | char *name; |
| 776 | hashdata data; |
| 777 | struct hashentry *next; |
| 778 | } hashentry; |
| 779 | |
| 780 | typedef struct hashtable { |
| 781 | hashentry **entries; |
| 782 | size_t size; |
| 783 | int collisions; |
| 784 | } hashtable; |
| 785 | |
| 786 | hashtable *new_hashtable(size_t); |
| 787 | size_t hashcode(char *); |
| 788 | void add_hashentry(hashtable *,char *,hashdata); |
| 789 | hashdata find_name(hashtable *,char *); |
| 790 | |
| 791 | #ifdef HAVE_TARGET_PRAGMAS |
| 792 | extern int handle_pragma(const char *); |
| 793 | #endif |
| 794 | #ifdef HAVE_LIBCALLS |
| 795 | extern char *use_libcall(int code,int t1,int t2); |
| 796 | #ifndef LIBCALL_CMPTYPE |
| 797 | #define LIBCALL_CMPTYPE INT |
| 798 | #endif |
| 799 | #endif |
| 800 | #ifdef HAVE_TARGET_VARHOOK_PRE |
| 801 | extern void add_var_hook_pre(const char *,type *,int,const_list *); |
| 802 | #endif |
| 803 | #ifdef HAVE_TARGET_VARHOOK_POST |
| 804 | extern void add_var_hook_post(Var *); |
| 805 | #endif |
| 806 | extern int cost_savings(IC *,int,obj *); |
| 807 | /* additional declarations for targets which pass arguments in */ |
| 808 | /* registers by default. */ |
| 809 | #ifdef HAVE_REGPARMS |
| 810 | extern treg_handle empty_reg_handle; |
| 811 | /* last parameter is function type or return type or pointer to function type */ |
| 812 | extern int reg_parm(treg_handle *, type *,int,type *); |
| 813 | #endif |
| 814 | #ifdef HAVE_TARGET_EFF_IC |
| 815 | extern void mark_eff_ics(void); |
| 816 | #else |
| 817 | #define mark_eff_ics() |
| 818 | #endif |
| 819 | #ifndef JUMP_TABLE_DENSITY |
| 820 | #define JUMP_TABLE_DENSITY 1 |
| 821 | #endif |
| 822 | #ifndef JUMP_TABLE_LENGTH |
| 823 | #define JUMP_TABLE_LENGTH 1000 |
| 824 | #endif |
| 825 | #ifndef ALLOCVLA_REG |
| 826 | #define ALLOCVLA_REG 0 |
| 827 | #endif |
| 828 | #ifndef ALLOCVLA_INLINEASM |
| 829 | #define ALLOCVLA_INLINEASM 0 |
| 830 | #endif |
| 831 | #ifndef FREEVLA_REG |
| 832 | #define FREEVLA_REG 0 |
| 833 | #endif |
| 834 | #ifndef FREEVLA_INLINEASM |
| 835 | #define FREEVLA_INLINEASM 0 |
| 836 | #endif |
| 837 | #ifndef OLDSPVLA_INLINEASM |
| 838 | #define OLDSPVLA_INLINEASM 0 |
| 839 | #endif |
| 840 | #ifndef FPVLA_REG |
| 841 | #define FPVLA_REG 0 |
| 842 | #endif |
| 843 | #ifndef MIN_INT_TO_FLOAT_TYPE |
| 844 | #define MIN_INT_TO_FLOAT_TYPE CHAR |
| 845 | #endif |
| 846 | #ifndef MIN_FLOAT_TO_INT_TYPE |
| 847 | #define MIN_FLOAT_TO_INT_TYPE CHAR |
| 848 | #endif |
| 849 | #ifndef AVOID_FLOAT_TO_UNSIGNED |
| 850 | #define AVOID_FLOAT_TO_UNSIGNED 0 |
| 851 | #endif |
| 852 | #ifndef AVOID_UNSIGNED_TO_FLOAT |
| 853 | #define AVOID_UNSIGNED_TO_FLOAT 0 |
| 854 | #endif |
| 855 | #ifndef CHARCONV |
| 856 | #define CHARCONV(x) (x) |
| 857 | #define CHARBACK(x) (x) |
| 858 | #define STRBACK(x) |
| 859 | #else |
| 860 | unsigned char CHARBACK(unsigned char); |
| 861 | void STRBACK(unsigned char *); |
| 862 | #endif |
| 863 | |
| 864 | #if HAVE_OSEK |
| 865 | /* removed */ |
| 866 | /* removed */ |
| 867 | /* removed */ |
| 868 | /* removed */ |
| 869 | /* removed */ |
| 870 | /* removed */ |
| 871 | /* removed */ |
| 872 | /* removed */ |
| 873 | /* removed */ |
| 874 | /* removed */ |
| 875 | /* removed */ |
| 876 | /* removed */ |
| 877 | #endif |
| 878 | |
| 879 | |
| 880 | #endif /* SUPP_H */ |