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