]>
Commit | Line | Data |
---|---|---|
5e6908ea | 1 | /* RTL specific diagnostic subroutines for GCC |
7adcbafe | 2 | Copyright (C) 2001-2022 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 | 8 | it under the terms of the GNU General Public License as published by |
9dcd6f09 | 9 | the Free Software Foundation; either version 3, or (at your option) |
c895acf2 GDR |
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 | |
9dcd6f09 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
c895acf2 GDR |
20 | |
21 | #include "config.h" | |
c895acf2 | 22 | #include "system.h" |
4977bab6 ZW |
23 | #include "coretypes.h" |
24 | #include "tm.h" | |
0cbd9993 | 25 | #include "rtl-error.h" |
c895acf2 | 26 | #include "diagnostic.h" |
957060b5 | 27 | #include "intl.h" |
c895acf2 | 28 | |
1c22488e DM |
29 | static location_t location_for_asm (const rtx_insn *); |
30 | static void diagnostic_for_asm (const rtx_insn *, const char *, va_list *, | |
31 | diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0); | |
c895acf2 | 32 | |
9a472a42 NS |
33 | /* Figure the location of the given INSN. */ |
34 | static location_t | |
1c22488e | 35 | location_for_asm (const rtx_insn *insn) |
c895acf2 GDR |
36 | { |
37 | rtx body = PATTERN (insn); | |
38 | rtx asmop; | |
9a472a42 | 39 | location_t loc; |
0c20a65f | 40 | |
c895acf2 GDR |
41 | /* Find the (or one of the) ASM_OPERANDS in the insn. */ |
42 | if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) | |
43 | asmop = SET_SRC (body); | |
44 | else if (GET_CODE (body) == ASM_OPERANDS) | |
45 | asmop = body; | |
46 | else if (GET_CODE (body) == PARALLEL | |
47 | && GET_CODE (XVECEXP (body, 0, 0)) == SET) | |
48 | asmop = SET_SRC (XVECEXP (body, 0, 0)); | |
49 | else if (GET_CODE (body) == PARALLEL | |
50 | && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) | |
51 | asmop = XVECEXP (body, 0, 0); | |
52 | else | |
53 | asmop = NULL; | |
54 | ||
55 | if (asmop) | |
6773e15f | 56 | loc = ASM_OPERANDS_SOURCE_LOCATION (asmop); |
c895acf2 | 57 | else |
9a472a42 NS |
58 | loc = input_location; |
59 | return loc; | |
c895acf2 GDR |
60 | } |
61 | ||
fa10beec | 62 | /* Report a diagnostic MESSAGE (an error or a WARNING) at the line number |
c895acf2 GDR |
63 | of the insn INSN. This is used only when INSN is an `asm' with operands, |
64 | and each ASM_OPERANDS records its own source file and line. */ | |
65 | static void | |
1c22488e | 66 | diagnostic_for_asm (const rtx_insn *insn, const char *msg, va_list *args_ptr, |
0c20a65f | 67 | diagnostic_t kind) |
c895acf2 | 68 | { |
47b69537 | 69 | diagnostic_info diagnostic; |
ebedc9a3 | 70 | rich_location richloc (line_table, location_for_asm (insn)); |
0c20a65f | 71 | |
9a472a42 | 72 | diagnostic_set_info (&diagnostic, msg, args_ptr, |
8a645150 | 73 | &richloc, kind); |
56d35585 | 74 | diagnostic_report_diagnostic (global_dc, &diagnostic); |
c895acf2 GDR |
75 | } |
76 | ||
77 | void | |
1c22488e | 78 | error_for_asm (const rtx_insn *insn, const char *gmsgid, ...) |
c895acf2 | 79 | { |
e34d07f2 | 80 | va_list ap; |
0c20a65f | 81 | |
4b794eaf JJ |
82 | va_start (ap, gmsgid); |
83 | diagnostic_for_asm (insn, gmsgid, &ap, DK_ERROR); | |
e34d07f2 | 84 | va_end (ap); |
c895acf2 GDR |
85 | } |
86 | ||
87 | void | |
1c22488e | 88 | warning_for_asm (const rtx_insn *insn, const char *gmsgid, ...) |
c895acf2 | 89 | { |
e34d07f2 | 90 | va_list ap; |
0c20a65f | 91 | |
4b794eaf JJ |
92 | va_start (ap, gmsgid); |
93 | diagnostic_for_asm (insn, gmsgid, &ap, DK_WARNING); | |
e34d07f2 | 94 | va_end (ap); |
c895acf2 GDR |
95 | } |
96 | ||
97 | void | |
f7d504c2 | 98 | _fatal_insn (const char *msgid, const_rtx insn, const char *file, int line, |
0c20a65f | 99 | const char *function) |
c895acf2 GDR |
100 | { |
101 | error ("%s", _(msgid)); | |
102 | ||
103 | /* The above incremented error_count, but isn't an error that we want to | |
104 | count, so reset it here. */ | |
105 | errorcount--; | |
106 | ||
107 | debug_rtx (insn); | |
108 | fancy_abort (file, line, function); | |
109 | } | |
110 | ||
111 | void | |
f7d504c2 | 112 | _fatal_insn_not_found (const_rtx insn, const char *file, int line, |
0c20a65f | 113 | const char *function) |
c895acf2 GDR |
114 | { |
115 | if (INSN_CODE (insn) < 0) | |
1f978f5f | 116 | _fatal_insn ("unrecognizable insn:", insn, file, line, function); |
c895acf2 | 117 | else |
1f978f5f | 118 | _fatal_insn ("insn does not satisfy its constraints:", |
c895acf2 GDR |
119 | insn, file, line, function); |
120 | } |