* 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
+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>
#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
{
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. */
/* 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
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)
/* ----------------------------------------------------------------------
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.
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
/* 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)
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
#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
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
return;
if (DECL_P (node))
- warning ("`%s' is deprecated (declared at %s:%d)",
- IDENTIFIER_POINTER (DECL_NAME (node)),
- DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+ {
+ expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
+ warning ("`%s' is deprecated (declared at %s:%d)",
+ IDENTIFIER_POINTER (DECL_NAME (node)),
+ xloc.file, xloc.line);
+ }
else if (TYPE_P (node))
{
const char *what = NULL;
&& DECL_NAME (TYPE_NAME (node)))
what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
- if (what)
+ if (decl)
{
- 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 ("`%s' is deprecated", what);
+ warning ("type is deprecated (declared at %s:%d)",
+ xloc.file, xloc.line);
}
- else if (decl)
- warning ("type is deprecated (declared at %s:%d)",
- DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
else
- warning ("type is deprecated");
+ {
+ if (what)
+ warning ("type is deprecated");
+ else
+ warning ("`%s' is deprecated", what);
+ }
}
}
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++;
}
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. */
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);
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;
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. */
{
annotate_with_file_line (node, locus.file, locus.line);
}
+#endif
\f
/* Return a declaration like DDECL except that its DECL_ATTRIBUTES
is ATTRIBUTE. */
/* 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. */
: (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. */
struct tree_exp GTY(())
{
struct tree_common common;
- location_t *locus;
+ source_locus locus;
int complexity;
tree block;
tree GTY ((special ("tree_exp"),
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)
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. */