]>
Commit | Line | Data |
---|---|---|
5e6908ea | 1 | /* RTL specific diagnostic subroutines for GCC |
d479d37f | 2 | Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. |
c895acf2 GDR |
3 | Contributed by Gabriel Dos Reis <gdr@codesourcery.com> |
4 | ||
40803cd5 | 5 | This file is part of GCC. |
c895acf2 | 6 | |
40803cd5 | 7 | GCC is free software; you can redistribute it and/or modify |
c895acf2 GDR |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
40803cd5 | 12 | GCC is distributed in the hope that it will be useful, |
c895acf2 GDR |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
40803cd5 | 18 | along with GCC; see the file COPYING. If not, write to |
c895acf2 GDR |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "config.h" | |
23 | #undef FLOAT /* This is for hpux. They should change hpux. */ | |
24 | #undef FFS /* Some systems define this in param.h. */ | |
25 | #include "system.h" | |
4977bab6 ZW |
26 | #include "coretypes.h" |
27 | #include "tm.h" | |
c895acf2 GDR |
28 | #include "rtl.h" |
29 | #include "insn-attr.h" | |
30 | #include "insn-config.h" | |
31 | #include "input.h" | |
32 | #include "toplev.h" | |
33 | #include "intl.h" | |
34 | #include "diagnostic.h" | |
35 | ||
0c20a65f AJ |
36 | static location_t location_for_asm (rtx); |
37 | static void diagnostic_for_asm (rtx, const char *, va_list *, diagnostic_t); | |
c895acf2 | 38 | |
9a472a42 NS |
39 | /* Figure the location of the given INSN. */ |
40 | static location_t | |
0c20a65f | 41 | location_for_asm (rtx insn) |
c895acf2 GDR |
42 | { |
43 | rtx body = PATTERN (insn); | |
44 | rtx asmop; | |
9a472a42 | 45 | location_t loc; |
0c20a65f | 46 | |
c895acf2 GDR |
47 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ |
48 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
49 | asmop = SET_SRC (body); | |
50 | else if (GET_CODE (body) == ASM_OPERANDS) | |
51 | asmop = body; | |
52 | else if (GET_CODE (body) == PARALLEL | |
53 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
54 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
55 | else if (GET_CODE (body) == PARALLEL | |
56 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
57 | asmop = XVECEXP (body, 0, 0); | |
58 | else | |
59 | asmop = NULL; | |
60 | ||
61 | if (asmop) | |
6773e15f PB |
62 | #ifdef USE_MAPPED_LOCATION |
63 | loc = ASM_OPERANDS_SOURCE_LOCATION (asmop); | |
64 | #else | |
c895acf2 | 65 | { |
9a472a42 NS |
66 | loc.file = ASM_OPERANDS_SOURCE_FILE (asmop); |
67 | loc.line = ASM_OPERANDS_SOURCE_LINE (asmop); | |
c895acf2 | 68 | } |
6773e15f | 69 | #endif |
c895acf2 | 70 | else |
9a472a42 NS |
71 | loc = input_location; |
72 | return loc; | |
c895acf2 GDR |
73 | } |
74 | ||
75 | /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number | |
76 | of the insn INSN. This is used only when INSN is an `asm' with operands, | |
77 | and each ASM_OPERANDS records its own source file and line. */ | |
78 | static void | |
0c20a65f AJ |
79 | diagnostic_for_asm (rtx insn, const char *msg, va_list *args_ptr, |
80 | diagnostic_t kind) | |
c895acf2 | 81 | { |
47b69537 | 82 | diagnostic_info diagnostic; |
0c20a65f | 83 | |
9a472a42 NS |
84 | diagnostic_set_info (&diagnostic, msg, args_ptr, |
85 | location_for_asm (insn), kind); | |
47b69537 | 86 | report_diagnostic (&diagnostic); |
c895acf2 GDR |
87 | } |
88 | ||
89 | void | |
e34d07f2 | 90 | error_for_asm (rtx insn, const char *msgid, ...) |
c895acf2 | 91 | { |
e34d07f2 | 92 | va_list ap; |
0c20a65f | 93 | |
e34d07f2 | 94 | va_start (ap, msgid); |
47b69537 | 95 | diagnostic_for_asm (insn, msgid, &ap, DK_ERROR); |
e34d07f2 | 96 | va_end (ap); |
c895acf2 GDR |
97 | } |
98 | ||
99 | void | |
e34d07f2 | 100 | warning_for_asm (rtx insn, const char *msgid, ...) |
c895acf2 | 101 | { |
e34d07f2 | 102 | va_list ap; |
0c20a65f | 103 | |
e34d07f2 | 104 | va_start (ap, msgid); |
47b69537 | 105 | diagnostic_for_asm (insn, msgid, &ap, DK_WARNING); |
e34d07f2 | 106 | va_end (ap); |
c895acf2 GDR |
107 | } |
108 | ||
109 | void | |
0c20a65f AJ |
110 | _fatal_insn (const char *msgid, rtx insn, const char *file, int line, |
111 | const char *function) | |
c895acf2 GDR |
112 | { |
113 | error ("%s", _(msgid)); | |
114 | ||
115 | /* The above incremented error_count, but isn't an error that we want to | |
116 | count, so reset it here. */ | |
117 | errorcount--; | |
118 | ||
119 | debug_rtx (insn); | |
120 | fancy_abort (file, line, function); | |
121 | } | |
122 | ||
123 | void | |
0c20a65f AJ |
124 | _fatal_insn_not_found (rtx insn, const char *file, int line, |
125 | const char *function) | |
c895acf2 GDR |
126 | { |
127 | if (INSN_CODE (insn) < 0) | |
1f978f5f | 128 | _fatal_insn ("unrecognizable insn:", insn, file, line, function); |
c895acf2 | 129 | else |
1f978f5f | 130 | _fatal_insn ("insn does not satisfy its constraints:", |
c895acf2 GDR |
131 | insn, file, line, function); |
132 | } |