diff mbox

Remove occurrences of int64_t (and int32_t)

Message ID 201112101823.09429.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Dec. 10, 2011, 5:23 p.m. UTC
Hi,

this removes all the occurrences of int64_t in the host code, as well as some 
gratuitous occurrences of int32_t (there are real ones in DFP and LTO code).
Tested on i586-suse-linux and x86_64-suse-linux.  Any objections?

Are the LTO files present in the gcc directory compiled when LTO is disabled?
If so, a compiler with a 64-bit type is required on the host since GCC 4.5.0.


2011-12-10  Eric Botcazou  <ebotcazou@adacore.com>

	* lto-streamer-out.c (write_symbol): Use proper 64-bit host type.
	* lto-cgraph.c (input_cgraph_opt_section): Use 'int' for offsets.
	* lto-streamer-in.c (lto_read_body): Likewise.
	(lto_input_toplevel_asms): Likewise.
	* lto-section-in.c (lto_create_simple_input_block): Likewise.
	* ipa-inline-analysis.c (inline_read_section): Likewise.
	* ipa-prop.c (ipa_prop_read_section): Likewise.
lto/
	* lto.h (lto_parse_hex): Delete.
	* lto.c (lto_read_decls): Use 'int' for offsets.
	(lto_parse_hex): Make static and return proper 64-bit host type.
	(lto_resolution_read): Use proper 64-bit host type.

Comments

Richard Biener Dec. 12, 2011, 9:34 a.m. UTC | #1
On Sat, Dec 10, 2011 at 6:23 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this removes all the occurrences of int64_t in the host code, as well as some
> gratuitous occurrences of int32_t (there are real ones in DFP and LTO code).
> Tested on i586-suse-linux and x86_64-suse-linux.  Any objections?
>
> Are the LTO files present in the gcc directory compiled when LTO is disabled?

Yes they are, but they will be unused at runtime.

> If so, a compiler with a 64-bit type is required on the host since GCC 4.5.0.

-      size = (HOST_BITS_PER_WIDE_INT >= 64)
-       ? (uint64_t) int_size_in_bytes (TREE_TYPE (t))
-       : (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
-               | TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#if HOST_BITS_PER_WIDE_INT >= 64
+      size = (unsigned host_int64) int_size_in_bytes (TREE_TYPE (t));
+#else
+      size
+       = (unsigned host_int64) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t)) << 32
+         || (unsigned host_int64) TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#endif

and this pattern looks bogus anyway (using TYPE_SIZE vs.
DECL_SIZE).  Please simply switch it to unconditional use of
tree_to_double_int (DECL_SIZE_UNIT (t)).low and make 'size'
a HOST_WIDE_INT (we properly require 64 bit hwi for targets
that have 64bit sizes/pointers).

+#if HOST_BITS_PER_WIDE_INT >= 64
+# define host_int64 HOST_WIDE_INT
+#elif HOST_BITS_PER_WIDEST_INT >= 64
+# define host_int64 HOST_WIDEST_INT
+#else
+# error "host has no 64-bit type"
+#endif

well, as previous communication has shown we should use
HOST_WIDEST_INT unconditionally for a 64-bit type (allowing
the code to compile when no such type is available during stage1).
If we really need a true 64bit type then we should amend hwint.h
accordingly.

Otherwise ok (the s/int32_t/int/ cases are obvious).

Thanks,
Richard.

>
> 2011-12-10  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * lto-streamer-out.c (write_symbol): Use proper 64-bit host type.
>        * lto-cgraph.c (input_cgraph_opt_section): Use 'int' for offsets.
>        * lto-streamer-in.c (lto_read_body): Likewise.
>        (lto_input_toplevel_asms): Likewise.
>        * lto-section-in.c (lto_create_simple_input_block): Likewise.
>        * ipa-inline-analysis.c (inline_read_section): Likewise.
>        * ipa-prop.c (ipa_prop_read_section): Likewise.
> lto/
>        * lto.h (lto_parse_hex): Delete.
>        * lto.c (lto_read_decls): Use 'int' for offsets.
>        (lto_parse_hex): Make static and return proper 64-bit host type.
>        (lto_resolution_read): Use proper 64-bit host type.
>
>
> --
> Eric Botcazou
Eric Botcazou Dec. 13, 2011, 12:22 p.m. UTC | #2
> Please simply switch it to unconditional use of tree_to_double_int
> (DECL_SIZE_UNIT (t)).low and make 'size' a HOST_WIDE_INT (we properly
> require 64 bit hwi for targets that have 64bit sizes/pointers).

Sure, but we need a 64-bit container for 'size' at least, because 8 bytes are 
read from it.  So I presume HOST_WIDEST_INT should simply be used there too.

> +#if HOST_BITS_PER_WIDE_INT >= 64
> +# define host_int64 HOST_WIDE_INT
> +#elif HOST_BITS_PER_WIDEST_INT >= 64
> +# define host_int64 HOST_WIDEST_INT
> +#else
> +# error "host has no 64-bit type"
> +#endif
>
> well, as previous communication has shown we should use
> HOST_WIDEST_INT unconditionally for a 64-bit type (allowing
> the code to compile when no such type is available during stage1).
> If we really need a true 64bit type then we should amend hwint.h
> accordingly.

OK.
diff mbox

Patch

Index: lto-cgraph.c
===================================================================
--- lto-cgraph.c	(revision 182102)
+++ lto-cgraph.c	(working copy)
@@ -1689,9 +1689,9 @@  input_cgraph_opt_section (struct lto_fil
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib_main;
   unsigned int i;
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 182102)
+++ lto-streamer-out.c	(working copy)
@@ -1271,6 +1271,14 @@  lto_out_decl_state_written_size (struct
 /* Write symbol T into STREAM in CACHE. SEEN specifies symbols we wrote
    so far.  */
 
+#if HOST_BITS_PER_WIDE_INT >= 64
+# define host_int64 HOST_WIDE_INT
+#elif HOST_BITS_PER_WIDEST_INT >= 64
+# define host_int64 HOST_WIDEST_INT
+#else
+# error "host has no 64-bit type"
+#endif
+
 static void
 write_symbol (struct streamer_tree_cache_d *cache,
 	      struct lto_output_stream *stream,
@@ -1280,7 +1288,7 @@  write_symbol (struct streamer_tree_cache
   enum gcc_plugin_symbol_kind kind;
   enum gcc_plugin_symbol_visibility visibility;
   unsigned slot_num;
-  uint64_t size;
+  unsigned host_int64 size;
   const char *comdat;
   unsigned char c;
 
@@ -1338,7 +1346,7 @@  write_symbol (struct streamer_tree_cache
      when symbol has attribute (visibility("hidden")) specified.
      targetm.binds_local_p check DECL_VISIBILITY_SPECIFIED and gets this
      right. */
-     
+
   if (DECL_EXTERNAL (t)
       && !targetm.binds_local_p (t))
     visibility = GCCPV_DEFAULT;
@@ -1363,10 +1371,13 @@  write_symbol (struct streamer_tree_cache
       && DECL_SIZE (t)
       && TREE_CODE (DECL_SIZE (t)) == INTEGER_CST)
     {
-      size = (HOST_BITS_PER_WIDE_INT >= 64)
-	? (uint64_t) int_size_in_bytes (TREE_TYPE (t))
-	: (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
-		| TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#if HOST_BITS_PER_WIDE_INT >= 64
+      size = (unsigned host_int64) int_size_in_bytes (TREE_TYPE (t));
+#else
+      size
+	= (unsigned host_int64) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t)) << 32
+	  || (unsigned host_int64) TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
+#endif
     }
   else
     size = 0;
Index: lto-streamer-in.c
===================================================================
--- lto-streamer-in.c	(revision 182102)
+++ lto-streamer-in.c	(working copy)
@@ -979,9 +979,9 @@  lto_read_body (struct lto_file_decl_data
 {
   const struct lto_function_header *header;
   struct data_in *data_in;
-  int32_t cfg_offset;
-  int32_t main_offset;
-  int32_t string_offset;
+  int cfg_offset;
+  int main_offset;
+  int string_offset;
   struct lto_input_block ib_cfg;
   struct lto_input_block ib_main;
 
@@ -1172,7 +1172,7 @@  lto_input_toplevel_asms (struct lto_file
   const char *data = lto_get_section_data (file_data, LTO_section_asm,
 					   NULL, &len);
   const struct lto_asm_header *header = (const struct lto_asm_header *) data;
-  int32_t string_offset;
+  int string_offset;
   struct data_in *data_in;
   struct lto_input_block ib;
   tree str;
Index: lto-section-in.c
===================================================================
--- lto-section-in.c	(revision 182102)
+++ lto-section-in.c	(working copy)
@@ -224,7 +224,7 @@  lto_create_simple_input_block (struct lt
     = (const struct lto_simple_header *) data;
 
   struct lto_input_block* ib_main;
-  int32_t main_offset = sizeof (struct lto_simple_header);
+  int main_offset = sizeof (struct lto_simple_header);
 
   if (!data)
     return NULL;
Index: ipa-inline-analysis.c
===================================================================
--- ipa-inline-analysis.c	(revision 182102)
+++ ipa-inline-analysis.c	(working copy)
@@ -3019,9 +3019,9 @@  inline_read_section (struct lto_file_dec
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib;
   unsigned int i, count2, j;
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 182102)
+++ lto/lto.c	(working copy)
@@ -267,7 +267,7 @@  lto_read_in_decl_state (struct data_in *
   uint32_t ix;
   tree decl;
   uint32_t i, j;
-  
+
   ix = *data++;
   decl = streamer_tree_cache_get (data_in->reader_cache, ix);
   if (TREE_CODE (decl) != FUNCTION_DECL)
@@ -879,9 +879,9 @@  lto_read_decls (struct lto_file_decl_dat
 		VEC(ld_plugin_symbol_resolution_t,heap) *resolutions)
 {
   const struct lto_decl_header *header = (const struct lto_decl_header *) data;
-  const int32_t decl_offset = sizeof (struct lto_decl_header);
-  const int32_t main_offset = decl_offset + header->decl_state_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int decl_offset = sizeof (struct lto_decl_header);
+  const int main_offset = decl_offset + header->decl_state_size;
+  const int string_offset = main_offset + header->main_size;
   struct lto_input_block ib_main;
   struct data_in *data_in;
   unsigned int i;
@@ -939,10 +939,21 @@  lto_read_decls (struct lto_file_decl_dat
   lto_data_in_delete (data_in);
 }
 
-/* strtoll is not portable. */
-int64_t
-lto_parse_hex (const char *p) {
-  uint64_t ret = 0;
+#if HOST_BITS_PER_WIDE_INT >= 64
+# define host_int64 HOST_WIDE_INT
+#elif HOST_BITS_PER_WIDEST_INT >= 64
+# define host_int64 HOST_WIDEST_INT
+#else
+# error "host has no 64-bit type"
+#endif
+
+/* strtoll is not portable.  */
+
+static host_int64
+lto_parse_hex (const char *p)
+{
+  host_int64 ret = 0;
+
   for (; *p != '\0'; ++p)
     {
       char c = *p;
@@ -958,6 +969,7 @@  lto_parse_hex (const char *p) {
         internal_error ("could not parse hex number");
       ret |= part;
     }
+
   return ret;
 }
 
@@ -993,7 +1005,7 @@  lto_resolution_read (splay_tree file_ids
     {
       int t;
       char offset_p[17];
-      int64_t offset;
+      host_int64 offset;
       t = fscanf (resolution, "@0x%16s", offset_p);
       if (t != 1)
         internal_error ("could not parse file offset");
Index: lto/lto.h
===================================================================
--- lto/lto.h	(revision 182102)
+++ lto/lto.h	(working copy)
@@ -68,6 +68,4 @@  struct lto_section_list
   struct lto_section_slot *first, *last;
 };
 
-int64_t lto_parse_hex (const char *p);
-
 #endif /* LTO_H */
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 182102)
+++ ipa-prop.c	(working copy)
@@ -3003,9 +3003,9 @@  ipa_prop_read_section (struct lto_file_d
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
-  const int32_t cfg_offset = sizeof (struct lto_function_header);
-  const int32_t main_offset = cfg_offset + header->cfg_size;
-  const int32_t string_offset = main_offset + header->main_size;
+  const int cfg_offset = sizeof (struct lto_function_header);
+  const int main_offset = cfg_offset + header->cfg_size;
+  const int string_offset = main_offset + header->main_size;
   struct data_in *data_in;
   struct lto_input_block ib_main;
   unsigned int i;