annotate gcc/brig/brigspec.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* brigspec.c -- Specific flags and argument handling of the gcc BRIG front end.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
kono
parents:
diff changeset
4 for General Processor Tech.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
11 version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
16 for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #include "config.h"
kono
parents:
diff changeset
23 #include "system.h"
kono
parents:
diff changeset
24 #include "coretypes.h"
kono
parents:
diff changeset
25 #include "tm.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 #include "opt-suggestions.h"
111
kono
parents:
diff changeset
27 #include "gcc.h"
kono
parents:
diff changeset
28 #include "opts.h"
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 /* This bit is set if we saw a `-xfoo' language specification. */
kono
parents:
diff changeset
31 #define LANGSPEC (1 << 1)
kono
parents:
diff changeset
32 /* This bit is set if they did `-lm' or `-lmath'. */
kono
parents:
diff changeset
33 #define MATHLIB (1 << 2)
kono
parents:
diff changeset
34 /* This bit is set if they did `-lpthread'. */
kono
parents:
diff changeset
35 #define THREADLIB (1 << 3)
kono
parents:
diff changeset
36 /* This bit is set if they did `-lc'. */
kono
parents:
diff changeset
37 #define WITHLIBC (1 << 4)
kono
parents:
diff changeset
38 /* Skip this option. */
kono
parents:
diff changeset
39 #define SKIPOPT (1 << 5)
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 #ifndef MATH_LIBRARY
kono
parents:
diff changeset
42 #define MATH_LIBRARY "m"
kono
parents:
diff changeset
43 #endif
kono
parents:
diff changeset
44 #ifndef MATH_LIBRARY_PROFILE
kono
parents:
diff changeset
45 #define MATH_LIBRARY_PROFILE MATH_LIBRARY
kono
parents:
diff changeset
46 #endif
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 #define LIBHSAIL "hsail-rt"
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 void
kono
parents:
diff changeset
51 lang_specific_driver (struct cl_decoded_option **in_decoded_options,
kono
parents:
diff changeset
52 unsigned int *in_decoded_options_count,
kono
parents:
diff changeset
53 int *in_added_libraries)
kono
parents:
diff changeset
54 {
kono
parents:
diff changeset
55 unsigned int i, j;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 /* The new argument list will be contained in this. */
kono
parents:
diff changeset
58 struct cl_decoded_option *new_decoded_options;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* An array used to flag each argument that needs a bit set for
kono
parents:
diff changeset
61 LANGSPEC, MATHLIB, or WITHLIBC. */
kono
parents:
diff changeset
62 int *args;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 /* By default, we throw on the math library if we have one. */
kono
parents:
diff changeset
65 int need_math = (MATH_LIBRARY[0] != '\0');
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* True if we should add -shared-libgcc to the command-line. */
kono
parents:
diff changeset
68 int shared_libgcc = 1;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* The total number of arguments with the new stuff. */
kono
parents:
diff changeset
71 unsigned int argc;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 /* The argument list. */
kono
parents:
diff changeset
74 struct cl_decoded_option *decoded_options;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 /* The number of libraries added in. */
kono
parents:
diff changeset
77 int added_libraries;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* The total number of arguments with the new stuff. */
kono
parents:
diff changeset
80 int num_args = 1;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 argc = *in_decoded_options_count;
kono
parents:
diff changeset
83 decoded_options = *in_decoded_options;
kono
parents:
diff changeset
84 added_libraries = *in_added_libraries;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 args = XCNEWVEC (int, argc);
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 for (i = 1; i < argc; i++)
kono
parents:
diff changeset
89 {
kono
parents:
diff changeset
90 switch (decoded_options[i].opt_index)
kono
parents:
diff changeset
91 {
kono
parents:
diff changeset
92 case OPT_o:
kono
parents:
diff changeset
93 break;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 case OPT_SPECIAL_input_file:
kono
parents:
diff changeset
96 break;
kono
parents:
diff changeset
97 }
kono
parents:
diff changeset
98 }
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* Make sure to have room for the trailing NULL argument. */
kono
parents:
diff changeset
101 num_args = argc + need_math + shared_libgcc + 10;
kono
parents:
diff changeset
102 new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args);
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 i = 0;
kono
parents:
diff changeset
105 j = 0;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 /* Copy the 0th argument, i.e., the name of the program itself. */
kono
parents:
diff changeset
108 new_decoded_options[j++] = decoded_options[i++];
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 /* NOTE: We start at 1 now, not 0. */
kono
parents:
diff changeset
111 while (i < argc)
kono
parents:
diff changeset
112 {
kono
parents:
diff changeset
113 new_decoded_options[j] = decoded_options[i];
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 if ((args[i] & SKIPOPT) != 0)
kono
parents:
diff changeset
116 --j;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 i++;
kono
parents:
diff changeset
119 j++;
kono
parents:
diff changeset
120 }
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 generate_option (OPT_l, LIBHSAIL, 1, CL_DRIVER, &new_decoded_options[j]);
kono
parents:
diff changeset
123 j++;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 *in_decoded_options_count = j;
kono
parents:
diff changeset
126 *in_decoded_options = new_decoded_options;
kono
parents:
diff changeset
127 *in_added_libraries = added_libraries;
kono
parents:
diff changeset
128 }
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 /* Called before linking. Returns 0 on success and -1 on failure. */
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 int lang_specific_pre_link (void) /* Not used for Brig. */ { return 0; }
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 /* Number of extra output files that lang_specific_pre_link may generate. */
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 int lang_specific_extra_outfiles = 0; /* Not used for Brig. */