On 05/03/2012 09:31 AM, Steven Bosscher wrote:
+/* This gen* file is unique, in that it writes out multiple files.
+
+   Before GCC 4.8, insn-attrtab.c was written out containing many large
+   functions and tables.  This made insn-attrtab.c_the_  bottle-neck in
+   a parallel build, and even made it impossible to build GCC on machines
+   with relatively small RAM space (PR other/29442).  Therefore, the
+   atrribute functions/tables are now written out to three separate
+   files: "*insn_default_latency" and "*internal_dfa_insn_code"
+   can be output to separate files, stdout and DFA_FILE_NAME respectively.
+   The remaining attributes can be output to ATTR_FILE_NAME.
+
+   Because the gen* support functions write their output to stdout, we have
+   to play tricks with freopen to redirect the output to the right files.  */
+
+static const char *attr_file_name = "tmp-attrtab.c";
+static const char *dfa_file_name = "tmp-dfatab.c";
+static const char *latency_file_name = "tmp-latencytab.c";
+
+static void
+switch_stdout (const char *file_name)
+{
+  if (fflush (stdout) || ferror (stdout))
+    exit (FATAL_EXIT_CODE);
+  if (!freopen (file_name, "a", stdout))
+    fatal ("cannot open file %s: %s", file_name, xstrerror (errno));
+}

I like the idea of the split, but this is unnecessarily gross.
I see nothing in gen* support that has anything to do with output at all;
it's all about input.

I see no reason you can't pass the output filenames at the beginning of
the argument list, increment argv for passing to init_rtx_reader_args,
and use normal fopen/fclose instead of freopen.


r~

Reply via email to