Mercurial > hg > truffle
annotate src/share/vm/adlc/main.cpp @ 14694:58cf34613a72
8036976: PPC64: implement the template interpreter
Reviewed-by: kvn, coleenp
Contributed-by: axel.siebenborn@sap.com, martin.doerr@sap.com
author | goetz |
---|---|
date | Mon, 10 Mar 2014 12:58:02 +0100 |
parents | abec000618bf |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
0 | 1 /* |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
10168
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
603
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
603
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
603
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // MAIN.CPP - Entry point for the Architecture Description Language Compiler | |
26 #include "adlc.hpp" | |
27 | |
28 //------------------------------Prototypes------------------------------------- | |
29 static void usage(ArchDesc& AD); // Print usage message and exit | |
30 static char *strip_ext(char *fname); // Strip off name extension | |
31 static char *base_plus_suffix(const char* base, const char *suffix);// New concatenated string | |
32 static int get_legal_text(FileBuff &fbuf, char **legal_text); // Get pointer to legal text | |
33 | |
34 ArchDesc* globalAD = NULL; // global reference to Architecture Description object | |
35 | |
1972 | 36 const char* get_basename(const char* filename) { |
37 const char *basename = filename; | |
38 const char *cp; | |
39 for (cp = basename; *cp; cp++) { | |
40 if (*cp == '/') { | |
41 basename = cp+1; | |
42 } | |
43 } | |
44 return basename; | |
45 } | |
46 | |
0 | 47 //------------------------------main------------------------------------------- |
48 int main(int argc, char *argv[]) | |
49 { | |
50 ArchDesc AD; // Architecture Description object | |
51 globalAD = &AD; | |
52 | |
53 // ResourceMark mark; | |
54 ADLParser *ADL_Parse; // ADL Parser object to parse AD file | |
55 | |
56 // Check for proper arguments | |
57 if( argc == 1 ) usage(AD); // No arguments? Then print usage | |
58 | |
59 // Read command line arguments and file names | |
60 for( int i = 1; i < argc; i++ ) { // For all arguments | |
61 register char *s = argv[i]; // Get option/filename | |
62 | |
63 if( *s++ == '-' ) { // It's a flag? (not a filename) | |
64 if( !*s ) { // Stand-alone `-' means stdin | |
65 //********** INSERT CODE HERE ********** | |
66 } else while (*s != '\0') { // While have flags on option | |
67 switch (*s++) { // Handle flag | |
68 case 'd': // Debug flag | |
69 AD._dfa_debug += 1; // Set Debug Flag | |
70 break; | |
71 case 'g': // Debug ad location flag | |
72 AD._adlocation_debug += 1; // Set Debug ad location Flag | |
73 break; | |
74 case 'o': // No Output Flag | |
75 AD._no_output ^= 1; // Toggle no_output flag | |
76 break; | |
77 case 'q': // Quiet Mode Flag | |
78 AD._quiet_mode ^= 1; // Toggle quiet_mode flag | |
79 break; | |
80 case 'w': // Disable Warnings Flag | |
81 AD._disable_warnings ^= 1; // Toggle disable_warnings flag | |
82 break; | |
83 case 'T': // Option to make DFA as many subroutine calls. | |
84 AD._dfa_small += 1; // Set Mode Flag | |
85 break; | |
86 case 'c': { // Set C++ Output file name | |
87 AD._CPP_file._name = s; | |
88 const char *base = strip_ext(strdup(s)); | |
89 AD._CPP_CLONE_file._name = base_plus_suffix(base,"_clone.cpp"); | |
90 AD._CPP_EXPAND_file._name = base_plus_suffix(base,"_expand.cpp"); | |
91 AD._CPP_FORMAT_file._name = base_plus_suffix(base,"_format.cpp"); | |
92 AD._CPP_GEN_file._name = base_plus_suffix(base,"_gen.cpp"); | |
93 AD._CPP_MISC_file._name = base_plus_suffix(base,"_misc.cpp"); | |
94 AD._CPP_PEEPHOLE_file._name = base_plus_suffix(base,"_peephole.cpp"); | |
95 AD._CPP_PIPELINE_file._name = base_plus_suffix(base,"_pipeline.cpp"); | |
96 s += strlen(s); | |
97 break; | |
98 } | |
99 case 'h': // Set C++ Output file name | |
100 AD._HPP_file._name = s; s += strlen(s); | |
101 break; | |
102 case 'v': // Set C++ Output file name | |
103 AD._VM_file._name = s; s += strlen(s); | |
104 break; | |
105 case 'a': // Set C++ Output file name | |
106 AD._DFA_file._name = s; | |
107 AD._bug_file._name = s; | |
108 s += strlen(s); | |
109 break; | |
110 case '#': // Special internal debug flag | |
111 AD._adl_debug++; // Increment internal debug level | |
112 break; | |
113 case 's': // Output which instructions are cisc-spillable | |
114 AD._cisc_spill_debug = true; | |
115 break; | |
116 case 'D': // Flag Definition | |
117 { | |
118 char* flag = s; | |
119 s += strlen(s); | |
120 char* def = strchr(flag, '='); | |
121 if (def == NULL) def = (char*)"1"; | |
122 else *def++ = '\0'; | |
123 AD.set_preproc_def(flag, def); | |
124 } | |
125 break; | |
126 case 'U': // Flag Un-Definition | |
127 { | |
128 char* flag = s; | |
129 s += strlen(s); | |
130 AD.set_preproc_def(flag, NULL); | |
131 } | |
132 break; | |
133 default: // Unknown option | |
134 usage(AD); // So print usage and exit | |
135 } // End of switch on options... | |
136 } // End of while have options... | |
137 | |
138 } else { // Not an option; must be a filename | |
139 AD._ADL_file._name = argv[i]; // Set the input filename | |
140 | |
141 // // Files for storage, based on input file name | |
142 const char *base = strip_ext(strdup(argv[i])); | |
143 char *temp = base_plus_suffix("dfa_",base); | |
144 AD._DFA_file._name = base_plus_suffix(temp,".cpp"); | |
145 delete temp; | |
146 temp = base_plus_suffix("ad_",base); | |
147 AD._CPP_file._name = base_plus_suffix(temp,".cpp"); | |
148 AD._CPP_CLONE_file._name = base_plus_suffix(temp,"_clone.cpp"); | |
149 AD._CPP_EXPAND_file._name = base_plus_suffix(temp,"_expand.cpp"); | |
150 AD._CPP_FORMAT_file._name = base_plus_suffix(temp,"_format.cpp"); | |
151 AD._CPP_GEN_file._name = base_plus_suffix(temp,"_gen.cpp"); | |
152 AD._CPP_MISC_file._name = base_plus_suffix(temp,"_misc.cpp"); | |
153 AD._CPP_PEEPHOLE_file._name = base_plus_suffix(temp,"_peephole.cpp"); | |
154 AD._CPP_PIPELINE_file._name = base_plus_suffix(temp,"_pipeline.cpp"); | |
155 AD._HPP_file._name = base_plus_suffix(temp,".hpp"); | |
156 delete temp; | |
157 temp = base_plus_suffix("adGlobals_",base); | |
158 AD._VM_file._name = base_plus_suffix(temp,".hpp"); | |
159 delete temp; | |
160 temp = base_plus_suffix("bugs_",base); | |
161 AD._bug_file._name = base_plus_suffix(temp,".out"); | |
162 delete temp; | |
163 } // End of files vs options... | |
164 } // End of while have command line arguments | |
165 | |
166 // Open files used to store the matcher and its components | |
167 if (AD.open_files() == 0) return 1; // Open all input/output files | |
168 | |
169 // Build the File Buffer, Parse the input, & Generate Code | |
170 FileBuff ADL_Buf(&AD._ADL_file, AD); // Create a file buffer for input file | |
171 | |
172 // Get pointer to legal text at the beginning of AD file. | |
173 // It will be used in generated ad files. | |
174 char* legal_text; | |
175 int legal_sz = get_legal_text(ADL_Buf, &legal_text); | |
176 | |
177 ADL_Parse = new ADLParser(ADL_Buf, AD); // Create a parser to parse the buffer | |
178 ADL_Parse->parse(); // Parse buffer & build description lists | |
179 | |
180 if( AD._dfa_debug >= 1 ) { // For higher debug settings, print dump | |
181 AD.dump(); | |
182 } | |
183 | |
184 delete ADL_Parse; // Delete parser | |
185 | |
186 // Verify that the results of the parse are consistent | |
187 AD.verify(); | |
188 | |
189 // Prepare to generate the result files: | |
190 AD.generateMatchLists(); | |
191 AD.identify_unique_operands(); | |
192 AD.identify_cisc_spill_instructions(); | |
193 AD.identify_short_branches(); | |
194 // Make sure every file starts with a copyright: | |
195 AD.addSunCopyright(legal_text, legal_sz, AD._HPP_file._fp); // .hpp | |
196 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_file._fp); // .cpp | |
197 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_CLONE_file._fp); // .cpp | |
198 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_EXPAND_file._fp); // .cpp | |
199 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_FORMAT_file._fp); // .cpp | |
200 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_GEN_file._fp); // .cpp | |
201 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_MISC_file._fp); // .cpp | |
202 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_PEEPHOLE_file._fp); // .cpp | |
203 AD.addSunCopyright(legal_text, legal_sz, AD._CPP_PIPELINE_file._fp); // .cpp | |
204 AD.addSunCopyright(legal_text, legal_sz, AD._VM_file._fp); // .hpp | |
205 AD.addSunCopyright(legal_text, legal_sz, AD._DFA_file._fp); // .cpp | |
1972 | 206 // Add include guards for all .hpp files |
207 AD.addIncludeGuardStart(AD._HPP_file, "GENERATED_ADFILES_AD_HPP"); // .hpp | |
208 AD.addIncludeGuardStart(AD._VM_file, "GENERATED_ADFILES_ADGLOBALS_HPP"); // .hpp | |
209 // Add includes | |
210 AD.addInclude(AD._CPP_file, "precompiled.hpp"); | |
211 AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._VM_file._name)); | |
212 AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._HPP_file._name)); | |
213 AD.addInclude(AD._CPP_file, "memory/allocation.inline.hpp"); | |
7204
f0c2369fda5a
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
6850
diff
changeset
|
214 AD.addInclude(AD._CPP_file, "asm/macroAssembler.inline.hpp"); |
10168
a6e09d6dd8e5
8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
7204
diff
changeset
|
215 AD.addInclude(AD._CPP_file, "code/compiledIC.hpp"); |
1972 | 216 AD.addInclude(AD._CPP_file, "code/vmreg.hpp"); |
217 AD.addInclude(AD._CPP_file, "gc_interface/collectedHeap.inline.hpp"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6179
diff
changeset
|
218 AD.addInclude(AD._CPP_file, "oops/compiledICHolder.hpp"); |
1972 | 219 AD.addInclude(AD._CPP_file, "oops/markOop.hpp"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6179
diff
changeset
|
220 AD.addInclude(AD._CPP_file, "oops/method.hpp"); |
1972 | 221 AD.addInclude(AD._CPP_file, "oops/oop.inline.hpp"); |
222 AD.addInclude(AD._CPP_file, "oops/oop.inline2.hpp"); | |
223 AD.addInclude(AD._CPP_file, "opto/cfgnode.hpp"); | |
224 AD.addInclude(AD._CPP_file, "opto/locknode.hpp"); | |
225 AD.addInclude(AD._CPP_file, "opto/opcodes.hpp"); | |
226 AD.addInclude(AD._CPP_file, "opto/regalloc.hpp"); | |
227 AD.addInclude(AD._CPP_file, "opto/regmask.hpp"); | |
228 AD.addInclude(AD._CPP_file, "opto/runtime.hpp"); | |
229 AD.addInclude(AD._CPP_file, "runtime/biasedLocking.hpp"); | |
230 AD.addInclude(AD._CPP_file, "runtime/sharedRuntime.hpp"); | |
231 AD.addInclude(AD._CPP_file, "runtime/stubRoutines.hpp"); | |
232 AD.addInclude(AD._CPP_file, "utilities/growableArray.hpp"); | |
233 #ifdef TARGET_ARCH_x86 | |
234 AD.addInclude(AD._CPP_file, "nativeInst_x86.hpp"); | |
235 AD.addInclude(AD._CPP_file, "vmreg_x86.inline.hpp"); | |
236 #endif | |
237 #ifdef TARGET_ARCH_sparc | |
238 AD.addInclude(AD._CPP_file, "nativeInst_sparc.hpp"); | |
239 AD.addInclude(AD._CPP_file, "vmreg_sparc.inline.hpp"); | |
240 #endif | |
2401
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
1972
diff
changeset
|
241 #ifdef TARGET_ARCH_arm |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
1972
diff
changeset
|
242 AD.addInclude(AD._CPP_file, "nativeInst_arm.hpp"); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
1972
diff
changeset
|
243 AD.addInclude(AD._CPP_file, "vmreg_arm.inline.hpp"); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
1972
diff
changeset
|
244 #endif |
14391 | 245 #ifdef TARGET_ARCH_ppc |
246 AD.addInclude(AD._CPP_file, "assembler_ppc.inline.hpp"); | |
247 AD.addInclude(AD._CPP_file, "nativeInst_ppc.hpp"); | |
248 AD.addInclude(AD._CPP_file, "vmreg_ppc.inline.hpp"); | |
249 #endif | |
1972 | 250 AD.addInclude(AD._HPP_file, "memory/allocation.hpp"); |
251 AD.addInclude(AD._HPP_file, "opto/machnode.hpp"); | |
252 AD.addInclude(AD._HPP_file, "opto/node.hpp"); | |
253 AD.addInclude(AD._HPP_file, "opto/regalloc.hpp"); | |
254 AD.addInclude(AD._HPP_file, "opto/subnode.hpp"); | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2426
diff
changeset
|
255 AD.addInclude(AD._HPP_file, "opto/vectornode.hpp"); |
1972 | 256 AD.addInclude(AD._CPP_CLONE_file, "precompiled.hpp"); |
257 AD.addInclude(AD._CPP_CLONE_file, "adfiles", get_basename(AD._HPP_file._name)); | |
258 AD.addInclude(AD._CPP_EXPAND_file, "precompiled.hpp"); | |
259 AD.addInclude(AD._CPP_EXPAND_file, "adfiles", get_basename(AD._HPP_file._name)); | |
260 AD.addInclude(AD._CPP_FORMAT_file, "precompiled.hpp"); | |
261 AD.addInclude(AD._CPP_FORMAT_file, "adfiles", get_basename(AD._HPP_file._name)); | |
262 AD.addInclude(AD._CPP_GEN_file, "precompiled.hpp"); | |
263 AD.addInclude(AD._CPP_GEN_file, "adfiles", get_basename(AD._HPP_file._name)); | |
264 AD.addInclude(AD._CPP_GEN_file, "opto/cfgnode.hpp"); | |
265 AD.addInclude(AD._CPP_GEN_file, "opto/locknode.hpp"); | |
266 AD.addInclude(AD._CPP_MISC_file, "precompiled.hpp"); | |
267 AD.addInclude(AD._CPP_MISC_file, "adfiles", get_basename(AD._HPP_file._name)); | |
268 AD.addInclude(AD._CPP_PEEPHOLE_file, "precompiled.hpp"); | |
269 AD.addInclude(AD._CPP_PEEPHOLE_file, "adfiles", get_basename(AD._HPP_file._name)); | |
270 AD.addInclude(AD._CPP_PIPELINE_file, "precompiled.hpp"); | |
271 AD.addInclude(AD._CPP_PIPELINE_file, "adfiles", get_basename(AD._HPP_file._name)); | |
272 AD.addInclude(AD._DFA_file, "precompiled.hpp"); | |
273 AD.addInclude(AD._DFA_file, "adfiles", get_basename(AD._HPP_file._name)); | |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14422
diff
changeset
|
274 AD.addInclude(AD._DFA_file, "opto/cfgnode.hpp"); // Use PROB_MAX in predicate. |
1972 | 275 AD.addInclude(AD._DFA_file, "opto/matcher.hpp"); |
276 AD.addInclude(AD._DFA_file, "opto/opcodes.hpp"); | |
0 | 277 // Make sure each .cpp file starts with include lines: |
278 // files declaring and defining generators for Mach* Objects (hpp,cpp) | |
279 // Generate the result files: | |
280 // enumerations, class definitions, object generators, and the DFA | |
281 // file containing enumeration of machine operands & instructions (hpp) | |
282 AD.addPreHeaderBlocks(AD._HPP_file._fp); // .hpp | |
283 AD.buildMachOperEnum(AD._HPP_file._fp); // .hpp | |
284 AD.buildMachOpcodesEnum(AD._HPP_file._fp); // .hpp | |
285 AD.buildMachRegisterNumbers(AD._VM_file._fp); // VM file | |
286 AD.buildMachRegisterEncodes(AD._HPP_file._fp); // .hpp file | |
287 AD.declareRegSizes(AD._HPP_file._fp); // .hpp | |
288 AD.build_pipeline_enums(AD._HPP_file._fp); // .hpp | |
289 // output definition of class "State" | |
290 AD.defineStateClass(AD._HPP_file._fp); // .hpp | |
291 // file declaring the Mach* classes derived from MachOper and MachNode | |
292 AD.declareClasses(AD._HPP_file._fp); | |
293 // declare and define maps: in the .hpp and .cpp files respectively | |
294 AD.addSourceBlocks(AD._CPP_file._fp); // .cpp | |
295 AD.addHeaderBlocks(AD._HPP_file._fp); // .hpp | |
296 AD.buildReduceMaps(AD._HPP_file._fp, AD._CPP_file._fp); | |
297 AD.buildMustCloneMap(AD._HPP_file._fp, AD._CPP_file._fp); | |
298 // build CISC_spilling oracle and MachNode::cisc_spill() methods | |
299 AD.build_cisc_spill_instructions(AD._HPP_file._fp, AD._CPP_file._fp); | |
300 // define methods for machine dependent State, MachOper, and MachNode classes | |
301 AD.defineClasses(AD._CPP_file._fp); | |
302 AD.buildMachOperGenerator(AD._CPP_GEN_file._fp);// .cpp | |
303 AD.buildMachNodeGenerator(AD._CPP_GEN_file._fp);// .cpp | |
304 // define methods for machine dependent instruction matching | |
305 AD.buildInstructMatchCheck(AD._CPP_file._fp); // .cpp | |
306 // define methods for machine dependent frame management | |
307 AD.buildFrameMethods(AD._CPP_file._fp); // .cpp | |
14449
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
308 AD.generate_needs_clone_jvms(AD._CPP_file._fp); |
0 | 309 |
310 // do this last: | |
311 AD.addPreprocessorChecks(AD._CPP_file._fp); // .cpp | |
312 AD.addPreprocessorChecks(AD._CPP_CLONE_file._fp); // .cpp | |
313 AD.addPreprocessorChecks(AD._CPP_EXPAND_file._fp); // .cpp | |
314 AD.addPreprocessorChecks(AD._CPP_FORMAT_file._fp); // .cpp | |
315 AD.addPreprocessorChecks(AD._CPP_GEN_file._fp); // .cpp | |
316 AD.addPreprocessorChecks(AD._CPP_MISC_file._fp); // .cpp | |
317 AD.addPreprocessorChecks(AD._CPP_PEEPHOLE_file._fp); // .cpp | |
318 AD.addPreprocessorChecks(AD._CPP_PIPELINE_file._fp); // .cpp | |
319 | |
320 // define the finite automata that selects lowest cost production | |
321 AD.buildDFA(AD._DFA_file._fp); | |
1972 | 322 // Add include guards for all .hpp files |
323 AD.addIncludeGuardEnd(AD._HPP_file, "GENERATED_ADFILES_AD_HPP"); // .hpp | |
324 AD.addIncludeGuardEnd(AD._VM_file, "GENERATED_ADFILES_ADGLOBALS_HPP"); // .hpp | |
0 | 325 |
326 AD.close_files(0); // Close all input/output files | |
327 | |
328 // Final printout and statistics | |
329 // cout << program; | |
330 | |
331 if( AD._dfa_debug & 2 ) { // For higher debug settings, print timing info | |
332 // Timer t_stop; | |
333 // Timer t_total = t_stop - t_start; // Total running time | |
334 // cerr << "\n---Architecture Description Totals---\n"; | |
335 // cerr << ", Total lines: " << TotalLines; | |
336 // float l = TotalLines; | |
337 // cerr << "\nTotal Compilation Time: " << t_total << "\n"; | |
338 // float ft = (float)t_total; | |
339 // if( ft > 0.0 ) fprintf(stderr,"Lines/sec: %#5.2f\n", l/ft); | |
340 } | |
341 return (AD._syntax_errs + AD._semantic_errs + AD._internal_errs); // Bye Bye!! | |
342 } | |
343 | |
344 //------------------------------usage------------------------------------------ | |
345 static void usage(ArchDesc& AD) | |
346 { | |
347 printf("Architecture Description Language Compiler\n\n"); | |
6850 | 348 printf("Usage: adlc [-doqwTs] [-#]* [-D<FLAG>[=<DEF>]] [-U<FLAG>] [-c<CPP_FILE_NAME>] [-h<HPP_FILE_NAME>] [-a<DFA_FILE_NAME>] [-v<GLOBALS_FILE_NAME>] <ADL_FILE_NAME>\n"); |
0 | 349 printf(" d produce DFA debugging info\n"); |
350 printf(" o no output produced, syntax and semantic checking only\n"); | |
351 printf(" q quiet mode, supresses all non-essential messages\n"); | |
352 printf(" w suppress warning messages\n"); | |
6850 | 353 printf(" T make DFA as many subroutine calls\n"); |
354 printf(" s output which instructions are cisc-spillable\n"); | |
355 printf(" D define preprocessor symbol\n"); | |
356 printf(" U undefine preprocessor symbol\n"); | |
0 | 357 printf(" c specify CPP file name (default: %s)\n", AD._CPP_file._name); |
358 printf(" h specify HPP file name (default: %s)\n", AD._HPP_file._name); | |
359 printf(" a specify DFA output file name\n"); | |
6850 | 360 printf(" v specify adGlobals output file name\n"); |
361 printf(" # increment ADL debug level\n"); | |
0 | 362 printf("\n"); |
363 } | |
364 | |
365 //------------------------------open_file------------------------------------ | |
366 int ArchDesc::open_file(bool required, ADLFILE & ADF, const char *action) | |
367 { | |
368 if (required && | |
369 (ADF._fp = fopen(ADF._name, action)) == NULL) { | |
370 printf("ERROR: Cannot open file for %s: %s\n", action, ADF._name); | |
371 close_files(1); | |
372 return 0; | |
373 } | |
374 return 1; | |
375 } | |
376 | |
377 //------------------------------open_files------------------------------------- | |
378 int ArchDesc::open_files(void) | |
379 { | |
380 if (_ADL_file._name == NULL) | |
381 { printf("ERROR: No ADL input file specified\n"); return 0; } | |
382 | |
383 if (!open_file(true , _ADL_file, "r")) { return 0; } | |
384 if (!open_file(!_no_output, _DFA_file, "w")) { return 0; } | |
385 if (!open_file(!_no_output, _HPP_file, "w")) { return 0; } | |
386 if (!open_file(!_no_output, _CPP_file, "w")) { return 0; } | |
387 if (!open_file(!_no_output, _CPP_CLONE_file, "w")) { return 0; } | |
388 if (!open_file(!_no_output, _CPP_EXPAND_file, "w")) { return 0; } | |
389 if (!open_file(!_no_output, _CPP_FORMAT_file, "w")) { return 0; } | |
390 if (!open_file(!_no_output, _CPP_GEN_file, "w")) { return 0; } | |
391 if (!open_file(!_no_output, _CPP_MISC_file, "w")) { return 0; } | |
392 if (!open_file(!_no_output, _CPP_PEEPHOLE_file, "w")) { return 0; } | |
393 if (!open_file(!_no_output, _CPP_PIPELINE_file, "w")) { return 0; } | |
394 if (!open_file(!_no_output, _VM_file , "w")) { return 0; } | |
395 if (!open_file(_dfa_debug != 0, _bug_file, "w")) { return 0; } | |
396 | |
397 return 1; | |
398 } | |
399 | |
400 //------------------------------close_file------------------------------------ | |
401 void ArchDesc::close_file(int delete_out, ADLFILE& ADF) | |
402 { | |
403 if (ADF._fp) { | |
404 fclose(ADF._fp); | |
405 if (delete_out) remove(ADF._name); | |
406 } | |
407 } | |
408 | |
409 //------------------------------close_files------------------------------------ | |
410 void ArchDesc::close_files(int delete_out) | |
411 { | |
412 if (_ADL_file._fp) fclose(_ADL_file._fp); | |
413 | |
414 close_file(delete_out, _CPP_file); | |
415 close_file(delete_out, _CPP_CLONE_file); | |
416 close_file(delete_out, _CPP_EXPAND_file); | |
417 close_file(delete_out, _CPP_FORMAT_file); | |
418 close_file(delete_out, _CPP_GEN_file); | |
419 close_file(delete_out, _CPP_MISC_file); | |
420 close_file(delete_out, _CPP_PEEPHOLE_file); | |
421 close_file(delete_out, _CPP_PIPELINE_file); | |
422 close_file(delete_out, _HPP_file); | |
423 close_file(delete_out, _DFA_file); | |
424 close_file(delete_out, _bug_file); | |
425 | |
426 if (!_quiet_mode) { | |
427 printf("\n"); | |
428 if (_no_output || delete_out) { | |
429 if (_ADL_file._name) printf("%s: ", _ADL_file._name); | |
430 printf("No output produced"); | |
431 } | |
432 else { | |
433 if (_ADL_file._name) printf("%s --> ", _ADL_file._name); | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
0
diff
changeset
|
434 printf("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s", |
0 | 435 _CPP_file._name, |
436 _CPP_CLONE_file._name, | |
437 _CPP_EXPAND_file._name, | |
438 _CPP_FORMAT_file._name, | |
439 _CPP_GEN_file._name, | |
440 _CPP_MISC_file._name, | |
441 _CPP_PEEPHOLE_file._name, | |
442 _CPP_PIPELINE_file._name, | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
0
diff
changeset
|
443 _HPP_file._name, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
0
diff
changeset
|
444 _DFA_file._name); |
0 | 445 } |
446 printf("\n"); | |
447 } | |
448 } | |
449 | |
450 //------------------------------strip_ext-------------------------------------- | |
451 static char *strip_ext(char *fname) | |
452 { | |
453 char *ep; | |
454 | |
455 if (fname) { | |
456 ep = fname + strlen(fname) - 1; // start at last character and look for '.' | |
457 while (ep >= fname && *ep != '.') --ep; | |
458 if (*ep == '.') *ep = '\0'; // truncate string at '.' | |
459 } | |
460 return fname; | |
461 } | |
462 | |
463 //------------------------------base_plus_suffix------------------------------- | |
464 // New concatenated string | |
465 static char *base_plus_suffix(const char* base, const char *suffix) | |
466 { | |
467 int len = (int)strlen(base) + (int)strlen(suffix) + 1; | |
468 | |
469 char* fname = new char[len]; | |
470 sprintf(fname,"%s%s",base,suffix); | |
471 return fname; | |
472 } | |
473 | |
474 //------------------------------get_legal_text--------------------------------- | |
475 // Get pointer to legal text at the beginning of AD file. | |
476 // This code assumes that a legal text starts at the beginning of .ad files, | |
477 // is commented by "//" at each line and ends with empty line. | |
478 // | |
479 int get_legal_text(FileBuff &fbuf, char **legal_text) | |
480 { | |
481 char* legal_start = fbuf.get_line(); | |
482 assert(legal_start[0] == '/' && legal_start[1] == '/', "Incorrect header of AD file"); | |
483 char* legal_end = fbuf.get_line(); | |
484 assert(strncmp(legal_end, "// Copyright", 12) == 0, "Incorrect header of AD file"); | |
485 while(legal_end[0] == '/' && legal_end[1] == '/') { | |
486 legal_end = fbuf.get_line(); | |
487 } | |
488 *legal_text = legal_start; | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
0
diff
changeset
|
489 return (int) (legal_end - legal_start); |
0 | 490 } |
491 | |
492 // VS2005 has its own definition, identical to this one. | |
493 #if !defined(_WIN32) || defined(_WIN64) || _MSC_VER < 1400 | |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
10168
diff
changeset
|
494 void *operator new( size_t size, int, const char *, int ) throw() { |
0 | 495 return ::operator new( size ); |
496 } | |
497 #endif |