OSDN Git Service

* config/i386/i386.md (floatunssisf2): Use
[pf3gnuchains/gcc-fork.git] / gcc / treelang / treelang.h
1 /* TREELANG Compiler common definitions (treelang.h)
2    
3    Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
4    2007 Free Software Foundation, Inc.
5    
6    This program is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by the
8    Free Software Foundation; either version 3, or (at your option) any
9    later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; see the file COPYING3.  If not see
18    <http://www.gnu.org/licenses/>.
19    
20    In other words, you are welcome to use, share and improve this program.
21    You are forbidden to forbid anyone else to use, share and improve
22    what you give them.   Help stamp out software-hoarding!  
23    
24    ---------------------------------------------------------------------------
25    
26    Written by Tim Josling 1999, 2000, 2001, based in part on other
27    parts of the GCC compiler.  */
28
29 #include "input.h"
30
31 /* Parse structure type.  */
32 enum category_enum 
33 { /* These values less likely to be there by chance unlike 0/1,
34       make checks more meaningful */
35   token_category = 111,
36   production_category = 222,
37   parameter_category = 333
38 };
39
40 /* Input file FILE.  */
41 extern FILE* yyin;
42
43 /* Forward references to satisfy mutually recursive definitions.  */
44 struct token_part;
45 struct production_part;
46 struct prod_token_parm_item;
47 typedef struct prod_token_parm_item item;
48
49 /* A token from the input file.  */
50
51 struct token_part GTY(())
52 {
53   location_t location;
54   unsigned int charno;
55   unsigned int length; /* The value.  */
56   const unsigned char *chars;
57 };
58
59 /* Definitions for fields in production.  */
60 #define NESTING_LEVEL(a) a->tp.pro.info[0]  /* Level used for variable definitions.  */
61 /* Numeric type used in type definitions and expressions.  */
62 #define NUMERIC_TYPE(a)  a->tp.pro.info[1]  
63 #define SUB_COUNT 5
64 #define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0]) /* Name token.  */
65 #define EXPRESSION_TYPE(a) (a->tp.pro.sub[1]) /* Type identifier.  */
66 #define OP1(a) (a->tp.pro.sub[2]) /* Exp operand1.  */
67 #define PARAMETERS(a) (a->tp.pro.sub[2]) /* Function parameters.  */
68 #define VARIABLE(a) (a->tp.pro.sub[2]) /* Parameter variable ptr.  */
69 #define VAR_INIT(a) (a->tp.pro.sub[2]) /* Variable init.  */
70 #define OP2(a) (a->tp.pro.sub[3]) /* Exp operand2.  */
71 /* Function parameters linked via struct tree_parameter_list.  */
72 #define FIRST_PARMS(a) (a->tp.pro.sub[3])
73 #define OP3(a) (a->tp.pro.sub[4]) /* Exp operand3.  */
74 #define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4]) /* Storage class token.  */
75 #define STORAGE_CLASS(a) a->tp.pro.flag1 /* Values in treetree.h.  */
76
77 struct production_part GTY(())
78 {
79   struct prod_token_parm_item *main_token; /* Main token for error msgs; variable name token.  */
80
81   unsigned int info[2]; /* Extra information.  */
82
83   struct prod_token_parm_item *sub[SUB_COUNT]; /* Sub productions or tokens.  */
84   tree code; /* Back end hook for this item.  */
85   struct prod_token_parm_item *next; /* Next in chains of various types.  */
86
87   unsigned int flag1:2;
88   unsigned int flag2:1;
89   unsigned int flag3:1;
90   unsigned int flag4:1;
91   unsigned int flag5:1;
92   unsigned int flag6:1;
93   unsigned int flag7:1;
94
95 };
96
97 /* Storage modes.  */
98 #define STATIC_STORAGE 0
99 #define AUTOMATIC_STORAGE 1
100 #define EXTERNAL_REFERENCE_STORAGE 2
101 #define EXTERNAL_DEFINITION_STORAGE 3
102
103 /* Numeric types.  */
104 #define SIGNED_CHAR 1
105 #define UNSIGNED_CHAR 2
106 #define SIGNED_INT 3 
107 #define UNSIGNED_INT 4
108 #define VOID_TYPE 5
109
110 /* Expression types.  */
111 #define EXP_PLUS 0 /* Addition expression.  */
112 #define EXP_REFERENCE 1 /* Variable reference.  */
113 #define EXP_ASSIGN 2 /* Assignment.  */
114 #define EXP_FUNCTION_INVOCATION 3  /* Call function.  */
115 #define EXP_MINUS 4  /* Subtraction.  */
116 #define EXP_EQUALS 5  /* Equality test.  */
117
118 /* Parameter list passed to back end.  */
119 struct parameter_part GTY(())
120 {
121   struct prod_token_parm_item *next; /* Next entry.  */
122   const unsigned char *variable_name; /* Name. */
123   tree * GTY ((skip)) where_to_put_var_tree; /* Where to save decl.  */
124 };
125
126 /* A production or a token.  */
127 struct prod_token_parm_item GTY(())
128 {
129   enum category_enum category; /* Token or production. */
130   unsigned int type; /* Token or production type.  */
131   union t_or_p
132   {
133     struct token_part GTY((tag ("token_category"))) tok;
134     struct production_part GTY((tag ("production_category"))) pro;
135     struct parameter_part GTY((tag ("parameter_category"))) par;
136   } GTY((desc ("((item *)&%1)->category"))) tp;
137 };
138
139
140 /* For parser. Alternatively you can define it using %union (bison) or
141    union. */
142 #define YYSTYPE void *
143
144 void *my_malloc (size_t size);
145 int insert_tree_name (struct prod_token_parm_item *prod);
146 struct prod_token_parm_item *lookup_tree_name (struct prod_token_parm_item *prod);
147 struct prod_token_parm_item *make_production (int type, struct prod_token_parm_item *main_tok);
148 void mark_production_used (struct prod_token_parm_item *pp);
149 void mark_token_used (struct prod_token_parm_item *tt);
150 void treelang_debug (void);
151
152 void sanity_check (struct prod_token_parm_item *item);