ignore .lib and .exe
[prop.git] / prop-src / sparc3.C
blobfa509c9bb7ee06da7f2cca866df7a436adc3f92d
1 ///////////////////////////////////////////////////////////////////////////////
2 //  This file is generated automatically using Prop (version 2.2.7),
3 //  last updated on Mar 20, 1996.
4 //  The original source file is "sparc3.pC".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_REWRITING_USED
8 #define PROP_EQUALITY_USED
9 #define PROP_QUARK_USED
10 #include <propdefs.h>
11 ///////////////////////////////////////////////////////////////////////////////
12 // Forward class definition for Inst
13 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef datatype_Inst_defined
15 #define datatype_Inst_defined
16    typedef class a_Inst * Inst;
17 #endif
19 ///////////////////////////////////////////////////////////////////////////////
20 // Class hierarchy for datatype Inst
21 ///////////////////////////////////////////////////////////////////////////////
22 class a_Inst; // base class for datatype Inst
23    class Inst_INT;      // subclass for 'INT int'
24    class Inst_LOAD;     // subclass for 'LOAD Inst'
25    class Inst_ADD;      // subclass for 'ADD (Inst, Inst)'
26    class Inst_SUB;      // subclass for 'SUB (Inst, Inst)'
27    class Inst_DIV;      // subclass for 'DIV (Inst, Inst)'
28    class Inst_MUL;      // subclass for 'MUL (Inst, Inst)'
30 ///////////////////////////////////////////////////////////////////////////////
31 // Base class for datatype 'Inst'
32 ///////////////////////////////////////////////////////////////////////////////
33 class a_Inst : public TermObj {
34 public:
35    enum Tag_Inst {
36       tag_INT = 0, tag_LOAD = 1, tag_ADD = 2, tag_SUB = 3, 
37       tag_DIV = 4, tag_MUL = 5
38    };
40 protected:
41    const Tag_Inst _tag_;
42    inline a_Inst(Tag_Inst _t_) : _tag_(_t_) {}
43 public:
44    inline int untag() const { return _tag_; }
45    inline friend int boxed(const a_Inst * x) { return 1; }
46    inline friend int untag(const a_Inst * x) { return x->_tag_; }
47    ////////////////////////////////////////////////////////////////////////////
48    // Downcasting functions for Inst
49    ////////////////////////////////////////////////////////////////////////////
50    inline friend Inst_INT * _INT(Inst _x_) { return (Inst_INT *)_x_; }
51    inline friend Inst_LOAD * _LOAD(Inst _x_) { return (Inst_LOAD *)_x_; }
52    inline friend Inst_ADD * _ADD(Inst _x_) { return (Inst_ADD *)_x_; }
53    inline friend Inst_SUB * _SUB(Inst _x_) { return (Inst_SUB *)_x_; }
54    inline friend Inst_DIV * _DIV(Inst _x_) { return (Inst_DIV *)_x_; }
55    inline friend Inst_MUL * _MUL(Inst _x_) { return (Inst_MUL *)_x_; }
58 ///////////////////////////////////////////////////////////////////////////////
59 // class for constructor 'Inst::INT int'
60 ///////////////////////////////////////////////////////////////////////////////
61 class Inst_INT : public a_Inst {
62 public:
63    int INT; 
64    inline Inst_INT (int _xINT)
65       : a_Inst(a_Inst::tag_INT), INT(_xINT) {}
66    inline friend a_Inst * INT (int _xINT)
67       { return new Inst_INT (_xINT); }
70 ///////////////////////////////////////////////////////////////////////////////
71 // class for constructor 'Inst::LOAD Inst'
72 ///////////////////////////////////////////////////////////////////////////////
73 class Inst_LOAD : public a_Inst {
74 public:
75    Inst LOAD; 
76    inline Inst_LOAD (Inst _xLOAD)
77       : a_Inst(a_Inst::tag_LOAD), LOAD(_xLOAD) {}
78    inline friend a_Inst * LOAD (Inst _xLOAD)
79       { return new Inst_LOAD (_xLOAD); }
82 ///////////////////////////////////////////////////////////////////////////////
83 // class for constructor 'Inst::ADD (Inst, Inst)'
84 ///////////////////////////////////////////////////////////////////////////////
85 class Inst_ADD : public a_Inst {
86 public:
87    Inst _1; Inst _2; 
88    inline Inst_ADD (Inst _x1, Inst _x2)
89       : a_Inst(a_Inst::tag_ADD), _1(_x1), _2(_x2) {}
90    inline friend a_Inst * ADD (Inst _x1, Inst _x2)
91       { return new Inst_ADD (_x1, _x2); }
94 ///////////////////////////////////////////////////////////////////////////////
95 // class for constructor 'Inst::SUB (Inst, Inst)'
96 ///////////////////////////////////////////////////////////////////////////////
97 class Inst_SUB : public a_Inst {
98 public:
99    Inst _1; Inst _2; 
100    inline Inst_SUB (Inst _x1, Inst _x2)
101       : a_Inst(a_Inst::tag_SUB), _1(_x1), _2(_x2) {}
102    inline friend a_Inst * SUB (Inst _x1, Inst _x2)
103       { return new Inst_SUB (_x1, _x2); }
106 ///////////////////////////////////////////////////////////////////////////////
107 // class for constructor 'Inst::DIV (Inst, Inst)'
108 ///////////////////////////////////////////////////////////////////////////////
109 class Inst_DIV : public a_Inst {
110 public:
111    Inst _1; Inst _2; 
112    inline Inst_DIV (Inst _x1, Inst _x2)
113       : a_Inst(a_Inst::tag_DIV), _1(_x1), _2(_x2) {}
114    inline friend a_Inst * DIV (Inst _x1, Inst _x2)
115       { return new Inst_DIV (_x1, _x2); }
118 ///////////////////////////////////////////////////////////////////////////////
119 // class for constructor 'Inst::MUL (Inst, Inst)'
120 ///////////////////////////////////////////////////////////////////////////////
121 class Inst_MUL : public a_Inst {
122 public:
123    Inst _1; Inst _2; 
124    inline Inst_MUL (Inst _x1, Inst _x2)
125       : a_Inst(a_Inst::tag_MUL), _1(_x1), _2(_x2) {}
126    inline friend a_Inst * MUL (Inst _x1, Inst _x2)
127       { return new Inst_MUL (_x1, _x2); }
132 void compile (Inst e)
134    extern void  _s_p_a_r_c_3co_X1_rewrite(Inst & );
135    _s_p_a_r_c_3co_X1_rewrite(e); 
137 class _s_p_a_r_c_3co_X1 : public BURS {
138 private:
139    _s_p_a_r_c_3co_X1(const _s_p_a_r_c_3co_X1&);               // no copy constructor
140    void operator = (const _s_p_a_r_c_3co_X1&); // no assignment
141 public:
142    struct _s_p_a_r_c_3co_X1_StateRec * stack__, * stack_top__;
143           void labeler(Inst & redex);
144    inline virtual void operator () (Inst & redex) { labeler(redex); }
145           void  reduce(Inst redex);
146 private: 
147    public:
148       inline _s_p_a_r_c_3co_X1() {}
150 void  _s_p_a_r_c_3co_X1_rewrite(Inst &  _x_) 
151 {  _s_p_a_r_c_3co_X1 _r_;
152    _r_(_x_); return _r_.reduce(_x_);
156 ///////////////////////////////////////////////////////////////////////////////
157 // State record for rewrite class _s_p_a_r_c_3co_X1
158 ///////////////////////////////////////////////////////////////////////////////
159 struct _s_p_a_r_c_3co_X1_StateRec {
160    TreeTables::Cost cost[3]; // cost for each non-terminal
161    struct { // accept rule number
162       unsigned int _exp : 3;
163       unsigned int _reg : 3;
164    } rule;
167 ///////////////////////////////////////////////////////////////////////////////
168 // Accept rules tables for rewrite class _s_p_a_r_c_3co_X1
169 ///////////////////////////////////////////////////////////////////////////////
170 const char _s_p_a_r_c_3co_X1_exp_accept[] = { -1, 8, 7, 6, 5, 4 };
172 const char _s_p_a_r_c_3co_X1_reg_accept[] = { -1, 3, 2, 1, 0 };
174 ///////////////////////////////////////////////////////////////////////////////
175 // Closure methods for rewrite class _s_p_a_r_c_3co_X1
176 ///////////////////////////////////////////////////////////////////////////////
177 static void _s_p_a_r_c_3co_X1_reg_closure(Inst redex,int cost);
179 static void _s_p_a_r_c_3co_X1_reg_closure(Inst redex,int cost__)
181    _s_p_a_r_c_3co_X1_StateRec * _state_rec = (_s_p_a_r_c_3co_X1_StateRec *)(redex->get_state_rec());
182    if (cost__ + 0 < _state_rec->cost[2])
183    {  _state_rec->cost[2] = cost__ + 0;
184       _state_rec->rule._exp = 1;
185    }
188 void _s_p_a_r_c_3co_X1::labeler (Inst redex)
190    int cost__;
191    _s_p_a_r_c_3co_X1_StateRec * _state_rec = (_s_p_a_r_c_3co_X1_StateRec *)mem[sizeof(_s_p_a_r_c_3co_X1_StateRec)];
192    redex->set_state_rec(_state_rec);
193    _state_rec->cost[0] = 0;
194    _state_rec->cost[1] = 
195    _state_rec->cost[2] = 32767;
196    {
197       switch (redex->untag()) {
198          case a_Inst::tag_INT: {
199             // Inst (0)
200             if (cost__ + 1 < state_rec->cost[1])
201             {   _state_rec->cost[1] = cost__ + 1;
202                 _state_rec->rule._reg = 4;
203                _s_p_a_r_c_3co_X1_reg_closure(redex, cost__ + 1);
204             }} break;
205          case a_Inst::tag_LOAD: {
206             // Inst (1)
207             switch (_LOAD(redex)->LOAD->untag()) {
208                case a_Inst::tag_INT: {
209                   if (cost__ + 2 < state_rec->cost[1])
210                   {   _state_rec->cost[1] = cost__ + 2;
211                       _state_rec->rule._reg = 3;
212                      _s_p_a_r_c_3co_X1_reg_closure(redex, cost__ + 2);
213                   }} break;
214                case a_Inst::tag_ADD: {
215                   if (cost__ + 3 < state_rec->cost[1])
216                   {   _state_rec->cost[1] = cost__ + 3;
217                       _state_rec->rule._reg = 2;
218                      _s_p_a_r_c_3co_X1_reg_closure(redex, cost__ + 3);
219                   }} break;
220                default: {} break;
221             }
222             int _X2 = cost(_LOAD(redex)->LOAD);
223             if (cost__ + _X2 < state_rec->cost[1])
224             {   _state_rec->cost[1] = cost__ + _X2;
225                 _state_rec->rule._reg = 1;
226                _s_p_a_r_c_3co_X1_reg_closure(redex, cost__ + _X2);
227             }} break;
228          case a_Inst::tag_ADD: {
229             // Inst (2)
230             if (cost__ + 1 < state_rec->cost[2])
231             {   _state_rec->cost[2] = cost__ + 1;
232                 _state_rec->rule._exp = 4;
233                _s_p_a_r_c_3co_X1_exp_closure(redex, cost__ + 1);
234             }} break;
235          case a_Inst::tag_SUB: {
236             // Inst (3)
237             if (cost__ + 1 < state_rec->cost[2])
238             {   _state_rec->cost[2] = cost__ + 1;
239                 _state_rec->rule._exp = 3;
240                _s_p_a_r_c_3co_X1_exp_closure(redex, cost__ + 1);
241             }} break;
242          case a_Inst::tag_DIV: {
243             // Inst (4)
244             int _X3 = notarget(a);
245             if (cost__ + _X3 < state_rec->cost[2])
246             {   _state_rec->cost[2] = cost__ + _X3;
247                 _state_rec->rule._exp = 1;
248                _s_p_a_r_c_3co_X1_exp_closure(redex, cost__ + _X3);
249             }} break;
250          default: {
251             // Inst (5)
252             if (cost__ + 2 < state_rec->cost[2])
253             {   _state_rec->cost[2] = cost__ + 2;
254                 _state_rec->rule._exp = 2;
255                _s_p_a_r_c_3co_X1_exp_closure(redex, cost__ + 2);
256             }} break;
257       }
258    }
259    
262 void _s_p_a_r_c_3co_X1::reduce(Inst redex)
264    int r__ = (_s_p_a_r_c_3co_X1_StateRec *)(redex->get_state_rec());
265    switch (r__) {
266       case 8: { // DIV (exp, exp)
267          reduce(_DIV(redex)->_1);
268          reduce(_DIV(redex)->_2);
269          } break;
270       case 7: { // MUL (exp, exp)
271          reduce(_MUL(redex)->_1);
272          reduce(_MUL(redex)->_2);
273          } break;
274       case 6: { // SUB (exp, exp)
275          reduce(_SUB(redex)->_1);
276          reduce(_SUB(redex)->_2);
277          } break;
278       case 5: { // ADD (exp, exp)
279          reduce(_ADD(redex)->_1);
280          reduce(_ADD(redex)->_2);
281          } break;
282       case 4: { // reg
283          reduce(redex);
284          } break;
285       case 3: { // LOAD reg
286          reduce(_LOAD(redex)->LOAD);
287          } break;
288       case 2: { // LOAD ADD (reg, reg)
289          reduce(_ADD(_LOAD(redex)->LOAD)->_1);
290          reduce(_ADD(_LOAD(redex)->LOAD)->_2);
291          } break;
292       case 1: { // LOAD INT addr
293          } break;
294       case 0: { // INT i
295          } break;
296    }
300 ------------------------------- Statistics -------------------------------
301 Merge matching rules         = yes
302 Number of DFA nodes merged   = 4
303 Number of ifs generated      = 0
304 Number of switches generated = 2
305 Number of labels             = 0
306 Number of gotos              = 0
307 Adaptive matching            = disabled
308 Fast string matching         = disabled
309 Inline downcasts             = disabled
310 --------------------------------------------------------------------------