1 |
48 |
robfinch |
#ifndef _EXPR_H
|
2 |
|
|
#define _EXPR_H
|
3 |
|
|
|
4 |
|
|
// ============================================================================
|
5 |
|
|
// __
|
6 |
|
|
// \\__/ o\ (C) 2012-2016 Robert Finch, Stratford
|
7 |
|
|
// \ __ / All rights reserved.
|
8 |
|
|
// \/_// robfinch<remove>@finitron.ca
|
9 |
|
|
// ||
|
10 |
|
|
//
|
11 |
|
|
// C32 - 'C' derived language compiler
|
12 |
|
|
// - 32 bit CPU
|
13 |
|
|
//
|
14 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
15 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
16 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
17 |
|
|
// (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// This source file is distributed in the hope that it will be useful,
|
20 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
|
|
// GNU General Public License for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License
|
25 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
26 |
|
|
//
|
27 |
|
|
// ============================================================================
|
28 |
|
|
//
|
29 |
|
|
/*
|
30 |
|
|
* 68000 C compiler
|
31 |
|
|
*
|
32 |
|
|
* Copyright 1984, 1985, 1986 Matthew Brandt.
|
33 |
|
|
* all commercial rights reserved.
|
34 |
|
|
*
|
35 |
|
|
* This compiler is intended as an instructive tool for personal use. Any
|
36 |
|
|
* use for profit without the written consent of the author is prohibited.
|
37 |
|
|
*
|
38 |
|
|
* This compiler may be distributed freely for non-commercial use as long
|
39 |
|
|
* as this notice stays intact. Please forward any enhancements or questions
|
40 |
|
|
* to:
|
41 |
|
|
*
|
42 |
|
|
* Matthew Brandt
|
43 |
|
|
* Box 920337
|
44 |
|
|
* Norcross, Ga 30092
|
45 |
|
|
*/
|
46 |
|
|
|
47 |
|
|
/* expression tree descriptions */
|
48 |
|
|
|
49 |
|
|
enum e_node {
|
50 |
|
|
en_void, /* used for parameter lists */
|
51 |
|
|
en_list, en_aggregate,
|
52 |
|
|
en_cbu, en_ccu, en_chu,
|
53 |
|
|
en_cubu, en_cucu, en_cuhu,
|
54 |
|
|
en_cbw, en_ccw, en_chw,
|
55 |
|
|
en_cubw, en_cucw, en_cuhw,
|
56 |
|
|
|
57 |
|
|
en_cbc, en_cbh,
|
58 |
|
|
en_cch,
|
59 |
|
|
en_cwl, en_cld, en_cfd,
|
60 |
|
|
en_icon, en_fcon, en_fqcon, en_dcon, en_tcon, en_labcon, en_nacon, en_autocon, en_autofcon, en_classcon,
|
61 |
|
|
en_clabcon, en_cnacon,
|
62 |
|
|
en_dlabcon, en_dnacon, // 30<-
|
63 |
|
|
|
64 |
|
|
en_c_ref, en_uc_ref, en_h_ref, en_uh_ref,
|
65 |
|
|
en_b_ref, en_w_ref, en_ub_ref, en_uw_ref,
|
66 |
|
|
en_ref32, en_ref32u,
|
67 |
|
|
en_struct_ref,
|
68 |
|
|
en_fcall, en_ifcall,
|
69 |
|
|
en_tempref, en_regvar, en_fpregvar, en_tempfpref,
|
70 |
|
|
en_add, en_sub, en_mul, en_mod,
|
71 |
|
|
en_ftadd, en_ftsub, en_ftmul, en_ftdiv,
|
72 |
|
|
en_fdadd, en_fdsub, en_fdmul, en_fddiv,
|
73 |
|
|
en_fsadd, en_fssub, en_fsmul, en_fsdiv,
|
74 |
|
|
en_fadd, en_fsub, en_fmul, en_fdiv,
|
75 |
|
|
en_i2d, en_i2t, en_i2q, en_d2i, en_q2i, en_s2q, en_t2i, // 63<-
|
76 |
|
|
en_div, en_asl, en_shl, en_shlu, en_shr, en_shru, en_asr, en_rol, en_ror,
|
77 |
|
|
en_cond, en_assign,
|
78 |
|
|
en_asadd, en_assub, en_asmul, en_asdiv, en_asdivu, en_asmod, en_asmodu,
|
79 |
|
|
en_asrsh, en_asrshu, en_asmulu, //81
|
80 |
|
|
en_aslsh, en_asand, en_asor, en_asxor, en_uminus, en_not, en_compl,
|
81 |
|
|
en_eq, en_ne, en_lt, en_le, en_gt, en_ge,
|
82 |
|
|
en_feq, en_fne, en_flt, en_fle, en_fgt, en_fge,
|
83 |
|
|
en_veq, en_vne, en_vlt, en_vle, en_vgt, en_vge,
|
84 |
|
|
en_and, en_or, en_land, en_lor, //104
|
85 |
|
|
en_xor, en_ainc, en_adec, en_mulu, en_udiv, en_umod, en_ugt,
|
86 |
|
|
en_uge, en_ule, en_ult,
|
87 |
|
|
en_ref, en_ursh,
|
88 |
|
|
en_uwfieldref,en_wfieldref,en_bfieldref,en_ubfieldref,
|
89 |
|
|
en_uhfieldref,en_hfieldref,en_ucfieldref,en_cfieldref,
|
90 |
|
|
en_dbl_ref, en_flt_ref, en_triple_ref, en_quad_ref,
|
91 |
|
|
en_chk,
|
92 |
|
|
en_abs, en_max, en_min,
|
93 |
|
|
// Vector
|
94 |
|
|
en_autovcon, en_autovmcon, en_vector_ref, en_vex, en_veins,
|
95 |
|
|
en_vadd, en_vsub, en_vmul, en_vdiv,
|
96 |
|
|
en_vadds, en_vsubs, en_vmuls, en_vdivs
|
97 |
|
|
};
|
98 |
|
|
|
99 |
|
|
class ENODE {
|
100 |
|
|
public:
|
101 |
|
|
enum e_node nodetype;
|
102 |
|
|
enum e_bt etype;
|
103 |
|
|
long esize;
|
104 |
|
|
TYP *tp;
|
105 |
|
|
SYM *sym;
|
106 |
|
|
__int8 constflag;
|
107 |
|
|
unsigned int predreg : 4;
|
108 |
|
|
unsigned int isVolatile : 1;
|
109 |
|
|
unsigned int isIO : 1;
|
110 |
|
|
unsigned int isUnsigned : 1;
|
111 |
|
|
unsigned int isDouble : 1;
|
112 |
|
|
unsigned int isCheckExpr : 1;
|
113 |
|
|
unsigned int isPascal : 1;
|
114 |
|
|
ENODE *vmask;
|
115 |
|
|
__int8 bit_width;
|
116 |
|
|
__int8 bit_offset;
|
117 |
|
|
__int8 scale;
|
118 |
|
|
// The following could be in a value union
|
119 |
|
|
int64_t i;
|
120 |
|
|
double f;
|
121 |
|
|
double f1, f2;
|
122 |
|
|
Float128 f128;
|
123 |
|
|
std::string *sp;
|
124 |
|
|
std::string *msp;
|
125 |
|
|
std::string *udnm; // undecorated name
|
126 |
|
|
void *ctor;
|
127 |
|
|
void *dtor;
|
128 |
|
|
ENODE *p[3];
|
129 |
|
|
void SetType(TYP *t) { tp = t; };
|
130 |
|
|
};
|
131 |
|
|
|
132 |
|
|
//typedef struct enode ENODE;
|
133 |
|
|
|
134 |
|
|
class CSE {
|
135 |
|
|
public:
|
136 |
|
|
short int nxt;
|
137 |
|
|
ENODE *exp; /* optimizable expression */
|
138 |
|
|
short int uses; /* number of uses */
|
139 |
|
|
short int duses; /* number of dereferenced uses */
|
140 |
|
|
short int voidf; /* cannot optimize flag */
|
141 |
|
|
short int reg; /* AllocateRegisterVarsd register */
|
142 |
|
|
unsigned int isfp : 1;
|
143 |
|
|
};
|
144 |
|
|
|
145 |
|
|
#define TRACE(x)
|
146 |
|
|
|
147 |
|
|
#endif
|