[llvm-commits] [123569] Read bytecodes from PCH file.

2007-02-07 Thread dpatel
Revision: 123569
Author:   dpatel
Date: 2007-02-07 20:36:09 -0800 (Wed, 07 Feb 2007)

Log Message:
---
Read bytecodes from PCH file.

Modified Paths:
--
apple-local/branches/llvm/gcc/Makefile.in
apple-local/branches/llvm/gcc/c-pch.c
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
apple-local/branches/llvm/gcc/llvm.h

Modified: apple-local/branches/llvm/gcc/Makefile.in
===
--- apple-local/branches/llvm/gcc/Makefile.in   2007-02-08 04:34:00 UTC (rev 
123568)
+++ apple-local/branches/llvm/gcc/Makefile.in   2007-02-08 04:36:09 UTC (rev 
123569)
@@ -1069,7 +1069,7 @@
 
 # We use llvm-config to determine the libraries that we need to link in our
 # target, optimizations analyses and the bcwriter.
-LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bcwriter 
ipo
+LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bcwriter 
ipo bcreader
 LLVMLIBFILES := $(shell $(LLVMBINPATH)/llvm-config --libfiles 
$(LLVMCOMPONENTS))
 LLVMLDFLAGS := $(shell $(LLVMBINPATH)/llvm-config --ldflags)
 LIBS += $(LLVMLDFLAGS)

Modified: apple-local/branches/llvm/gcc/c-pch.c
===
--- apple-local/branches/llvm/gcc/c-pch.c   2007-02-08 04:34:00 UTC (rev 
123568)
+++ apple-local/branches/llvm/gcc/c-pch.c   2007-02-08 04:36:09 UTC (rev 
123569)
@@ -429,6 +429,12 @@
  written += size;
}
   free (buf);
+  /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+  llvm_pch_read();
+#endif
+  /* APPLE LOCAL end LLVM */
+
 }
   else
 {
@@ -438,6 +444,7 @@
cpp_errno (pfile, CPP_DL_ERROR, "seeking");
 }
 
+
   cpp_prepare_state (pfile, &smd);
 
   gt_pch_restore (f);

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-08 04:34:00 UTC 
(rev 123568)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-08 04:36:09 UTC 
(rev 123569)
@@ -32,6 +32,7 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Bytecode/WriteBytecodePass.h"
+#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
@@ -184,6 +185,21 @@
 
 oFILEstream *AsmOutStream = 0;
 
+void llvm_pch_read(void) {
+
+  if (TheModule)
+delete TheModule;
+
+  fclose (asm_out_file);
+  std::string ErrMsg;
+  TheModule = ParseBytecodeFile(asm_file_name, &ErrMsg);
+  if (!TheModule) {
+cerr << "Error reading bytecodes from PCH file\n";
+cerr << ErrMsg << "\n";
+exit(1);
+  }
+}
+
 // Initialize PCH writing. 
 void llvm_pch_write_init(void) {
   timevar_push(TV_LLVM_INIT);

Modified: apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
===
--- apple-local/branches/llvm/gcc/llvm-linker-hack.cpp  2007-02-08 04:34:00 UTC 
(rev 123568)
+++ apple-local/branches/llvm/gcc/llvm-linker-hack.cpp  2007-02-08 04:36:09 UTC 
(rev 123569)
@@ -26,6 +26,7 @@
 #include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Bytecode/Writer.h"
+#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/Streams.h"
@@ -41,6 +42,7 @@
   new llvm::ExistingModuleProvider(0);
   llvm::createVerifierPass();
   llvm::WriteBytecodeToFile(0, llvm::cout);
+  llvm::ParseBytecodeFile(NULL,NULL);
 
   llvm::createInstructionCombiningPass();
   llvm::createScalarReplAggregatesPass();

Modified: apple-local/branches/llvm/gcc/llvm.h
===
--- apple-local/branches/llvm/gcc/llvm.h2007-02-08 04:34:00 UTC (rev 
123568)
+++ apple-local/branches/llvm/gcc/llvm.h2007-02-08 04:36:09 UTC (rev 
123569)
@@ -83,6 +83,9 @@
 /* Init pch writing. */
 void llvm_pch_write_init(void);
 
+/* Read bytecodes from PCH file.  */
+void llvm_pch_read(void);
+
 /* llvm_asm_file_start - Start the .s file. */
 void llvm_asm_file_start(void);
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123742] Quote PCH patch in preprocessed output.

2007-02-12 Thread dpatel
Revision: 123742
Author:   dpatel
Date: 2007-02-12 09:41:51 -0800 (Mon, 12 Feb 2007)

Log Message:
---
Quote PCH patch in preprocessed output. Patch by Anton Korobeynikov.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-ppoutput.c

Modified: apple-local/branches/llvm/gcc/c-ppoutput.c
===
--- apple-local/branches/llvm/gcc/c-ppoutput.c  2007-02-12 09:32:08 UTC (rev 
123741)
+++ apple-local/branches/llvm/gcc/c-ppoutput.c  2007-02-12 17:41:51 UTC (rev 
123742)
@@ -21,6 +21,8 @@
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+/* APPLE LOCAL LLVM */
+#include "toplev.h"
 #include "cpplib.h"
 #include "../libcpp/internal.h"
 #include "tree.h"
@@ -435,6 +437,10 @@
 {
   c_common_read_pch (pfile, name, fd, orig_name);
   
-  fprintf (print.outf, "#pragma GCC pch_preprocess \"%s\"\n", name);
+  /* APPLE LOCAL begin LLVM */
+  fprintf (print.outf, "#pragma GCC pch_preprocess ");
+  output_quoted_string (print.outf, name);
+  fprintf (print.outf, "\n");
+  /* APPLE LOCAL end LLVM */
   print.src_line++;
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123743] Avoid including GCC's system headers.

2007-02-12 Thread dpatel
Revision: 123743
Author:   dpatel
Date: 2007-02-12 10:01:31 -0800 (Mon, 12 Feb 2007)

Log Message:
---
Avoid including GCC's system headers. They poison stuff
like malloc that we use in LLVM subsystem.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-debug.h

Modified: apple-local/branches/llvm/gcc/llvm-debug.h
===
--- apple-local/branches/llvm/gcc/llvm-debug.h  2007-02-12 17:41:51 UTC (rev 
123742)
+++ apple-local/branches/llvm/gcc/llvm-debug.h  2007-02-12 18:01:31 UTC (rev 
123743)
@@ -31,10 +31,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 
 extern "C" {
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-union tree_node;
+#include "llvm.h"
 }  
 
 #include 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123793] Fix target-specific .cpp files dependencies.

2007-02-13 Thread dpatel
Revision: 123793
Author:   dpatel
Date: 2007-02-13 10:19:31 -0800 (Tue, 13 Feb 2007)

Log Message:
---
Fix target-specific .cpp files dependencies.

Modified Paths:
--
apple-local/branches/llvm/gcc/Makefile.in

Modified: apple-local/branches/llvm/gcc/Makefile.in
===
--- apple-local/branches/llvm/gcc/Makefile.in   2007-02-13 17:23:34 UTC (rev 
123792)
+++ apple-local/branches/llvm/gcc/Makefile.in   2007-02-13 18:19:31 UTC (rev 
123793)
@@ -2488,9 +2488,9 @@
$(out_file) $(OUTPUT_OPTION)
 # APPLE LOCAL begin LLVM
 ifneq ($(out_cxx_file),)
-$(out_cxx_object_file): $(srcdir)/config/$(out_cxx_file) $(CONFIG_H) 
coretypes.h $(TM_H) $(TREE_H) $(GGC_H) \
+$(out_cxx_object_file): $(srcdir)/config/$(out_cxx_file) $(ALL_HEADERS) 
$(TREE_H) $(GGC_H) \
$(RTL_H) $(REGS_H) hard-reg-set.h real.h insn-config.h conditions.h \
-   output.h $(INSN_ATTR_H) $(SYSTEM_H) toplev.h $(TARGET_H) libfuncs.h \
+   output.h $(INSN_ATTR_H) toplev.h $(TARGET_H) libfuncs.h \
$(TARGET_DEF_H) function.h $(SCHED_INT_H) $(TM_P_H) $(EXPR_H) $(OPTABS_H) \
langhooks.h
$(CXX) -c $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123794] Fix llvm-gcc builds without --enable-llvm

2007-02-13 Thread dpatel
Revision: 123794
Author:   dpatel
Date: 2007-02-13 10:39:43 -0800 (Tue, 13 Feb 2007)

Log Message:
---
Fix llvm-gcc builds without --enable-llvm

Modified Paths:
--
apple-local/branches/llvm/gcc/Makefile.in

Modified: apple-local/branches/llvm/gcc/Makefile.in
===
--- apple-local/branches/llvm/gcc/Makefile.in   2007-02-13 18:19:31 UTC (rev 
123793)
+++ apple-local/branches/llvm/gcc/Makefile.in   2007-02-13 18:39:43 UTC (rev 
123794)
@@ -1030,8 +1030,10 @@
 OBJS-md = $(out_object_file)
 # APPLE LOCAL begin LLVM
 ifneq ($(out_cxx_file),)
+ifneq ($(LLVMOBJDIR),)
 OBJC-md += $(out_cxx_object_file)
 endif
+endif
 # APPLE LOCAL end LLVM
 OBJS-archive = $(EXTRA_OBJS) $(host_hook_obj) tree-inline.o   \
   cgraph.o cgraphunit.o tree-nomudflap.o
@@ -1125,8 +1127,10 @@
 OBJS = $(OBJS-common) $(out_object_file) $(OBJS-archive)
 # APPLE LOCAL begin LLVM
 ifneq ($(out_cxx_file),)
+ifneq ($(LLVMOBJDIR),)
 OBJS += $(out_cxx_object_file)
 endif
+endif
 # APPLE LOCAL end LLVM
 OBJS-onestep = libbackend.o $(OBJS-archive)
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123874] Maintain GCC Type Tree <--> LLVM Type connection during

2007-02-14 Thread dpatel
Revision: 123874
Author:   dpatel
Date: 2007-02-14 13:54:21 -0800 (Wed, 14 Feb 2007)

Log Message:
---
Maintain GCC Type Tree <--> LLVM Type connection during
PCH write and PCH read.

Use LLVM Type vector index, instead of pointer to LLVM Type,
to connect LLVM Type with GCC Type Tree node.

Modified Paths:
--
apple-local/branches/llvm/gcc/flags.h
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
apple-local/branches/llvm/gcc/llvm-types.cpp
apple-local/branches/llvm/gcc/toplev.c
apple-local/branches/llvm/gcc/tree.h

Modified: apple-local/branches/llvm/gcc/flags.h
===
--- apple-local/branches/llvm/gcc/flags.h   2007-02-14 20:34:14 UTC (rev 
123873)
+++ apple-local/branches/llvm/gcc/flags.h   2007-02-14 21:54:21 UTC (rev 
123874)
@@ -334,4 +334,7 @@
 extern int flag_save_repository;
 /* APPLE LOCAL end ss2 */
 
+/* APPLE LOCAL LLVM */
+extern int flag_llvm_pch_read;
+
 #endif /* ! GCC_FLAGS_H */

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-14 20:34:14 UTC 
(rev 123873)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-14 21:54:21 UTC 
(rev 123874)
@@ -64,6 +64,9 @@
 #include "tree-inline.h"
 }
 
+// Non-zero if bytecode from PCH is successfully read.
+int flag_llvm_pch_read;
+
 // Global state for the LLVM backend.
 Module *TheModule = 0;
 DebugInfo *TheDebugInfo = 0;
@@ -184,6 +187,8 @@
 
 oFILEstream *AsmOutStream = 0;
 
+/// Read bytecode from PCH file. Initialize TheModue and setup
+/// LTypes vector.
 void llvm_pch_read(void) {
 
   if (TheModule)
@@ -199,10 +204,15 @@
 cerr << ErrMsg << "\n";
 exit(1);
   }
+
+  // Read LLVM Types string table
+  readLLVMTypesStringTable();
+  flag_llvm_pch_read = 1;
 }
 
 // Initialize PCH writing. 
 void llvm_pch_write_init(void) {
+
   timevar_push(TV_LLVM_INIT);
   AsmOutStream = new oFILEstream(asm_out_file);
   AsmOutFile = new OStream(*AsmOutStream);
@@ -218,6 +228,8 @@
   // wrong for llvm/.bc emission cases.
   flag_no_ident = 1;
 
+  flag_llvm_pch_read = 0;
+
   timevar_pop(TV_LLVM_INIT);
 }
 
@@ -227,6 +239,8 @@
   AsmOutStream = new oFILEstream(asm_out_file);
   AsmOutFile = new OStream(*AsmOutStream);
   
+  flag_llvm_pch_read = 0;
+
   // Create and set up the per-function pass manager.
   // FIXME: Move the code generator to be function-at-a-time.
   PerFunctionPasses =
@@ -410,7 +424,10 @@
 void llvm_asm_file_end(void) {
   timevar_push(TV_LLVM_PERFILE);
   llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
-  
+
+  if (flag_pch_file)
+writeLLVMTypesStringTable();
+
   // Add an llvm.global_ctors global if needed.
   if (!StaticCtors.empty())
 CreateStructorsList(StaticCtors, "llvm.global_ctors");

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===
--- apple-local/branches/llvm/gcc/llvm-internal.h   2007-02-14 20:34:14 UTC 
(rev 123873)
+++ apple-local/branches/llvm/gcc/llvm-internal.h   2007-02-14 21:54:21 UTC 
(rev 123874)
@@ -94,6 +94,9 @@
 extern std::map EmittedGlobalVars;
 extern std::map EmittedFunctions;
 
+extern void readLLVMTypesStringTable();
+extern void writeLLVMTypesStringTable();
+
 struct StructTypeConversionInfo;
 
 /// TypeConverter - Implement the converter from GCC types to LLVM types.

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-02-14 20:34:14 UTC 
(rev 123873)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-02-14 21:54:21 UTC 
(rev 123874)
@@ -29,9 +29,11 @@
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
+#include "llvm/TypeSymbolTable.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Assembly/Writer.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include 
 #include 
@@ -45,7 +47,149 @@
 #include "llvm-abi.h"
 
 
+//===--===//
+//   Matching LLVM types with GCC trees
+//===--===//
+//
+// LTypes is a vector of LLVM types. GCC tree nodes keep track of LLVM types 
+// using this vector's index. It is easier to save and restore the index than 
+// the LLVM type pointer while usig PCH. STL vector does not provide fast 
+// searching mechanism which is required to remove LLVM Type entry when type 
is 
+// refined and replaced by another LLVM Type. This

[llvm-commits] [123875] Clear llvm bytecode from asm_out_file after reading PCH.

2007-02-14 Thread dpatel
Revision: 123875
Author:   dpatel
Date: 2007-02-14 14:42:10 -0800 (Wed, 14 Feb 2007)

Log Message:
---
Clear llvm bytecode from asm_out_file after reading PCH.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/toplev.c

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-14 21:54:21 UTC 
(rev 123874)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-14 22:42:10 UTC 
(rev 123875)
@@ -195,6 +195,7 @@
 delete TheModule;
 
   fclose (asm_out_file);
+  
   std::string ErrMsg;
   TheModule = ParseBytecodeFile(asm_file_name,
 Compressor::decompressToNewBuffer,
@@ -205,6 +206,12 @@
 exit(1);
   }
 
+  // Reopen asm_out_file for the rest of the compiler's use.
+  // This also removes llvm byte code from the asm_out_file.
+  asm_out_file = fopen (asm_file_name, "w+b");
+  if (asm_out_file == 0)
+fatal_error ("can%'t open %s for writing: %m", asm_file_name);
+
   // Read LLVM Types string table
   readLLVMTypesStringTable();
   flag_llvm_pch_read = 1;

Modified: apple-local/branches/llvm/gcc/toplev.c
===
--- apple-local/branches/llvm/gcc/toplev.c  2007-02-14 21:54:21 UTC (rev 
123874)
+++ apple-local/branches/llvm/gcc/toplev.c  2007-02-14 22:42:10 UTC (rev 
123875)
@@ -2279,13 +2279,6 @@
unlink (asm_file_name2);
   else if (fclose (asm_out_file) != 0)
/* APPLE LOCAL end ss2 */
-/* APPLE LOCAL begin LLVM */
-#ifdef ENABLE_LLVM
-/* While reading bytecodes from PCH file, asm_out_file was already 
-   closed by llvm-backend.  */
-if (!flag_llvm_pch_read)
-#endif
-  /* APPLE LOCAL end LLVM */
fatal_error ("error closing %s: %m", asm_file_name);
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [123989] Save and Restore LLVM values to GCC DECL tree link.

2007-02-16 Thread dpatel
Revision: 123989
Author:   dpatel
Date: 2007-02-16 16:10:49 -0800 (Fri, 16 Feb 2007)

Log Message:
---
Save and Restore LLVM values to GCC DECL tree link.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
apple-local/branches/llvm/gcc/llvm-types.cpp
apple-local/branches/llvm/gcc/tree.h

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-16 23:44:15 UTC 
(rev 123988)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-02-17 00:10:49 UTC 
(rev 123989)
@@ -214,6 +214,8 @@
 
   // Read LLVM Types string table
   readLLVMTypesStringTable();
+  readLLVMValuesStringTable();
+
   flag_llvm_pch_read = 1;
 }
 
@@ -432,8 +434,10 @@
   timevar_push(TV_LLVM_PERFILE);
   llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
 
-  if (flag_pch_file)
+  if (flag_pch_file) {
 writeLLVMTypesStringTable();
+writeLLVMValuesStringTable();
+  }
 
   // Add an llvm.global_ctors global if needed.
   if (!StaticCtors.empty())

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-02-16 23:44:15 UTC 
(rev 123988)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-02-17 00:10:49 UTC 
(rev 123989)
@@ -24,6 +24,7 @@
 // This is the code that converts GCC AST nodes into LLVM code.
 
//===--===//
 
+#include "llvm/ValueSymbolTable.h"
 #include "llvm-abi.h"
 #include "llvm-internal.h"
 #include "llvm-debug.h"
@@ -38,6 +39,7 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/DenseMap.h"
 #include 
 
 extern "C" {
@@ -61,6 +63,137 @@
 extern int get_pointer_alignment (tree exp, unsigned int max_align);
 }
 
+//===--===//
+//   Matching LLVM Values with GCC DECL trees
+//===--===//
+//
+// LLVMValues is a vector of LLVM Values. GCC tree nodes keep track of LLVM 
+// Values using this vector's index. It is easier to save and restore the 
index 
+// than the LLVM Value pointer while usig PCH. 
+
+// Collection of LLVM Values
+static std::vector LLVMValues;
+typedef DenseMap LLVMValuesMapTy;
+static LLVMValuesMapTy LLVMValuesMap;
+
+// Remember the LLVM value for GCC tree node.
+void llvm_set_decl(tree Tr, Value *V) {
+
+  // If there is not any value then do not add new LLVMValues entry.
+  // However clear Tr index if it is non zero.
+  if (!V) {
+if (GET_DECL_LLVM_INDEX(Tr))
+  SET_DECL_LLVM_INDEX(Tr, 0);
+return;
+  }
+
+  unsigned &ValueSlot = LLVMValuesMap[V];
+  if (ValueSlot) {
+// Already in map
+SET_DECL_LLVM_INDEX(Tr, ValueSlot);
+return;
+  }
+
+  unsigned Index = LLVMValues.size() + 1;
+  LLVMValues.push_back(V);
+  SET_DECL_LLVM_INDEX(Tr, Index);
+  LLVMValuesMap[V] = Index;
+}
+
+// Return TRUE if there is a LLVM Value associate with GCC tree node.
+bool llvm_set_decl_p(tree Tr) {
+  unsigned Index = GET_DECL_LLVM_INDEX(Tr);
+  if (Index == 0)
+return false;
+
+  if (LLVMValues[Index - 1])
+return true;
+
+  return false;
+}
+
+// Get LLVM Value for the GCC tree node based on LLVMValues vector index.
+// If there is not any value associated then use make_decl_llvm() to 
+// make LLVM value. When GCC tree node is initialized, it has 0 as the 
+// index value. This is why all recorded indices are offset by 1.
+Value *llvm_get_decl(tree Tr) {
+
+  unsigned Index = GET_DECL_LLVM_INDEX(Tr);
+  if (Index == 0) {
+make_decl_llvm(Tr);
+Index = GET_DECL_LLVM_INDEX(Tr);
+  }
+  assert ((Index - 1) < LLVMValues.size() && "Invalid LLVM Value index");
+
+  return LLVMValues[Index - 1];
+}
+
+// Read LLVM Types string table
+void readLLVMValuesStringTable() {
+
+  GlobalValue *V = TheModule->getNamedGlobal("llvm.pch.values");
+  if (!V)
+return;
+
+  GlobalVariable *GV = cast(V);
+  ConstantStruct *LValueNames = cast(GV->getOperand(0));
+
+  for (unsigned i = 0; i < LValueNames->getNumOperands(); ++i) {
+Value *Va = LValueNames->getOperand(i);
+
+if (!Va) {
+  // If V is empty then nsert NULL to represent empty entries.
+  LLVMValues.push_back(Va);
+  continue;
+}
+if (ConstantArray *CA = dyn_cast(Va)) {
+  std::string Str = CA->getAsString();
+  Va = TheModule->getValueSymbolTable().lookup(Str);
+} 
+assert (Va != NULL && "Invalid Value in LL

[llvm-commits] [124164] Backport mingw32 support from FSF GCC mainline.

2007-02-21 Thread dpatel
Revision: 124164
Author:   dpatel
Date: 2007-02-21 13:13:42 -0800 (Wed, 21 Feb 2007)

Log Message:
---
Backport mingw32 support from FSF GCC mainline.
Patch by Anton Korobeynikov.

Added Paths:
---
apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c
apple-local/branches/llvm/gcc/config/i386/winnt-stubs.c

Added: apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c
===
--- apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c   
(rev 0)
+++ apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c   2007-02-21 
21:13:42 UTC (rev 124164)
@@ -0,0 +1,167 @@
+/* Target support for C++ classes on Windows.
+   Contributed by Danny Smith ([EMAIL PROTECTED])
+   Copyright (C) 2005
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "regs.h"
+#include "hard-reg-set.h"
+#include "output.h"
+#include "tree.h"
+#include "cp/cp-tree.h" /* this is why we're a separate module */
+#include "flags.h"
+#include "tm_p.h"
+#include "toplev.h"
+#include "hashtab.h"
+
+bool
+i386_pe_type_dllimport_p (tree decl)
+{
+   gcc_assert (TREE_CODE (decl) == VAR_DECL 
+   || TREE_CODE (decl) == FUNCTION_DECL);
+
+   if (TARGET_NOP_FUN_DLLIMPORT && TREE_CODE (decl) == FUNCTION_DECL)
+ return false;
+
+   /* We ignore the dllimport attribute for inline member functions.
+  This differs from MSVC behavior which treats it like GNUC
+  'extern inline' extension.  Also ignore for template
+  instantiations with linkonce semantics and artificial methods.  */
+if (TREE_CODE (decl) ==  FUNCTION_DECL
+&& (DECL_DECLARED_INLINE_P (decl)
+   || DECL_TEMPLATE_INSTANTIATION (decl)
+   || DECL_ARTIFICIAL (decl)))
+  return false;
+
+   /* Since we can't treat a pointer to a dllimport'd symbol as a
+   constant address, we turn off the attribute on C++ virtual
+   methods to allow creation of vtables using thunks.  */
+else if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
+&& DECL_VIRTUAL_P (decl))
+  {
+   /* Even though we ignore the attribute from the start, warn if we later 
see
+  an out-of class definition, as we do for other member functions in
+  tree.c:merge_dllimport_decl_attributes.  If this is the key method, 
the
+  definition may affect the import-export status of vtables, depending
+   on how we handle MULTIPLE_SYMBOL_SPACES in cp/decl2.c.   */
+   if (DECL_INITIAL (decl))
+ {
+   warning ("%q+D redeclared without dllimport attribute: "
+   "previous dllimport ignored", decl);
+#ifdef PE_DLL_DEBUG
+   if (decl == CLASSTYPE_KEY_METHOD (DECL_CONTEXT (decl)))
+ warning ("key method %q+D of dllimport'd class defined"
+  decl);
+#endif
+ }
+   return false;
+  }
+
+  /* Don't mark defined functions as dllimport.  This code will only be
+ reached if we see a non-inline function defined out-of-class.  */
+else if (TREE_CODE (decl) ==  FUNCTION_DECL
+&& (DECL_INITIAL (decl)))
+  return false;
+
+/*  Don't allow definitions of static data members in dllimport class,
+If vtable data is marked as DECL_EXTERNAL, import it; otherwise just
+ignore the class attribute.  */
+else if (TREE_CODE (decl) == VAR_DECL
+&& TREE_STATIC (decl) && TREE_PUBLIC (decl)
+&& !DECL_EXTERNAL (decl))
+  {
+   if (!DECL_VIRTUAL_P (decl))
+error ("definition of static data member %q+D of "
+   "dllimport'd class", decl);
+   return false;
+  }
+
+return true;
+}
+
+
+bool
+i386_pe_type_dllexport_p (tree decl)
+{
+   gcc_assert (TREE_CODE (decl) == VAR_DECL 
+   || TREE_CODE (decl) == FUNCTION_DECL);
+   /* Avoid expo

[llvm-commits] [124163] Backport mingw32 support from FSF GCC mainline.

2007-02-26 Thread dpatel
Revision: 124163
Author:   dpatel
Date: 2007-02-21 12:19:03 -0800 (Wed, 21 Feb 2007)

Log Message:
---
Backport mingw32 support from FSF GCC mainline.
This patch is prepared by Anton Korobeynikov.

Modified Paths:
--
apple-local/branches/llvm/gcc/config/i386/cygming.h
apple-local/branches/llvm/gcc/config/i386/i386-protos.h
apple-local/branches/llvm/gcc/config/i386/i386.c
apple-local/branches/llvm/gcc/config/i386/t-cygming
apple-local/branches/llvm/gcc/config/i386/t-mingw32
apple-local/branches/llvm/gcc/config/i386/winnt.c
apple-local/branches/llvm/gcc/config.gcc
apple-local/branches/llvm/gcc/cp/decl.c
apple-local/branches/llvm/gcc/doc/extend.texi
apple-local/branches/llvm/gcc/doc/fragments.texi
apple-local/branches/llvm/gcc/doc/tm.texi
apple-local/branches/llvm/gcc/target-def.h
apple-local/branches/llvm/gcc/target.h
apple-local/branches/llvm/gcc/tree.c
apple-local/branches/llvm/gcc/tree.h
apple-local/branches/llvm/gcc/varasm.c

Modified: apple-local/branches/llvm/gcc/config/i386/cygming.h
===
--- apple-local/branches/llvm/gcc/config/i386/cygming.h 2007-02-21 17:50:03 UTC 
(rev 124162)
+++ apple-local/branches/llvm/gcc/config/i386/cygming.h 2007-02-21 20:19:03 UTC 
(rev 124163)
@@ -207,8 +207,10 @@
section and we need to set DECL_SECTION_NAME so we do that here.
Note that we can be called twice on the same decl.  */
 
-#undef TARGET_ENCODE_SECTION_INFO
-#define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
+ /* APPLE LOCAL begin mainline 2005-07-31 */
+#undef SUBTARGET_ENCODE_SECTION_INFO
+#define SUBTARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
+ /* APPLE LOCAL end mainline 2005-07-31 */
 #undef  TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
 
@@ -216,6 +218,11 @@
 #undef ASM_OUTPUT_LABELREF
 #define ASM_OUTPUT_LABELREF  i386_pe_output_labelref
 
+ /* APPLE LOCAL begin mainline 2005-07-31 */
+#undef  COMMON_ASM_OP
+#define COMMON_ASM_OP  "\t.comm\t"
+ /* APPLE LOCAL end mainline 2005-07-31 */
+
 /* Output a common block.  */
 #undef ASM_OUTPUT_COMMON
 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
@@ -422,6 +429,23 @@
 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
 #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
 
+ /* APPLE LOCAL begin mainline 2005-10-12 */
+#define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P i386_pe_valid_dllimport_attribute_p
+#define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION 
i386_pe_adjust_class_at_definition
+ /* APPLE LOCAL end mainline 2005-10-12 */
+
+ /* APPLE LOCAL begin mainline 2005-06-01 */
+/*  mcount() does not need a counter variable.  */
+#undef NO_PROFILE_COUNTERS
+#define NO_PROFILE_COUNTERS 1
+ /* APPLE LOCAL end mainline 2005-06-01 */
+
+ /* APPLE LOCAL begin mainline 2005-04-01 */
+#define SUBTARGET_ATTRIBUTE_TABLE \
+  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ \
+  { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute }
+ /* APPLE LOCAL end mainline 2005-04-01 */
+
 #undef TREE
 
 #ifndef BUFSIZ

Modified: apple-local/branches/llvm/gcc/config/i386/i386-protos.h
===
--- apple-local/branches/llvm/gcc/config/i386/i386-protos.h 2007-02-21 
17:50:03 UTC (rev 124162)
+++ apple-local/branches/llvm/gcc/config/i386/i386-protos.h 2007-02-21 
20:19:03 UTC (rev 124163)
@@ -237,6 +237,9 @@
 extern int ix86_local_alignment (tree, int);
 extern int ix86_constant_alignment (tree, int);
 extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
+/* APPLE LOCAL begin mainline 2005-04-01 */
+extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *); 
+/* APPLE LOCAL end mainline 2005-04-01 */
 
 extern unsigned int i386_pe_section_type_flags (tree, const char *, int);
 extern void i386_pe_asm_named_section (const char *, unsigned int, tree);
@@ -261,6 +264,15 @@
 extern const char *i386_pe_strip_name_encoding (const char *);
 extern const char *i386_pe_strip_name_encoding_full (const char *);
 extern void i386_pe_output_labelref (FILE *, const char *);
+ /* APPLE LOCAL begin mainline 2005-10-12 */
+extern int i386_pe_valid_dllimport_attribute_p (tree);
+
+/* In winnt-cxx.c and winnt-stubs.c  */
+extern void i386_pe_adjust_class_at_definition (tree);
+extern bool i386_pe_type_dllimport_p (tree);
+extern bool i386_pe_type_dllexport_p (tree);
+
+ /* APPLE LOCAL end mainline 2005-10-12 */
 extern rtx maybe_get_pool_constant (rtx);
 
 extern char internal_label_prefix[16];

Modified: apple-local/branches/llvm/gcc/config/i386/i386.c
===
--- apple-local/branches/llvm/gcc/config/i386/i386.c2007-02-21 17:50:03 UTC 
(rev 124162)
+++ apple-local/branches/llvm/gcc/config/i386/i386.c2007-02-21 20:19

[llvm-commits] [124571] While reading PCH, Parse Bytecodes directly from memory.

2007-03-05 Thread dpatel
Revision: 124571
Author:   dpatel
Date: 2007-03-05 14:40:18 -0800 (Mon, 05 Mar 2007)

Log Message:
---
While reading PCH, Parse Bytecodes directly from memory.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-pch.c
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm.h

Modified: apple-local/branches/llvm/gcc/c-pch.c
===
--- apple-local/branches/llvm/gcc/c-pch.c   2007-03-05 11:35:52 UTC (rev 
124570)
+++ apple-local/branches/llvm/gcc/c-pch.c   2007-03-05 22:40:18 UTC (rev 
124571)
@@ -415,6 +415,13 @@
 
   if (!flag_preprocess_only)
 {
+  /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+  unsigned char *buf = xmalloc (h.asm_size);
+  if (fread (buf, h.asm_size, 1, f) != 1)
+cpp_errno (pfile, CPP_DL_ERROR, "reading");
+  llvm_pch_read(buf, h.asm_size);
+#else
   unsigned long written;
   char * buf = xmalloc (16384);
 
@@ -428,13 +435,9 @@
cpp_errno (pfile, CPP_DL_ERROR, "reading");
  written += size;
}
+#endif
+  /* APPLE LOCAL end LLVM */
   free (buf);
-  /* APPLE LOCAL begin LLVM */
-#ifdef ENABLE_LLVM
-  llvm_pch_read();
-#endif
-  /* APPLE LOCAL end LLVM */
-
 }
   else
 {

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-03-05 11:35:52 UTC 
(rev 124570)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-03-05 22:40:18 UTC 
(rev 124571)
@@ -189,16 +189,16 @@
 
 /// Read bytecode from PCH file. Initialize TheModue and setup
 /// LTypes vector.
-void llvm_pch_read(void) {
+void llvm_pch_read(const unsigned char *Buffer, unsigned Size) {
 
+  std::string ModuleName = TheModule->getModuleIdentifier();
   if (TheModule)
 delete TheModule;
 
-  fclose (asm_out_file);
-  
-  std::string ErrMsg;
   clearTargetBuiltinCache();
-  TheModule = ParseBytecodeFile(asm_file_name,
+
+  std::string ErrMsg;
+  TheModule = ParseBytecodeBuffer(Buffer, Size, ModuleName,
 Compressor::decompressToNewBuffer,
 &ErrMsg);
   if (!TheModule) {
@@ -207,12 +207,6 @@
 exit(1);
   }
 
-  // Reopen asm_out_file for the rest of the compiler's use.
-  // This also removes llvm byte code from the asm_out_file.
-  asm_out_file = fopen (asm_file_name, "w+b");
-  if (asm_out_file == 0)
-fatal_error ("can%'t open %s for writing: %m", asm_file_name);
-
   // Read LLVM Types string table
   readLLVMTypesStringTable();
   readLLVMValuesStringTable();

Modified: apple-local/branches/llvm/gcc/llvm.h
===
--- apple-local/branches/llvm/gcc/llvm.h2007-03-05 11:35:52 UTC (rev 
124570)
+++ apple-local/branches/llvm/gcc/llvm.h2007-03-05 22:40:18 UTC (rev 
124571)
@@ -89,7 +89,7 @@
 void llvm_pch_write_init(void);
 
 /* Read bytecodes from PCH file.  */
-void llvm_pch_read(void);
+void llvm_pch_read(const unsigned char *, unsigned);
 
 /* llvm_asm_file_start - Start the .s file. */
 void llvm_asm_file_start(void);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124572] Handle -mllvm.

2007-03-05 Thread dpatel
Revision: 124572
Author:   dpatel
Date: 2007-03-05 16:42:33 -0800 (Mon, 05 Mar 2007)

Log Message:
---
Handle -mllvm.

Modified Paths:
--
apple-local/branches/llvm/gcc/config/darwin.h
apple-local/branches/llvm/gcc/gcc.c

Modified: apple-local/branches/llvm/gcc/config/darwin.h
===
--- apple-local/branches/llvm/gcc/config/darwin.h   2007-03-05 22:40:18 UTC 
(rev 124571)
+++ apple-local/branches/llvm/gcc/config/darwin.h   2007-03-06 00:42:33 UTC 
(rev 124572)
@@ -156,6 +156,8 @@
   { "-image_base", "-Zimage_base" },  \
   { "-init", "-Zinit" },  \
   { "-install_name", "-Zinstall_name" },  \
+  /* APPLE LOCAL llvm */ \
+  { "-mllvm", "-Zmllvm" },  \
   /* APPLE LOCAL mainline */ \
   { "-mkernel", "-mkernel -static -Wa,-static" }, \
   { "-multiply_defined_unused", "-Zmultiplydefinedunused" },  \
@@ -305,6 +307,8 @@
!strcmp (STR, "Zimage_base") ? 1 :   \
!strcmp (STR, "Zinit") ? 1 : \
!strcmp (STR, "Zinstall_name") ? 1 : \
+  /* APPLE LOCAL llvm */ \
+   !strcmp (STR, "Zmllvm") ? 1 :\
!strcmp (STR, "Zmultiplydefinedunused") ? 1 : \
!strcmp (STR, "Zmultiply_defined") ? 1 : \
!strcmp (STR, "precomp-trustfile") ? 1 : \

Modified: apple-local/branches/llvm/gcc/gcc.c
===
--- apple-local/branches/llvm/gcc/gcc.c 2007-03-05 22:40:18 UTC (rev 124571)
+++ apple-local/branches/llvm/gcc/gcc.c 2007-03-06 00:42:33 UTC (rev 124572)
@@ -829,7 +829,8 @@
  %{fastcp:-O3}"
 /* APPLE LOCAL end -fast */
 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
+"/* APPLE LOCAL llvm */"\
+ %1 %{!Q:-quiet} -dumpbase %B %{d*} %{Zmllvm*: -mllvm %*} %{m*} %{a*}\
  %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}}\
  %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
  %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124656] Include looppass.h

2007-03-06 Thread dpatel
Revision: 124656
Author:   dpatel
Date: 2007-03-06 20:35:26 -0800 (Tue, 06 Mar 2007)

Log Message:
---
Include looppass.h

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-03-07 01:01:43 UTC 
(rev 124655)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-03-07 04:35:26 UTC 
(rev 124656)
@@ -28,6 +28,7 @@
 #include "llvm/Module.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/PassManager.h"
+#include "llvm/Analysis/LoopPass.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Assembly/PrintModulePass.h"


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124795] Ignore BUILT_IN_UPDATE_SETJMP_BUF.

2007-03-09 Thread dpatel
Revision: 124795
Author:   dpatel
Date: 2007-03-09 15:59:47 -0800 (Fri, 09 Mar 2007)

Log Message:
---
Ignore BUILT_IN_UPDATE_SETJMP_BUF. 
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-09 21:37:10 UTC 
(rev 124794)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-09 23:59:47 UTC 
(rev 124795)
@@ -3928,6 +3928,7 @@
 case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
 case BUILT_IN_SETJMP:
 case BUILT_IN_LONGJMP:
+case BUILT_IN_UPDATE_SETJMP_BUF:
 case BUILT_IN_TRAP:
   
   // Various hooks for the DWARF 2 __throw routine.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124887] Fix component reference handling.

2007-03-12 Thread dpatel
Revision: 124887
Author:   dpatel
Date: 2007-03-12 15:27:39 -0700 (Mon, 12 Mar 2007)

Log Message:
---
Fix component reference handling. Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-12 18:24:41 UTC 
(rev 124886)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-12 22:27:39 UTC 
(rev 124887)
@@ -4596,6 +4596,20 @@
   return Result;
 }
 
+/// getComponentRefOffsetInBits - Return the offset (in bits) of the field
+/// referenced in a COMPONENT_REF exp.
+static unsigned getComponentRefOffsetInBits(tree exp) {
+  assert(TREE_CODE(exp) == COMPONENT_REF && "not a COMPONENT_REF!");
+  tree field = TREE_OPERAND(exp, 1);
+  assert(TREE_CODE(field) == FIELD_DECL && "not a FIELD_DECL!");
+  tree field_offset = component_ref_field_offset (exp);
+  assert(DECL_FIELD_BIT_OFFSET(field) && field_offset);
+  unsigned Result = TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(field));
+  if (TREE_CODE(field_offset) == INTEGER_CST)
+Result += TREE_INT_CST_LOW(field_offset)*8;
+  return Result;
+}
+
 LValue TreeToLLVM::EmitLV_COMPONENT_REF(tree exp) {
   LValue StructAddrLV = EmitLV(TREE_OPERAND(exp, 0));
   tree FieldDecl = TREE_OPERAND(exp, 1);
@@ -4618,11 +4632,12 @@
   
   // BitStart - This is the actual offset of the field from the start of the
   // struct, in bits.  For bitfields this may be on a non-byte boundary.
-  unsigned BitStart = getFieldOffsetInBits(FieldDecl);
+  unsigned BitStart = getComponentRefOffsetInBits(exp);
   Value *FieldPtr;
   
+  tree field_offset = component_ref_field_offset (exp);
   // If this is a normal field at a fixed offset from the start, handle it.
-  if (TREE_CODE(DECL_FIELD_OFFSET(FieldDecl)) == INTEGER_CST) {
+  if (TREE_CODE(field_offset) == INTEGER_CST) {
 assert(DECL_LLVM_SET_P(FieldDecl) && "Struct not laid out for LLVM?");
 ConstantInt *CI = cast(DECL_LLVM(FieldDecl));
 uint32_t MemberIndex = CI->getZExtValue();
@@ -4646,7 +4661,7 @@
 }
 
   } else {
-Value *Offset = Emit(DECL_FIELD_OFFSET(FieldDecl), 0);
+Value *Offset = Emit(field_offset, 0);
 Value *Ptr = CastToType(Instruction::PtrToInt, StructAddrLV.Ptr, 
 Offset->getType());
 Ptr = BinaryOperator::createAdd(Ptr, Offset, "tmp", CurBB);
@@ -5663,13 +5678,14 @@
   
   // BitStart - This is the actual offset of the field from the start of the
   // struct, in bits.  For bitfields this may be on a non-byte boundary.
-  unsigned BitStart = getFieldOffsetInBits(FieldDecl);
+  unsigned BitStart = getComponentRefOffsetInBits(exp);
   unsigned BitSize  = 0;
   Constant *FieldPtr;
   const TargetData &TD = getTargetData();
-  
+
+  tree field_offset = component_ref_field_offset (exp);
   // If this is a normal field at a fixed offset from the start, handle it.
-  if (TREE_CODE(DECL_FIELD_OFFSET(FieldDecl)) == INTEGER_CST) {
+  if (TREE_CODE(field_offset) == INTEGER_CST) {
 assert(DECL_LLVM_SET_P(FieldDecl) && "Struct not laid out for LLVM?");
 ConstantInt *CI = cast(DECL_LLVM(FieldDecl));
 uint64_t MemberIndex = CI->getZExtValue();
@@ -5689,18 +5705,18 @@
   }
 } else {
   // We were unable to make a nice offset, emit an ugly one.
-  Constant *Offset = Convert(DECL_FIELD_OFFSET(FieldDecl));
+  Constant *Offset = Convert(field_offset);
   FieldPtr = ConstantExpr::getPtrToInt(StructAddrLV, Offset->getType());
   FieldPtr = ConstantExpr::getAdd(FieldPtr, Offset);
   FieldPtr = ConstantExpr::getIntToPtr(FieldPtr, 
PointerType::get(FieldTy));
   
   // Do horrible pointer arithmetic to get the address of the field.
-  unsigned ByteOffset = TREE_INT_CST_LOW(DECL_FIELD_OFFSET(FieldDecl));
+  unsigned ByteOffset = TREE_INT_CST_LOW(field_offset);
   BitStart -= ByteOffset * 8;
 }
 
   } else {
-Constant *Offset = Convert(DECL_FIELD_OFFSET(FieldDecl));
+Constant *Offset = Convert(field_offset);
 Constant *Ptr = ConstantExpr::getPtrToInt(StructAddrLV, Offset->getType());
 Ptr = ConstantExpr::getAdd(Ptr, Offset);
 FieldPtr = ConstantExpr::getIntToPtr(Ptr, PointerType::get(FieldTy));


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [124921] Support arrays with non-zero lower bound

2007-03-12 Thread dpatel
Revision: 124921
Author:   dpatel
Date: 2007-03-12 16:07:59 -0700 (Mon, 12 Mar 2007)

Log Message:
---
Support arrays with non-zero lower bound
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-abi.h
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-abi.h
===
--- apple-local/branches/llvm/gcc/llvm-abi.h2007-03-12 22:37:51 UTC (rev 
124920)
+++ apple-local/branches/llvm/gcc/llvm-abi.h2007-03-12 23:07:59 UTC (rev 
124921)
@@ -110,16 +110,11 @@
   }
 return FoundField ? isSingleElementStructOrArray(FoundField) : 0;
   case ARRAY_TYPE:
-tree Domain = TYPE_DOMAIN(type);
-if (!Domain || !TYPE_MIN_VALUE(Domain) || !TYPE_MAX_VALUE(Domain))
+if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
   return 0;
-if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST ||
-TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
-TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST)
+tree length = arrayLength(type);
+if (!length || !integer_onep(length))
   return 0;
-if (TREE_INT_CST_LOW(TYPE_MAX_VALUE(Domain)) !=
-TREE_INT_CST_LOW(TYPE_MIN_VALUE(Domain)))
-  return 0;
 return isSingleElementStructOrArray(TREE_TYPE(type));
   }
 }

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-12 22:37:51 UTC 
(rev 124920)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-12 23:07:59 UTC 
(rev 124921)
@@ -1353,18 +1353,14 @@
 DECL_USER_ALIGN(decl) = 0;
 Alignment = DECL_ALIGN(decl)/8;
   } else {
+tree length;
+
 // Dynamic-size object: must push space on the stack.
-if (TREE_CODE(type) == ARRAY_TYPE && TYPE_DOMAIN(type)) {
+if (TREE_CODE(type) == ARRAY_TYPE && (length = arrayLength(type))) {
   Ty = ConvertType(TREE_TYPE(type));  // Get array element type.
-  // Compute the size of the number of elements of the array.
-  Size = Emit(TYPE_MAX_VALUE(TYPE_DOMAIN(type)), 0);
-  Size = CastToUIntType(Size, Type::Int32Ty);
-  
-  // Annoyingly, TYPE_MAX_VALUE returns the maximum valid index, NOT the
-  // number of elements in the array.  Thus, we must add one to the 
returned
-  // value.  This addition should be optimized out later.
-  Size = BinaryOperator::createAdd(Size, ConstantInt::get(Type::Int32Ty, 
1),
-   "tmp", CurBB);
+  // Compute the number of elements in the array.
+  Size = Emit(length, 0);
+  Size = CastToUIntType(Size, Size->getType());
 } else {
   // Compute the variable's size in bytes.
   Size = CastToUIntType(Emit(DECL_SIZE_UNIT(decl), 0), Type::Int32Ty);
@@ -4538,9 +4534,8 @@
   // If this is an index into an array, codegen as a GEP.
   if (TREE_CODE(TREE_TYPE(Array)) == ARRAY_TYPE) {
 // Check for variable sized array reference.
-tree Domain = TYPE_DOMAIN(TREE_TYPE(Array));
-if (Domain && TYPE_MAX_VALUE(Domain) &&
-TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST) {
+tree length = arrayLength(TREE_TYPE(Array));
+if (length && !host_integerp(length, 1)) {
   // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep.
   tree ElTy = TREE_TYPE(TREE_TYPE(Array));
   ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty));
@@ -5003,7 +4998,7 @@
 // If this is a variable sized array type, set the length to Len.
 if (ConstantSize == 0) {
   tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
-  if (Domain == 0 || TYPE_MAX_VALUE(Domain) == 0) {
+  if (!Domain || !TYPE_MAX_VALUE(Domain)) {
 ConstantSize = Len;
 StrTy = ArrayType::get(ElTy, Len);
   }
@@ -5102,21 +5097,23 @@
   // type indirectly.
   assert(TREE_CODE(TREE_TYPE(exp)) != VECTOR_TYPE &&
  "VECTOR_TYPE's haven't been tested!");
-  
-  // If we have constant lower bound for the range of the type, get it.  */
+
+  // If we have a lower bound for the range of the type, get it.  */
   tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
-  unsigned MinElement = 0;
-  if (Domain && TYPE_MIN_VALUE(Domain) && 
-  host_integerp(TYPE_MIN_VALUE(Domain), 0))
-MinElement = tree_low_cst(TYPE_MIN_VALUE(Domain), 0);
-  
+  tree min_element = size_zero_node;
+  if (Domain && TYPE_MIN_VALUE(Domain))
+min_element = fold_convert(sizetype, TYPE_MIN_VALUE(Domain));
+
   std::vector ResultElts;
   Constant *SomeVal = 0;
   
-  if (Domain && TYPE_MAX_VALUE(Domain) && 
-  host_integerp(TYPE_MAX_VALUE(Domain), 0)) {
-unsigned MaxElement = tree_low_cst(TYP

[llvm-commits] [124975] Fix VIEW_CONVERT_EXPR handling.

2007-03-14 Thread dpatel
Revision: 124975
Author:   dpatel
Date: 2007-03-14 11:22:11 -0700 (Wed, 14 Mar 2007)

Log Message:
---
Fix VIEW_CONVERT_EXPR handling. Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-14 17:34:05 UTC 
(rev 124974)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-14 18:22:11 UTC 
(rev 124975)
@@ -2760,25 +2760,50 @@
 
 Value *TreeToLLVM::EmitVIEW_CONVERT_EXPR(tree exp, Value *DestLoc) {
   tree Op = TREE_OPERAND(exp, 0);
-  const Type *OpTy = ConvertType(TREE_TYPE(Op));
 
   if (isAggregateTreeType(TREE_TYPE(Op))) {
-if (DestLoc) {
+const Type *OpTy = ConvertType(TREE_TYPE(Op));
+Value *Target = DestLoc ?
   // This is an aggregate-to-agg VIEW_CONVERT_EXPR, just evaluate in place.
-  Value *OpVal = Emit(Op, CastToType(Instruction::BitCast, DestLoc, 
- PointerType::get(OpTy)));
-  assert(OpVal == 0 && "Expected an aggregate operand!");
-  return 0;
-} else {
+  CastToType(Instruction::BitCast, DestLoc, PointerType::get(OpTy)) :
   // This is an aggregate-to-scalar VIEW_CONVERT_EXPR, evaluate, then load.
-  Value *DestLoc = CreateTemporary(OpTy);
-  Value *OpVal = Emit(Op, DestLoc);
+  CreateTemporary(OpTy);
+
+switch (TREE_CODE(Op)) {
+default: {
+  Value *OpVal = Emit(Op, Target);
   assert(OpVal == 0 && "Expected an aggregate operand!");
-  
-  const Type *ExpTy = ConvertType(TREE_TYPE(exp));
-  return new LoadInst(CastToType(Instruction::BitCast, DestLoc, 
- PointerType::get(ExpTy)), "tmp", CurBB);
+  break;
 }
+
+// Lvalues
+case VAR_DECL:
+case PARM_DECL:
+case RESULT_DECL:
+case INDIRECT_REF:
+case ARRAY_REF:
+case ARRAY_RANGE_REF:
+case COMPONENT_REF:
+case BIT_FIELD_REF:
+case STRING_CST:
+case REALPART_EXPR:
+case IMAGPART_EXPR:
+  // Same as EmitLoadOfLValue but taking the size from TREE_TYPE(exp), 
since
+  // the size of TREE_TYPE(Op) may not be available.
+  LValue LV = EmitLV(Op);
+  assert(!LV.isBitfield() && "Expected an aggregate operand!");
+  bool isVolatile = TREE_THIS_VOLATILE(Op);
+
+  EmitAggregateCopy(Target, LV.Ptr, TREE_TYPE(exp), false, isVolatile);
+  break;
+}
+
+if (DestLoc)
+  return 0;
+
+const Type *ExpTy = ConvertType(TREE_TYPE(exp));
+return new LoadInst(CastToType(Instruction::BitCast, Target,
+   PointerType::get(ExpTy)), "tmp", CurBB);
   }
   
   if (DestLoc) {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125159] Fix arry ref size calculation.

2007-03-19 Thread dpatel
Revision: 125159
Author:   dpatel
Date: 2007-03-19 12:06:59 -0700 (Mon, 19 Mar 2007)

Log Message:
---
Fix arry ref size calculation. Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 08:51:20 UTC 
(rev 125158)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 19:06:59 UTC 
(rev 125159)
@@ -4562,9 +4562,8 @@
 tree length = arrayLength(TREE_TYPE(Array));
 if (length && !host_integerp(length, 1)) {
   // Make sure that ArrayAddr is of type ElementTy*, then do a 2-index gep.
-  tree ElTy = TREE_TYPE(TREE_TYPE(Array));
   ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty));
-  Value *Scale = Emit(TYPE_SIZE_UNIT(ElTy), 0);
+  Value *Scale = Emit(array_ref_element_size(exp), 0);
   if (Scale->getType() != IntPtrTy)
 Scale = CastToUIntType(Scale, IntPtrTy);
 
@@ -4595,7 +4594,7 @@
   //   float foo(int w, float A[][w], int g) { return A[g][0]; }
   
   ArrayAddr = BitCastToType(ArrayAddr, PointerType::get(Type::Int8Ty));
-  Value *TypeSize = Emit(TYPE_SIZE_UNIT(IndexedType), 0);
+  Value *TypeSize = Emit(array_ref_element_size(exp), 0);
 
   if (TypeSize->getType() != IntPtrTy)
 TypeSize = CastToUIntType(TypeSize, IntPtrTy);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125160] Better support for variable size struct fields.

2007-03-19 Thread dpatel
Revision: 125160
Author:   dpatel
Date: 2007-03-19 13:55:02 -0700 (Mon, 19 Mar 2007)

Log Message:
---
Better support for variable size struct fields.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 19:06:59 UTC 
(rev 125159)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 20:55:02 UTC 
(rev 125160)
@@ -4660,12 +4660,6 @@
 assert(DECL_LLVM_SET_P(FieldDecl) && "Struct not laid out for LLVM?");
 ConstantInt *CI = cast(DECL_LLVM(FieldDecl));
 uint32_t MemberIndex = CI->getZExtValue();
-if (MemberIndex == ~0U) {
-  assert(isStructWithVarSizeArrayAtEnd(StructTy) &&
- "Isn't var sized array access!");
-  CI = ConstantInt::get(Type::Int32Ty, StructTy->getNumContainedTypes()-1);
-  MemberIndex = CI->getZExtValue();
-}
 assert(MemberIndex < StructTy->getNumContainedTypes() &&
"Field Idx out of range!");
 FieldPtr = new GetElementPtrInst(StructAddrLV.Ptr,
@@ -5476,35 +5470,32 @@
   // If not, things are much simpler.
   assert(DECL_LLVM_SET_P(Field) && "Struct not laid out for LLVM?");
   unsigned FieldNo = cast(DECL_LLVM(Field))->getZExtValue();
-  
+  assert(FieldNo < ResultElts.size() && "Invalid struct field number!");
+
+  // Example: struct X { int A; char C[]; } x = { 4, "foo" };
+  assert(TYPE_SIZE(TREE_TYPE(Field)) ||
+ (FieldNo == ResultElts.size()-1 &&
+  isStructWithVarSizeArrayAtEnd(STy))
+ && "field with no size is not array at end of struct!");
+
   // If this is an initialization of a global that ends with a variable
   // sized array at its end, and the initializer has a non-zero number of
-  // elements, we must handle this case now.  In this case, FieldNo is ~0U
-  // and Val contains the actual type for the array.  
-  if (FieldNo == ~0U) {
-// Handle: struct X { int A; char C[]; } x = { 4, "foo" };
-assert(isStructWithVarSizeArrayAtEnd(STy) &&
-   "Struct doesn't end with variable sized array!");
-FieldNo = STy->getNumElements()-1;
-ResultElts[FieldNo] = Val;
-  } else {
-assert(FieldNo < ResultElts.size() && "Invalid struct field number!");
-
-// Otherwise, we know that the initializer has to match the element 
type
-// of the LLVM structure field.  If not, then there is something that 
is
-// not straight-forward going on.  For example, we could be 
initializing
-// an unaligned integer field (e.g. due to attribute packed) with an 
-// integer.  The struct field will have type [4 x ubyte] instead of
-// "int" for example.  If we ignored this, we would lay out the
-// initializer wrong.
-if (Val->getType() != STy->getElementType(FieldNo))
-  Val = ConvertStructFieldInitializerToType(Val, 
+  // elements, then Val contains the actual type for the array.  Otherwise,
+  // we know that the initializer has to match the element type of the LLVM
+  // structure field.  If not, then there is something that is not
+  // straight-forward going on.  For example, we could be initializing an
+  // unaligned integer field (e.g. due to attribute packed) with an
+  // integer.  The struct field will have type [4 x ubyte] instead of
+  // "int" for example.  If we ignored this, we would lay out the
+  // initializer wrong.
+  if (TYPE_SIZE(TREE_TYPE(Field)) &&
+  Val->getType() != STy->getElementType(FieldNo))
+Val = ConvertStructFieldInitializerToType(Val,
   
STy->getElementType(FieldNo));
 
-ResultElts[FieldNo] = Val;
-  }
+  ResultElts[FieldNo] = Val;
 }
-
+
 NextField = TREE_CHAIN(Field);
   }
   
@@ -5716,31 +5707,18 @@
 ConstantInt *CI = cast(DECL_LLVM(FieldDecl));
 uint64_t MemberIndex = CI->getZExtValue();
 
-if (MemberIndex  != ~0U) {
-  std::vector Idxs;
-  Idxs.push_back(Constant::getNullValue(Type::Int32Ty));
-  Idxs.push_back(CI);
-  FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, &Idxs[0], 
-Idxs.size());
-  
-  // Now that we did an offset from the start of the struct, subtract off
-  // the offset from BitStart.
-  if (MemberIndex) {
-const StructLayout *SL = 
TD.getStructLayout(cast(StructTy));
-Bit

[llvm-commits] [125161] Return the correct type for ARRAY_RANGE_REF.

2007-03-19 Thread dpatel
Revision: 125161
Author:   dpatel
Date: 2007-03-19 16:38:02 -0700 (Mon, 19 Mar 2007)

Log Message:
---
Return the correct type for ARRAY_RANGE_REF.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 20:55:02 UTC 
(rev 125160)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-19 23:38:02 UTC 
(rev 125161)
@@ -4558,6 +4558,8 @@
 
   // If this is an index into an array, codegen as a GEP.
   if (TREE_CODE(TREE_TYPE(Array)) == ARRAY_TYPE) {
+Value *Ptr;
+
 // Check for variable sized array reference.
 tree length = arrayLength(TREE_TYPE(Array));
 if (length && !host_integerp(length, 1)) {
@@ -4568,13 +4570,16 @@
 Scale = CastToUIntType(Scale, IntPtrTy);
 
   IndexVal = BinaryOperator::createMul(IndexVal, Scale, "tmp", CurBB);
-  Value *Ptr = new GetElementPtrInst(ArrayAddr, IndexVal, "tmp", CurBB);
-  return BitCastToType(Ptr, PointerType::get(ConvertType(TREE_TYPE(exp;
+  Ptr = new GetElementPtrInst(ArrayAddr, IndexVal, "tmp", CurBB);
+} else {
+  // Otherwise, this is not a variable-sized array, use a GEP to index.
+  Ptr = new GetElementPtrInst(ArrayAddr, ConstantInt::get(Type::Int32Ty, 
0),
+  IndexVal, "tmp", CurBB);
 }
 
-// Otherwise, this is not a variable-sized array, use a GEP to index.
-return new GetElementPtrInst(ArrayAddr, ConstantInt::get(Type::Int32Ty, 0),
- IndexVal, "tmp", CurBB);
+// The result type is an ElementTy* in the case of an ARRAY_REF, an array
+// of ElementTy in the case of ARRAY_RANGE_REF.  Return the correct type.
+return BitCastToType(Ptr, PointerType::get(ConvertType(TREE_TYPE(exp;
   }
 
   // Otherwise, this is an index off a pointer, codegen as a 2-idx GEP.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125246] Do not map 80 bit and 96 bit float point types to

2007-03-22 Thread dpatel
Revision: 125246
Author:   dpatel
Date: 2007-03-22 11:31:30 -0700 (Thu, 22 Mar 2007)

Log Message:
---
Do not map 80 bit and 96 bit float point types to
64 bit LLVM type.

Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-03-22 17:31:43 UTC 
(rev 125245)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-03-22 18:31:30 UTC 
(rev 125246)
@@ -471,8 +471,6 @@
   debug_tree(type);
   abort();
 case 32: return SET_TYPE_LLVM(type, Type::FloatTy);
-case 80: // Map long doubles to doubles.
-case 96: // Map long doubles to doubles.
 case 64: return SET_TYPE_LLVM(type, Type::DoubleTy);
 case 128:
   // 128-bit long doubles map onto { double, double }.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125252] Emit switch cases with a wide range as a conditional branch.

2007-03-22 Thread dpatel
Revision: 125252
Author:   dpatel
Date: 2007-03-22 16:02:12 -0700 (Thu, 22 Mar 2007)

Log Message:
---
Emit switch cases with a wide range as a conditional branch.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-22 21:39:17 UTC 
(rev 125251)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-22 23:02:12 UTC 
(rev 125252)
@@ -1666,6 +1666,7 @@
   
   // Emit the condition.
   Value *SwitchExp = Emit(SWITCH_COND(exp), 0);
+  bool ExpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(SWITCH_COND(exp)));
   
   // Emit the switch instruction.
   SwitchInst *SI = new SwitchInst(SwitchExp, CurBB,
@@ -1673,39 +1674,68 @@
   EmitBlock(new BasicBlock(""));
   SI->setSuccessor(0, CurBB);   // Default location starts out as fall-through
 
-  // Output the body of the switch.
-  if (SWITCH_BODY(exp))
-Emit(SWITCH_BODY(exp), 0);
-  
+  assert(!SWITCH_BODY(exp) && "not a gimple switch?");
+
+  BasicBlock *DefaultDest = NULL;
   for (unsigned i = 0, e = TREE_VEC_LENGTH(Cases); i != e; ++i) {
 BasicBlock *Dest = getLabelDeclBlock(CASE_LABEL(TREE_VEC_ELT(Cases, i)));
-if (CASE_LOW(TREE_VEC_ELT(Cases, i)) == 0) {
-  SI->setSuccessor(0, Dest);  // Change the default destination.
+
+tree low = CASE_LOW(TREE_VEC_ELT(Cases, i));
+if (!low) {
+  DefaultDest = Dest;
   continue;
 }
 
 // Convert the integer to the right type.
-Value *Val = Emit(CASE_LOW(TREE_VEC_ELT(Cases, i)), 0);
-Val = CastToSIntType(Val, SwitchExp->getType());
-ConstantInt *ValC = cast(Val);
-if (CASE_HIGH(TREE_VEC_ELT(Cases, i)) == 0) {
-  SI->addCase(ValC, Dest); // Single destination.
+Value *Val = Emit(low, 0);
+Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(low)),
+SwitchExp->getType(), ExpIsSigned);
+ConstantInt *LowC = cast(Val);
+
+tree high = CASE_HIGH(TREE_VEC_ELT(Cases, i));
+if (!high) {
+  SI->addCase(LowC, Dest); // Single destination.
   continue;
 }
 
-// Otherwise, we have a range, like 'case 1 ... 17'.  Add all of the
-// necessary successors to the switch.
-Val = Emit(CASE_HIGH(TREE_VEC_ELT(Cases, i)), 0);
-// Make sure the case value is the same type as the switch expression (int)
-Val = CastToSIntType(Val, SwitchExp->getType());
-ConstantInt *HiC = cast(Val);
-Constant *OneC = ConstantInt::get(ValC->getType(), 1);
-while (1) {
-  SI->addCase(ValC, Dest);
-  if (ValC == HiC) break;  // Emitted the last one.
-  ValC = cast(ConstantExpr::getAdd(ValC, OneC));
+// Otherwise, we have a range, like 'case 1 ... 17'.
+Val = Emit(high, 0);
+// Make sure the case value is the same type as the switch expression
+Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(high)),
+SwitchExp->getType(), ExpIsSigned);
+ConstantInt *HighC = cast(Val);
+
+APInt Range = HighC->getValue() - LowC->getValue();
+if (Range.ult(APInt(Range.getBitWidth(), 64))) {
+  // Add all of the necessary successors to the switch.
+  APInt CurrentValue = LowC->getValue();
+  while (1) {
+SI->addCase(LowC, Dest);
+if (LowC == HighC) break;  // Emitted the last one.
+CurrentValue++;
+LowC = ConstantInt::get(CurrentValue);
+  }
+} else {
+  // The range is too big to add to the switch - emit an "if".
+  Value *Diff = BinaryOperator::create(Instruction::Sub, SwitchExp, LowC,
+   "tmp", CurBB);
+  Value *Cond = new ICmpInst(ICmpInst::ICMP_ULE, Diff,
+ ConstantInt::get(Range), "tmp", CurBB);
+  BasicBlock *False_Block = new BasicBlock("case_false");
+  new BranchInst(Dest, False_Block, Cond, CurBB);
+  EmitBlock(False_Block);
 }
   }
+
+  if (DefaultDest)
+if (SI->getSuccessor(0) == CurBB)
+  SI->setSuccessor(0, DefaultDest);
+else {
+  new BranchInst(DefaultDest, CurBB);
+  // Emit a "fallthrough" block, which is almost certainly dead.
+  EmitBlock(new BasicBlock(""));
+}
+
   return 0;
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125417] The address of a VIEW_CONVERT_EXPR is the address of its

2007-03-27 Thread dpatel
Revision: 125417
Author:   dpatel
Date: 2007-03-27 13:12:24 -0700 (Tue, 27 Mar 2007)

Log Message:
---
The address of a VIEW_CONVERT_EXPR is the address of its
operand, but the type is the type of the expression.  The
current code gets the address right but the type wrong.

Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-27 19:54:13 UTC 
(rev 125416)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-03-27 20:12:24 UTC 
(rev 125417)
@@ -850,14 +850,17 @@
   case BIT_FIELD_REF: return EmitLV_BIT_FIELD_REF(exp);
   case REALPART_EXPR: return EmitLV_PART_EXPR(exp, 0);
   case IMAGPART_EXPR: return EmitLV_PART_EXPR(exp, 1);
+
   // Constants.
   case LABEL_DECL:return TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
   case STRING_CST:return 
LValue(TreeConstantToLLVM::EmitLV_STRING_CST(exp));
 
+  // Type Conversion.
+  case VIEW_CONVERT_EXPR: return EmitLV_VIEW_CONVERT_EXPR(exp);
+
   // Trivial Cases.
-  case VIEW_CONVERT_EXPR:
   case WITH_SIZE_EXPR:
-// The address of a these is the address of their operand.
+// The address is the address of the operand.
 return EmitLV(TREE_OPERAND(exp, 0));
   case INDIRECT_REF:
 // The lvalue is just the address.
@@ -4850,6 +4853,15 @@
   "tmp", CurBB));
 }
 
+LValue TreeToLLVM::EmitLV_VIEW_CONVERT_EXPR(tree exp) {
+  // The address is the address of the operand.
+  LValue LV = EmitLV(TREE_OPERAND(exp, 0));
+  // The type is the type of the expression.
+  const Type *Ty = ConvertType(TREE_TYPE(exp));
+  LV.Ptr = BitCastToType(LV.Ptr, PointerType::get(Ty));
+  return LV;
+}
+
 
//===--===//
 //   ... Constant Expressions ...
 
//===--===//

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===
--- apple-local/branches/llvm/gcc/llvm-internal.h   2007-03-27 19:54:13 UTC 
(rev 125416)
+++ apple-local/branches/llvm/gcc/llvm-internal.h   2007-03-27 20:12:24 UTC 
(rev 125417)
@@ -521,6 +521,7 @@
   LValue EmitLV_COMPONENT_REF(tree_node *exp);
   LValue EmitLV_BIT_FIELD_REF(tree_node *exp);
   LValue EmitLV_PART_EXPR(tree_node *exp, unsigned Idx);
+  LValue EmitLV_VIEW_CONVERT_EXPR(tree_node *exp);
 
   // Constant Expressions.
   Value *EmitINTEGER_CST(tree_node *exp);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125528] Apply Geoff's patch to fix bootstrap failures.

2007-03-29 Thread dpatel
Revision: 125528
Author:   dpatel
Date: 2007-03-29 15:06:04 -0700 (Thu, 29 Mar 2007)

Log Message:
---
Apply Geoff's patch to fix bootstrap failures.

Modified Paths:
--
apple-local/branches/llvm/ChangeLog.apple
apple-local/branches/llvm/build_gcc

Modified: apple-local/branches/llvm/ChangeLog.apple
===
--- apple-local/branches/llvm/ChangeLog.apple   2007-03-29 19:54:52 UTC (rev 
125527)
+++ apple-local/branches/llvm/ChangeLog.apple   2007-03-29 22:06:04 UTC (rev 
125528)
@@ -1,3 +1,32 @@
+2007-03-15  Geoffrey Keating  <[EMAIL PROTECTED]>
+
+   * build_gcc: Unset RC_DEBUG_OPTIONS when bootstrapping.
+
+2006-12-13  Geoffrey Keating  <[EMAIL PROTECTED]>
+
+   Radar 4697325
+   * driverdriver.c: New.
+   * build_gcc: Use driverdriver.c rather than
+   gcc/config/darwin-driver.c.
+
+2007-02-27  Geoffrey Keating  <[EMAIL PROTECTED]>
+
+   Radar 4913513
+   * build_gcc: Copy contents of dSYM directories, not just
+   directory itself.
+
+2007-02-06  Mike Stump  <[EMAIL PROTECTED]>
+
+   Radar 4979322
+   * build_gcc: Remove sdk bits.
+   * sdk: Remove.
+   * sdk-test: Remove.
+
+2007-01-26  Mike Stump  <[EMAIL PROTECTED]>
+
+   Radar 4895582
+   * sdk: Build up liibstdcxx fixups for 10.4 SDKs.
+
 2007-01-05  Geoffrey Keating  <[EMAIL PROTECTED]>
 
Radar 4913513

Modified: apple-local/branches/llvm/build_gcc
===
--- apple-local/branches/llvm/build_gcc 2007-03-29 19:54:52 UTC (rev 125527)
+++ apple-local/branches/llvm/build_gcc 2007-03-29 22:06:04 UTC (rev 125528)
@@ -244,7 +244,9 @@
`if [ $BUILD = i686 ] ; then echo $I386_CPU ; fi` \
--host=$BUILD-apple-darwin$DARWIN_VERS 
--target=$BUILD-apple-darwin$DARWIN_VERS || exit 1
 fi
-make $MAKEFLAGS $BOOTSTRAP CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
+# Unset RC_DEBUG_OPTIONS because it causes the bootstrap to fail.
+RC_DEBUG_OPTIONS= \
+  make $MAKEFLAGS $BOOTSTRAP CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
 make $MAKEFLAGS html CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
 make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$BUILD install-gcc install-target \
   CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125745] Improve Packed structure support by used

2007-04-05 Thread dpatel
Revision: 125745
Author:   dpatel
Date: 2007-04-05 09:48:13 -0700 (Thu, 05 Apr 2007)

Log Message:
---
Improve Packed structure support by used 
Packed StructType.

Original version of this patch was written by
Andrew Lenharth. Later this patch was updated by
Duncan Sands. I updated packed bit field 
support in this patch.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-05 14:21:17 UTC 
(rev 125744)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-05 16:48:13 UTC 
(rev 125745)
@@ -4780,6 +4780,10 @@
 // the size of the field.  To get the pointer close enough, add some
 // number of alignment units to the pointer.
 unsigned ByteAlignment = TD.getABITypeAlignment(FieldTy);
+// It is possible that an individual field is Packed. This information 
is
+// not reflected in FieldTy. Check DECL_PACKED here.
+if (DECL_PACKED(FieldDecl))
+  ByteAlignment = 1;
 assert(ByteAlignment*8 <= LLVMValueBitSize && "Unknown overlap case!");
 unsigned NumAlignmentUnits = BitStart/(ByteAlignment*8);
 assert(NumAlignmentUnits && "Not adjusting pointer?");
@@ -5560,7 +5564,7 @@
 if (ResultElts[i] == 0)
   ResultElts[i] = Constant::getNullValue(STy->getElementType(i));
   
-  return ConstantStruct::get(ResultElts, false);
+  return ConstantStruct::get(ResultElts, STy->isPacked());
 }
 
 Constant *TreeConstantToLLVM::ConvertUnionCONSTRUCTOR(tree exp) {

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-05 14:21:17 UTC 
(rev 125744)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-05 16:48:13 UTC 
(rev 125745)
@@ -845,10 +845,27 @@
   std::vector ElementSizeInBytes;
   const TargetData &TD;
   unsigned GCCStructAlignmentInBytes;
+  bool Packed; // True if struct is packed
+  bool LastFieldStartsAtNonByteBoundry;
+  unsigned ExtraBitsAvailable; // Non-zero if last field is bit field and it
+   // does not use all allocated bits
 
-  StructTypeConversionInfo(TargetMachine &TM, unsigned GCCAlign)
-: TD(*TM.getTargetData()), GCCStructAlignmentInBytes(GCCAlign) {}
+  StructTypeConversionInfo(TargetMachine &TM, unsigned GCCAlign, bool P)
+: TD(*TM.getTargetData()), GCCStructAlignmentInBytes(GCCAlign),
+  Packed(P), LastFieldStartsAtNonByteBoundry(false), ExtraBitsAvailable(0) 
{}
 
+  void lastFieldStartsAtNonByteBoundry(bool value) {
+LastFieldStartsAtNonByteBoundry = value;
+  }
+
+  void extraBitsAvailable (unsigned E) {
+ExtraBitsAvailable = E;
+  }
+
+  void markAsPacked() {
+Packed = true;
+  }
+
   unsigned getGCCStructAlignmentInBytes() const {
 return GCCStructAlignmentInBytes;
   }
@@ -856,7 +873,7 @@
   /// getTypeAlignment - Return the alignment of the specified type in bytes.
   ///
   unsigned getTypeAlignment(const Type *Ty) const {
-return TD.getABITypeAlignment(Ty);
+return Packed ? 1 : TD.getABITypeAlignment(Ty);
   }
   
   /// getTypeSize - Return the size of the specified type in bytes.
@@ -868,7 +885,7 @@
   /// getLLVMType - Return the LLVM type for the specified object.
   ///
   const Type *getLLVMType() const {
-return StructType::get(Elements, false);
+return StructType::get(Elements, Packed);
   }
   
   /// getSizeAsLLVMStruct - Return the size of this struct if it were converted
@@ -877,25 +894,103 @@
   uint64_t getSizeAsLLVMStruct() const {
 if (Elements.empty()) return 0;
 unsigned MaxAlign = 1;
-for (unsigned i = 0, e = Elements.size(); i != e; ++i)
-  MaxAlign = std::max(MaxAlign, getTypeAlignment(Elements[i]));
+if (!Packed)
+  for (unsigned i = 0, e = Elements.size(); i != e; ++i)
+MaxAlign = std::max(MaxAlign, getTypeAlignment(Elements[i]));
 
 uint64_t Size = ElementOffsetInBytes.back()+ElementSizeInBytes.back();
 return (Size+MaxAlign-1) & ~(MaxAlign-1);
   }
-  
-  /// RemoveLastElementIfOverlapsWith - If the last element in the struct
-  /// includes the specified byte, remove it.
-  void RemoveLastElementIfOverlapsWith(uint64_t ByteOffset) {
-if (Elements.empty()) return;
-assert(ElementOffsetInBytes.back() <= ByteOffset &&
-   "Cannot go backwards in struct");
-if (ElementOffsetInBytes.back()+ElementSizeInBytes.back() > ByteOffset) {
-  // The last element overlapped with this one, remove it.
-  Elements.pop_back();
-  ElementOffsetInBytes.pop_back();
-  ElementSizeInBytes.pop_back();
+
+  // If this is a Packed struct and E

[llvm-commits] [125850] Fix SingleSource/Regression/C/2--3=-5=21BitfieldHandling failures.

2007-04-06 Thread dpatel
Revision: 125850
Author:   dpatel
Date: 2007-04-06 19:43:09 -0700 (Fri, 06 Apr 2007)

Log Message:
---
Fix SingleSource/Regression/C/2--3=-5=21BitfieldHandling failures.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-06 21:26:05 UTC 
(rev 125849)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-07 02:43:09 UTC 
(rev 125850)
@@ -846,13 +846,15 @@
   const TargetData &TD;
   unsigned GCCStructAlignmentInBytes;
   bool Packed; // True if struct is packed
+  bool AllBitFields; // True if all struct fields are bit fields
   bool LastFieldStartsAtNonByteBoundry;
   unsigned ExtraBitsAvailable; // Non-zero if last field is bit field and it
// does not use all allocated bits
 
   StructTypeConversionInfo(TargetMachine &TM, unsigned GCCAlign, bool P)
 : TD(*TM.getTargetData()), GCCStructAlignmentInBytes(GCCAlign),
-  Packed(P), LastFieldStartsAtNonByteBoundry(false), ExtraBitsAvailable(0) 
{}
+  Packed(P), AllBitFields(true), LastFieldStartsAtNonByteBoundry(false), 
+  ExtraBitsAvailable(0) {}
 
   void lastFieldStartsAtNonByteBoundry(bool value) {
 LastFieldStartsAtNonByteBoundry = value;
@@ -866,6 +868,10 @@
 Packed = true;
   }
 
+  void allFieldsAreNotBitFields() {
+AllBitFields = false;
+  }
+
   unsigned getGCCStructAlignmentInBytes() const {
 return GCCStructAlignmentInBytes;
   }
@@ -894,7 +900,7 @@
   uint64_t getSizeAsLLVMStruct() const {
 if (Elements.empty()) return 0;
 unsigned MaxAlign = 1;
-if (!Packed)
+if (!Packed && !AllBitFields)
   for (unsigned i = 0, e = Elements.size(); i != e; ++i)
 MaxAlign = std::max(MaxAlign, getTypeAlignment(Elements[i]));
 
@@ -908,7 +914,7 @@
 
 unsigned NoOfBytesToRemove = ExtraBitsAvailable/8;
 
-if (!Packed)
+if (!Packed && !AllBitFields)
   return;
 
 if (NoOfBytesToRemove == 0)
@@ -1193,6 +1199,8 @@
 return;
   }
 
+  Info.allFieldsAreNotBitFields();
+
   // Get the starting offset in the record.
   unsigned StartOffsetInBits = getFieldOffsetInBits(Field);
   assert((StartOffsetInBits & 7) == 0 && "Non-bit-field has non-byte offset!");
@@ -1289,12 +1297,17 @@
 unsigned NumBitsRequired = FieldSizeInBits + 
   (prevFieldTypeSizeInBits/8 - 1)*8 + StartOffsetFromByteBoundry;
 
-// If type used to access previous field is not large enough then
-// remove previous field and insert new field that is large enough to
-// hold both fields.
-Info.RemoveFieldsAfter(Info.Elements.size() - 1);
-for (unsigned idx = 0; idx < (prevFieldTypeSizeInBits/8); ++idx)
-  FirstUnallocatedByte--;
+if (NumBitsRequired > 64) {
+  // Use bits from previous field.
+  NumBitsRequired = NumBitsRequired - FirstUnallocatedByte*8;
+} else {
+  // If type used to access previous field is not large enough then
+  // remove previous field and insert new field that is large enough to
+  // hold both fields.
+  Info.RemoveFieldsAfter(Info.Elements.size() - 1);
+  for (unsigned idx = 0; idx < (prevFieldTypeSizeInBits/8); ++idx)
+   FirstUnallocatedByte--;
+}
 Info.addNewBitField(NumBitsRequired, FirstUnallocatedByte);
 // Do this after adding Field.
 Info.lastFieldStartsAtNonByteBoundry(true);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125851] Fix bit field regression.

2007-04-06 Thread dpatel
Revision: 125851
Author:   dpatel
Date: 2007-04-06 20:05:09 -0700 (Fri, 06 Apr 2007)

Log Message:
---
Fix bit field regression. One llvm field, array of bytes,
can be  used by two struct bitfields. In this situation
while iniitalizing smaller bitfield add empty elements
in extra bytes.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-07 02:43:09 UTC 
(rev 125850)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-07 03:05:09 UTC 
(rev 125851)
@@ -5362,7 +5362,13 @@
   OffsetToBitFieldStart = 0;
   NumBitsToInsert -= NumEltBitsToInsert;
 }
-
+
+// Pad extra array elements. This may happens when one llvm field
+// is used to access two struct fields and llvm field is represented
+// as an array of bytes.
+for (; i < Elts.size(); ++i)
+  Elts[i] = ConstantInt::get((cast(FieldTy))->getElementType(), 
0);
+
 return ConstantArray::get(cast(FieldTy), Elts);
   }
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125951] Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/ Week-of-Mon-20070409/047164.html

2007-04-10 Thread dpatel
Revision: 125951
Author:   dpatel
Date: 2007-04-10 14:43:39 -0700 (Tue, 10 Apr 2007)

Log Message:
---
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047164.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-10 18:47:54 UTC 
(rev 125950)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-10 21:43:39 UTC 
(rev 125951)
@@ -1226,11 +1226,10 @@
 // ordering.  Therefore convert to a packed struct and try again.
 Info.convertToPacked();
 DecodeStructFields(Field, Info);
-  }
-
-  // At this point, we know that adding the element will happen at the right
-  // offset.  Add it.
-  Info.addElement(Ty, StartOffsetInBytes, Info.getTypeSize(Ty));
+  } else 
+// At this point, we know that adding the element will happen at the right
+// offset.  Add it.
+Info.addElement(Ty, StartOffsetInBytes, Info.getTypeSize(Ty));
 }
 
 /// DecodeStructBitField - This method decodes the specified bit-field, adding


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125983] No need to map llvm values with GCC trees using names.

2007-04-11 Thread dpatel
Revision: 125983
Author:   dpatel
Date: 2007-04-11 10:17:11 -0700 (Wed, 11 Apr 2007)

Log Message:
---
No need to map llvm values with GCC trees using names.
llvm.pch.values table can directly hold values.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 11:13:54 UTC 
(rev 125982)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 17:17:11 UTC 
(rev 125983)
@@ -198,18 +198,10 @@
 
   for (std::vector::iterator I = LLVMValues.begin(),
  E = LLVMValues.end(); I != E; ++I)  {
-Value *V = *I;
-
-if (!V) {
-  LLVMValuesNames.push_back(ConstantArray::get("", false));  
-  continue;
-}
-
-// Give names to nameless values.
-if (!V->hasName())
-  V->setName("llvm.fe.val");
-
-LLVMValuesNames.push_back(ConstantArray::get(V->getName(), false));
+if (Constant *C = dyn_cast(*I))
+  LLVMValuesNames.push_back(C);
+else
+  LLVMValuesNames.push_back(NULL);
   }
 
   // Create string table.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125984] Cosmetic changes.

2007-04-11 Thread dpatel
Revision: 125984
Author:   dpatel
Date: 2007-04-11 10:29:14 -0700 (Wed, 11 Apr 2007)

Log Message:
---
Cosmetic changes. Rename fns/variales, add comment.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-04-11 17:17:11 UTC 
(rev 125983)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-04-11 17:29:14 UTC 
(rev 125984)
@@ -210,7 +210,7 @@
 
   // Read LLVM Types string table
   readLLVMTypesStringTable();
-  readLLVMValuesStringTable();
+  readLLVMValues();
 
   flag_llvm_pch_read = 1;
 }
@@ -432,7 +432,7 @@
 
   if (flag_pch_file) {
 writeLLVMTypesStringTable();
-writeLLVMValuesStringTable();
+writeLLVMValues();
   }
 
   // Add an llvm.global_ctors global if needed.

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 17:17:11 UTC 
(rev 125983)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 17:29:14 UTC 
(rev 125984)
@@ -157,17 +157,17 @@
 }
 
 // Read LLVM Types string table
-void readLLVMValuesStringTable() {
+void readLLVMValues() {
 
   GlobalValue *V = TheModule->getNamedGlobal("llvm.pch.values");
   if (!V)
 return;
 
   GlobalVariable *GV = cast(V);
-  ConstantStruct *LValueNames = cast(GV->getOperand(0));
+  ConstantStruct *ValuesFromPCH = cast(GV->getOperand(0));
 
-  for (unsigned i = 0; i < LValueNames->getNumOperands(); ++i) {
-Value *Va = LValueNames->getOperand(i);
+  for (unsigned i = 0; i < ValuesFromPCH->getNumOperands(); ++i) {
+Value *Va = ValuesFromPCH->getOperand(i);
 
 if (!Va) {
   // If V is empty then nsert NULL to represent empty entries.
@@ -189,23 +189,25 @@
 // GCC tree's uses LLVMValues vector's index to reach LLVM Values.
 // Create a string table to hold these LLVM Values' names. This string
 // table will be used to recreate LTypes vector after loading PCH.
-void writeLLVMValuesStringTable() {
+void writeLLVMValues() {
   
   if (LLVMValues.empty()) 
 return;
 
-  std::vector LLVMValuesNames;
+  std::vector ValuesForPCH;
 
   for (std::vector::iterator I = LLVMValues.begin(),
  E = LLVMValues.end(); I != E; ++I)  {
 if (Constant *C = dyn_cast(*I))
-  LLVMValuesNames.push_back(C);
+  ValuesForPCH.push_back(C);
 else
-  LLVMValuesNames.push_back(NULL);
+  // Non constant values, e.g. arguments, are not at global scope.
+  // When PCH is read, only global scope values are used.
+  ValuesForPCH.push_back(NULL);
   }
 
   // Create string table.
-  Constant *LLVMValuesNameTable = ConstantStruct::get(LLVMValuesNames, false);
+  Constant *LLVMValuesNameTable = ConstantStruct::get(ValuesForPCH, false);
 
   // Create variable to hold this string table.
   new GlobalVariable(LLVMValuesNameTable->getType(), true,

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===
--- apple-local/branches/llvm/gcc/llvm-internal.h   2007-04-11 17:17:11 UTC 
(rev 125983)
+++ apple-local/branches/llvm/gcc/llvm-internal.h   2007-04-11 17:29:14 UTC 
(rev 125984)
@@ -90,8 +90,8 @@
 void changeLLVMValue(Value *Old, Value *New);
 void readLLVMTypesStringTable();
 void writeLLVMTypesStringTable();
-void readLLVMValuesStringTable();
-void writeLLVMValuesStringTable();
+void readLLVMValues();
+void writeLLVMValues();
 void clearTargetBuiltinCache();
 
 struct StructTypeConversionInfo;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125985] cosmetic.

2007-04-11 Thread dpatel
Revision: 125985
Author:   dpatel
Date: 2007-04-11 10:41:38 -0700 (Wed, 11 Apr 2007)

Log Message:
---
cosmetic.
s/LLVMValuesNameTable/LLVMValuesTable/g

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 17:29:14 UTC 
(rev 125984)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-11 17:41:38 UTC 
(rev 125985)
@@ -207,12 +207,12 @@
   }
 
   // Create string table.
-  Constant *LLVMValuesNameTable = ConstantStruct::get(ValuesForPCH, false);
+  Constant *LLVMValuesTable = ConstantStruct::get(ValuesForPCH, false);
 
   // Create variable to hold this string table.
-  new GlobalVariable(LLVMValuesNameTable->getType(), true,
+  new GlobalVariable(LLVMValuesTable->getType(), true,
  GlobalValue::ExternalLinkage, 
- LLVMValuesNameTable,
+ LLVMValuesTable,
  "llvm.pch.values", TheModule);
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [125991] Fix num of bits required calculation for bitfields that

2007-04-11 Thread dpatel
Revision: 125991
Author:   dpatel
Date: 2007-04-11 17:33:44 -0700 (Wed, 11 Apr 2007)

Log Message:
---
Fix num of bits required calculation for bitfields that 
do not start at byte boundary.

Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047340.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-11 23:44:56 UTC 
(rev 125990)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-12 00:33:44 UTC 
(rev 125991)
@@ -1287,11 +1287,11 @@
 
   if (StartOffsetInBits < FirstUnallocatedByte*8) {
 
+unsigned AvailableBits = FirstUnallocatedByte * 8 - StartOffsetInBits;
 // This field's starting point is already allocated.
 if (StartOffsetFromByteBoundry == 0) {
   // This field starts at byte boundry. Need to allocate space
   // for additional bytes not yet allocated.
-  unsigned AvailableBits = FirstUnallocatedByte * 8 - StartOffsetInBits;
   unsigned NumBitsToAdd = FieldSizeInBits - AvailableBits;
   Info.addNewBitField(NumBitsToAdd, FirstUnallocatedByte);
   return;
@@ -1300,15 +1300,15 @@
 // Otherwise, this field's starting point is inside previously used byte. 
 // This happens with Packed bit fields. In this case one LLVM Field is
 // used to access previous field and current field.
-
 unsigned prevFieldTypeSizeInBits = 
-  Info.Elements.back()->getPrimitiveSizeInBits();
-unsigned NumBitsRequired = FieldSizeInBits + 
-  (prevFieldTypeSizeInBits/8 - 1)*8 + StartOffsetFromByteBoundry;
+  Info.ElementSizeInBytes[Info.Elements.size() - 1] * 8;
 
+unsigned NumBitsRequired = prevFieldTypeSizeInBits 
+  + (FieldSizeInBits - AvailableBits);
+
 if (NumBitsRequired > 64) {
   // Use bits from previous field.
-  NumBitsRequired = NumBitsRequired - FirstUnallocatedByte*8;
+  NumBitsRequired = FieldSizeInBits - AvailableBits;
 } else {
   // If type used to access previous field is not large enough then
   // remove previous field and insert new field that is large enough to


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126202] Fix assertion that was off by one.

2007-04-16 Thread dpatel
Revision: 126202
Author:   dpatel
Date: 2007-04-16 11:11:23 -0700 (Mon, 16 Apr 2007)

Log Message:
---
Fix assertion that was off by one. Update comments.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-16 18:10:57 UTC 
(rev 126201)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-16 18:11:23 UTC 
(rev 126202)
@@ -1256,14 +1256,12 @@
   unsigned StartOffsetInBits = getFieldOffsetInBits(Field);
   unsigned EndBitOffset= FieldSizeInBits+StartOffsetInBits;
   
-  // If  the last inserted LLVM field completely contains this bitfield, just
+  // If the last inserted LLVM field completely contains this bitfield, just
   // ignore this field.
   if (!Info.Elements.empty()) {
-// If the last field does not completely contain *this* bitfield, extend
-// it.
 unsigned LastFieldBitOffset = Info.ElementOffsetInBytes.back()*8;
 unsigned LastFieldBitSize   = Info.ElementSizeInBytes.back()*8;
-assert(LastFieldBitOffset < StartOffsetInBits &&
+assert(LastFieldBitOffset <= StartOffsetInBits &&
"This bitfield isn't part of the last field!");
 if (EndBitOffset <= LastFieldBitOffset+LastFieldBitSize &&
 LastFieldBitOffset+LastFieldBitSize >= StartOffsetInBits) {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126204] Do not emit debug info for fields at variable offset, for now.

2007-04-16 Thread dpatel
Revision: 126204
Author:   dpatel
Date: 2007-04-16 11:13:49 -0700 (Mon, 16 Apr 2007)

Log Message:
---
Do not emit debug info for fields at variable offset, for now.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-debug.cpp

Modified: apple-local/branches/llvm/gcc/llvm-debug.cpp
===
--- apple-local/branches/llvm/gcc/llvm-debug.cpp2007-04-16 18:12:08 UTC 
(rev 126203)
+++ apple-local/branches/llvm/gcc/llvm-debug.cpp2007-04-16 18:13:49 UTC 
(rev 126204)
@@ -676,6 +676,10 @@
NULL;
 
 if (TREE_CODE(Member) == FIELD_DECL) {
+  if (TREE_CODE(DECL_FIELD_OFFSET(Member)) != INTEGER_CST)
+// FIXME: field with variable position, skip it for now.
+continue;
+
   DerivedTypeDesc *MemberDesc = new DerivedTypeDesc(DW_TAG_member);
   // Field type is the declared type of the field.
   tree FieldNodeType = FieldType(Member);


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126210] Fix handling of arrays with var-sized elements

2007-04-16 Thread dpatel
Revision: 126210
Author:   dpatel
Date: 2007-04-16 13:01:41 -0700 (Mon, 16 Apr 2007)

Log Message:
---
Fix handling of arrays with var-sized elements
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-abi.h
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-debug.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-abi.h
===
--- apple-local/branches/llvm/gcc/llvm-abi.h2007-04-16 18:55:33 UTC (rev 
126209)
+++ apple-local/branches/llvm/gcc/llvm-abi.h2007-04-16 20:01:41 UTC (rev 
126210)
@@ -110,7 +110,7 @@
   }
 return FoundField ? isSingleElementStructOrArray(FoundField) : 0;
   case ARRAY_TYPE:
-if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
+if (!isArrayCompatible(type))
   return 0;
 tree length = arrayLength(type);
 if (!length || !integer_onep(length))

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-16 18:55:33 UTC 
(rev 126209)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-16 20:01:41 UTC 
(rev 126210)
@@ -253,6 +253,35 @@
   }
 }
 
+/// isInt64 - Return true if t is an INTEGER_CST that fits in a 64 bit integer.
+/// If Unsigned is false, returns whether it fits in a int64_t.  If Unsigned is
+/// true, returns whether the value is non-negative and fits in a uint64_t.
+/// Always returns false for overflowed constants.
+bool isInt64(tree_node *t, bool Unsigned) {
+  if (HOST_BITS_PER_WIDE_INT == 64)
+return host_integerp(t, Unsigned);
+  else {
+assert(HOST_BITS_PER_WIDE_INT == 32 &&
+   "Only 32- and 64-bit hosts supported!");
+return
+  (TREE_CODE (t) == INTEGER_CST && !TREE_OVERFLOW (t))
+  && ((TYPE_UNSIGNED(TREE_TYPE(t)) == Unsigned) ||
+  // If the constant is signed and we want an unsigned result, check
+  // that the value is non-negative.  If the constant is unsigned and
+  // we want a signed result, check it fits in 63 bits.
+  (HOST_WIDE_INT)TREE_INT_CST_HIGH(t) >= 0);
+  }
+}
+
+/// getInt64 - Extract the value of an INTEGER_CST as a 64 bit integer.  If
+/// Unsigned is false, the value must fit in a int64_t.  If Unsigned is true,
+/// the value must be non-negative and fit in a uint64_t.  Must not be used on
+/// overflowed constants.  These conditions can be checked by calling isInt64.
+uint64_t getInt64(tree_node *t, bool Unsigned) {
+  assert(isInt64(t, Unsigned) && "invalid constant!");
+  return getINTEGER_CSTVal(t);
+}
+
 
//===--===//
 // ... High-Level Methods ...
 
//===--===//
@@ -1374,16 +1403,18 @@
 tree length;
 
 // Dynamic-size object: must push space on the stack.
-if (TREE_CODE(type) == ARRAY_TYPE && (length = arrayLength(type))) {
+if (TREE_CODE(type) == ARRAY_TYPE &&
+isSequentialCompatible(type) &&
+(length = arrayLength(type))) {
   Ty = ConvertType(TREE_TYPE(type));  // Get array element type.
   // Compute the number of elements in the array.
   Size = Emit(length, 0);
-  Size = CastToUIntType(Size, Size->getType());
 } else {
   // Compute the variable's size in bytes.
-  Size = CastToUIntType(Emit(DECL_SIZE_UNIT(decl), 0), Type::Int32Ty);
+  Size = Emit(DECL_SIZE_UNIT(decl), 0);
   Ty = Type::Int8Ty;
 }
+Size = CastToUIntType(Size, Type::Int32Ty);
   }
   
   const char *Name;  // Name of variable
@@ -4645,94 +4676,71 @@
 }
 
 LValue TreeToLLVM::EmitLV_ARRAY_REF(tree exp) {
+  // The result type is an ElementTy* in the case of an ARRAY_REF, an array
+  // of ElementTy in the case of ARRAY_RANGE_REF.
+
   tree Array = TREE_OPERAND(exp, 0);
+  tree ArrayType = TREE_TYPE(Array);
   tree Index = TREE_OPERAND(exp, 1);
-  assert((TREE_CODE (TREE_TYPE(Array)) == ARRAY_TYPE ||
-  TREE_CODE (TREE_TYPE(Array)) == POINTER_TYPE ||
-  TREE_CODE (TREE_TYPE(Array)) == REFERENCE_TYPE) &&
+  tree IndexType = TREE_TYPE(Index);
+  tree ElementType = TREE_TYPE(ArrayType);
+
+  assert((TREE_CODE (ArrayType) == ARRAY_TYPE ||
+  TREE_CODE (ArrayType) == POINTER_TYPE ||
+  TREE_CODE (ArrayType) == REFERENCE_TYPE) &&
  "Unknown ARRAY_REF!");
-  
+
   // As an LLVM extension, we allow ARRAY_REF with a pointer as the first
   // operand.  This construct maps directly to a getelementptr instruction.
   Value *ArrayAddr;
-  
-  if (TREE_CODE(TREE_TYPE(Array)) == ARRAY_TYPE) {
+
+  if (TREE_CODE(ArrayType

[llvm-commits] [126245] Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/ Week-of-Mon-20070416/047943.html

2007-04-17 Thread dpatel
Revision: 126245
Author:   dpatel
Date: 2007-04-17 13:29:12 -0700 (Tue, 17 Apr 2007)

Log Message:
---
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070416/047943.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-17 16:28:45 UTC 
(rev 126244)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-17 20:29:12 UTC 
(rev 126245)
@@ -1382,8 +1382,10 @@
   Pad = ArrayType::get(Pad, PadBytes);
 Info.addElement(Pad, FirstUnallocatedByte, PadBytes);
 FirstUnallocatedByte = StartOffsetInBits/8;
-// This field will use some of the bits from this PadBytes.
-FieldSizeInBits = FieldSizeInBits - (PadBytes*8 - PadBits);
+// This field will use some of the bits from this PadBytes, if
+// starting offset is not at byte boundry.
+if (StartOffsetFromByteBoundry != 0)
+  FieldSizeInBits = FieldSizeInBits - (8 - PadBits);
   }
 
   // Now, Field starts at FirstUnallocatedByte and everything is aligned.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126246] If all struct bitfields are packed then struct is packed.

2007-04-17 Thread dpatel
Revision: 126246
Author:   dpatel
Date: 2007-04-17 14:59:37 -0700 (Tue, 17 Apr 2007)

Log Message:
---
If all struct bitfields are packed then struct is packed.
This fixes recent SingleSource 2003-05-21-BitFieldHandling.c regression.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-17 20:29:12 UTC 
(rev 126245)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-17 21:59:37 UTC 
(rev 126246)
@@ -945,7 +945,7 @@
   /// getLLVMType - Return the LLVM type for the specified object.
   ///
   const Type *getLLVMType() const {
-return StructType::get(Elements, Packed);
+return StructType::get(Elements, Packed || AllBitFields);
   }
   
   /// getSizeAsLLVMStruct - Return the size of this struct if it were converted


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126319] Enable loop rotation.

2007-04-19 Thread dpatel
Revision: 126319
Author:   dpatel
Date: 2007-04-19 15:05:17 -0700 (Thu, 19 Apr 2007)

Log Message:
---
Enable loop rotation.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-linker-hack.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-04-19 21:20:06 UTC 
(rev 126318)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-04-19 22:05:17 UTC 
(rev 126319)
@@ -315,6 +315,7 @@
 PM->add(createTailCallEliminationPass());   // Eliminate tail calls
 PM->add(createCFGSimplificationPass()); // Merge & remove BBs
 PM->add(createReassociatePass());   // Reassociate expressions
+PM->add(createLoopRotatePass());// Rotate Loop
 PM->add(createLICMPass());  // Hoist loop invariants
 PM->add(createLoopUnswitchPass());  // Unswitch loops.
 PM->add(createInstructionCombiningPass());  // Clean up after LICM/reassoc

Modified: apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
===
--- apple-local/branches/llvm/gcc/llvm-linker-hack.cpp  2007-04-19 21:20:06 UTC 
(rev 126318)
+++ apple-local/branches/llvm/gcc/llvm-linker-hack.cpp  2007-04-19 22:05:17 UTC 
(rev 126319)
@@ -53,6 +53,7 @@
   llvm::createLinearScanRegisterAllocator();
 
   llvm::createGCSEPass();
+  llvm::createLoopRotatePass();
   llvm::createLICMPass();
   llvm::createSCCPPass();
   llvm::createPruneEHPass();


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126435] Fix PR 1344

2007-04-23 Thread dpatel
Revision: 126435
Author:   dpatel
Date: 2007-04-23 15:07:27 -0700 (Mon, 23 Apr 2007)

Log Message:
---
Fix PR 1344

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-23 22:06:28 UTC 
(rev 126434)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-04-23 22:07:27 UTC 
(rev 126435)
@@ -1560,8 +1560,10 @@
   bool OldConvertingStruct = ConvertingStruct;
   ConvertingStruct = true;
   
-  // Find the type with the largest size, and if we have multiple things with
-  // the same size, the thing with the largest alignment.
+  // Find the type with the largest aligment, and if we have multiple types 
with
+  // the same alignment, select one with largest size. If type with max. align
+  // is smaller then other types then we will add padding later on anyway to 
+  // match union size.
   const TargetData &TD = getTargetData();
   const Type *UnionTy = 0;
   unsigned MaxSize = 0, MaxAlign = 0;
@@ -1576,9 +1578,10 @@
 const Type *TheTy = ConvertType(TREE_TYPE(Field));
 unsigned Size = TD.getTypeSize(TheTy);
 unsigned Align = TD.getABITypeAlignment(TheTy);
-if (UnionTy == 0 || Size>MaxSize || (Size == MaxSize && Align > MaxAlign)) 
{
+if (UnionTy == 0 || Align > MaxAlign 
+|| (MaxAlign == Align && Size > MaxSize)) {
   UnionTy = TheTy;
-  MaxSize = Size;
+  MaxSize = MAX(MaxSize, Size);
   MaxAlign = Align;
 }
   }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126481] Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/ Week-of-Mon-20070423/048355.html

2007-04-24 Thread dpatel
Revision: 126481
Author:   dpatel
Date: 2007-04-24 12:27:29 -0700 (Tue, 24 Apr 2007)

Log Message:
---
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048355.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-24 16:16:23 UTC 
(rev 126480)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-24 19:27:29 UTC 
(rev 126481)
@@ -2973,6 +2973,11 @@
 
 Value *TreeToLLVM::EmitBIT_NOT_EXPR(tree exp) {
   Value *Op = Emit(TREE_OPERAND(exp, 0), 0);
+  if (isa(Op->getType())) {
+assert (TREE_CODE(TREE_TYPE(exp)) == INTEGER_TYPE &&
+"Expected integer type here");
+Op = CastToType(Instruction::PtrToInt, Op, TREE_TYPE(exp));
+  }
   return BinaryOperator::createNot(Op, Op->getName()+"not", CurBB);
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126482] Magic!

2007-04-24 Thread dpatel
Revision: 126482
Author:   dpatel
Date: 2007-04-24 14:07:03 -0700 (Tue, 24 Apr 2007)

Log Message:
---
Magic!
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048357.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-24 19:27:29 UTC 
(rev 126481)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-04-24 21:07:03 UTC 
(rev 126482)
@@ -5796,7 +5796,7 @@
   // Create a new string global.
   GlobalVariable *GV = new GlobalVariable(Init->getType(), StringIsConstant,
   GlobalVariable::InternalLinkage,
-  Init, "str", TheModule);
+  Init, ".str", TheModule);
   if (SlotP) *SlotP = GV;
   return GV;
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126812] Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/ Week-of-Mon-20070430/048922.html

2007-05-02 Thread dpatel
Revision: 126812
Author:   dpatel
Date: 2007-05-02 18:11:09 -0700 (Wed, 02 May 2007)

Log Message:
---
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070430/048922.html

Modified Paths:
--
apple-local/branches/llvm/gcc/c-typeck.c

Modified: apple-local/branches/llvm/gcc/c-typeck.c
===
--- apple-local/branches/llvm/gcc/c-typeck.c2007-05-02 23:33:36 UTC (rev 
126811)
+++ apple-local/branches/llvm/gcc/c-typeck.c2007-05-03 01:11:09 UTC (rev 
126812)
@@ -1896,8 +1896,12 @@
* pointer, not an array.  The LLVM backend supports this use of 
ARRAY_REF
* and it provides it with more information for optimization.
*/
-  return build4 (ARRAY_REF, TREE_TYPE(TREE_TYPE(ar)), ar, index,
- NULL_TREE, NULL_TREE);
+  {
+tree ty = TREE_TYPE(TREE_TYPE(ar));
+if (TREE_CODE(ty) != ARRAY_TYPE)
+  ty = TYPE_MAIN_VARIANT (ty);
+return build4 (ARRAY_REF, ty, ar, index, NULL_TREE, NULL_TREE);
+  }
 #endif
   /* APPLE LOCAL end LLVM */
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126856] Handle edge case, when starting offset for bit field

2007-05-03 Thread dpatel
Revision: 126856
Author:   dpatel
Date: 2007-05-03 17:31:00 -0700 (Thu, 03 May 2007)

Log Message:
---
Handle edge case, when starting offset for bit field
is outside allocated bytes and starting offset is not
at byte boundry.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 00:26:47 UTC 
(rev 126855)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 00:31:00 UTC 
(rev 126856)
@@ -1384,10 +1384,11 @@
 if (StartOffsetFromByteBoundry != 0) {
   // New field does not start at byte boundry. 
   PadBits = StartOffsetInBits - (FirstUnallocatedByte*8);
-  PadBytes = PadBits/8 + 1;
-}
+  PadBytes = PadBits/8;
+  PadBits = PadBits - PadBytes*8;
+} else
+  PadBytes = StartOffsetInBits/8-FirstUnallocatedByte;
 
-PadBytes += StartOffsetInBits/8-FirstUnallocatedByte;
 const Type *Pad = Type::Int8Ty;
 if (PadBytes != 1)
   Pad = ArrayType::get(Pad, PadBytes);
@@ -1396,7 +1397,7 @@
 // This field will use some of the bits from this PadBytes, if
 // starting offset is not at byte boundry.
 if (StartOffsetFromByteBoundry != 0)
-  FieldSizeInBits = FieldSizeInBits - (8 - PadBits);
+  FieldSizeInBits = PadBits;
   }
 
   // Now, Field starts at FirstUnallocatedByte and everything is aligned.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126896] Fix PR 1250.

2007-05-04 Thread dpatel
Revision: 126896
Author:   dpatel
Date: 2007-05-04 11:42:00 -0700 (Fri, 04 May 2007)

Log Message:
---
Fix PR 1250.
Apply Duncan's patch.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 16:16:23 UTC 
(rev 126895)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 18:42:00 UTC 
(rev 126896)
@@ -473,16 +473,17 @@
   }
   case ENUMERAL_TYPE:
 // Use of an enum that is implicitly declared?
-if (TYPE_SIZE(type) == 0) {
+if (TYPE_SIZE(orig_type) == 0) {
   // If we already compiled this type, use the old type.
-  if (const Type *Ty = GET_TYPE_LLVM(type))
+  if (const Type *Ty = GET_TYPE_LLVM(orig_type))
 return Ty;
 
   const Type *Ty = OpaqueType::get();
   TheModule->addTypeName(GetTypeName("enum.", orig_type), Ty);
-  return TypeDB.setType(type, Ty);
+  return TypeDB.setType(orig_type, Ty);
 }
 // FALL THROUGH.
+type = orig_type;
   case INTEGER_TYPE:
 if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty;
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126898] Use one i32 instead of four i8 while emitting

2007-05-04 Thread dpatel
Revision: 126898
Author:   dpatel
Date: 2007-05-04 14:44:39 -0700 (Fri, 04 May 2007)

Log Message:
---
Use one i32 instead of four i8 while emitting
tail padding.

This addresses first part of PR1278.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 21:04:24 UTC 
(rev 126897)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 21:44:39 UTC 
(rev 126898)
@@ -1452,10 +1452,22 @@
  "LLVM type size doesn't match GCC type size!");
   uint64_t LLVMLastElementEnd = Info.getNewElementByteOffset(1);
   const Type *PadTy = Type::Int8Ty;
-  if (GCCTypeSize-LLVMLastElementEnd != 1)
-PadTy = ArrayType::get(PadTy, GCCTypeSize-LLVMStructSize);
-  Info.addElement(PadTy, GCCTypeSize-LLVMLastElementEnd, 
-  GCCTypeSize-LLVMLastElementEnd);
+  if (GCCTypeSize-LLVMLastElementEnd != 1) {
+unsigned Int32ArraySize = (GCCTypeSize-LLVMStructSize)/4;
+unsigned Int8ArraySize = (GCCTypeSize-LLVMStructSize) % 4;
+if (Int32ArraySize != 0) {
+  PadTy = ArrayType::get(Type::Int32Ty, Int32ArraySize);
+  Info.addElement(PadTy, GCCTypeSize - LLVMLastElementEnd,
+  Int32ArraySize);
+}
+if (Int8ArraySize != 0) {
+  PadTy = ArrayType::get(Type::Int8Ty, Int8ArraySize);
+  Info.addElement(PadTy, GCCTypeSize - Info.getNewElementByteOffset(1),
+  Int8ArraySize);
+}
+  } else
+Info.addElement(PadTy, GCCTypeSize - LLVMLastElementEnd, 
+GCCTypeSize - LLVMLastElementEnd);
 }
   }
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126899] Revert previous patch.

2007-05-04 Thread dpatel
Revision: 126899
Author:   dpatel
Date: 2007-05-04 16:10:12 -0700 (Fri, 04 May 2007)

Log Message:
---
Revert  previous patch. It does not 
handle all cases properly.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 21:44:39 UTC 
(rev 126898)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-04 23:10:12 UTC 
(rev 126899)
@@ -1452,22 +1452,10 @@
  "LLVM type size doesn't match GCC type size!");
   uint64_t LLVMLastElementEnd = Info.getNewElementByteOffset(1);
   const Type *PadTy = Type::Int8Ty;
-  if (GCCTypeSize-LLVMLastElementEnd != 1) {
-unsigned Int32ArraySize = (GCCTypeSize-LLVMStructSize)/4;
-unsigned Int8ArraySize = (GCCTypeSize-LLVMStructSize) % 4;
-if (Int32ArraySize != 0) {
-  PadTy = ArrayType::get(Type::Int32Ty, Int32ArraySize);
-  Info.addElement(PadTy, GCCTypeSize - LLVMLastElementEnd,
-  Int32ArraySize);
-}
-if (Int8ArraySize != 0) {
-  PadTy = ArrayType::get(Type::Int8Ty, Int8ArraySize);
-  Info.addElement(PadTy, GCCTypeSize - Info.getNewElementByteOffset(1),
-  Int8ArraySize);
-}
-  } else
-Info.addElement(PadTy, GCCTypeSize - LLVMLastElementEnd, 
-GCCTypeSize - LLVMLastElementEnd);
+  if (GCCTypeSize-LLVMLastElementEnd != 1)
+PadTy = ArrayType::get(PadTy, GCCTypeSize-LLVMStructSize);
+  Info.addElement(PadTy, GCCTypeSize-LLVMLastElementEnd, 
+  GCCTypeSize-LLVMLastElementEnd);
 }
   }
   


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126994] Do not apply inreg attribute to static chain.

2007-05-07 Thread dpatel
Revision: 126994
Author:   dpatel
Date: 2007-05-07 15:27:34 -0700 (Mon, 07 May 2007)

Log Message:
---
Do not apply inreg attribute to static chain.
Patch by Duncan Sands.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-07 22:23:43 UTC 
(rev 126993)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-07 22:27:34 UTC 
(rev 126994)
@@ -752,17 +752,7 @@
   for (; Args && TREE_TYPE(Args) != void_type_node; Args = TREE_CHAIN(Args))
 ABIConverter.HandleArgument(TREE_TYPE(Args));
 
-  ParamAttrsList *PAL = 0;
-
-  if (static_chain) {
-// Pass the static chain in a register.
-ParamAttrsVector Attrs;
-ParamAttrsWithIndex PAWI; PAWI.index = 1; PAWI.attrs = ParamAttr::InReg;
-Attrs.push_back(PAWI);
-PAL = ParamAttrsList::get(Attrs);
-  }
-
-  return FunctionType::get(RetTy, ArgTys, false, PAL);
+  return FunctionType::get(RetTy, ArgTys, false, 0);
 }
 
 const FunctionType *TypeConverter::ConvertFunctionType(tree type,
@@ -843,12 +833,6 @@
   LLVM_TARGET_INIT_REGPARM(lparam, type);
 #endif // LLVM_TARGET_ENABLE_REGPARM
 
-  if (static_chain) {
-// Pass the static chain in a register.
-ParamAttrsWithIndex PAWI; PAWI.index = Idx++; PAWI.attrs = 
ParamAttr::InReg;
-Attrs.push_back(PAWI);
-  }
-  
   // The struct return attribute must be associated with the first
   // parameter but that parameter may have other attributes too so we set up
   // the first Attributes value here based on struct return. This only works


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [126997] Fix PR1278.

2007-05-07 Thread dpatel
Revision: 126997
Author:   dpatel
Date: 2007-05-07 23:15:09 -0700 (Mon, 07 May 2007)

Log Message:
---
Fix PR1278.

- While adding padding elements at the end of LLVM struct use
  an array of i32 (instead of an array of i8) if possible.

- Keep track of padding elements at the end of LLVM struct.
  Do not copy them while copying aggregates.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-05-08 05:09:41 UTC 
(rev 126996)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-05-08 06:15:09 UTC 
(rev 126997)
@@ -1085,6 +1085,8 @@
   } else if (const StructType *STy = dyn_cast(ElTy)) {
 Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
 for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+  if (isPaddingElement(STy, i))
+continue;
   Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
   Value *DElPtr = new GetElementPtrInst(DestPtr, Zero, Idx, "tmp", CurBB);
   Value *SElPtr = new GetElementPtrInst(SrcPtr, Zero, Idx, "tmp", CurBB);

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===
--- apple-local/branches/llvm/gcc/llvm-internal.h   2007-05-08 05:09:41 UTC 
(rev 126996)
+++ apple-local/branches/llvm/gcc/llvm-internal.h   2007-05-08 06:15:09 UTC 
(rev 126997)
@@ -96,6 +96,10 @@
 
 struct StructTypeConversionInfo;
 
+/// Return true if and only if field no. N from struct type T is a padding
+/// element added to match llvm struct type size and gcc struct type size.
+bool isPaddingElement(const Type *T, unsigned N);
+
 /// TypeConverter - Implement the converter from GCC types to LLVM types.
 ///
 class TypeConverter {

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-08 05:09:41 UTC 
(rev 126996)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-08 06:15:09 UTC 
(rev 126997)
@@ -893,6 +893,7 @@
   std::vector Elements;
   std::vector ElementOffsetInBytes;
   std::vector ElementSizeInBytes;
+  std::vector PaddingElement; // True if field is used for padding
   const TargetData &TD;
   unsigned GCCStructAlignmentInBytes;
   bool Packed; // True if struct is packed
@@ -1071,10 +1072,12 @@
   
   /// addElement - Add an element to the structure with the specified type,
   /// offset and size.
-  void addElement(const Type *Ty, uint64_t Offset, uint64_t Size) {
+  void addElement(const Type *Ty, uint64_t Offset, uint64_t Size,
+  bool ExtraPadding = false) {
 Elements.push_back(Ty);
 ElementOffsetInBytes.push_back(Offset);
 ElementSizeInBytes.push_back(Size);
+PaddingElement.push_back(ExtraPadding);
 lastFieldStartsAtNonByteBoundry(false);
 ExtraBitsAvailable = 0;
   }
@@ -1223,7 +1226,25 @@
   }
 }
 
+std::map StructTypeInfoMap;
 
+/// Return true if and only if field no. N from struct type T is a padding
+/// element added to match llvm struct type size and gcc struct type size.
+bool isPaddingElement(const Type *Ty, unsigned index) {
+  
+  StructTypeConversionInfo *Info = StructTypeInfoMap[Ty];
+
+  // If info is not available then be conservative and return false.
+  if (!Info)
+return false;
+
+  assert ( Info->Elements.size() == Info->PaddingElement.size()
+   && "Invalid StructTypeConversionInfo");
+  assert ( index < Info->PaddingElement.size()  
+   && "Invalid PaddingElement index");
+  return Info->PaddingElement[index];
+}
+
 /// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a
 /// structure.
 static unsigned getFieldOffsetInBits(tree Field) {
@@ -1417,29 +1438,46 @@
   ConvertType(BINFO_TYPE(BINFO_BASE_BINFO(binfo, i)));
   }
   
-  StructTypeConversionInfo Info(*TheTarget, TYPE_ALIGN_UNIT(type), 
-TYPE_PACKED(type));
+  StructTypeConversionInfo *Info = 
+new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN_UNIT(type), 
+ TYPE_PACKED(type));
+
   
   // Convert over all of the elements of the struct.
   for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
-DecodeStructFields(Field, Info);
+DecodeStructFields(Field, *Info);
 
-  Info.RemoveExtraBytes();
+  Info->RemoveExtraBytes();
   // If the LLVM struct requires explicit tail padding to be the same size as
   // the GCC struct, insert tail padding now.  This handles, e.g., "{}" in C++.
   if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZ

[llvm-commits] [127041] Fix PR1400

2007-05-08 Thread dpatel
Revision: 127041
Author:   dpatel
Date: 2007-05-08 11:09:27 -0700 (Tue, 08 May 2007)

Log Message:
---
Fix PR1400
Test case
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070507/049420.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-05-08 10:44:37 UTC 
(rev 127040)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-05-08 18:09:27 UTC 
(rev 127041)
@@ -203,7 +203,7 @@
 else
   // Non constant values, e.g. arguments, are not at global scope.
   // When PCH is read, only global scope values are used.
-  ValuesForPCH.push_back(NULL);
+  ValuesForPCH.push_back(Constant::getNullValue(Type::Int32Ty));
   }
 
   // Create string table.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127042] If new bit field's starting offset is not at byte boundary

2007-05-08 Thread dpatel
Revision: 127042
Author:   dpatel
Date: 2007-05-08 11:24:04 -0700 (Tue, 08 May 2007)

Log Message:
---
If new bit field's starting offset is not at byte boundary
_AND_ the field's starting offset is outside already allocated
bytes for enclosing structure then

- Do not insert PadBytes array if PadBytes are zero.
- Update Field size to count  PadBits.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-08 18:09:27 UTC 
(rev 127041)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-08 18:24:04 UTC 
(rev 127042)
@@ -1395,15 +1395,18 @@
 } else
   PadBytes = StartOffsetInBits/8-FirstUnallocatedByte;
 
-const Type *Pad = Type::Int8Ty;
-if (PadBytes != 1)
-  Pad = ArrayType::get(Pad, PadBytes);
-Info.addElement(Pad, FirstUnallocatedByte, PadBytes);
+if (PadBytes) {
+  const Type *Pad = Type::Int8Ty;
+  if (PadBytes != 1)
+Pad = ArrayType::get(Pad, PadBytes);
+  Info.addElement(Pad, FirstUnallocatedByte, PadBytes);
+}
+
 FirstUnallocatedByte = StartOffsetInBits/8;
 // This field will use some of the bits from this PadBytes, if
 // starting offset is not at byte boundry.
 if (StartOffsetFromByteBoundry != 0)
-  FieldSizeInBits = PadBits;
+  FieldSizeInBits += PadBits;
   }
 
   // Now, Field starts at FirstUnallocatedByte and everything is aligned.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127060] Add missing undefs.

2007-05-08 Thread dpatel
Revision: 127060
Author:   dpatel
Date: 2007-05-08 16:23:00 -0700 (Tue, 08 May 2007)

Log Message:
---
Add missing undefs. Patch by Reid.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-common.c

Modified: apple-local/branches/llvm/gcc/c-common.c
===
--- apple-local/branches/llvm/gcc/c-common.c2007-05-08 21:48:47 UTC (rev 
127059)
+++ apple-local/branches/llvm/gcc/c-common.c2007-05-08 23:23:00 UTC (rev 
127060)
@@ -3545,6 +3545,8 @@
 #undef DEF_FUNCTION_TYPE_2
 #undef DEF_FUNCTION_TYPE_3
 #undef DEF_FUNCTION_TYPE_4
+#undef DEF_FUNCTION_TYPE_5
+#undef DEF_FUNCTION_TYPE_6
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
 #undef DEF_FUNCTION_TYPE_VAR_2


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127082] Map -dA to -asm-verbose.

2007-05-09 Thread dpatel
Revision: 127082
Author:   dpatel
Date: 2007-05-09 09:58:33 -0700 (Wed, 09 May 2007)

Log Message:
---
Map -dA to -asm-verbose.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-09 11:00:59 UTC 
(rev 127081)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-09 16:58:33 UTC 
(rev 127082)
@@ -107,6 +107,9 @@
 Args.push_back("--disable-fp-elim");
   if (!flag_zero_initialized_in_bss)
 Args.push_back("--nozero-initialized-in-bss");
+  if (flag_debug_asm)
+Args.push_back("--asm-verbose");
+
 // Disabled until PR1224 is resolved.
   //if (flag_exceptions)
   //  Args.push_back("--enable-eh");


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127089] Anton Korobeynikov's fixincludes patch for mingw32

2007-05-09 Thread dpatel
Revision: 127089
Author:   dpatel
Date: 2007-05-09 23:21:25 -0700 (Wed, 09 May 2007)

Log Message:
---
Anton Korobeynikov's fixincludes patch for mingw32

Modified Paths:
--
apple-local/branches/llvm/fixincludes/fixincl.x
apple-local/branches/llvm/fixincludes/inclhack.def
apple-local/branches/llvm/fixincludes/mkfixinc.sh

Modified: apple-local/branches/llvm/fixincludes/fixincl.x
===
--- apple-local/branches/llvm/fixincludes/fixincl.x 2007-05-10 04:40:54 UTC 
(rev 127088)
+++ apple-local/branches/llvm/fixincludes/fixincl.x 2007-05-10 06:21:25 UTC 
(rev 127089)
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  Friday July  8, 2005 at 03:33:04 PM PDT
+ * It has been AutoGen-ed  Thursday May 10, 2007 at 03:18:13 AM MSD
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT CVS-MERGE THIS FILE, EITHER Fri Jul  8 15:33:04 PDT 2005
+/* DO NOT CVS-MERGE THIS FILE, EITHER Thu May 10 03:18:13 MSD 2007
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 195 fixup descriptions.
+ * This file contains 196 fixup descriptions.
  *
  * See README for more information.
  *
@@ -26,7 +26,8 @@
  *  
  *  You may redistribute it and/or modify it under the terms of the
  *  GNU General Public License, as published by the Free Software
- *  Foundation; either version 2, or (at your option) any later version.
+ *  Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
  *  
  *  inclhack is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,10 +35,10 @@
  *  See the GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with inclhack.  See the file "COPYING".  If not,
- *  write to:  The Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330,
- * Boston,  MA  02111-1307, USA.
+ *  along with inclhack.  If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301, USA.
  */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -4050,6 +4051,43 @@
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
+ *  Description of Mingw_Inline_Fp_Math fix
+ */
+tSCC zMingw_Inline_Fp_MathName[] =
+ "mingw_inline_fp_math";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zMingw_Inline_Fp_MathList[] =
+  "|complex.h|";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzMingw_Inline_Fp_MathMachs[] = {
+"i[34567]86-*-mingw*",
+(const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zMingw_Inline_Fp_MathSelect0[] =
+   "[ \\t]*__asm__[ \\t]*\\(\\\"fpatan";
+
+#defineMINGW_INLINE_FP_MATH_TEST_CT  1
+static tTestDesc aMingw_Inline_Fp_MathTests[] = {
+  { TT_EGREP,zMingw_Inline_Fp_MathSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Mingw_Inline_Fp_Math
+ */
+static const char* apzMingw_Inline_Fp_MathPatch[] = { "sed",
+"-e", "/^\\#ifdef[ \\t]*__GNUC__$/,/^\\#endif[ \\t]*\\/*[ \\t]*__GNUC__[ 
\\t]*$/ { :ack N; /\\n[ \\t]*:/! b ack; s/\\(\\n[ \\t]*double[ 
\\t]*res;\\)\\n/\\1\\n#ifdef __NO_MATH_INLINES\\nres = atan((__imag__ _Z) 
\\/ (__real__ _Z));\\n#else\\n/; s/\\(\\n[ \\t]*float[ 
\\t]*res;\\)\\n/\\1\\n#ifdef __NO_MATH_INLINES\\nres = atanf((__imag__ _Z) 
\\/ (__real__ _Z));\\n#else\\n/; s/\\(\\n[ \\t]*long[ \\t]*double[ 
\\t]*res;\\)\\n/\\1\\n#ifdef __NO_MATH_INLINES\\nres = atanl((__imag__ _Z) 
\\/ (__real__ _Z));\\n#else\\n/; s/\\(\\\"st[(]1[)]\\\"[)];[ 
\\t]*\\)$/\\1\\n#endif/g }",
+"-e", "s/\\(\\#include[ \\t]*<_mingw.h>\\)/\\1\\n\\#include /",
+(char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
  *  Description of Nested_Auth_Des fix
  */
 tSCC zNested_Auth_DesName[] =
@@ -7932,9 +7970,9 @@
  *
  *  List of all fixes
  */
-#define REGEX_COUNT  234
+#define REGEX_COUNT  235
 #define MACH_LIST_SIZE_LIMIT 261
-#define FIX_COUNT195
+#define FIX_COUNT196
 
 /*
  *  Enumerate the fixes
@@ -8037,6 +8075,7 @@
 MACHINE_NAME_FIXIDX,
 MATH_EXCEPTION_FIXIDX,
 MATH_HUGE_VAL_FROM_DBL_MAX_FIXIDX,
+MINGW_INLINE_FP_MATH_FIXIDX,
 NESTED_AUTH_DES_FIXIDX,
 NESTED_MOTOROLA_FIXIDX,
 NESTED_SYS_LIMITS_FIXIDX,
@@ -8623,6 +8662,11 @@
  MATH_HUGE_VAL_FROM_DBL_MAX_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
  aMath_Huge_Val_

[llvm-commits] [127292] Fix PR 1419

2007-05-15 Thread dpatel
Revision: 127292
Author:   dpatel
Date: 2007-05-15 16:46:37 -0700 (Tue, 15 May 2007)

Log Message:
---
Fix PR 1419
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070514/049641.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-15 23:37:35 UTC 
(rev 127291)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-15 23:46:37 UTC 
(rev 127292)
@@ -1245,6 +1245,29 @@
   return Info->PaddingElement[index];
 }
 
+/// OldTy and NewTy are union members. If they are representing
+/// structs then adjust their PaddingElement bits. Padding
+/// field in one struct may not be a padding field in another
+/// struct.
+void adjustPaddingElement(const Type *OldTy, const Type *NewTy) {
+
+  StructTypeConversionInfo *OldInfo = StructTypeInfoMap[OldTy];
+  StructTypeConversionInfo *NewInfo = StructTypeInfoMap[NewTy];
+
+  if (!OldInfo || !NewInfo)
+return;
+
+  /// FIXME : Find overlapping padding fields and preserve their
+  /// isPaddingElement bit. For now, clear all isPaddingElement bits.
+  for (unsigned i = 0, size =  NewInfo->PaddingElement.size(); i != size; ++i)
+NewInfo->PaddingElement[i] = false;
+
+  for (unsigned i = 0, size =  OldInfo->PaddingElement.size(); i != size; ++i)
+OldInfo->PaddingElement[i] = false;
+
+}
+
+
 /// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a
 /// structure.
 static unsigned getFieldOffsetInBits(tree Field) {
@@ -1606,6 +1629,7 @@
 const Type *TheTy = ConvertType(TREE_TYPE(Field));
 unsigned Size = TD.getTypeSize(TheTy);
 unsigned Align = TD.getABITypeAlignment(TheTy);
+adjustPaddingElement(UnionTy, TheTy);
 if (UnionTy == 0 || Align > MaxAlign 
 || (MaxAlign == Align && Size > MaxSize)) {
   UnionTy = TheTy;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127320] Fix PR1417

2007-05-16 Thread dpatel
Revision: 127320
Author:   dpatel
Date: 2007-05-16 09:52:34 -0700 (Wed, 16 May 2007)

Log Message:
---
Fix PR1417
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070514/049666.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-16 09:35:42 UTC 
(rev 127319)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-16 16:52:34 UTC 
(rev 127320)
@@ -942,7 +942,9 @@
   /// getLLVMType - Return the LLVM type for the specified object.
   ///
   const Type *getLLVMType() const {
-return StructType::get(Elements, Packed || AllBitFields);
+// Use Packed type if Packed is set or all struct fields are bitfields.
+// Empty struct is not packed unless packed is set.
+return StructType::get(Elements, Packed || (!Elements.empty() && 
AllBitFields));
   }
   
   /// getSizeAsLLVMStruct - Return the size of this struct if it were converted


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127336] Fix http://lists.cs.uiuc.edu/pipermail/llvm-commits/ Week-of-Mon-20070514/049736.html

2007-05-16 Thread dpatel
Revision: 127336
Author:   dpatel
Date: 2007-05-16 23:23:29 -0700 (Wed, 16 May 2007)

Log Message:
---
Fix 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070514/049736.html

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-17 05:58:55 UTC 
(rev 127335)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-05-17 06:23:29 UTC 
(rev 127336)
@@ -1017,6 +1017,7 @@
 Elements.pop_back();
 ElementOffsetInBytes.pop_back();
 ElementSizeInBytes.pop_back();
+PaddingElement.pop_back();
   }
 }
 
@@ -1060,6 +1061,8 @@
ElementOffsetInBytes.end());
 ElementSizeInBytes.erase(ElementSizeInBytes.begin()+FieldNo,
  ElementSizeInBytes.end());
+PaddingElement.erase(PaddingElement.begin()+FieldNo, 
+ PaddingElement.end());
   }
   
   /// getNewElementByteOffset - If we add a new element with the specified
@@ -1181,6 +1184,7 @@
   ElementOffsetInBytes[x-1] + 
ElementSizeInBytes[x-1]);
   ElementSizeInBytes.insert(ElementSizeInBytes.begin() + x, padding);
   Elements.insert(Elements.begin() + x, Pad);
+  PaddingElement.insert(PaddingElement.begin() + x, true);
 }
   }
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127364] Fix PCH.

2007-05-17 Thread dpatel
Revision: 127364
Author:   dpatel
Date: 2007-05-17 07:35:46 -0700 (Thu, 17 May 2007)

Log Message:
---
Fix PCH. Patch by Anton Korobeynikov.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-17 09:01:27 UTC 
(rev 127363)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-17 14:35:46 UTC 
(rev 127364)
@@ -88,6 +88,8 @@
 static PassManager *PerModulePasses = 0;
 static FunctionPassManager *CodeGenPasses = 0;
 
+static void createOptimizationPasses();
+
 void llvm_initialize_backend(void) {
   // Initialize LLVM options.
   std::vector Args;
@@ -209,13 +211,21 @@
   std::string ErrMsg;
   TheModule = ParseBitcodeFile(MB, &ErrMsg);
   delete MB;
-  
+
   if (!TheModule) {
 cerr << "Error reading bytecodes from PCH file\n";
 cerr << ErrMsg << "\n";
 exit(1);
   }
 
+  if (PerFunctionPasses || PerModulePasses || CodeGenPasses) {
+delete PerFunctionPasses;
+delete PerModulePasses;
+delete CodeGenPasses;
+
+createOptimizationPasses();
+  }
+
   // Read LLVM Types string table
   readLLVMTypesStringTable();
   readLLVMValues();
@@ -225,7 +235,6 @@
 
 // Initialize PCH writing. 
 void llvm_pch_write_init(void) {
-
   timevar_push(TV_LLVM_INIT);
   AsmOutStream = new oFILEstream(asm_out_file);
   AsmOutFile = new OStream(*AsmOutStream);
@@ -246,14 +255,7 @@
   timevar_pop(TV_LLVM_INIT);
 }
 
-// llvm_asm_file_start - Start the .s file.
-void llvm_asm_file_start(void) {
-  timevar_push(TV_LLVM_INIT);
-  AsmOutStream = new oFILEstream(asm_out_file);
-  AsmOutFile = new OStream(*AsmOutStream);
-  
-  flag_llvm_pch_read = 0;
-
+static void createOptimizationPasses() {
   // Create and set up the per-function pass manager.
   // FIXME: Move the code generator to be function-at-a-time.
   PerFunctionPasses =
@@ -411,7 +413,19 @@
 delete PerModulePasses;
 PerModulePasses = 0;
   }
+}
+
+
+// llvm_asm_file_start - Start the .s file.
+void llvm_asm_file_start(void) {
+  timevar_push(TV_LLVM_INIT);
+  AsmOutStream = new oFILEstream(asm_out_file);
+  AsmOutFile = new OStream(*AsmOutStream);
   
+  flag_llvm_pch_read = 0;
+
+  createOptimizationPasses();
+  
   timevar_pop(TV_LLVM_INIT);
 }
 
@@ -480,8 +494,9 @@
 CodeGenPasses->run(*I);
 CodeGenPasses->doFinalization();
   }
-  
+
   AsmOutStream->flush();
+  fflush(asm_out_file);
   delete AsmOutStream;
   AsmOutStream = 0;
   delete AsmOutFile;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127823] Set __APPLE_CC__ value to base gcc build number

2007-05-30 Thread dpatel
Revision: 127823
Author:   dpatel
Date: 2007-05-30 11:12:10 -0700 (Wed, 30 May 2007)

Log Message:
---
Set __APPLE_CC__ value to base gcc build number
instead of llvm build number.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-cppbuiltin.c
apple-local/branches/llvm/gcc/version.c

Modified: apple-local/branches/llvm/gcc/c-cppbuiltin.c
===
--- apple-local/branches/llvm/gcc/c-cppbuiltin.c2007-05-30 15:40:29 UTC 
(rev 127822)
+++ apple-local/branches/llvm/gcc/c-cppbuiltin.c2007-05-30 18:12:10 UTC 
(rev 127823)
@@ -329,24 +329,37 @@
   /* APPLE LOCAL begin LLVM version number */
 #else
 #ifdef CONFIG_DARWIN_H
+  /* This chunk of code defines __APPLE_CC__ from the version
+ string.  It expects to see a substring of the version string of
+ the form "build )", where each N is a digit, and the first
+ N is nonzero (there can be 4 or 5 digits).  It will abort() if
+ these conditions are not met, since that usually means that
+ someone's broken the version string.  */
+
   /* LLVM builds multiple different ways.  For example, for official releases,
  the version number is something like "1.8".  We don't want to disable
  __APPLE_CC__ entirely, as this breaks system headers.  If the build number
- is not a 4-digit code, just define __APPLE_CC__ to 1.
+ is not a 4-digit code, just define __APPLE_CC__ to 1 instead of abort()ing
+ as per above comment.
*/
   {
-char Version[] = LLVM_VERSION_INFO;
-if (! ISDIGIT (Version[0])
-|| ! ISDIGIT (Version[1])
-|| ! ISDIGIT (Version[2])
-|| ! ISDIGIT (Version[3])
-|| Version[4] != 0) {
-  Version[0] = '1';
-  Version[1] = '\0';
-  builtin_define_with_value_n ("__APPLE_CC__", Version, 1);
-} else {
-  builtin_define_with_value_n ("__APPLE_CC__", Version, 4);
-}
+const char *vt;
+
+vt = strstr (version_string, "build ");
+if (vt == NULL)
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+
+vt += strlen ("build ");
+if (! ISDIGIT (*vt))
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+for (q = vt; *q != 0 && ISDIGIT (*q); q++)
+  ;
+if (q == vt || *q != ')')
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+
+if ((q - vt != 4 && q - vt != 5) || *vt == '0')
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
   }
 #endif /*CONFIG_DARWIN_H*/
 #endif /*LLVM_VERSION_INFO*/

Modified: apple-local/branches/llvm/gcc/version.c
===
--- apple-local/branches/llvm/gcc/version.c 2007-05-30 15:40:29 UTC (rev 
127822)
+++ apple-local/branches/llvm/gcc/version.c 2007-05-30 18:12:10 UTC (rev 
127823)
@@ -16,17 +16,15 @@
  to get version number string. Do not use new line.
 */
 
-const char version_string[] = "4.0.1 "
+const char version_string[] = "4.0.1 (Apple Computer, Inc. build 5449)"
 #ifdef ENABLE_LLVM
-  "LLVM "
-#endif
-  "(Apple Computer, Inc. build "
+  "(LLVM build "
 #ifdef LLVM_VERSION_INFO
   LLVM_VERSION_INFO
-#else
-  "5449"
 #endif
-  ")";
+  ")"
+#endif
+  ;
 /* APPLE LOCAL end Apple version */
 
 /* This is the location of the online document giving instructions for


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127825] Fix previous patch.

2007-05-30 Thread dpatel
Revision: 127825
Author:   dpatel
Date: 2007-05-30 11:47:21 -0700 (Wed, 30 May 2007)

Log Message:
---
Fix previous patch.
Make it safer.  Return after defining APPLE_CC.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-cppbuiltin.c

Modified: apple-local/branches/llvm/gcc/c-cppbuiltin.c
===
--- apple-local/branches/llvm/gcc/c-cppbuiltin.c2007-05-30 18:17:46 UTC 
(rev 127824)
+++ apple-local/branches/llvm/gcc/c-cppbuiltin.c2007-05-30 18:47:21 UTC 
(rev 127825)
@@ -346,20 +346,27 @@
 const char *vt;
 
 vt = strstr (version_string, "build ");
-if (vt == NULL)
-  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+if (vt == NULL) {
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+  return;
+}
 
 vt += strlen ("build ");
-if (! ISDIGIT (*vt))
-  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+if (! ISDIGIT (*vt)) {
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+  return;
+}
 for (q = vt; *q != 0 && ISDIGIT (*q); q++)
   ;
-if (q == vt || *q != ')')
-  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
+if (q == vt || *q != ')') {
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+  return;
+}
 
 if ((q - vt != 4 && q - vt != 5) || *vt == '0')
-  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);  
-builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
+  builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
+else
+  builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
   }
 #endif /*CONFIG_DARWIN_H*/
 #endif /*LLVM_VERSION_INFO*/


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127872] Fix objective-c runtime data alignment.

2007-05-31 Thread dpatel
Revision: 127872
Author:   dpatel
Date: 2007-05-31 10:39:08 -0700 (Thu, 31 May 2007)

Log Message:
---
Fix objective-c runtime data alignment.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-31 11:13:57 UTC 
(rev 127871)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-31 17:39:08 UTC 
(rev 127872)
@@ -68,6 +68,8 @@
 #include "langhooks.h"
 }
 
+extern int flag_next_runtime;
+
 // Non-zero if bytecode from PCH is successfully read.
 int flag_llvm_pch_read;
 
@@ -733,6 +735,9 @@
 } else if (const char *Section = 
 LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)) {
   GV->setSection(Section);
+  // Next runtime expects 4 byte alignment for Objective-C data.
+  if (flag_next_runtime)
+GV->setAlignment(4);
 #endif
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [127876] Explicitly set alignment for Objective-C protocols.

2007-05-31 Thread dpatel
Revision: 127876
Author:   dpatel
Date: 2007-05-31 14:56:52 -0700 (Thu, 31 May 2007)

Log Message:
---
Explicitly set alignment for Objective-C protocols.
Set Global Value alignment if it is specified by User.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/objc/objc-act.c

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-31 20:27:28 UTC 
(rev 127875)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-05-31 21:56:52 UTC 
(rev 127876)
@@ -68,8 +68,6 @@
 #include "langhooks.h"
 }
 
-extern int flag_next_runtime;
-
 // Non-zero if bytecode from PCH is successfully read.
 int flag_llvm_pch_read;
 
@@ -735,17 +733,17 @@
 } else if (const char *Section = 
 LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)) {
   GV->setSection(Section);
-  // Next runtime expects 4 byte alignment for Objective-C data.
-  if (flag_next_runtime)
-GV->setAlignment(4);
 #endif
 }
 
-// Set the alignment for the global.
-if (DECL_ALIGN_UNIT(decl) && 
-getTargetData().getABITypeAlignment(GV->getType()->getElementType()) !=
-DECL_ALIGN_UNIT(decl))
-  GV->setAlignment(DECL_ALIGN_UNIT(decl));
+// Set the alignment for the global if one of the following condition is 
met
+// 1) DECL_ALIGN_UNIT does not match alignment as per ABI specification
+// 2) DECL_ALIGN is set by user.
+if (DECL_ALIGN_UNIT(decl)) {
+  unsigned TargetAlign = 
getTargetData().getABITypeAlignment(GV->getType()->getElementType());
+  if (DECL_USER_ALIGN(decl) || TargetAlign != DECL_ALIGN_UNIT(decl))
+GV->setAlignment(DECL_ALIGN_UNIT(decl));
+}
 
 // Handle used decls
 if (DECL_PRESERVE_P (decl))

Modified: apple-local/branches/llvm/gcc/objc/objc-act.c
===
--- apple-local/branches/llvm/gcc/objc/objc-act.c   2007-05-31 20:27:28 UTC 
(rev 127875)
+++ apple-local/branches/llvm/gcc/objc/objc-act.c   2007-05-31 21:56:52 UTC 
(rev 127876)
@@ -9270,6 +9270,11 @@
 /* APPLE LOCAL radar 4695109 */
 UOBJC_PROTOCOL_EXT_decl, 
NULL_TREE);
   /* APPLE LOCAL end radar 4585769 - Objective-C 1.0 extensions */
+  /* APPLE LOCAL begin LLVM */
+  /* Force 4 byte alignment for protocols */
+  DECL_ALIGN(decl) = 32;
+  DECL_USER_ALIGN(decl) = 1;
+  /* APPLE LOCAL end LLVM */
   finish_var_decl (decl, initlist);
 }
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [128027] Let loop unswitch pass know whether we are optimizing for size or not.

2007-06-05 Thread dpatel
Revision: 128027
Author:   dpatel
Date: 2007-06-05 17:23:16 -0700 (Tue, 05 Jun 2007)

Log Message:
---
Let loop unswitch pass know whether we are optimizing for size or not.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-06-05 23:45:35 UTC 
(rev 128026)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-06-06 00:23:16 UTC 
(rev 128027)
@@ -327,7 +327,7 @@
 PM->add(createReassociatePass());   // Reassociate expressions
 PM->add(createLoopRotatePass());// Rotate Loop
 PM->add(createLICMPass());  // Hoist loop invariants
-PM->add(createLoopUnswitchPass());  // Unswitch loops.
+PM->add(createLoopUnswitchPass(optimize_size ? true : false));
 PM->add(createInstructionCombiningPass());  // Clean up after LICM/reassoc
 PM->add(createIndVarSimplifyPass());// Canonicalize indvars
 if (flag_unroll_loops)


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [128706] Fix 1519.

2007-06-21 Thread dpatel
Revision: 128706
Author:   dpatel
Date: 2007-06-21 16:28:14 -0700 (Thu, 21 Jun 2007)

Log Message:
---
Fix 1519. Patch by Rafael Espindola.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-06-21 22:36:49 UTC 
(rev 128705)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-06-21 23:28:14 UTC 
(rev 128706)
@@ -1070,6 +1070,8 @@
 
   void allFieldsAreNotBitFields() {
 AllBitFields = false;
+// Next field is not a bitfield.
+LastFieldStartsAtNonByteBoundry = false;
   }
 
   unsigned getGCCStructAlignmentInBytes() const {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [128742] Fix warning.

2007-06-22 Thread dpatel
Revision: 128742
Author:   dpatel
Date: 2007-06-22 13:28:02 -0700 (Fri, 22 Jun 2007)

Log Message:
---
Fix warning.

Modified Paths:
--
apple-local/branches/llvm/gcc/c-lex.c

Modified: apple-local/branches/llvm/gcc/c-lex.c
===
--- apple-local/branches/llvm/gcc/c-lex.c   2007-06-22 17:28:14 UTC (rev 
128741)
+++ apple-local/branches/llvm/gcc/c-lex.c   2007-06-22 20:28:02 UTC (rev 
128742)
@@ -826,7 +826,7 @@
 my_cpp_num_sign_extend (cpp_num num, size_t precision)
 {
   if (num.high)
-printf("%lu\n", num.high);
+printf("%lu\n", (long unsigned int) num.high);
   if (!num.unsignedp)
 {
   if (precision > PART_PRECISION)


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [129769] Provide command line switches to print pass manager info useful for debugging .

2007-07-20 Thread dpatel
Revision: 129769
Author:   dpatel
Date: 2007-07-20 16:11:01 -0700 (Fri, 20 Jul 2007)

Log Message:
---
Provide command line switches to print pass manager info useful for debugging.

Modified Paths:
--
apple-local/branches/llvm/gcc/common.opt
apple-local/branches/llvm/gcc/llvm-backend.cpp

Modified: apple-local/branches/llvm/gcc/common.opt
===
--- apple-local/branches/llvm/gcc/common.opt2007-07-20 22:58:17 UTC (rev 
129768)
+++ apple-local/branches/llvm/gcc/common.opt2007-07-20 23:11:01 UTC (rev 
129769)
@@ -202,6 +202,15 @@
 emit-llvm-bc
 Common Report Var(emit_llvm_bc)
 Emit LLVM IR to the output file instead of native machine code.
+
+; Debug pass manager
+fdebug-pass-structure
+Common Report Var(flag_debug_pass_structure)
+Print pass manager structure
+
+fdebug-pass-arguments
+Common Report Var(flag_debug_pass_arguments)
+Print pass manager arguments
 ; APPLE LOCAL end LLVM
 
 ; The version of the C++ ABI in use.  The following values are allowed:

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===
--- apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-07-20 22:58:17 UTC 
(rev 129768)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp  2007-07-20 23:11:01 UTC 
(rev 129769)
@@ -118,7 +118,10 @@
 Args.push_back("--nozero-initialized-in-bss");
   if (flag_debug_asm)
 Args.push_back("--asm-verbose");
-
+  if (flag_debug_pass_structure)
+Args.push_back("--debug-pass=Structure");
+  if (flag_debug_pass_arguments)
+Args.push_back("--debug-pass=Arguments");
 // Disabled until PR1224 is resolved.
   //if (flag_exceptions)
   //  Args.push_back("--enable-eh");


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits