Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
96e3ac4f
Commit
96e3ac4f
authored
Jun 10, 2002
by
Tim Josling
Committed by
Tim Josling
Jun 10, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to make treelang worg with PCH gengtype.c changes.
From-SVN: r54425
parent
02ef40d9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
238 additions
and
215 deletions
+238
-215
gcc/ChangeLog
+8
-0
gcc/gengtype.c
+12
-2
gcc/treelang/ChangeLog
+56
-0
gcc/treelang/Make-lang.in
+5
-2
gcc/treelang/config-lang.in
+3
-0
gcc/treelang/lex.l
+21
-24
gcc/treelang/parse.y
+0
-0
gcc/treelang/tree1.c
+28
-91
gcc/treelang/treelang.h
+79
-43
gcc/treelang/treetree.c
+24
-23
gcc/treelang/treetree.h
+2
-30
No files found.
gcc/ChangeLog
View file @
96e3ac4f
2002-06-10 Tim Josling <tej@melbpc.org.au>
* gengtype.c (unnamed enum containing BASE_FILE_*): Add languages
TREELANG and COBOL.
(lang_names): Add treelang and cobol.
(get_file_basename): Add code to support treelang and cobol as
4th and 5th users of c-common.c.
2002-06-09 Geoffrey Keating <geoffk@redhat.com>
2002-06-09 Geoffrey Keating <geoffk@redhat.com>
* Makefile.in (install-driver): Install driver as
* Makefile.in (install-driver): Install driver as
...
...
gcc/gengtype.c
View file @
96e3ac4f
...
@@ -500,10 +500,13 @@ FILE * header_file;
...
@@ -500,10 +500,13 @@ FILE * header_file;
enum
{
enum
{
BASE_FILE_C
,
BASE_FILE_C
,
BASE_FILE_OBJC
,
BASE_FILE_OBJC
,
BASE_FILE_CPLUSPLUS
BASE_FILE_CPLUSPLUS
,
BASE_FILE_TREELANG
,
BASE_FILE_COBOL
};
};
static
const
char
*
lang_names
[]
=
{
static
const
char
*
lang_names
[]
=
{
"c"
,
"objc"
,
"cp"
,
"f"
,
"ada"
,
"java"
"c"
,
"objc"
,
"cp"
,
"
treelang"
,
"cobol"
,
"
f"
,
"ada"
,
"java"
};
};
#define NUM_BASE_FILES (sizeof (lang_names) / sizeof (lang_names[0]))
#define NUM_BASE_FILES (sizeof (lang_names) / sizeof (lang_names[0]))
FILE
*
base_files
[
NUM_BASE_FILES
];
FILE
*
base_files
[
NUM_BASE_FILES
];
...
@@ -608,6 +611,10 @@ get_file_basename (f)
...
@@ -608,6 +611,10 @@ get_file_basename (f)
basename
-=
5
;
basename
-=
5
;
else
if
(
startswith
(
basename
-
f
,
basename
-
5
,
"objc/"
))
else
if
(
startswith
(
basename
-
f
,
basename
-
5
,
"objc/"
))
basename
-=
5
;
basename
-=
5
;
else
if
(
startswith
(
basename
-
f
,
basename
-
9
,
"treelang/"
))
basename
-=
9
;
else
if
(
startswith
(
basename
-
f
,
basename
-
6
,
"cobol/"
))
basename
-=
6
;
return
basename
;
return
basename
;
}
}
...
@@ -643,6 +650,9 @@ get_base_file_bitmap (input_file)
...
@@ -643,6 +650,9 @@ get_base_file_bitmap (input_file)
||
strcmp
(
basename
,
"c-decl.c"
)
==
0
||
strcmp
(
basename
,
"c-decl.c"
)
==
0
||
strcmp
(
basename
,
"c-objc-common.c"
)
==
0
)
||
strcmp
(
basename
,
"c-objc-common.c"
)
==
0
)
return
1
<<
BASE_FILE_C
|
1
<<
BASE_FILE_OBJC
;
return
1
<<
BASE_FILE_C
|
1
<<
BASE_FILE_OBJC
;
else
if
(
startswith
(
len
,
basename
,
"c-common.c"
))
return
1
<<
BASE_FILE_C
|
1
<<
BASE_FILE_OBJC
|
1
<<
BASE_FILE_CPLUSPLUS
|
1
<<
BASE_FILE_TREELANG
|
1
<<
BASE_FILE_COBOL
;
else
if
(
startswith
(
len
,
basename
,
"c-"
))
else
if
(
startswith
(
len
,
basename
,
"c-"
))
return
1
<<
BASE_FILE_C
|
1
<<
BASE_FILE_OBJC
|
1
<<
BASE_FILE_CPLUSPLUS
;
return
1
<<
BASE_FILE_C
|
1
<<
BASE_FILE_OBJC
|
1
<<
BASE_FILE_CPLUSPLUS
;
else
else
...
...
gcc/treelang/ChangeLog
View file @
96e3ac4f
2002-06-10 Tim Josling <tej@melbpc.org.au>
Cleanup
* Make-lang.in (check-treelang). Add. Remove direct dependency of
'check' on 'treelang.check' as redundant.
PCH Garbage collection regime (gengtypes.c) phase 1.
* Make-lang.in (treelang/tree1.o). Depend on gt-treelang-tree1.h
gt-treelang-treelang.h gtype-treelang.h.
(gt-treelang-tree1.h) Depend on s-gtype.
(gt-treelang-treelang.h) Depend on s-gtype.
(gtype-treelang.h) Depend on s-gtype.
* config-lang.in (gtfiles): Define.
* lex.l (main): Remove '#if 0' dead code.
(main): Move undef of IN_GCC so define of tree typedef works.
(all): Replace token and production by prod_token_parm_item.
* parse.y
(all): Replace token and production by prod_token_parm_item.
* tree1.c (main): Remove include of "output.h".
(symbol_table): Add GTY details.
(symbol_table_ggc): Remove.
(treelang_init): Remove root definitions for garage collection.
(mark_production_used): Remove.
(mark_token_used): Remove.
(main, at end): include generated garage collection routines.
* treelang.h (category_enum ): Add parameter_category.
(all): Replace token and production and parameters by union
prod_token_parm_item containing production_part, token_part,
parameter_part.
(STATIC_STORAGE AUTOMATIC_STORAGE EXTERNAL_REFERENCE_STORAGE
EXTERNAL_DEFINITION_STORAGE SIGNED_CHAR UNSIGNED_CHAR SIGNED_INT
UNSIGNED_INT VOID_TYPE EXP_PLUS EXP_REFERENCE EXP_ASSIGN
EXP_FUNCTION_INVOCATION EXP_MINUS EXP_EQUALS): Move here from
treetree.h.
* treetree.c
(tm_p.h): Do not include.
(ansidecl.h): Move include after config.h.
(treelang.h): Include it.
(ADDROOT): Remove.
(all): Replace token, production and parameter by prod_token_parm_item.
(tree_parameter_list): Move to treelang.h as part of
prod_token_parm_item.
(STATIC_STORAGE AUTOMATIC_STORAGE EXTERNAL_REFERENCE_STORAGE
EXTERNAL_DEFINITION_STORAGE SIGNED_CHAR UNSIGNED_CHAR SIGNED_INT
UNSIGNED_INT VOID_TYPE EXP_PLUS EXP_REFERENCE EXP_ASSIGN
EXP_FUNCTION_INVOCATION EXP_MINUS EXP_EQUALS): Move from here to
treelang.h.
2002-05-19 Tim Josling <tej@melbpc.org.au>
2002-05-19 Tim Josling <tej@melbpc.org.au>
* treetree.c (warn_format_zero_length): Add.
* treetree.c (warn_format_zero_length): Add.
...
...
gcc/treelang/Make-lang.in
View file @
96e3ac4f
...
@@ -90,7 +90,8 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
...
@@ -90,7 +90,8 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
# object file makes
# object file makes
treelang/tree1.o
:
$(srcdir)/treelang/tree1.c $(srcdir)/treelang/treelang.h $(srcdir)/treelang/parse.h
treelang/tree1.o
:
$(srcdir)/treelang/tree1.c $(srcdir)/treelang/treelang.h $(srcdir)/treelang/parse.h
\
gt-treelang-tree1.h gt-treelang-treelang.h gtype-treelang.h
$(CC)
-o
$@
-c
$(ALL_CFLAGS)
$(INCLUDES)
$<
$(CC)
-o
$@
-c
$(ALL_CFLAGS)
$(INCLUDES)
$<
treelang/treetree.o
:
$(srcdir)/treelang/treetree.c $(srcdir)/treelang/treetree.h
treelang/treetree.o
:
$(srcdir)/treelang/treetree.c $(srcdir)/treelang/treetree.h
...
@@ -114,6 +115,8 @@ $(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.h: $(srcdir)/treelang/parse.
...
@@ -114,6 +115,8 @@ $(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.h: $(srcdir)/treelang/parse.
--output
=
$(srcdir)
/treelang/parse.c
--defines
--output
=
$(srcdir)
/treelang/parse.c
--defines
# -v
# -v
gt-treelang-tree1.h gt-treelang-treelang.h gtype-treelang.h
:
s-gtype; @true
#
#
# Build hooks:
# Build hooks:
...
@@ -246,7 +249,7 @@ treelang.distdir:
...
@@ -246,7 +249,7 @@ treelang.distdir:
# test hook
# test hook
# the other languages are hard coded in the main makefile.in - that seems to be wrong
# the other languages are hard coded in the main makefile.in - that seems to be wrong
check
:
treelang.check
check
-treelang
:
treelang.check
TESTSUITEDIR
=
testsuite
TESTSUITEDIR
=
testsuite
...
...
gcc/treelang/config-lang.in
View file @
96e3ac4f
...
@@ -35,3 +35,6 @@ stagestuff=
...
@@ -35,3 +35,6 @@ stagestuff=
diff_excludes="-x lex.c -x parse.c -x parse.h"
diff_excludes="-x lex.c -x parse.c -x parse.h"
headers=
headers=
build_by_default="no"
build_by_default="no"
gtfiles="\$(srcdir)/treelang/tree1.c \$(srcdir)/treelang/treelang.h"
gcc/treelang/lex.l
View file @
96e3ac4f
...
@@ -33,22 +33,18 @@
...
@@ -33,22 +33,18 @@
*/
*/
/* Avoid poisoned malloc problem. */
#undef IN_GCC
#if 0
/* tree is defined as void* here to avoid any knowledge of tree stuff in this file. */
typedef void *tree;
#endif
#include <stdio.h>
#include <stdio.h>
#if 0
#include <ctype.h>
#endif
#include <memory.h>
#include <memory.h>
#include "ansidecl.h"
#include "ansidecl.h"
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
/* Avoid poisoned malloc problem. */
#undef IN_GCC
#include "config.h"
#include "diagnostic.h"
#include "diagnostic.h"
#include "tree.h"
/* Token defs. */
/* Token defs. */
#include "treelang.h"
#include "treelang.h"
...
@@ -81,9 +77,10 @@ static void dump_lex_value (int lexret);
...
@@ -81,9 +77,10 @@ static void dump_lex_value (int lexret);
%%
%%
{
{
yylval
=
my_malloc
(
sizeof
(
struct
token
));
/* Should really allocate only what we need. lll;. */
((
struct
token
*
)
yylval
)
->
lineno
=
next_tree_lineno
;
yylval
=
my_malloc
(
sizeof
(
struct
prod_token_parm_item
));
((
struct
token
*
)
yylval
)
->
charno
=
next_tree_charno
;
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
lineno
=
next_tree_lineno
;
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
charno
=
next_tree_charno
;
}
}
[
\
n
]
+
{
[
\
n
]
+
{
...
@@ -221,8 +218,8 @@ static void dump_lex_value (int lexret);
...
@@ -221,8 +218,8 @@ static void dump_lex_value (int lexret);
[
^
\
n
]
{
[
^
\
n
]
{
update_lineno_charno
();
update_lineno_charno
();
fprintf
(
stderr
,
"%s:%i:%i: Unrecognized character %c
\n
"
,
in_fname
,
fprintf
(
stderr
,
"%s:%i:%i: Unrecognized character %c
\n
"
,
in_fname
,
((
struct
token
*
)
yylval
)
->
lineno
,
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
lineno
,
((
struct
token
*
)
yylval
)
->
charno
,
yytext
[
0
]);
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
charno
,
yytext
[
0
]);
errorcount
++
;
errorcount
++
;
}
}
...
@@ -238,8 +235,8 @@ update_lineno_charno (void)
...
@@ -238,8 +235,8 @@ update_lineno_charno (void)
/* Update the values we send to caller in case we sometimes don't
/* Update the values we send to caller in case we sometimes don't
tell them about all the 'tokens' eg comments etc. */
tell them about all the 'tokens' eg comments etc. */
int
yyl
;
int
yyl
;
((
struct
token
*
)
yylval
)
->
lineno
=
next_tree_lineno
;
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
lineno
=
next_tree_lineno
;
((
struct
token
*
)
yylval
)
->
charno
=
next_tree_charno
;
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
charno
=
next_tree_charno
;
for
(
yyl
=
0
;
yyl
<
yyleng
;
++
yyl
)
for
(
yyl
=
0
;
yyl
<
yyleng
;
++
yyl
)
{
{
if
(
yytext
[
yyl
]
==
'\n'
)
if
(
yytext
[
yyl
]
==
'\n'
)
...
@@ -257,16 +254,16 @@ update_lineno_charno (void)
...
@@ -257,16 +254,16 @@ update_lineno_charno (void)
void
void
update_yylval
(
int
a
)
update_yylval
(
int
a
)
{
{
struct
token
*
tok
;
struct
prod_token_parm_item
*
tok
;
tok
=
yylval
;
tok
=
yylval
;
tok
->
category
=
token_category
;
tok
->
category
=
token_category
;
tok
->
type
=
a
;
tok
->
type
=
a
;
tok
->
length
=
yyleng
;
tok
->
tp
.
tok
.
length
=
yyleng
;
/* Have to copy yytext as it is just a ptr into the buffer at the
/* Have to copy yytext as it is just a ptr into the buffer at the
moment. */
moment. */
tok
->
chars
=
my_malloc
(
yyleng
+
1
);
tok
->
tp
.
tok
.
chars
=
my_malloc
(
yyleng
+
1
);
memcpy
(
tok
->
chars
,
yytext
,
yyleng
);
memcpy
(
tok
->
tp
.
tok
.
chars
,
yytext
,
yyleng
);
}
}
/* Trace the value LEXRET and the position and token details being
/* Trace the value LEXRET and the position and token details being
...
@@ -277,9 +274,9 @@ dump_lex_value (int lexret)
...
@@ -277,9 +274,9 @@ dump_lex_value (int lexret)
{
{
int
ix
;
int
ix
;
fprintf
(
stderr
,
" %d l:%d c:%d ln:%d text="
,
lexret
,
fprintf
(
stderr
,
" %d l:%d c:%d ln:%d text="
,
lexret
,
((
struct
token
*
)
yylval
)
->
lineno
,
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
lineno
,
((
struct
token
*
)
yylval
)
->
charno
,
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
charno
,
((
struct
token
*
)
yylval
)
->
length
);
((
struct
prod_token_parm_item
*
)
yylval
)
->
tp
.
tok
.
length
);
for
(
ix
=
0
;
ix
<
yyleng
;
ix
++
)
for
(
ix
=
0
;
ix
<
yyleng
;
ix
++
)
{
{
fprintf
(
stderr
,
"%c"
,
yytext
[
ix
]);
fprintf
(
stderr
,
"%c"
,
yytext
[
ix
]);
...
...
gcc/treelang/parse.y
View file @
96e3ac4f
This diff is collapsed.
Click to expand it.
gcc/treelang/tree1.c
View file @
96e3ac4f
...
@@ -35,7 +35,6 @@
...
@@ -35,7 +35,6 @@
#include "system.h"
#include "system.h"
#include "ansidecl.h"
#include "ansidecl.h"
#include "flags.h"
#include "flags.h"
#include "output.h"
#include "toplev.h"
#include "toplev.h"
#include "ggc.h"
#include "ggc.h"
...
@@ -55,7 +54,7 @@
...
@@ -55,7 +54,7 @@
extern
int
yyparse
(
void
);
extern
int
yyparse
(
void
);
/* Linked list of symbols - all must be unique in treelang. */
/* Linked list of symbols - all must be unique in treelang. */
st
ruct
production
*
symbol_table
=
NULL
;
st
atic
GTY
(())
struct
prod_token_parm_item
*
symbol_table
=
NULL
;
/* Language for usage for messages. */
/* Language for usage for messages. */
...
@@ -65,9 +64,6 @@ const char *const language_string = "TREELANG - sample front end for GCC ";
...
@@ -65,9 +64,6 @@ const char *const language_string = "TREELANG - sample front end for GCC ";
void
version
(
void
);
void
version
(
void
);
/* GC routine for symbol table. */
static
void
symbol_table_ggc
(
void
*
m
);
/* Global variables. */
/* Global variables. */
extern
struct
cbl_tree_struct_parse_tree_top
*
parse_tree_top
;
extern
struct
cbl_tree_struct_parse_tree_top
*
parse_tree_top
;
...
@@ -191,18 +187,6 @@ treelang_decode_option (num_options_left, first_option_left)
...
@@ -191,18 +187,6 @@ treelang_decode_option (num_options_left, first_option_left)
const
char
*
const
char
*
treelang_init
(
const
char
*
filename
)
treelang_init
(
const
char
*
filename
)
{
{
/* Define my garbage collection routines. */
ggc_add_root
(
&
symbol_table
,
1
,
/* Unused size. */
sizeof
(
void
*
),
symbol_table_ggc
);
/* Note: only storage that has to be kept across functions needs to
be protected from GC. */
/* Define my garbage collection routines. */
ggc_add_root
(
&
symbol_table
,
1
,
/* Unused size. */
sizeof
(
void
*
),
symbol_table_ggc
);
/* Note: only storage that has to be kept across functions needs to
be protected from GC. */
/* Set up the declarations needed for this front end. */
/* Set up the declarations needed for this front end. */
input_filename
=
""
;
input_filename
=
""
;
...
@@ -250,58 +234,6 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
...
@@ -250,58 +234,6 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
yyparse
();
yyparse
();
}
}
/* Scan the symbol table* M, marking storage used. */
static
void
symbol_table_ggc
(
void
*
m
)
{
struct
production
*
pp
;
pp
=
*
(
struct
production
**
)
m
;
/* Actually it is a pointer to a pointer, to allow reallocation and
relinking. */
mark_production_used
(
pp
);
}
/* Mark a production PP as used so it wont be garbage collected. */
void
mark_production_used
(
struct
production
*
pp
)
{
int
sub_ix
;
loop
:
if
(
!
pp
)
return
;
ggc_mark
(
pp
);
if
(
pp
->
category
==
token_category
)
{
mark_token_used
((
struct
token
*
)
pp
);
return
;
}
if
(
pp
->
category
!=
production_category
)
abort
();
mark_token_used
(
pp
->
main_token
);
for
(
sub_ix
=
0
;
sub_ix
<
SUB_COUNT
;
sub_ix
++
)
mark_production_used
(
pp
->
sub
[
sub_ix
]);
/* The macro tests for NULL so I don't need to. */
ggc_mark_tree
(
pp
->
code
);
pp
=
pp
->
next
;
goto
loop
;
}
/* Mark a token TT as used so it wont be garbage collected. */
void
mark_token_used
(
struct
token
*
tt
)
{
if
(
!
tt
)
return
;
ggc_mark
(
tt
);
if
(
tt
->
chars
)
ggc_mark
(
tt
->
chars
);
}
/* Allocate SIZE bytes and clear them. */
/* Allocate SIZE bytes and clear them. */
void
*
void
*
...
@@ -322,45 +254,46 @@ my_malloc (size_t size)
...
@@ -322,45 +254,46 @@ my_malloc (size_t size)
return the symbol table entry from the symbol table if found there,
return the symbol table entry from the symbol table if found there,
else 0. */
else 0. */
struct
prod
uction
*
struct
prod
_token_parm_item
*
lookup_tree_name
(
struct
prod
uction
*
prod
)
lookup_tree_name
(
struct
prod
_token_parm_item
*
prod
)
{
{
struct
prod
uction
*
this
;
struct
prod
_token_parm_item
*
this
;
struct
token
*
this_tok
;
struct
prod_token_parm_item
*
this_tok
;
struct
token
*
tok
;
struct
prod_token_parm_item
*
tok
;
tok
=
SYMBOL_TABLE_NAME
(
prod
);
tok
=
SYMBOL_TABLE_NAME
(
prod
);
for
(
this
=
symbol_table
;
this
;
this
=
this
->
next
)
for
(
this
=
symbol_table
;
this
;
this
=
this
->
tp
.
pro
.
next
)
{
{
this_tok
=
this
->
main_token
;
this_tok
=
this
->
tp
.
pro
.
main_token
;
if
(
tok
->
length
!=
this_tok
->
length
)
if
(
tok
->
tp
.
tok
.
length
!=
this_tok
->
tp
.
tok
.
length
)
continue
;
continue
;
if
(
memcmp
(
tok
->
chars
,
this_tok
->
chars
,
this_tok
->
length
))
if
(
memcmp
(
tok
->
tp
.
tok
.
chars
,
this_tok
->
tp
.
tok
.
chars
,
this_tok
->
tp
.
tok
.
length
))
continue
;
continue
;
if
(
option_parser_trace
)
if
(
option_parser_trace
)
fprintf
(
stderr
,
"Found symbol %s (%i:%i) as %i
\n
"
,
tok
->
chars
,
fprintf
(
stderr
,
"Found symbol %s (%i:%i) as %i
\n
"
,
tok
->
tp
.
tok
.
chars
,
tok
->
lineno
,
tok
->
charno
,
NUMERIC_TYPE
(
this
));
tok
->
tp
.
tok
.
lineno
,
tok
->
tp
.
tok
.
charno
,
NUMERIC_TYPE
(
this
));
return
this
;
return
this
;
}
}
if
(
option_parser_trace
)
if
(
option_parser_trace
)
fprintf
(
stderr
,
"Not found symbol %s (%i:%i) as %i
\n
"
,
tok
->
chars
,
fprintf
(
stderr
,
"Not found symbol %s (%i:%i) as %i
\n
"
,
tok
->
tp
.
tok
.
chars
,
tok
->
lineno
,
tok
->
charno
,
tok
->
type
);
tok
->
tp
.
tok
.
lineno
,
tok
->
tp
.
tok
.
charno
,
tok
->
type
);
return
NULL
;
return
NULL
;
}
}
/* Insert name PROD into the symbol table. Return 1 if duplicate, 0 if OK. */
/* Insert name PROD into the symbol table. Return 1 if duplicate, 0 if OK. */
int
int
insert_tree_name
(
struct
prod
uction
*
prod
)
insert_tree_name
(
struct
prod
_token_parm_item
*
prod
)
{
{
struct
token
*
tok
;
struct
prod_token_parm_item
*
tok
;
tok
=
SYMBOL_TABLE_NAME
(
prod
);
tok
=
SYMBOL_TABLE_NAME
(
prod
);
if
(
lookup_tree_name
(
prod
))
if
(
lookup_tree_name
(
prod
))
{
{
fprintf
(
stderr
,
"%s:%i:%i duplicate name %s
\n
"
,
in_fname
,
tok
->
lineno
,
tok
->
charno
,
tok
->
chars
);
fprintf
(
stderr
,
"%s:%i:%i duplicate name %s
\n
"
,
in_fname
,
tok
->
tp
.
tok
.
lineno
,
tok
->
tp
.
tok
.
charno
,
tok
->
tp
.
tok
.
chars
);
errorcount
++
;
errorcount
++
;
return
1
;
return
1
;
}
}
prod
->
next
=
symbol_table
;
prod
->
tp
.
pro
.
next
=
symbol_table
;
NESTING_LEVEL
(
prod
)
=
work_nesting_level
;
NESTING_LEVEL
(
prod
)
=
work_nesting_level
;
symbol_table
=
prod
;
symbol_table
=
prod
;
return
0
;
return
0
;
...
@@ -368,15 +301,19 @@ insert_tree_name (struct production *prod)
...
@@ -368,15 +301,19 @@ insert_tree_name (struct production *prod)
/* Create a struct productions of type TYPE, main token MAIN_TOK. */
/* Create a struct productions of type TYPE, main token MAIN_TOK. */
struct
prod
uction
*
struct
prod
_token_parm_item
*
make_production
(
int
type
,
struct
token
*
main_tok
)
make_production
(
int
type
,
struct
prod_token_parm_item
*
main_tok
)
{
{
struct
prod
uction
*
prod
;
struct
prod
_token_parm_item
*
prod
;
prod
=
my_malloc
(
sizeof
(
struct
prod
uction
));
prod
=
my_malloc
(
sizeof
(
struct
prod
_token_parm_item
));
prod
->
category
=
production_category
;
prod
->
category
=
production_category
;
prod
->
type
=
type
;
prod
->
type
=
type
;
prod
->
main_token
=
main_tok
;
prod
->
tp
.
pro
.
main_token
=
main_tok
;
return
prod
;
return
prod
;
}
}
/* New garbage collection regime see gty.texi. */
#include "gt-treelang-tree1.h"
/*#include "gt-treelang-treelang.h"*/
#include "gtype-treelang.h"
gcc/treelang/treelang.h
View file @
96e3ac4f
...
@@ -35,64 +35,57 @@ enum category_enum
...
@@ -35,64 +35,57 @@ enum category_enum
{
/* These values less likely to be there by chance unlike 0/1,
{
/* These values less likely to be there by chance unlike 0/1,
make checks more meaningful */
make checks more meaningful */
token_category
=
111
,
token_category
=
111
,
production_category
=
222
production_category
=
222
,
parameter_category
=
333
};
};
/* Input file name and FILE. */
/* Input file name and FILE. */
extern
unsigned
char
*
in_fname
;
extern
unsigned
char
*
in_fname
;
extern
FILE
*
yyin
;
extern
FILE
*
yyin
;
#if 0
/* Forward references to satisfy mutually recursive definitions. */
extern int errorcount; /* In toplev.c. */
struct
token_part
;
#endif
struct
production_part
;
struct
prod_token_parm_item
;
typedef
struct
GTY
(())
prod_token_parm_item
item
;
struct
token
/* A token from the input file. */
struct
token_part
GTY
(())
{
{
enum
category_enum
category
;
/* Token or production. */
unsigned
int
type
;
/* Token type. */
/* Prior to this point, production must match token. */
unsigned
int
lineno
;
unsigned
int
lineno
;
unsigned
int
charno
;
unsigned
int
charno
;
unsigned
int
length
;
/* The value. */
unsigned
int
length
;
/* The value. */
unsigned
char
*
chars
;
unsigned
char
*
chars
;
};
};
struct
production
/* Definitions for fields in production. */
#define NESTING_LEVEL(a) a->tp.pro.info[0]
/* Level used for variable definitions. */
#define NUMERIC_TYPE(a) a->tp.pro.info[1]
/* Numeric type used in type definitions and expressions. */
#define SUB_COUNT 5
#define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0])
/* Name token. */
#define EXPRESSION_TYPE(a) (a->tp.pro.sub[1])
/* Type identifier. */
#define OP1(a) (a->tp.pro.sub[2])
/* Exp operand1. */
#define PARAMETERS(a) (a->tp.pro.sub[2])
/* Function parameters. */
#define VARIABLE(a) (a->tp.pro.sub[2])
/* Parameter variable ptr. */
#define VAR_INIT(a) (a->tp.pro.sub[2])
/* Variable init. */
#define OP2(a) (a->tp.pro.sub[3])
/* Exp operand2. */
#define FIRST_PARMS(a) (a->tp.pro.sub[3])
/* Function parameters linked via struct tree_parameter_list. */
#define OP3(a) (a->tp.pro.sub[4])
/* Exp operand3. */
#define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4])
/* Storage class token. */
#define STORAGE_CLASS(a) a->tp.pro.flag1
/* Values in treetree.h. */
struct
production_part
GTY
(())
{
{
enum
category_enum
category
;
/* Token or Production. */
struct
prod_token_parm_item
*
main_token
;
/* Main token for error msgs; variable name token. */
unsigned
int
type
;
/* Production type - a fake token name. */
/* Prior to this point, production must match token. */
struct
token
*
main_token
;
/* Main token for error msgs; variable name token. */
unsigned
int
info
[
2
];
/* Extra information. */
unsigned
int
info
[
2
];
/* Extra information. */
#define NESTING_LEVEL(a) a->info[0]
/* Level used for variable definitions. */
#define NUMERIC_TYPE(a) a->info[1]
/* Numeric type used in type definitions and expressions. */
#define SUB_COUNT 5
void
*
sub
[
SUB_COUNT
];
/* Sub productions or tokens. */
#define SYMBOL_TABLE_NAME(a) (a->sub[0])
/* Name token. */
#define EXPRESSION_TYPE(a) (a->sub[1])
/* Type identifier. */
#define OP1(a) (a->sub[2])
/* Exp operand1. */
#define PARAMETERS(a) (a->sub[2])
/* Function parameters. */
#define VARIABLE(a) (a->sub[2])
/* Parameter variable ptr. */
#define VAR_INIT(a) (a->sub[2])
/* Variable init. */
#define OP2(a) (a->sub[3])
/* Exp operand2. */
#define FIRST_PARMS(a) (a->sub[3])
/* Function parameters linked via struct tree_parameter_list. */
#define OP3(a) (a->sub[4])
/* Exp operand3. */
struct
prod_token_parm_item
*
sub
[
SUB_COUNT
];
/* Sub productions or tokens. */
#define STORAGE_CLASS_TOKEN(a) (a->sub[4])
/* Storage class token. */
tree
code
;
/* Back end hook for this item. */
struct
prod_token_parm_item
*
next
;
/* Next in chains of various types. */
void
*
code
;
/* Back end hook for this item. */
struct
production
*
next
;
/* Next in chains of various types. */
unsigned
int
flag1
:
2
;
unsigned
int
flag1
:
2
;
#define STORAGE_CLASS(a) a->flag1
/* Values in treetree.h. */
unsigned
int
flag2
:
1
;
unsigned
int
flag2
:
1
;
unsigned
int
flag3
:
1
;
unsigned
int
flag3
:
1
;
unsigned
int
flag4
:
1
;
unsigned
int
flag4
:
1
;
...
@@ -102,15 +95,58 @@ struct production
...
@@ -102,15 +95,58 @@ struct production
};
};
/* Storage modes. */
#define STATIC_STORAGE 0
#define AUTOMATIC_STORAGE 1
#define EXTERNAL_REFERENCE_STORAGE 2
#define EXTERNAL_DEFINITION_STORAGE 3
/* Numeric types. */
#define SIGNED_CHAR 1
#define UNSIGNED_CHAR 2
#define SIGNED_INT 3
#define UNSIGNED_INT 4
#define VOID_TYPE 5
/* Expression types. */
#define EXP_PLUS 0
/* Addition expression. */
#define EXP_REFERENCE 1
/* Variable reference. */
#define EXP_ASSIGN 2
/* Assignment. */
#define EXP_FUNCTION_INVOCATION 3
/* Call function. */
#define EXP_MINUS 4
/* Subtraction. */
#define EXP_EQUALS 5
/* Equality test. */
/* Parameter list passed to back end. */
struct
parameter_part
GTY
(())
{
struct
prod_token_parm_item
*
next
;
/* Next entry. */
unsigned
char
*
variable_name
;
/* Name. */
tree
*
GTY
((
length
(
"1"
)))
where_to_put_var_tree
;
/* Where to save decl. */
};
/* A production or a token. */
struct
prod_token_parm_item
GTY
(())
{
enum
category_enum
category
;
/* Token or production. */
unsigned
int
type
;
/* Token or production type. */
union
t_or_p
{
struct
token_part
GTY
((
tag
(
"token_category"
)))
tok
;
struct
production_part
GTY
((
tag
(
"production_category"
)))
pro
;
struct
parameter_part
GTY
((
tag
(
"parameter_category"
)))
par
;
}
GTY
((
desc
(
"((item *)&%1)->category"
)))
tp
;
};
/* For parser. Alternatively you can define it using %union (bison) or
/* For parser. Alternatively you can define it using %union (bison) or
union. */
union. */
#define YYSTYPE void *
#define YYSTYPE void *
void
*
my_malloc
(
size_t
size
);
void
*
my_malloc
(
size_t
size
);
int
insert_tree_name
(
struct
prod
uction
*
prod
);
int
insert_tree_name
(
struct
prod
_token_parm_item
*
prod
);
struct
prod
uction
*
lookup_tree_name
(
struct
production
*
prod
);
struct
prod
_token_parm_item
*
lookup_tree_name
(
struct
prod_token_parm_item
*
prod
);
struct
prod
uction
*
make_production
(
int
type
,
struct
token
*
main_tok
);
struct
prod
_token_parm_item
*
make_production
(
int
type
,
struct
prod_token_parm_item
*
main_tok
);
void
mark_production_used
(
struct
prod
uction
*
pp
);
void
mark_production_used
(
struct
prod
_token_parm_item
*
pp
);
void
mark_token_used
(
struct
token
*
tt
);
void
mark_token_used
(
struct
prod_token_parm_item
*
tt
);
void
treelang_debug
(
void
);
void
treelang_debug
(
void
);
gcc/treelang/treetree.c
View file @
96e3ac4f
...
@@ -70,21 +70,21 @@
...
@@ -70,21 +70,21 @@
/* GCC headers. */
/* GCC headers. */
#include "ansidecl.h"
#include "config.h"
#include "config.h"
#include "ansidecl.h"
#include "system.h"
#include "system.h"
#include "tree.h"
#include "tree.h"
#include "flags.h"
#include "flags.h"
#include "output.h"
#include "output.h"
#include "c-tree.h"
#include "c-tree.h"
#include "rtl.h"
#include "rtl.h"
#include "tm_p.h"
#include "ggc.h"
#include "ggc.h"
#include "toplev.h"
#include "toplev.h"
#include "varray.h"
#include "varray.h"
#include "langhooks-def.h"
#include "langhooks-def.h"
#include "langhooks.h"
#include "langhooks.h"
#include "treelang.h"
#include "treetree.h"
#include "treetree.h"
extern
int
option_main
;
extern
int
option_main
;
...
@@ -163,14 +163,6 @@ const char *const tree_code_name[] = {
...
@@ -163,14 +163,6 @@ const char *const tree_code_name[] = {
unsigned
int
tree_code_int_size
=
0
;
unsigned
int
tree_code_int_size
=
0
;
unsigned
int
tree_code_char_size
=
0
;
unsigned
int
tree_code_char_size
=
0
;
/* In this case there is very little to keep between functions - we
keep the symbol table only and the things that hang off that - see
tree1.c. Garbage collection is only invoked when we call
rest_of_compilation at the end of a function. */
#define ADDROOT(where) ggc_add_root (&where, 1,
/* Unused size. */
sizeof (void*), \
tree_ggc_storage_always_used);
/* Return the tree stuff for this type TYPE_NUM. */
/* Return the tree stuff for this type TYPE_NUM. */
tree
tree
...
@@ -242,13 +234,13 @@ tree
...
@@ -242,13 +234,13 @@ tree
tree_code_create_function_prototype
(
unsigned
char
*
chars
,
tree_code_create_function_prototype
(
unsigned
char
*
chars
,
unsigned
int
storage_class
,
unsigned
int
storage_class
,
unsigned
int
ret_type
,
unsigned
int
ret_type
,
struct
tree_parameter_list
*
parms
,
struct
prod_token_parm_item
*
parms
,
unsigned
char
*
filename
,
unsigned
char
*
filename
,
int
lineno
)
int
lineno
)
{
{
tree
id
;
tree
id
;
struct
tree_parameter_list
*
parm
;
struct
prod_token_parm_item
*
parm
;
tree
type_list
=
NULL_TREE
;
tree
type_list
=
NULL_TREE
;
tree
type_node
;
tree
type_node
;
tree
fn_type
;
tree
fn_type
;
...
@@ -256,7 +248,7 @@ tree_code_create_function_prototype (unsigned char* chars,
...
@@ -256,7 +248,7 @@ tree_code_create_function_prototype (unsigned char* chars,
/* Build the type. */
/* Build the type. */
id
=
get_identifier
((
const
char
*
)
chars
);
id
=
get_identifier
((
const
char
*
)
chars
);
for
(
parm
=
parms
;
parm
;
parm
=
parm
->
next
)
for
(
parm
=
parms
;
parm
;
parm
=
parm
->
tp
.
par
.
next
)
{
{
type_node
=
get_type_for_numeric_type
(
parm
->
type
);
type_node
=
get_type_for_numeric_type
(
parm
->
type
);
type_list
=
tree_cons
(
NULL_TREE
,
type_node
,
type_list
);
type_list
=
tree_cons
(
NULL_TREE
,
type_node
,
type_list
);
...
@@ -328,7 +320,7 @@ void
...
@@ -328,7 +320,7 @@ void
tree_code_create_function_initial
(
tree
prev_saved
,
tree_code_create_function_initial
(
tree
prev_saved
,
unsigned
char
*
filename
,
unsigned
char
*
filename
,
int
lineno
,
int
lineno
,
struct
tree_parameter_list
*
parms
)
struct
prod_token_parm_item
*
parms
)
{
{
tree
fn_decl
;
tree
fn_decl
;
tree
param_decl
;
tree
param_decl
;
...
@@ -337,8 +329,8 @@ tree_code_create_function_initial (tree prev_saved,
...
@@ -337,8 +329,8 @@ tree_code_create_function_initial (tree prev_saved,
tree
parm_decl
;
tree
parm_decl
;
tree
parm_list
;
tree
parm_list
;
tree
resultdecl
;
tree
resultdecl
;
struct
tree_parameter_list
*
this_parm
;
struct
prod_token_parm_item
*
this_parm
;
struct
tree_parameter_list
*
parm
;
struct
prod_token_parm_item
*
parm
;
fn_decl
=
prev_saved
;
fn_decl
=
prev_saved
;
if
(
!
fn_decl
)
if
(
!
fn_decl
)
...
@@ -368,10 +360,11 @@ tree_code_create_function_initial (tree prev_saved,
...
@@ -368,10 +360,11 @@ tree_code_create_function_initial (tree prev_saved,
/* Make the argument variable decls. */
/* Make the argument variable decls. */
parm_list
=
NULL_TREE
;
parm_list
=
NULL_TREE
;
for
(
parm
=
parms
;
parm
;
parm
=
parm
->
next
)
for
(
parm
=
parms
;
parm
;
parm
=
parm
->
tp
.
par
.
next
)
{
{
parm_decl
=
build_decl
(
PARM_DECL
,
get_identifier
((
const
char
*
)
(
parm
->
variable_name
)),
parm_decl
=
build_decl
(
PARM_DECL
,
get_identifier
get_type_for_numeric_type
(
parm
->
type
));
((
const
char
*
)
(
parm
->
tp
.
par
.
variable_name
)),
get_type_for_numeric_type
(
parm
->
type
));
/* Some languages have different nominal and real types. */
/* Some languages have different nominal and real types. */
DECL_ARG_TYPE
(
parm_decl
)
=
TREE_TYPE
(
parm_decl
);
DECL_ARG_TYPE
(
parm_decl
)
=
TREE_TYPE
(
parm_decl
);
...
@@ -395,11 +388,11 @@ tree_code_create_function_initial (tree prev_saved,
...
@@ -395,11 +388,11 @@ tree_code_create_function_initial (tree prev_saved,
this_parm
=
parms
;
this_parm
=
parms
;
param_decl
;
param_decl
;
param_decl
=
TREE_CHAIN
(
param_decl
),
param_decl
=
TREE_CHAIN
(
param_decl
),
this_parm
=
this_parm
->
next
)
this_parm
=
this_parm
->
tp
.
par
.
next
)
{
{
if
(
!
this_parm
)
if
(
!
this_parm
)
abort
();
/* Too few. */
abort
();
/* Too few. */
*
this_parm
->
where_to_put_var_tree
=
param_decl
;
*
this_parm
->
tp
.
par
.
where_to_put_var_tree
=
param_decl
;
}
}
if
(
this_parm
)
if
(
this_parm
)
abort
();
/* Too many. */
abort
();
/* Too many. */
...
@@ -1032,8 +1025,16 @@ handle_format_arg_attribute (tree *node ATTRIBUTE_UNUSED,
...
@@ -1032,8 +1025,16 @@ handle_format_arg_attribute (tree *node ATTRIBUTE_UNUSED,
int
int
cpp_handle_option
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_handle_option
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
int
argc
ATTRIBUTE_UNUSED
,
int
argc
ATTRIBUTE_UNUSED
,
char
**
argv
ATTRIBUTE_UNUSED
,
char
**
argv
ATTRIBUTE_UNUSED
)
int
ignore
ATTRIBUTE_UNUSED
)
{
abort
();
}
/* Should not be called for treelang. */
void
cpp_assert
(
cpp_reader
*
cr
ATTRIBUTE_UNUSED
,
const
char
*
s
ATTRIBUTE_UNUSED
)
{
{
abort
();
abort
();
}
}
...
...
gcc/treelang/treetree.h
View file @
96e3ac4f
...
@@ -31,15 +31,6 @@
...
@@ -31,15 +31,6 @@
*/
*/
/* Parameter list passed to back end. */
struct
tree_parameter_list
{
struct
tree_parameter_list
*
next
;
/* Next entry. */
int
type
;
/* See numeric types below. */
unsigned
char
*
variable_name
;
/* Name. */
tree
*
where_to_put_var_tree
;
/* Where to save decl. */
};
tree
tree_code_init_parameters
(
void
);
tree
tree_code_init_parameters
(
void
);
tree
tree_code_add_parameter
(
tree
list
,
tree
proto_exp
,
tree
exp
);
tree
tree_code_add_parameter
(
tree
list
,
tree
proto_exp
,
tree
exp
);
tree
tree_code_get_integer_value
(
unsigned
char
*
chars
,
unsigned
int
length
);
tree
tree_code_get_integer_value
(
unsigned
char
*
chars
,
unsigned
int
length
);
...
@@ -49,12 +40,12 @@ tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree
...
@@ -49,12 +40,12 @@ tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree
tree
tree_code_get_numeric_type
(
unsigned
int
size1
,
unsigned
int
sign1
);
tree
tree_code_get_numeric_type
(
unsigned
int
size1
,
unsigned
int
sign1
);
void
tree_code_create_function_initial
(
tree
prev_saved
,
void
tree_code_create_function_initial
(
tree
prev_saved
,
unsigned
char
*
filename
,
int
lineno
,
unsigned
char
*
filename
,
int
lineno
,
struct
tree_parameter_list
*
parms
);
struct
prod_token_parm_item
*
parms
);
void
tree_code_create_function_wrapup
(
unsigned
char
*
filename
,
int
lineno
);
void
tree_code_create_function_wrapup
(
unsigned
char
*
filename
,
int
lineno
);
tree
tree_code_create_function_prototype
(
unsigned
char
*
chars
,
tree
tree_code_create_function_prototype
(
unsigned
char
*
chars
,
unsigned
int
storage_class
,
unsigned
int
storage_class
,
unsigned
int
ret_type
,
unsigned
int
ret_type
,
struct
tree_parameter_list
*
parms
,
struct
prod_token_parm_item
*
parms
,
unsigned
char
*
filename
,
unsigned
char
*
filename
,
int
lineno
);
int
lineno
);
tree
tree_code_create_variable
(
unsigned
int
storage_class
,
tree
tree_code_create_variable
(
unsigned
int
storage_class
,
...
@@ -78,24 +69,5 @@ void treelang_parse_file (int debug_flag);
...
@@ -78,24 +69,5 @@ void treelang_parse_file (int debug_flag);
void
push_var_level
(
void
);
void
push_var_level
(
void
);
void
pop_var_level
(
void
);
void
pop_var_level
(
void
);
/* Storage modes. */
#define STATIC_STORAGE 0
#define AUTOMATIC_STORAGE 1
#define EXTERNAL_REFERENCE_STORAGE 2
#define EXTERNAL_DEFINITION_STORAGE 3
/* Numeric types. */
#define SIGNED_CHAR 1
#define UNSIGNED_CHAR 2
#define SIGNED_INT 3
#define UNSIGNED_INT 4
#define VOID_TYPE 5
#define EXP_PLUS 0
/* Addition expression. */
#define EXP_REFERENCE 1
/* Variable reference. */
#define EXP_ASSIGN 2
/* Assignment. */
#define EXP_FUNCTION_INVOCATION 3
/* Call function. */
#define EXP_MINUS 4
/* Subtraction. */
#define EXP_EQUALS 5
/* Equality test. */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment