Conditionally compile support for --enable-mapped_location.

* input.h:  #include line-map.h for source_location typedef.
	(BUILTINS_LOCATION, UNKNOWN_LOCATION, expand_location,
	LOCATION_FILE, LOCATION_LINE):  New macros and functions.
	(expanded_location, source_locus):  New typedefs.
	(push_srcloc):  Change parameter list if USE_MAPPED_LOCATION.
	* rtl.def (NOTE, ASM_OPERANDS):  Modify specifcation, if
	USE_MAPPED_LOCATION.
	* rtl.h (NOTE_DELETED_LABEL_NAME):  New macro.
	(NOTE_SOURCE_LOCATION, NOTE_EXPNDED_LOCATION, SET_INSN_DELETED):
	New conditional macros.
	(ASM_OPERANDS_SOURCE_FILE, ASM_OPERANDS_SOURCE_LINE):  Replace
	by ASM_OPERANDS_SOURCE_LOCATION if USE_MAPPED_LOCATION.
	* tree.h (EXPR_LOCATION, SET_EXPR_LOCATION, EXPR_HAS_LOCATION,
	EXPR_LOCUS, SET_EXPR_LOCUS, EXPR_FILENAME, EXPR_LINENO,
	DECL_IS_BUILTIN):  New macros, most depending on USE_MAPPED__LOCATION.
	(tree_exp):  Change type of locus to use new source_locus typedef.
	* tree.c (build1_stat):  Use SET_EXPR_LOCATION.
	(annotate_with_locus, annotate_with_file_line):  Conditionalize.
	(expand_location):  New function.
	* toplev.c (unknown_location):  New static, when USE_MAPPED_LOCATION.
	(push_srcloc, pop_loc):  Adjust parameter handling.
	(process_options):  Don't set input_filename by itself.
	(lang_dependent_init):  Save, set input_location to <built-in>.
	(warn_deprecated_use):  Use expand_location.

From-SVN: r83918
This commit is contained in:
Per Bothner 2004-06-30 10:58:21 -07:00 committed by Per Bothner
parent b5674962f1
commit c166747038
7 changed files with 219 additions and 31 deletions

View File

@ -1,3 +1,31 @@
2004-06-30 Per Bothner <per@bothner.com>
Conditionally compile support for --enable-mapped_location.
* input.h: #include line-map.h for source_location typedef.
(BUILTINS_LOCATION, UNKNOWN_LOCATION, expand_location,
LOCATION_FILE, LOCATION_LINE): New macros and functions.
(expanded_location, source_locus): New typedefs.
(push_srcloc): Change parameter list if USE_MAPPED_LOCATION.
* rtl.def (NOTE, ASM_OPERANDS): Modify specifcation, if
USE_MAPPED_LOCATION.
* rtl.h (NOTE_DELETED_LABEL_NAME): New macro.
(NOTE_SOURCE_LOCATION, NOTE_EXPNDED_LOCATION, SET_INSN_DELETED):
New conditional macros.
(ASM_OPERANDS_SOURCE_FILE, ASM_OPERANDS_SOURCE_LINE): Replace
by ASM_OPERANDS_SOURCE_LOCATION if USE_MAPPED_LOCATION.
* tree.h (EXPR_LOCATION, SET_EXPR_LOCATION, EXPR_HAS_LOCATION,
EXPR_LOCUS, SET_EXPR_LOCUS, EXPR_FILENAME, EXPR_LINENO,
DECL_IS_BUILTIN): New macros, most depending on USE_MAPPED__LOCATION.
(tree_exp): Change type of locus to use new source_locus typedef.
* tree.c (build1_stat): Use SET_EXPR_LOCATION.
(annotate_with_locus, annotate_with_file_line): Conditionalize.
(expand_location): New function.
* toplev.c (unknown_location): New static, when USE_MAPPED_LOCATION.
(push_srcloc, pop_loc): Adjust parameter handling.
(process_options): Don't set input_filename by itself.
(lang_dependent_init): Save, set input_location to <built-in>.
(warn_deprecated_use): Use expand_location.
2004-06-30 Richard Sandiford <rsandifo@redhat.com>
Eric Christopher <echristo@redhat.com>

View File

@ -22,19 +22,41 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_INPUT_H
#define GCC_INPUT_H
#include "line-map.h"
extern struct line_maps line_table;
/* The data structure used to record a location in a translation unit. */
/* Long-term, we want to get rid of this and typedef fileline location_t. */
struct location_s GTY (())
/* The location for declarations in "<built-in>" */
#define BUILTINS_LOCATION ((source_location) 2)
typedef struct location_s GTY(())
{
/* The name of the source file involved. */
const char *file;
/* The line-location in the source file. */
int line;
};
/* FUTURE (but confuses gentype): int column. */
} expanded_location;
#ifdef USE_MAPPED_LOCATION
extern expanded_location expand_location (source_location);
#define UNKNOWN_LOCATION ((source_location) 0)
typedef source_location location_t; /* deprecated typedef */
typedef source_location source_locus; /* to be removed */
#else /* ! USE_MAPPED_LOCATION */
typedef struct location_s location_t;
typedef location_t *source_locus;
#define expand_location(FILELINE) (FILELINE)
extern location_t unknown_location;
#define UNKNOWN_LOCATION unknown_location
#endif /* ! USE_MAPPED_LOCATION */
struct file_stack
{
@ -46,8 +68,18 @@ struct file_stack
extern const char *main_input_filename;
extern location_t input_location;
#define input_line (input_location.line)
#define input_filename (input_location.file)
#ifdef USE_MAPPED_LOCATION
extern void push_srcloc (location_t);
#else /* ! USE_MAPPED_LOCATION */
extern void push_srcloc (const char *name, int line);
#endif /* ! USE_MAPPED_LOCATION */
extern void pop_srcloc (void);
#define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
#define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
#define input_line LOCATION_LINE(input_location)
#define input_filename LOCATION_FILE(input_location)
/* Stack of currently pending input files.
The line member is not accurate for the innermost file on the stack. */
@ -56,7 +88,4 @@ extern struct file_stack *input_file_stack;
/* Incremented on each change to input_file_stack. */
extern int input_file_stack_tick;
extern void push_srcloc (const char *name, int line);
extern void pop_srcloc (void);
#endif

View File

@ -640,11 +640,19 @@ DEF_RTL_EXPR(BARRIER, "barrier", "iuu000000", RTX_EXTRA)
7: is the user-given name of the label, if any. */
DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuB00is", RTX_EXTRA)
#ifdef USE_MAPPED_LOCATION
/* Say where in the code a source line starts, for symbol table's sake.
Operand:
4: unused if line number > 0, note-specific data otherwise.
5: line number if > 0, enum note_insn otherwise.
6: CODE_LABEL_NUMBER if line number == NOTE_INSN_DELETED_LABEL. */
#else
/* Say where in the code a source line starts, for symbol table's sake.
Operand:
4: filename, if line number > 0, note-specific data otherwise.
5: line number if > 0, enum note_insn otherwise.
6: unique number if line number == note_insn_deleted_label. */
#endif
DEF_RTL_EXPR(NOTE, "note", "iuuB0ni", RTX_EXTRA)
/* ----------------------------------------------------------------------
@ -671,6 +679,20 @@ DEF_RTL_EXPR(PARALLEL, "parallel", "E", RTX_EXTRA)
as a convenient way to hold a string. */
DEF_RTL_EXPR(ASM_INPUT, "asm_input", "s", RTX_EXTRA)
#ifdef USE_MAPPED_LOCATION
/* An assembler instruction with operands.
1st operand is the instruction template.
2nd operand is the constraint for the output.
3rd operand is the number of the output this expression refers to.
When an insn stores more than one value, a separate ASM_OPERANDS
is made for each output; this integer distinguishes them.
4th is a vector of values of input operands.
5th is a vector of modes and constraints for the input operands.
Each element is an ASM_INPUT containing a constraint string
and whose mode indicates the mode of the input operand.
6th is the source line number. */
DEF_RTL_EXPR(ASM_OPERANDS, "asm_operands", "ssiEEi", RTX_EXTRA)
#else
/* An assembler instruction with operands.
1st operand is the instruction template.
2nd operand is the constraint for the output.
@ -684,6 +706,7 @@ DEF_RTL_EXPR(ASM_INPUT, "asm_input", "s", RTX_EXTRA)
6th is the name of the containing source file.
7th is the source line number. */
DEF_RTL_EXPR(ASM_OPERANDS, "asm_operands", "ssiEEsi", RTX_EXTRA)
#endif
/* A machine-specific operation.
1st operand is a vector of operands being used by the operation so that

View File

@ -914,7 +914,22 @@ extern const char * const reg_note_name[];
/* Opaque data. */
#define NOTE_DATA(INSN) RTL_CHECKC1 (INSN, 4, NOTE)
#define NOTE_DELETED_LABEL_NAME(INSN) XCSTR (INSN, 4, NOTE)
#ifdef USE_MAPPED_LOCATION
#define NOTE_SOURCE_LOCATION(INSN) XCUINT (INSN, 5, NOTE)
#define NOTE_EXPANDED_LOCATION(XLOC, INSN) \
(XLOC) = expand_location (NOTE_SOURCE_LOCATION (INSN))
#define SET_INSN_DELETED(INSN) \
(PUT_CODE (INSN, NOTE), NOTE_LINE_NUMBER (INSN) = NOTE_INSN_DELETED)
#else
#define NOTE_EXPANDED_LOCATION(XLOC, INSN) \
((XLOC).file = NOTE_SOURCE_FILE (INSN), \
(XLOC).line = NOTE_LINE_NUMBER (INSN))
#define NOTE_SOURCE_FILE(INSN) XCSTR (INSN, 4, NOTE)
#define SET_INSN_DELETED(INSN) \
(PUT_CODE (INSN, NOTE), NOTE_SOURCE_FILE (INSN) = 0, \
NOTE_LINE_NUMBER (INSN) = NOTE_INSN_DELETED)
#endif
#define NOTE_BLOCK(INSN) XCTREE (INSN, 4, NOTE)
#define NOTE_EH_HANDLER(INSN) XCINT (INSN, 4, NOTE)
#define NOTE_BASIC_BLOCK(INSN) XCBBDEF (INSN, 4, NOTE)
@ -1247,8 +1262,12 @@ do { \
XSTR (XCVECEXP (RTX, 4, N, ASM_OPERANDS), 0)
#define ASM_OPERANDS_INPUT_MODE(RTX, N) \
GET_MODE (XCVECEXP (RTX, 4, N, ASM_OPERANDS))
#ifdef USE_MAPPED_LOCATION
#define ASM_OPERANDS_SOURCE_LOCATION(RTX) XCUINT (RTX, 5, ASM_OPERANDS)
#else
#define ASM_OPERANDS_SOURCE_FILE(RTX) XCSTR (RTX, 5, ASM_OPERANDS)
#define ASM_OPERANDS_SOURCE_LINE(RTX) XCINT (RTX, 6, ASM_OPERANDS)
#endif
/* 1 if RTX is a mem and we should keep the alias set for this mem
unchanged when we access a component. Set to 1, or example, when we
@ -2001,6 +2020,11 @@ extern GTY(()) rtx return_address_pointer_rtx;
#ifndef NO_GENRTL_H
#include "genrtl.h"
#ifndef USE_MAPPED_LOCATION
#undef gen_rtx_ASM_OPERANDS
#define gen_rtx_ASM_OPERANDS(MODE, ARG0, ARG1, ARG2, ARG3, ARG4, LOC) \
gen_rtx_fmt_ssiEEsi (ASM_OPERANDS, (MODE), (ARG0), (ARG1), (ARG2), (ARG3), (ARG4), (LOC).file, (LOC).line)
#endif
#endif
/* There are some RTL codes that require special attention; the

View File

@ -140,6 +140,10 @@ static const char **save_argv;
const char *main_input_filename;
#ifndef USE_MAPPED_LOCATION
location_t unknown_location = { NULL, 0 };
#endif
/* Used to enable -fvar-tracking, -fweb and -frename-registers according
to optimize and default_debug_hooks in process_options (). */
#define AUTODETECT_FLAG_VAR_TRACKING 2
@ -879,9 +883,12 @@ warn_deprecated_use (tree node)
return;
if (DECL_P (node))
{
expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
warning ("`%s' is deprecated (declared at %s:%d)",
IDENTIFIER_POINTER (DECL_NAME (node)),
DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
xloc.file, xloc.line);
}
else if (TYPE_P (node))
{
const char *what = NULL;
@ -893,19 +900,24 @@ warn_deprecated_use (tree node)
&& DECL_NAME (TYPE_NAME (node)))
what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
if (what)
{
if (decl)
{
expanded_location xloc
= expand_location (DECL_SOURCE_LOCATION (decl));
if (what)
warning ("`%s' is deprecated (declared at %s:%d)", what,
DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
xloc.file, xloc.line);
else
warning ("type is deprecated (declared at %s:%d)",
xloc.file, xloc.line);
}
else
{
if (what)
warning ("type is deprecated");
else
warning ("`%s' is deprecated", what);
}
else if (decl)
warning ("type is deprecated (declared at %s:%d)",
DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
else
warning ("type is deprecated");
}
}
@ -914,15 +926,23 @@ warn_deprecated_use (tree node)
INPUT_LOCATION accordingly. */
void
#ifdef USE_MAPPED_LOCATION
push_srcloc (location_t fline)
#else
push_srcloc (const char *file, int line)
#endif
{
struct file_stack *fs;
fs = xmalloc (sizeof (struct file_stack));
fs->location = input_location;
fs->next = input_file_stack;
#ifdef USE_MAPPED_LOCATION
input_location = fline;
#else
input_filename = file;
input_line = line;
#endif
input_file_stack = fs;
input_file_stack_tick++;
}
@ -1607,7 +1627,9 @@ process_options (void)
sets the original filename if appropriate (e.g. foo.i -> foo.c)
so we can correctly initialize debug output. */
no_backend = lang_hooks.post_options (&main_input_filename);
#ifndef USE_MAPPED_LOCATION
input_filename = main_input_filename;
#endif
#ifdef OVERRIDE_OPTIONS
/* Some machines may reject certain combinations of options. */
@ -1928,12 +1950,20 @@ backend_init (void)
static int
lang_dependent_init (const char *name)
{
location_t save_loc = input_location;
if (dump_base_name == 0)
dump_base_name = name ? name : "gccdump";
/* Other front-end initialization. */
#ifdef USE_MAPPED_LOCATION
input_location = BUILTINS_LOCATION;
#else
input_filename = "<built-in>";
input_line = 0;
#endif
if (lang_hooks.init () == 0)
return 0;
input_location = save_loc;
init_asm_output (name);

View File

@ -2438,7 +2438,11 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
TREE_SET_CODE (t, code);
TREE_TYPE (t) = type;
#ifdef USE_MAPPED_LOCATION
SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
#else
SET_EXPR_LOCUS (t, NULL);
#endif
TREE_COMPLEXITY (t) = 0;
TREE_OPERAND (t, 0) = node;
TREE_BLOCK (t) = NULL_TREE;
@ -2748,7 +2752,28 @@ build_block (tree vars, tree tags ATTRIBUTE_UNUSED, tree subblocks,
return block;
}
#if 1 /* ! defined(USE_MAPPED_LOCATION) */
/* ??? gengtype doesn't handle conditionals */
static GTY(()) tree last_annotated_node;
#endif
#ifdef USE_MAPPED_LOCATION
expanded_location
expand_location (source_location loc)
{
expanded_location xloc;
if (loc == 0) { xloc.file = NULL; xloc.line = 0; }
else
{
const struct line_map *map = linemap_lookup (&line_table, loc);
xloc.file = map->to_file;
xloc.line = SOURCE_LINE (map, loc);
};
return xloc;
}
#else
/* Record the exact location where an expression or an identifier were
encountered. */
@ -2792,6 +2817,7 @@ annotate_with_locus (tree node, location_t locus)
{
annotate_with_file_line (node, locus.file, locus.line);
}
#endif
/* Return a declaration like DDECL except that its DECL_ATTRIBUTES
is ATTRIBUTE. */

View File

@ -1073,6 +1073,31 @@ struct tree_vec GTY(())
/* In a LOOP_EXPR node. */
#define LOOP_EXPR_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_EXPR, 0)
#ifdef USE_MAPPED_LOCATION
/* The source location of this expression. Non-tree_exp nodes such as
decls and constants can be shared among multiple locations, so
return nothing. */
#define EXPR_LOCATION(NODE) \
(IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (NODE))) \
? (NODE)->exp.locus \
: UNKNOWN_LOCATION)
#define SET_EXPR_LOCATION(NODE, FROM) \
(EXPR_CHECK (NODE)->exp.locus = (FROM))
#define EXPR_HAS_LOCATION(NODE) (EXPR_LOCATION (NODE) != UNKNOWN_LOCATION)
/* EXPR_LOCUS and SET_EXPR_LOCUS are deprecated. */
#define EXPR_LOCUS(NODE) \
(IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (NODE))) \
? &(NODE)->exp.locus \
: (location_t *)NULL)
#define SET_EXPR_LOCUS(NODE, FROM) \
do { source_location *loc_tmp = FROM; \
EXPR_CHECK (NODE)->exp.locus \
= loc_tmp == NULL ? UNKNOWN_LOCATION : *loc_tmp; } while (0)
#define EXPR_FILENAME(NODE) \
LOCATION_FILE (EXPR_CHECK (NODE)->exp.locus)
#define EXPR_LINENO(NODE) \
LOCATION_LINE (EXPR_CHECK (NODE)->exp.locus)
#else
/* The source location of this expression. Non-tree_exp nodes such as
decls and constants can be shared among multiple locations, so
return nothing. */
@ -1082,19 +1107,14 @@ struct tree_vec GTY(())
: (location_t *)NULL)
#define SET_EXPR_LOCUS(NODE, FROM) \
(EXPR_CHECK (NODE)->exp.locus = (FROM))
#define SET_EXPR_LOCATION(NODE, FROM) annotate_with_locus (NODE, FROM)
#define EXPR_FILENAME(NODE) \
(EXPR_CHECK (NODE)->exp.locus->file)
#define EXPR_LINENO(NODE) \
(EXPR_CHECK (NODE)->exp.locus->line)
#ifdef USE_MAPPED_LOCATION
#define EXPR_LOCATION(NODE) \
(IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (NODE))) \
? (NODE)->exp.locus \
: UNKNOWN_LOCATION)
#define EXPR_HAS_LOCATION(NODE) (EXPR_LOCATION (NODE) != UNKNOWN_LOCATION)
#else
#define EXPR_LOCATION(NODE) (*EXPR_LOCUS (NODE))
#define EXPR_HAS_LOCATION(NODE) (EXPR_LOCUS (NODE) != NULL)
#define EXPR_LOCATION(NODE) \
(EXPR_HAS_LOCATION(NODE) ? *(NODE)->exp.locus : UNKNOWN_LOCATION)
#endif
/* In a TARGET_EXPR node. */
@ -1172,7 +1192,7 @@ struct tree_vec GTY(())
struct tree_exp GTY(())
{
struct tree_common common;
location_t *locus;
source_locus locus;
int complexity;
tree block;
tree GTY ((special ("tree_exp"),
@ -1773,8 +1793,14 @@ struct tree_type GTY(())
function that is declared first and then defined later), this
information should refer to the definition. */
#define DECL_SOURCE_LOCATION(NODE) (DECL_CHECK (NODE)->decl.locus)
#define DECL_SOURCE_FILE(NODE) (DECL_SOURCE_LOCATION (NODE).file)
#define DECL_SOURCE_LINE(NODE) (DECL_SOURCE_LOCATION (NODE).line)
#define DECL_SOURCE_FILE(NODE) LOCATION_FILE (DECL_SOURCE_LOCATION (NODE))
#define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE))
#ifdef USE_MAPPED_LOCATION
#define DECL_IS_BUILTIN(DECL) \
(DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION)
#else
#define DECL_IS_BUILTIN(DECL) (DECL_SOURCE_LINE(DECL) == 0)
#endif
/* Holds the size of the datum, in bits, as a tree expression.
Need not be constant. */
#define DECL_SIZE(NODE) (DECL_CHECK (NODE)->decl.size)
@ -2665,8 +2691,10 @@ extern tree build_tree_list_stat (tree, tree MEM_STAT_DECL);
extern tree build_decl_stat (enum tree_code, tree, tree MEM_STAT_DECL);
#define build_decl(c,t,q) build_decl_stat (c,t,q MEM_STAT_INFO)
extern tree build_block (tree, tree, tree, tree, tree);
#ifndef USE_MAPPED_LOCATION
extern void annotate_with_file_line (tree, const char *, int);
extern void annotate_with_locus (tree, location_t);
#endif
extern tree build_empty_stmt (void);
/* Construct various nodes representing data types. */