Mercurial > hg > CbC > CbC_gcc
comparison gcc/brig/brigspec.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* brigspec.c -- Specific flags and argument handling of the gcc BRIG front end. | |
2 Copyright (C) 2016-2017 Free Software Foundation, Inc. | |
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" | |
26 #include "gcc.h" | |
27 #include "opts.h" | |
28 | |
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) | |
39 | |
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 | |
46 | |
47 #define LIBHSAIL "hsail-rt" | |
48 | |
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) | |
53 { | |
54 unsigned int i, j; | |
55 | |
56 /* The new argument list will be contained in this. */ | |
57 struct cl_decoded_option *new_decoded_options; | |
58 | |
59 /* An array used to flag each argument that needs a bit set for | |
60 LANGSPEC, MATHLIB, or WITHLIBC. */ | |
61 int *args; | |
62 | |
63 /* By default, we throw on the math library if we have one. */ | |
64 int need_math = (MATH_LIBRARY[0] != '\0'); | |
65 | |
66 /* True if we should add -shared-libgcc to the command-line. */ | |
67 int shared_libgcc = 1; | |
68 | |
69 /* The total number of arguments with the new stuff. */ | |
70 unsigned int argc; | |
71 | |
72 /* The argument list. */ | |
73 struct cl_decoded_option *decoded_options; | |
74 | |
75 /* The number of libraries added in. */ | |
76 int added_libraries; | |
77 | |
78 /* The total number of arguments with the new stuff. */ | |
79 int num_args = 1; | |
80 | |
81 argc = *in_decoded_options_count; | |
82 decoded_options = *in_decoded_options; | |
83 added_libraries = *in_added_libraries; | |
84 | |
85 args = XCNEWVEC (int, argc); | |
86 | |
87 for (i = 1; i < argc; i++) | |
88 { | |
89 switch (decoded_options[i].opt_index) | |
90 { | |
91 case OPT_o: | |
92 break; | |
93 | |
94 case OPT_SPECIAL_input_file: | |
95 break; | |
96 } | |
97 } | |
98 | |
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); | |
102 | |
103 i = 0; | |
104 j = 0; | |
105 | |
106 /* Copy the 0th argument, i.e., the name of the program itself. */ | |
107 new_decoded_options[j++] = decoded_options[i++]; | |
108 | |
109 /* NOTE: We start at 1 now, not 0. */ | |
110 while (i < argc) | |
111 { | |
112 new_decoded_options[j] = decoded_options[i]; | |
113 | |
114 if ((args[i] & SKIPOPT) != 0) | |
115 --j; | |
116 | |
117 i++; | |
118 j++; | |
119 } | |
120 | |
121 generate_option (OPT_l, LIBHSAIL, 1, CL_DRIVER, &new_decoded_options[j]); | |
122 j++; | |
123 | |
124 *in_decoded_options_count = j; | |
125 *in_decoded_options = new_decoded_options; | |
126 *in_added_libraries = added_libraries; | |
127 } | |
128 | |
129 /* Called before linking. Returns 0 on success and -1 on failure. */ | |
130 | |
131 int lang_specific_pre_link (void) /* Not used for Brig. */ { return 0; } | |
132 | |
133 /* Number of extra output files that lang_specific_pre_link may generate. */ | |
134 | |
135 int lang_specific_extra_outfiles = 0; /* Not used for Brig. */ |