* as/hc08/lkaomf51.c (OutputName),
[fw/sdcc] / src / SDCCval.h
1 /*----------------------------------------------------------------------
2   SDCCval.h - value wrapper related header information
3   Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1997)
4
5   This program is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License as published by the
7   Free Software Foundation; either version 2, or (at your option) any
8   later version.
9   
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14   
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18   
19   In other words, you are welcome to use, share and improve this program.
20   You are forbidden to forbid anyone else to use, share and improve
21   what you give them.   Help stamp out software-hoarding!  
22 -------------------------------------------------------------------------*/
23 #ifndef SDCCVAL_H
24 #define SDCCVAL_H
25
26 #include "SDCCsymt.h"
27
28 /* value wrapper */
29 typedef struct value
30   {
31     char name[SDCC_NAME_MAX + 1];       /* operand accessing this value */
32     sym_link *type;             /* start of type chain     */
33     sym_link *etype;            /* end of type chain       */
34     symbol *sym;                /* Original Symbol         */
35     struct value *next;         /* used in initializer list */
36     unsigned vArgs:1;           /* arg list ended with variable arg           */
37
38   }
39 value;
40
41 typedef struct literalList
42 {
43     double    literalValue;
44     unsigned  count;
45     struct literalList *next;
46 } literalList;
47
48
49 enum
50   {
51     INIT_NODE,
52     INIT_DEEP,
53     INIT_HOLE
54   };
55
56 /* initializer lists use this structure */
57 typedef struct initList
58   {
59     int type;
60     int lineno;
61     char *filename;
62     union
63       {
64         struct ast *node;
65         struct initList *deep;
66       }
67     init;
68
69     struct initList *next;
70   }
71 initList;
72
73 /* return values from checkConstantRange */
74 typedef enum
75   {
76     CCR_OK,           /* evaluate at runtime */
77     CCR_OVL,
78     CCR_ALWAYS_FALSE,
79     CCR_ALWAYS_TRUE
80   }
81 CCR_RESULT;
82
83 #define  IS_VARG(x)             (x->vArgs)
84
85 /* forward definitions for the symbol table related functions */
86 void initValue ();
87 value *newValue ();
88 value *constVal (char *);
89 value *reverseVal (value *);
90 value *reverseValWithType (value *);
91 value *copyValue (value *);
92 value *copyValueChain (value *);
93 value *strVal (char *);
94 value *charVal (char *);
95 value *symbolVal (symbol *);
96 void printVal (value *);
97 double floatFromVal (value *);
98
99 /* convert a fixed16x16 type to double */
100 double doubleFromFixed16x16(TYPE_TARGET_ULONG value);
101
102 /* convert a double type to fixed16x16 */
103 TYPE_TARGET_ULONG fixed16x16FromDouble(double value);
104
105 CCR_RESULT checkConstantRange (sym_link *var, sym_link *lit, int op, bool exchangeOps);
106 value *array2Ptr (value *);
107 value *valUnaryPM (value *);
108 value *valComplement (value *);
109 value *valNot (value *);
110 value *valMult (value *, value *);
111 value *valDiv (value *, value *);
112 value *valMod (value *, value *);
113 value *valPlus (value *, value *);
114 value *valMinus (value *, value *);
115 value *valShift (value *, value *, int);
116 value *valCompare (value *, value *, int);
117 value *valBitwise (value *, value *, int);
118 value *valLogicAndOr (value *, value *, int);
119 value *valCastLiteral (sym_link *, double);
120 value *valueFromLit (double);
121 initList *newiList (int, void *);
122 initList *revinit (initList *);
123 initList *copyIlist (initList *);
124 double list2int (initList *);
125 value *list2val (initList *);
126 struct ast *list2expr (initList *);
127 void resolveIvalSym (initList *, sym_link *);
128 value *valFromType (sym_link *);
129 value *constFloatVal (char *);
130 value *constFixed16x16Val (char *);
131 int getNelements (sym_link *, initList *);
132 value *valForArray (struct ast *);
133 value *valForStructElem (struct ast *, struct ast *);
134 value *valForCastAggr (struct ast *, sym_link *, struct ast *, int);
135 value *valForCastArr (struct ast * , sym_link *);
136 bool convertIListToConstList(initList *src, literalList **lList);
137 literalList *copyLiteralList(literalList *src);
138 #endif