Fix build on sparc64-linux-gnu.
[official-gcc.git] / gcc / brig / brigspec.c
blob2c8a3faf8ffbb804b7f1ad1ad0358e3261ad32ef
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 "opt-suggestions.h"
27 #include "gcc.h"
28 #include "opts.h"
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)
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
48 #define LIBHSAIL "hsail-rt"
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)
55 unsigned int i, j;
57 /* The new argument list will be contained in this. */
58 struct cl_decoded_option *new_decoded_options;
60 /* An array used to flag each argument that needs a bit set for
61 LANGSPEC, MATHLIB, or WITHLIBC. */
62 int *args;
64 /* By default, we throw on the math library if we have one. */
65 int need_math = (MATH_LIBRARY[0] != '\0');
67 /* True if we should add -shared-libgcc to the command-line. */
68 int shared_libgcc = 1;
70 /* The total number of arguments with the new stuff. */
71 unsigned int argc;
73 /* The argument list. */
74 struct cl_decoded_option *decoded_options;
76 /* The number of libraries added in. */
77 int added_libraries;
79 /* The total number of arguments with the new stuff. */
80 int num_args = 1;
82 argc = *in_decoded_options_count;
83 decoded_options = *in_decoded_options;
84 added_libraries = *in_added_libraries;
86 args = XCNEWVEC (int, argc);
88 for (i = 1; i < argc; i++)
90 switch (decoded_options[i].opt_index)
92 case OPT_o:
93 break;
95 case OPT_SPECIAL_input_file:
96 break;
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);
104 i = 0;
105 j = 0;
107 /* Copy the 0th argument, i.e., the name of the program itself. */
108 new_decoded_options[j++] = decoded_options[i++];
110 /* NOTE: We start at 1 now, not 0. */
111 while (i < argc)
113 new_decoded_options[j] = decoded_options[i];
115 if ((args[i] & SKIPOPT) != 0)
116 --j;
118 i++;
119 j++;
122 generate_option (OPT_l, LIBHSAIL, 1, CL_DRIVER, &new_decoded_options[j]);
123 j++;
125 *in_decoded_options_count = j;
126 *in_decoded_options = new_decoded_options;
127 *in_added_libraries = added_libraries;
130 /* Called before linking. Returns 0 on success and -1 on failure. */
132 int lang_specific_pre_link (void) /* Not used for Brig. */ { return 0; }
134 /* Number of extra output files that lang_specific_pre_link may generate. */
136 int lang_specific_extra_outfiles = 0; /* Not used for Brig. */