[m-rev.] for review: enable the use of unboxed 64-bit integers

Julien Fischer jfischer at opturion.com
Fri Feb 16 19:59:46 AEDT 2018


For review by anyone.

This replaces part of an earlier uncommitted change.  I don't think
we actually need to bump the binary grade compatibility number here
(as I did in th previous version).

-----------------------------

Enable the use of unboxed 64-bit integers.

Enable the use of unboxed 64-bit integers in C grades on 64-bit
machines.

Add a new internal grade component corresponding to the use of 64-bit
integers.

configure.ac:
     Test whether we can use unboxed 64-bit integers.

     Extend the check for whether previously built C files are compatible with
     configure determined settings to cover whether 64-bit integer are boxed
     or not.

scripts/Mercury.config.boostrap.in:
scripts/Mercury.config.in:
      Set the compiler flag for unboxed 64-bit integers if configure determines
      they can be used.

runtime/mercury_grade.h:
      Add the "ubi64" grade component

diff --git a/configure.ac b/configure.ac
index a47734d..f53b58d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2329,11 +2329,28 @@ AC_SUBST(MR_LONG_DOUBLE_IS_64_BIT)

  #-----------------------------------------------------------------------------#

-# XXX INT64 -- while we are boostrapping the changes that introduce int64
-# and uint64, we always box them.  Support for unboxed 64-bit integer types
-# will be enabled later.
-
-AC_DEFINE(MR_BOXED_INT64S)
+AC_MSG_CHECKING([whether we can use unboxed 64-bit integers])
+AC_CACHE_VAL([mercury_cv_unboxed_int64s],
+    AC_TRY_RUN([
+    #include <stdint.h>
+    int main() {
+        if (sizeof(uint64_t) == sizeof(void *))
+            exit(0);
+        else
+            exit(1);
+        }],
+        [mercury_cv_unboxed_int64s=yes],
+        [mercury_cv_unboxed_int64s=no],
+        [mercury_cv_unboxed_int64s=no])
+)
+AC_MSG_RESULT($mercury_cv_unbxed_int64s)
+if test "$mercury_cv_unboxed_int64s" = yes; then
+    HAVE_BOXED_INT64S="--unboxed-int64s"
+else
+    AC_DEFINE(MR_BOXED_INT64S)
+    HAVE_BOXED_INT64S="--no-unboxed-int64s"
+fi
+AC_SUBST([HAVE_BOXED_INT64S])

  #-----------------------------------------------------------------------------#

@@ -5363,11 +5380,13 @@ mercury_check_c_files () {
          *.pregen*)
              need_low_tag_bits=2
              need_unboxed_floats=no
+            need_unboxed_int64s=no
              need_pregen_dist=yes
              ;;
          *)
              need_low_tag_bits=$mercury_cv_low_tag_bits
              need_unboxed_floats=$mercury_cv_unboxed_floats
+            need_unboxed_int64s=$mercury_cv_unboxed_int64s
              need_pregen_dist=no
              ;;
      esac
@@ -5385,6 +5404,8 @@ mercury_check_c_files () {
                      confscratch > /dev/null 2>&1 \
                  && grep "UNBOXED_FLOAT=$need_unboxed_floats" \
                      confscratch > /dev/null 2>&1 \
+                && grep "UNBOXED_INT64S=$need_unbox_int64s" \
+                    confscratch > /dev/null 2>&1 \
                  && grep "PREGENERATED_DIST=$need_pregen_dist" \
                      confscratch > /dev/null 2>&1 \
                  && grep "HIGHLEVEL_CODE=$need_hl_c_files" \
diff --git a/runtime/mercury_grade.h b/runtime/mercury_grade.h
index 501d5fd..baf9eda 100644
--- a/runtime/mercury_grade.h
+++ b/runtime/mercury_grade.h
@@ -1,6 +1,7 @@
  // vim: ts=4 sw=4 expandtab ft=c

-// Copyright (C) 1997-2011 The University of Melbourne.
+// Copyright (C) 1997-2012 The University of Melbourne.
+// Copyright (C) 2013-2014, 2016-2018 The Mercury team.
  // This file may only be copied under the terms of the GNU Library General
  // Public License - see the file COPYING.LIB in the Mercury distribution.

@@ -499,8 +500,16 @@
    #define MR_GRADE_OPT_PART_18  MR_GRADE_OPT_PART_17
  #endif

-#define MR_GRADE                MR_GRADE_PART_18
-#define MR_GRADE_OPT            MR_GRADE_OPT_PART_18
+#if defined(MR_BOXED_INT64S)
+  #define MR_GRADE_PART_19     MR_GRADE_PART_18
+  #define MR_GRADE_OPT_PART_19 MR_GRADE_OPT_PART_18
+#else                          // "ubi64" stands for "unboxed integers 64-bit"
+  #define MR_GRADE_PART_19     MR_PASTE2(MR_GRADE_PART_18, _ubi64)
+  #define MR_GRADE_OPT_PART_19 MR_GRADE_OPT_PART_18
+#endif
+
+#define MR_GRADE                MR_GRADE_PART_19
+#define MR_GRADE_OPT            MR_GRADE_OPT_PART_19

  #define MR_GRADE_VAR            MR_PASTE2(MR_grade_,MR_GRADE)
  #define MR_GRADE_STRING         MR_STRINGIFY(MR_GRADE)
diff --git a/scripts/Mercury.config.bootstrap.in b/scripts/Mercury.config.bootstrap.in
index 40fe776..9903b4e 100644
--- a/scripts/Mercury.config.bootstrap.in
+++ b/scripts/Mercury.config.bootstrap.in
@@ -129,6 +129,7 @@ DEFAULT_MCFLAGS=\
  		--target-env-type "@TARGET_ENV_TYPE@" \
  		@HAVE_DELAY_SLOT@ \
  		@HAVE_BOXED_FLOATS@ \
+		@HAVE_BOXED_INT64S@ \
  		@MCFLAGS_FOR_CC@ \
  		$(MERCURY_DEFAULT_OPT_LEVEL) \
  		@MMC_USE_SYMLINKS_OPT@ \
diff --git a/scripts/Mercury.config.in b/scripts/Mercury.config.in
index a548856..1dde74e 100644
--- a/scripts/Mercury.config.in
+++ b/scripts/Mercury.config.in
@@ -132,6 +132,7 @@ DEFAULT_MCFLAGS=\
  		@RESTRICTED_COMMAND_LINE_OPT@ \
  		@HAVE_DELAY_SLOT@ \
  		@HAVE_BOXED_FLOATS@ \
+		@HAVE_BOXED_INT64S@ \
  		@MCFLAGS_FOR_CC@ \
  		$(MERCURY_DEFAULT_OPT_LEVEL) \
  		@MMC_USE_SYMLINKS_OPT@


More information about the reviews mailing list