[llvm-commits] [PATCH] Write llvm byte code into PCH while creating PCH
Devang Patel
dpatel at apple.com
Fri Feb 2 16:26:06 PST 2007
I checked in following patch today. First step as part of GCC PCH
integration work.
-
Devang
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c (revision 123268)
+++ gcc/toplev.c (working copy)
@@ -1163,7 +1163,8 @@ compile_file (void)
#ifndef ENABLE_LLVM
targetm.asm_out.file_end ();
#else
- llvm_asm_file_end();
+ if (!flag_pch_file)
+ llvm_asm_file_end();
#endif
/* APPLE LOCAL end LLVM */
}
@@ -1563,7 +1564,10 @@ init_asm_output (const char *name)
#ifndef ENABLE_LLVM
targetm.asm_out.file_start ();
#else
- llvm_asm_file_start();
+ if (flag_pch_file)
+ llvm_pch_write_init();
+ else
+ llvm_asm_file_start();
#endif
/* APPLE LOCAL end LLVM */
Index: gcc/llvm.h
===================================================================
--- gcc/llvm.h (revision 123268)
+++ gcc/llvm.h (working copy)
@@ -80,6 +80,9 @@ void llvm_emit_typedef(union tree_node*)
*/
void print_llvm(FILE *file, void *LLVM);
+/* Init pch writing. */
+void llvm_pch_write_init(void);
+
/* llvm_asm_file_start - Start the .s file. */
void llvm_asm_file_start(void);
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c (revision 123268)
+++ gcc/cp/decl2.c (working copy)
@@ -2846,8 +2846,12 @@ cp_finish_file (void)
if (! global_bindings_p () || current_class_type ||
decl_namespace_list)
return;
- if (pch_file)
+ /* APPLE LOCAL begin LLVM */
+ if (pch_file) {
c_common_write_pch ();
+ return;
+ }
+ /* APPLE LOCAL end LLVM */
#ifdef USE_MAPPED_LOCATION
/* FIXME - huh? */
Index: gcc/llvm-backend.cpp
===================================================================
--- gcc/llvm-backend.cpp (revision 123268)
+++ gcc/llvm-backend.cpp (working copy)
@@ -183,6 +183,26 @@ void llvm_lang_dependent_init(const char
oFILEstream *AsmOutStream = 0;
+// Initialize PCH writing.
+void llvm_pch_write_init(void) {
+ timevar_push(TV_LLVM_INIT);
+ AsmOutStream = new oFILEstream(asm_out_file);
+ AsmOutFile = new OStream(*AsmOutStream);
+
+ PerModulePasses = new PassManager();
+ PerModulePasses->add(new TargetData(*TheTarget->getTargetData()));
+
+ // Emit an LLVM .bc file to the output. This is used when passed
+ // -emit-llvm -c to the GCC driver.
+ PerModulePasses->add(new WriteBytecodePass(AsmOutFile));
+
+ // Disable emission of .ident into the output file... which is
completely
+ // wrong for llvm/.bc emission cases.
+ flag_no_ident = 1;
+
+ timevar_pop(TV_LLVM_INIT);
+}
+
// llvm_asm_file_start - Start the .s file.
void llvm_asm_file_start(void) {
timevar_push(TV_LLVM_INIT);
Index: gcc/c-pch.c
===================================================================
--- gcc/c-pch.c (revision 123268)
+++ gcc/c-pch.c (working copy)
@@ -193,6 +193,11 @@ c_common_write_pch (void)
long written;
struct c_pch_header h;
+ /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+ llvm_asm_file_end();
+#endif
+ /* APPLE LOCAL end LLVM */
(*debug_hooks->handle_pch) (1);
cpp_write_pch_deps (parse_in, pch_outfile);
More information about the llvm-commits
mailing list