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
27f94314
Commit
27f94314
authored
Mar 01, 2003
by
Tim Josling
Committed by
Tim Josling
Mar 01, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treelang fixes.
From-SVN: r63604
parent
b063b379
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
120 additions
and
19 deletions
+120
-19
gcc/testsuite/treelang/ChangeLog
+5
-0
gcc/testsuite/treelang/treetests.exp
+1
-1
gcc/treelang/ChangeLog
+37
-0
gcc/treelang/Make-lang.in
+2
-1
gcc/treelang/lex.l
+3
-3
gcc/treelang/parse.y
+20
-2
gcc/treelang/tree1.c
+29
-2
gcc/treelang/treelang.h
+2
-1
gcc/treelang/treetree.c
+18
-6
gcc/treelang/treetree.h
+3
-3
No files found.
gcc/testsuite/treelang/ChangeLog
View file @
27f94314
2003-02-25 Tim Josling <tej@melbpc.org.au>
* treetests.exp (run3): set options to force aggressive GC, to
ensure GC is all set up correct,
2002-05-07 Tim Josling <tej@melbpc.org.au>
* Makefile.in: Fix copyright
...
...
gcc/testsuite/treelang/treetests.exp
View file @
27f94314
...
...
@@ -301,7 +301,7 @@ if {${check_rc} == 1} {
#
#set X "x"
set X ""
run3 "${sourcedir}" "${testdir}" " -g -O3
" 01 01 0 3 0 1 0
run3 "${sourcedir}" "${testdir}" " -g -O3 --param ggc-min-heapsize=0 --param ggc-min-expand=0
" 01 01 0 3 0 1 0
set X ""
}
gcc/treelang/ChangeLog
View file @
27f94314
2003-02-24 Tim Josling <tej@melbpc.org.au>
* parse.y (my_yylex): New - ensure lexer time is charged to
TV_LEX.
(yylex): redefine as invocation of my_yylex which then calls
flex-generated yylex.
(timevar.h): include.
2003-02-23 Tim Josling <tej@melbpc.org.au>
Fix garbage collection, add more error checking, force GC always.
* Make-lang.in (treelang/tree1.o): Depend on treelang/treetree.h
(treelang/treetree.o): Depend on treelang/parse.h
* lex.l: include "treetree.h"
* lex.l (update_yylval): Allocate string using get_string so GC
works.
* parse.y (function_prototype): Set category correctly so GC works.
(function): Set category in search so checking works.
(function_invocation): Ditto.
(variable_ref): Ditto.
* tree1.c (lookup_tree_name): Call sanity_check for passed
production and associated token and for symbol table entries.
* tree1.c (sanity_check): New, basic check that struct is valid.
* treelang.h: Prototype for sanity_check.
2003-01-27 Tim Josling <tej@melbpc.org.au>
* treetree.c (treelang_init_decl_processing): Change memory
allocation to use GC.
2003-02-04 Joseph S. Myers <jsm@polyomino.org.uk>
* treelang.texi: Update to GFDL 1.2.
...
...
gcc/treelang/Make-lang.in
View file @
27f94314
...
...
@@ -94,12 +94,13 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
treelang/tree1.o
:
treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
\
flags.h toplev.h $(GGC_H) $(TREE_H) diagnostic.h treelang/treelang.h
\
treelang/treetree.h
\
treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h
treelang/treetree.o
:
treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
\
$(TM_H) $(TREE_H) flags.h output.h $(C_TREE_H) $(RTL_H) $(GGC_H) toplev.h
\
varray.h $(LANGHOOKS_DEF_H) langhooks.h treelang/treelang.h
\
treelang/treetree.h
treelang/treetree.h
treelang/parse.h
treelang/parse.o
:
treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
\
$(TM_H) diagnostic.h treelang/treelang.h treelang/treetree.h
...
...
gcc/treelang/lex.l
View file @
27f94314
...
...
@@ -4,7 +4,7 @@
---------------------------------------------------------------------
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
...
...
@@ -44,6 +44,7 @@
/* Token defs. */
#include "treelang.h"
#include "parse.h"
#include "treetree.h"
extern
int
option_lexer_trace
;
...
...
@@ -257,8 +258,7 @@ update_yylval (int a)
tok
->
tp
.
tok
.
length
=
yyleng
;
/* Have to copy yytext as it is just a ptr into the buffer at the
moment. */
tok
->
tp
.
tok
.
chars
=
my_malloc
(
yyleng
+
1
);
memcpy
(
tok
->
tp
.
tok
.
chars
,
yytext
,
yyleng
);
tok
->
tp
.
tok
.
chars
=
(
unsigned
char
*
)
get_string
(
yytext
,
yyleng
);
}
/* Trace the value LEXRET and the position and token details being
...
...
gcc/treelang/parse.y
View file @
27f94314
...
...
@@ -5,7 +5,7 @@
---------------------------------------------------------------------
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002
, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
...
...
@@ -47,6 +47,7 @@
#include "coretypes.h"
#include "tm.h"
#include "diagnostic.h"
#include "timevar.h"
#include "treelang.h"
#include "treetree.h"
...
...
@@ -55,13 +56,26 @@
#define YYPRINT(file, type, value) print_token (file, type, value)
#define YYERROR_VERBOSE YES
/* My yylex routine used to intercept calls to flex generated code, to
record lex time. */
int
yylex
(
void
);
static
inline
int
my_yylex
(
void
);
/* Call lex, but ensure time is charged to TV_LEX. */
static
inline
int
my_yylex
()
{
int
res
;
timevar_push
(
TV_LEX
);
res
=
yylex
();
timevar_pop
(
TV_LEX
);
return
res
;
}
#define yylex my_yylex
extern
int
option_parser_trace
;
/* Local prototypes. */
static
void
yyerror
(
const
char
*
error_message
);
int
yylex
(
void
);
int
yyparse
(
void
);
void
print_token
(
FILE
*
file
,
unsigned
int
type
ATTRIBUTE_UNUSED
,
YYSTYPE
value
);
static
struct
prod_token_parm_item
*
reverse_prod_list
(
struct
prod_token_parm_item
*
old_first
);
...
...
@@ -287,6 +301,7 @@ storage typename NAME LEFT_PARENTHESIS parameters RIGHT_PARENTHESIS SEMICOLON {
if
(
!
this_parm_var
->
tp
.
pro
.
main_token
)
abort
();
this_parms
->
tp
.
par
.
variable_name
=
this_parm_var
->
tp
.
pro
.
main_token
->
tp
.
tok
.
chars
;
this_parms
->
category
=
parameter_category
;
this_parms
->
type
=
NUMERIC_TYPE
((
(
struct
prod_token_parm_item
*
)
EXPRESSION_TYPE
(
this_parm_var
)));
if
(
last_parms
)
{
...
...
@@ -318,6 +333,7 @@ NAME LEFT_BRACE {
struct
prod_token_parm_item
*
this_parm
;
tok
=
$
1
;
SYMBOL_TABLE_NAME
((
&
search_prod
))
=
tok
;
search_prod
.
category
=
token_category
;
current_function
=
proto
=
lookup_tree_name
(
&
search_prod
);
if
(
!
proto
)
{
...
...
@@ -690,6 +706,7 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS {
SYMBOL_TABLE_NAME
(
prod
)
=
tok
;
PARAMETERS
(
prod
)
=
reverse_prod_list
(
$
3
);
SYMBOL_TABLE_NAME
((
&
search_prod
))
=
tok
;
search_prod
.
category
=
token_category
;
proto
=
lookup_tree_name
(
&
search_prod
);
if
(
!
proto
)
{
...
...
@@ -768,6 +785,7 @@ NAME {
tok
=
$
1
;
SYMBOL_TABLE_NAME
((
&
search_prod
))
=
tok
;
search_prod
.
category
=
token_category
;
symbol_table_entry
=
lookup_tree_name
(
&
search_prod
);
if
(
!
symbol_table_entry
)
{
...
...
gcc/treelang/tree1.c
View file @
27f94314
...
...
@@ -3,7 +3,7 @@
TREELANG Compiler almost main (tree1)
Called by GCC's toplev.c
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
...
...
@@ -187,6 +187,8 @@ treelang_init (const char* filename)
input_filename
=
""
;
lineno
=
0
;
/* Init decls etc. */
treelang_init_decl_processing
();
/* This error will not happen from GCC as it will always create a
...
...
@@ -229,7 +231,8 @@ treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
yyparse
();
}
/* Allocate SIZE bytes and clear them. */
/* Allocate SIZE bytes and clear them. Not to be used for strings
which must go in stringpool. */
void
*
my_malloc
(
size_t
size
)
...
...
@@ -255,10 +258,17 @@ lookup_tree_name (struct prod_token_parm_item *prod)
struct
prod_token_parm_item
*
this
;
struct
prod_token_parm_item
*
this_tok
;
struct
prod_token_parm_item
*
tok
;
sanity_check
(
prod
);
tok
=
SYMBOL_TABLE_NAME
(
prod
);
sanity_check
(
tok
);
for
(
this
=
symbol_table
;
this
;
this
=
this
->
tp
.
pro
.
next
)
{
sanity_check
(
this
);
this_tok
=
this
->
tp
.
pro
.
main_token
;
sanity_check
(
this_tok
);
if
(
tok
->
tp
.
tok
.
length
!=
this_tok
->
tp
.
tok
.
length
)
continue
;
if
(
memcmp
(
tok
->
tp
.
tok
.
chars
,
this_tok
->
tp
.
tok
.
chars
,
this_tok
->
tp
.
tok
.
length
))
...
...
@@ -281,6 +291,7 @@ insert_tree_name (struct prod_token_parm_item *prod)
{
struct
prod_token_parm_item
*
tok
;
tok
=
SYMBOL_TABLE_NAME
(
prod
);
sanity_check
(
prod
);
if
(
lookup_tree_name
(
prod
))
{
fprintf
(
stderr
,
"%s:%i:%i duplicate name %s
\n
"
,
in_fname
,
tok
->
tp
.
tok
.
lineno
,
...
...
@@ -307,6 +318,22 @@ make_production (int type, struct prod_token_parm_item *main_tok)
return
prod
;
}
/* Abort if ITEM is not a valid structure, based on 'category'. */
void
sanity_check
(
struct
prod_token_parm_item
*
item
)
{
switch
(
item
->
category
)
{
case
token_category
:
case
production_category
:
case
parameter_category
:
break
;
default
:
abort
();
}
}
/* New garbage collection regime see gty.texi. */
#include "gt-treelang-tree1.h"
...
...
gcc/treelang/treelang.h
View file @
27f94314
...
...
@@ -2,7 +2,7 @@
TREELANG Compiler common definitions (treelang.h)
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
...
...
@@ -150,3 +150,4 @@ void mark_production_used (struct prod_token_parm_item *pp);
void
mark_token_used
(
struct
prod_token_parm_item
*
tt
);
void
treelang_debug
(
void
);
void
sanity_check
(
struct
prod_token_parm_item
*
item
);
gcc/treelang/treetree.c
View file @
27f94314
...
...
@@ -6,8 +6,8 @@
If you want a working example of how to write a front end to GCC,
you are in the right place.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000,
2001, 2002
Free Software Foundation, Inc.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003,
Free Software Foundation, Inc.
This code is based on toy.c written by Richard Kenner.
...
...
@@ -73,6 +73,7 @@
#include "treelang.h"
#include "treetree.h"
#include "parse.h"
extern
int
option_main
;
extern
char
**
file_names
;
...
...
@@ -233,6 +234,8 @@ tree_code_create_function_prototype (unsigned char* chars,
id
=
get_identifier
((
const
char
*
)
chars
);
for
(
parm
=
parms
;
parm
;
parm
=
parm
->
tp
.
par
.
next
)
{
if
(
parm
->
category
!=
parameter_category
)
abort
();
type_node
=
get_type_for_numeric_type
(
parm
->
type
);
type_list
=
tree_cons
(
NULL_TREE
,
type_node
,
type_list
);
}
...
...
@@ -1243,10 +1246,7 @@ treelang_init_decl_processing ()
unsigned
int
i
;
tree
id
;
/* It is not necessary to register ridpointers as a GC root, because
all the trees it points to are permanently interned in the
get_identifier hash anyway. */
ridpointers
=
(
tree
*
)
xcalloc
((
int
)
RID_MAX
,
sizeof
(
tree
));
ridpointers
=
(
tree
*
)
ggc_calloc
((
int
)
RID_MAX
,
sizeof
(
tree
));
for
(
i
=
0
;
i
<
N_reswords
;
i
++
)
{
...
...
@@ -1284,3 +1284,15 @@ dt (tree t)
{
debug_tree
(
t
);
}
/* Get a stringpool entry for a string S of length L. This is needed
because the GTY routines don't mark strings, forcing you to put
them into stringpool, which is never freed. */
const
char
*
get_string
(
const
char
*
s
,
size_t
l
)
{
tree
t
;
t
=
get_identifier_with_length
(
s
,
l
);
return
IDENTIFIER_POINTER
(
t
);
}
gcc/treelang/treetree.h
View file @
27f94314
...
...
@@ -3,7 +3,7 @@
TREELANG Compiler definitions for interfacing to treetree.c
(compiler back end interface).
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
...
...
@@ -63,11 +63,11 @@ void tree_code_if_end (unsigned char* filename, int lineno);
tree
tree_code_get_type
(
int
type_num
);
void
treelang_init_decl_processing
(
void
);
void
treelang_finish
(
void
);
const
char
*
treelang_init
(
const
char
*
filename
);
const
char
*
treelang_init
(
const
char
*
filename
);
int
treelang_decode_option
(
int
,
char
**
);
void
treelang_parse_file
(
int
debug_flag
);
void
push_var_level
(
void
);
void
pop_var_level
(
void
);
const
char
*
get_string
(
const
char
*
s
,
size_t
l
);
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