1 /* brigspec.c -- Specific flags and argument handling of the gcc BRIG front end.
2 Copyright (C) 2016-2019 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
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
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/>. */
24 #include "coretypes.h"
26 #include "opt-suggestions.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)
42 #define MATH_LIBRARY "m"
44 #ifndef MATH_LIBRARY_PROFILE
45 #define MATH_LIBRARY_PROFILE MATH_LIBRARY
48 #define LIBHSAIL "hsail-rt"
51 lang_specific_driver (struct cl_decoded_option
**in_decoded_options
,
52 unsigned int *in_decoded_options_count
,
53 int *in_added_libraries
)
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. */
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. */
73 /* The argument list. */
74 struct cl_decoded_option
*decoded_options
;
76 /* The number of libraries added in. */
79 /* The total number of arguments with the new stuff. */
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
)
95 case OPT_SPECIAL_input_file
:
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
);
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. */
113 new_decoded_options
[j
] = decoded_options
[i
];
115 if ((args
[i
] & SKIPOPT
) != 0)
122 generate_option (OPT_l
, LIBHSAIL
, 1, CL_DRIVER
, &new_decoded_options
[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. */