PR c++/85662
[official-gcc.git] / gcc / brig / brigspec.c
blob35e2460b1e5043ed43ba529d731c5e82a3cffcf8
1 /* brigspec.c -- Specific flags and argument handling of the gcc BRIG front end.
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4 for General Processor Tech.
6 This file is part of GCC.
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.
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.
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/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "gcc.h"
27 #include "opts.h"
29 /* This bit is set if we saw a `-xfoo' language specification. */
30 #define LANGSPEC (1 << 1)
31 /* This bit is set if they did `-lm' or `-lmath'. */
32 #define MATHLIB (1 << 2)
33 /* This bit is set if they did `-lpthread'. */
34 #define THREADLIB (1 << 3)
35 /* This bit is set if they did `-lc'. */
36 #define WITHLIBC (1 << 4)
37 /* Skip this option. */
38 #define SKIPOPT (1 << 5)
40 #ifndef MATH_LIBRARY
41 #define MATH_LIBRARY "m"
42 #endif
43 #ifndef MATH_LIBRARY_PROFILE
44 #define MATH_LIBRARY_PROFILE MATH_LIBRARY
45 #endif
47 #define LIBHSAIL "hsail-rt"
49 void
50 lang_specific_driver (struct cl_decoded_option **in_decoded_options,
51 unsigned int *in_decoded_options_count,
52 int *in_added_libraries)
54 unsigned int i, j;
56 /* The new argument list will be contained in this. */
57 struct cl_decoded_option *new_decoded_options;
59 /* An array used to flag each argument that needs a bit set for
60 LANGSPEC, MATHLIB, or WITHLIBC. */
61 int *args;
63 /* By default, we throw on the math library if we have one. */
64 int need_math = (MATH_LIBRARY[0] != '\0');
66 /* True if we should add -shared-libgcc to the command-line. */
67 int shared_libgcc = 1;
69 /* The total number of arguments with the new stuff. */
70 unsigned int argc;
72 /* The argument list. */
73 struct cl_decoded_option *decoded_options;
75 /* The number of libraries added in. */
76 int added_libraries;
78 /* The total number of arguments with the new stuff. */
79 int num_args = 1;
81 argc = *in_decoded_options_count;
82 decoded_options = *in_decoded_options;
83 added_libraries = *in_added_libraries;
85 args = XCNEWVEC (int, argc);
87 for (i = 1; i < argc; i++)
89 switch (decoded_options[i].opt_index)
91 case OPT_o:
92 break;
94 case OPT_SPECIAL_input_file:
95 break;
99 /* Make sure to have room for the trailing NULL argument. */
100 num_args = argc + need_math + shared_libgcc + 10;
101 new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args);
103 i = 0;
104 j = 0;
106 /* Copy the 0th argument, i.e., the name of the program itself. */
107 new_decoded_options[j++] = decoded_options[i++];
109 /* NOTE: We start at 1 now, not 0. */
110 while (i < argc)
112 new_decoded_options[j] = decoded_options[i];
114 if ((args[i] & SKIPOPT) != 0)
115 --j;
117 i++;
118 j++;
121 generate_option (OPT_l, LIBHSAIL, 1, CL_DRIVER, &new_decoded_options[j]);
122 j++;
124 *in_decoded_options_count = j;
125 *in_decoded_options = new_decoded_options;
126 *in_added_libraries = added_libraries;
129 /* Called before linking. Returns 0 on success and -1 on failure. */
131 int lang_specific_pre_link (void) /* Not used for Brig. */ { return 0; }
133 /* Number of extra output files that lang_specific_pre_link may generate. */
135 int lang_specific_extra_outfiles = 0; /* Not used for Brig. */