OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [treelang/] [treelang.h] - Blame information for rev 819

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.