Files
mercury/tests/hard_coded/arith_uint64.exp
Julien Fischer f80463dbcb Add builtin 64-bit integer types -- Part 2.
Replace placeholder types with int64 and uint64 as appropriate throughout the
system.

Enable support for 64-bit integer literals in the compiler.

Add initial library support for 64-bit integers.

configure.ac:
     Check that the bootstrap compiler recognises int64 and uint64 as
     builtins.

library/int64.m:
library/uint64.m:
     Populate these two modules to the extent that we can now run
     basic tests of 64-bit integer support.

     Note that since the bootstrap compiler will not recognise
     64-bit integer literals, any such literals are current written
     as conversions from ints; this will be replaced once this change
     has bootstrapped.

library/private_builtin.m:
    Replace the placeholder definitions for builtin unification and
    comparison of 64-bit integers with their actual definitions.

library/integer.m:
    Add procedures for converting integers to- and from int64 and uint64.

library/string.m:
    Add functions for converting 64-bit integers into strings.

library/io.m:
    Add predicates for writing 64-bit integers to text streams.
    (Support for 64-bit integers with binary streams will be done
    separately.)

library/stream.string_writer.m:
    Add put_int64/4 and put_uint/64.

    Extend the implementations of print and write to cover int64 and
    uint64.

library/pprint.m:
    Make int64 and uint64 instances of the doc/1 type class.

library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
    Handle int64 and uint64 properly in deconstruct.

library/term.m:
    Add functions for converting 64-bit integers into terms.

library/term_conversion.m:
    Support int64 and uint64 in univ -> term conversion.

library/Mercury.options:
    Avoid a warning about the import of the require being
    unused in the int64 and uint64 modules.  It *is* used,
    but only in the definitions used by the Erlang backend.

compiler/superhomogeneous.m:
     Accept 64-bit integer literals.

compiler/c_util.m:
     In C, write out the value of the min_int64 as the symbolic
     constant INT64_MIN.  This expands in such a way as to avoid
     generating warnings from the C compiler.

compiler/builtin_ops.m:
compiler/bytecode.m:
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/hlds_data.m:
compiler/hlds_out_util.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/lookup_switch.m:
compiler/mercury_to_mercury.m:
compiler/mlds.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
     Replace the use of int as a placeholder with int64 or uint64 as
     appropriate.

tests/hard_coded/Mmakefile:
tests/hard_coded/arith_int64.{m,exp}:
tests/hard_coded/arith_uint64.{m,exp}:
tests/hard_coded/bitwise_int64.{m,exp}:
tests/hard_coded/bitwise_uint64.{m,exp}:
tests/hard_coded/cmp_int64.{m,exp}:
tests/hard_coded/cmp_uint64.{m,exp}:
tests/hard_coded/integer_int64_conv.{m,exp}:
tests/hard_coded/integer_uint64_conv.{m,exp}:
     Add tests of basic operations on 64-bit integers.

tests/hard_coded/construct_test.{m,exp}:
    Extend this test to cover 64-bit integers.
2018-02-02 10:33:25 -05:00

620 lines
14 KiB
Plaintext

*** Test binary operation '+' ***
0 + 0 = 0
0 + 1 = 1
0 + 2 = 2
0 + 8 = 8
0 + 10 = 10
0 + 16 = 16
0 + 255 = 255
0 + 65535 = 65535
0 + 2147483647 = 2147483647
0 + 4294967295 = 4294967295
0 + 18446744073709551615 = 18446744073709551615
1 + 0 = 1
1 + 1 = 2
1 + 2 = 3
1 + 8 = 9
1 + 10 = 11
1 + 16 = 17
1 + 255 = 256
1 + 65535 = 65536
1 + 2147483647 = 2147483648
1 + 4294967295 = 4294967296
1 + 18446744073709551615 = 0
2 + 0 = 2
2 + 1 = 3
2 + 2 = 4
2 + 8 = 10
2 + 10 = 12
2 + 16 = 18
2 + 255 = 257
2 + 65535 = 65537
2 + 2147483647 = 2147483649
2 + 4294967295 = 4294967297
2 + 18446744073709551615 = 1
8 + 0 = 8
8 + 1 = 9
8 + 2 = 10
8 + 8 = 16
8 + 10 = 18
8 + 16 = 24
8 + 255 = 263
8 + 65535 = 65543
8 + 2147483647 = 2147483655
8 + 4294967295 = 4294967303
8 + 18446744073709551615 = 7
10 + 0 = 10
10 + 1 = 11
10 + 2 = 12
10 + 8 = 18
10 + 10 = 20
10 + 16 = 26
10 + 255 = 265
10 + 65535 = 65545
10 + 2147483647 = 2147483657
10 + 4294967295 = 4294967305
10 + 18446744073709551615 = 9
16 + 0 = 16
16 + 1 = 17
16 + 2 = 18
16 + 8 = 24
16 + 10 = 26
16 + 16 = 32
16 + 255 = 271
16 + 65535 = 65551
16 + 2147483647 = 2147483663
16 + 4294967295 = 4294967311
16 + 18446744073709551615 = 15
255 + 0 = 255
255 + 1 = 256
255 + 2 = 257
255 + 8 = 263
255 + 10 = 265
255 + 16 = 271
255 + 255 = 510
255 + 65535 = 65790
255 + 2147483647 = 2147483902
255 + 4294967295 = 4294967550
255 + 18446744073709551615 = 254
65535 + 0 = 65535
65535 + 1 = 65536
65535 + 2 = 65537
65535 + 8 = 65543
65535 + 10 = 65545
65535 + 16 = 65551
65535 + 255 = 65790
65535 + 65535 = 131070
65535 + 2147483647 = 2147549182
65535 + 4294967295 = 4295032830
65535 + 18446744073709551615 = 65534
2147483647 + 0 = 2147483647
2147483647 + 1 = 2147483648
2147483647 + 2 = 2147483649
2147483647 + 8 = 2147483655
2147483647 + 10 = 2147483657
2147483647 + 16 = 2147483663
2147483647 + 255 = 2147483902
2147483647 + 65535 = 2147549182
2147483647 + 2147483647 = 4294967294
2147483647 + 4294967295 = 6442450942
2147483647 + 18446744073709551615 = 2147483646
4294967295 + 0 = 4294967295
4294967295 + 1 = 4294967296
4294967295 + 2 = 4294967297
4294967295 + 8 = 4294967303
4294967295 + 10 = 4294967305
4294967295 + 16 = 4294967311
4294967295 + 255 = 4294967550
4294967295 + 65535 = 4295032830
4294967295 + 2147483647 = 6442450942
4294967295 + 4294967295 = 8589934590
4294967295 + 18446744073709551615 = 4294967294
18446744073709551615 + 0 = 18446744073709551615
18446744073709551615 + 1 = 0
18446744073709551615 + 2 = 1
18446744073709551615 + 8 = 7
18446744073709551615 + 10 = 9
18446744073709551615 + 16 = 15
18446744073709551615 + 255 = 254
18446744073709551615 + 65535 = 65534
18446744073709551615 + 2147483647 = 2147483646
18446744073709551615 + 4294967295 = 4294967294
18446744073709551615 + 18446744073709551615 = 18446744073709551614
*** Test binary operation '-' ***
0 - 0 = 0
0 - 1 = 18446744073709551615
0 - 2 = 18446744073709551614
0 - 8 = 18446744073709551608
0 - 10 = 18446744073709551606
0 - 16 = 18446744073709551600
0 - 255 = 18446744073709551361
0 - 65535 = 18446744073709486081
0 - 2147483647 = 18446744071562067969
0 - 4294967295 = 18446744069414584321
0 - 18446744073709551615 = 1
1 - 0 = 1
1 - 1 = 0
1 - 2 = 18446744073709551615
1 - 8 = 18446744073709551609
1 - 10 = 18446744073709551607
1 - 16 = 18446744073709551601
1 - 255 = 18446744073709551362
1 - 65535 = 18446744073709486082
1 - 2147483647 = 18446744071562067970
1 - 4294967295 = 18446744069414584322
1 - 18446744073709551615 = 2
2 - 0 = 2
2 - 1 = 1
2 - 2 = 0
2 - 8 = 18446744073709551610
2 - 10 = 18446744073709551608
2 - 16 = 18446744073709551602
2 - 255 = 18446744073709551363
2 - 65535 = 18446744073709486083
2 - 2147483647 = 18446744071562067971
2 - 4294967295 = 18446744069414584323
2 - 18446744073709551615 = 3
8 - 0 = 8
8 - 1 = 7
8 - 2 = 6
8 - 8 = 0
8 - 10 = 18446744073709551614
8 - 16 = 18446744073709551608
8 - 255 = 18446744073709551369
8 - 65535 = 18446744073709486089
8 - 2147483647 = 18446744071562067977
8 - 4294967295 = 18446744069414584329
8 - 18446744073709551615 = 9
10 - 0 = 10
10 - 1 = 9
10 - 2 = 8
10 - 8 = 2
10 - 10 = 0
10 - 16 = 18446744073709551610
10 - 255 = 18446744073709551371
10 - 65535 = 18446744073709486091
10 - 2147483647 = 18446744071562067979
10 - 4294967295 = 18446744069414584331
10 - 18446744073709551615 = 11
16 - 0 = 16
16 - 1 = 15
16 - 2 = 14
16 - 8 = 8
16 - 10 = 6
16 - 16 = 0
16 - 255 = 18446744073709551377
16 - 65535 = 18446744073709486097
16 - 2147483647 = 18446744071562067985
16 - 4294967295 = 18446744069414584337
16 - 18446744073709551615 = 17
255 - 0 = 255
255 - 1 = 254
255 - 2 = 253
255 - 8 = 247
255 - 10 = 245
255 - 16 = 239
255 - 255 = 0
255 - 65535 = 18446744073709486336
255 - 2147483647 = 18446744071562068224
255 - 4294967295 = 18446744069414584576
255 - 18446744073709551615 = 256
65535 - 0 = 65535
65535 - 1 = 65534
65535 - 2 = 65533
65535 - 8 = 65527
65535 - 10 = 65525
65535 - 16 = 65519
65535 - 255 = 65280
65535 - 65535 = 0
65535 - 2147483647 = 18446744071562133504
65535 - 4294967295 = 18446744069414649856
65535 - 18446744073709551615 = 65536
2147483647 - 0 = 2147483647
2147483647 - 1 = 2147483646
2147483647 - 2 = 2147483645
2147483647 - 8 = 2147483639
2147483647 - 10 = 2147483637
2147483647 - 16 = 2147483631
2147483647 - 255 = 2147483392
2147483647 - 65535 = 2147418112
2147483647 - 2147483647 = 0
2147483647 - 4294967295 = 18446744071562067968
2147483647 - 18446744073709551615 = 2147483648
4294967295 - 0 = 4294967295
4294967295 - 1 = 4294967294
4294967295 - 2 = 4294967293
4294967295 - 8 = 4294967287
4294967295 - 10 = 4294967285
4294967295 - 16 = 4294967279
4294967295 - 255 = 4294967040
4294967295 - 65535 = 4294901760
4294967295 - 2147483647 = 2147483648
4294967295 - 4294967295 = 0
4294967295 - 18446744073709551615 = 4294967296
18446744073709551615 - 0 = 18446744073709551615
18446744073709551615 - 1 = 18446744073709551614
18446744073709551615 - 2 = 18446744073709551613
18446744073709551615 - 8 = 18446744073709551607
18446744073709551615 - 10 = 18446744073709551605
18446744073709551615 - 16 = 18446744073709551599
18446744073709551615 - 255 = 18446744073709551360
18446744073709551615 - 65535 = 18446744073709486080
18446744073709551615 - 2147483647 = 18446744071562067968
18446744073709551615 - 4294967295 = 18446744069414584320
18446744073709551615 - 18446744073709551615 = 0
*** Test binary operation '*' ***
0 * 0 = 0
0 * 1 = 0
0 * 2 = 0
0 * 8 = 0
0 * 10 = 0
0 * 16 = 0
0 * 255 = 0
0 * 65535 = 0
0 * 2147483647 = 0
0 * 4294967295 = 0
0 * 18446744073709551615 = 0
1 * 0 = 0
1 * 1 = 1
1 * 2 = 2
1 * 8 = 8
1 * 10 = 10
1 * 16 = 16
1 * 255 = 255
1 * 65535 = 65535
1 * 2147483647 = 2147483647
1 * 4294967295 = 4294967295
1 * 18446744073709551615 = 18446744073709551615
2 * 0 = 0
2 * 1 = 2
2 * 2 = 4
2 * 8 = 16
2 * 10 = 20
2 * 16 = 32
2 * 255 = 510
2 * 65535 = 131070
2 * 2147483647 = 4294967294
2 * 4294967295 = 8589934590
2 * 18446744073709551615 = 18446744073709551614
8 * 0 = 0
8 * 1 = 8
8 * 2 = 16
8 * 8 = 64
8 * 10 = 80
8 * 16 = 128
8 * 255 = 2040
8 * 65535 = 524280
8 * 2147483647 = 17179869176
8 * 4294967295 = 34359738360
8 * 18446744073709551615 = 18446744073709551608
10 * 0 = 0
10 * 1 = 10
10 * 2 = 20
10 * 8 = 80
10 * 10 = 100
10 * 16 = 160
10 * 255 = 2550
10 * 65535 = 655350
10 * 2147483647 = 21474836470
10 * 4294967295 = 42949672950
10 * 18446744073709551615 = 18446744073709551606
16 * 0 = 0
16 * 1 = 16
16 * 2 = 32
16 * 8 = 128
16 * 10 = 160
16 * 16 = 256
16 * 255 = 4080
16 * 65535 = 1048560
16 * 2147483647 = 34359738352
16 * 4294967295 = 68719476720
16 * 18446744073709551615 = 18446744073709551600
255 * 0 = 0
255 * 1 = 255
255 * 2 = 510
255 * 8 = 2040
255 * 10 = 2550
255 * 16 = 4080
255 * 255 = 65025
255 * 65535 = 16711425
255 * 2147483647 = 547608329985
255 * 4294967295 = 1095216660225
255 * 18446744073709551615 = 18446744073709551361
65535 * 0 = 0
65535 * 1 = 65535
65535 * 2 = 131070
65535 * 8 = 524280
65535 * 10 = 655350
65535 * 16 = 1048560
65535 * 255 = 16711425
65535 * 65535 = 4294836225
65535 * 2147483647 = 140735340806145
65535 * 4294967295 = 281470681677825
65535 * 18446744073709551615 = 18446744073709486081
2147483647 * 0 = 0
2147483647 * 1 = 2147483647
2147483647 * 2 = 4294967294
2147483647 * 8 = 17179869176
2147483647 * 10 = 21474836470
2147483647 * 16 = 34359738352
2147483647 * 255 = 547608329985
2147483647 * 65535 = 140735340806145
2147483647 * 2147483647 = 4611686014132420609
2147483647 * 4294967295 = 9223372030412324865
2147483647 * 18446744073709551615 = 18446744071562067969
4294967295 * 0 = 0
4294967295 * 1 = 4294967295
4294967295 * 2 = 8589934590
4294967295 * 8 = 34359738360
4294967295 * 10 = 42949672950
4294967295 * 16 = 68719476720
4294967295 * 255 = 1095216660225
4294967295 * 65535 = 281470681677825
4294967295 * 2147483647 = 9223372030412324865
4294967295 * 4294967295 = 18446744065119617025
4294967295 * 18446744073709551615 = 18446744069414584321
18446744073709551615 * 0 = 0
18446744073709551615 * 1 = 18446744073709551615
18446744073709551615 * 2 = 18446744073709551614
18446744073709551615 * 8 = 18446744073709551608
18446744073709551615 * 10 = 18446744073709551606
18446744073709551615 * 16 = 18446744073709551600
18446744073709551615 * 255 = 18446744073709551361
18446744073709551615 * 65535 = 18446744073709486081
18446744073709551615 * 2147483647 = 18446744071562067969
18446744073709551615 * 4294967295 = 18446744069414584321
18446744073709551615 * 18446744073709551615 = 1
*** Test binary operation '/' ***
0 / 0 = <<exception>>
0 / 1 = 0
0 / 2 = 0
0 / 8 = 0
0 / 10 = 0
0 / 16 = 0
0 / 255 = 0
0 / 65535 = 0
0 / 2147483647 = 0
0 / 4294967295 = 0
0 / 18446744073709551615 = 0
1 / 0 = <<exception>>
1 / 1 = 1
1 / 2 = 0
1 / 8 = 0
1 / 10 = 0
1 / 16 = 0
1 / 255 = 0
1 / 65535 = 0
1 / 2147483647 = 0
1 / 4294967295 = 0
1 / 18446744073709551615 = 0
2 / 0 = <<exception>>
2 / 1 = 2
2 / 2 = 1
2 / 8 = 0
2 / 10 = 0
2 / 16 = 0
2 / 255 = 0
2 / 65535 = 0
2 / 2147483647 = 0
2 / 4294967295 = 0
2 / 18446744073709551615 = 0
8 / 0 = <<exception>>
8 / 1 = 8
8 / 2 = 4
8 / 8 = 1
8 / 10 = 0
8 / 16 = 0
8 / 255 = 0
8 / 65535 = 0
8 / 2147483647 = 0
8 / 4294967295 = 0
8 / 18446744073709551615 = 0
10 / 0 = <<exception>>
10 / 1 = 10
10 / 2 = 5
10 / 8 = 1
10 / 10 = 1
10 / 16 = 0
10 / 255 = 0
10 / 65535 = 0
10 / 2147483647 = 0
10 / 4294967295 = 0
10 / 18446744073709551615 = 0
16 / 0 = <<exception>>
16 / 1 = 16
16 / 2 = 8
16 / 8 = 2
16 / 10 = 1
16 / 16 = 1
16 / 255 = 0
16 / 65535 = 0
16 / 2147483647 = 0
16 / 4294967295 = 0
16 / 18446744073709551615 = 0
255 / 0 = <<exception>>
255 / 1 = 255
255 / 2 = 127
255 / 8 = 31
255 / 10 = 25
255 / 16 = 15
255 / 255 = 1
255 / 65535 = 0
255 / 2147483647 = 0
255 / 4294967295 = 0
255 / 18446744073709551615 = 0
65535 / 0 = <<exception>>
65535 / 1 = 65535
65535 / 2 = 32767
65535 / 8 = 8191
65535 / 10 = 6553
65535 / 16 = 4095
65535 / 255 = 257
65535 / 65535 = 1
65535 / 2147483647 = 0
65535 / 4294967295 = 0
65535 / 18446744073709551615 = 0
2147483647 / 0 = <<exception>>
2147483647 / 1 = 2147483647
2147483647 / 2 = 1073741823
2147483647 / 8 = 268435455
2147483647 / 10 = 214748364
2147483647 / 16 = 134217727
2147483647 / 255 = 8421504
2147483647 / 65535 = 32768
2147483647 / 2147483647 = 1
2147483647 / 4294967295 = 0
2147483647 / 18446744073709551615 = 0
4294967295 / 0 = <<exception>>
4294967295 / 1 = 4294967295
4294967295 / 2 = 2147483647
4294967295 / 8 = 536870911
4294967295 / 10 = 429496729
4294967295 / 16 = 268435455
4294967295 / 255 = 16843009
4294967295 / 65535 = 65537
4294967295 / 2147483647 = 2
4294967295 / 4294967295 = 1
4294967295 / 18446744073709551615 = 0
18446744073709551615 / 0 = <<exception>>
18446744073709551615 / 1 = 18446744073709551615
18446744073709551615 / 2 = 9223372036854775807
18446744073709551615 / 8 = 2305843009213693951
18446744073709551615 / 10 = 1844674407370955161
18446744073709551615 / 16 = 1152921504606846975
18446744073709551615 / 255 = 72340172838076673
18446744073709551615 / 65535 = 281479271743489
18446744073709551615 / 2147483647 = 8589934596
18446744073709551615 / 4294967295 = 4294967297
18446744073709551615 / 18446744073709551615 = 1
*** Test binary operation 'rem' ***
0 rem 0 = <<exception>>
0 rem 1 = 0
0 rem 2 = 0
0 rem 8 = 0
0 rem 10 = 0
0 rem 16 = 0
0 rem 255 = 0
0 rem 65535 = 0
0 rem 2147483647 = 0
0 rem 4294967295 = 0
0 rem 18446744073709551615 = 0
1 rem 0 = <<exception>>
1 rem 1 = 0
1 rem 2 = 1
1 rem 8 = 1
1 rem 10 = 1
1 rem 16 = 1
1 rem 255 = 1
1 rem 65535 = 1
1 rem 2147483647 = 1
1 rem 4294967295 = 1
1 rem 18446744073709551615 = 1
2 rem 0 = <<exception>>
2 rem 1 = 0
2 rem 2 = 0
2 rem 8 = 2
2 rem 10 = 2
2 rem 16 = 2
2 rem 255 = 2
2 rem 65535 = 2
2 rem 2147483647 = 2
2 rem 4294967295 = 2
2 rem 18446744073709551615 = 2
8 rem 0 = <<exception>>
8 rem 1 = 0
8 rem 2 = 0
8 rem 8 = 0
8 rem 10 = 8
8 rem 16 = 8
8 rem 255 = 8
8 rem 65535 = 8
8 rem 2147483647 = 8
8 rem 4294967295 = 8
8 rem 18446744073709551615 = 8
10 rem 0 = <<exception>>
10 rem 1 = 0
10 rem 2 = 0
10 rem 8 = 2
10 rem 10 = 0
10 rem 16 = 10
10 rem 255 = 10
10 rem 65535 = 10
10 rem 2147483647 = 10
10 rem 4294967295 = 10
10 rem 18446744073709551615 = 10
16 rem 0 = <<exception>>
16 rem 1 = 0
16 rem 2 = 0
16 rem 8 = 0
16 rem 10 = 6
16 rem 16 = 0
16 rem 255 = 16
16 rem 65535 = 16
16 rem 2147483647 = 16
16 rem 4294967295 = 16
16 rem 18446744073709551615 = 16
255 rem 0 = <<exception>>
255 rem 1 = 0
255 rem 2 = 1
255 rem 8 = 7
255 rem 10 = 5
255 rem 16 = 15
255 rem 255 = 0
255 rem 65535 = 255
255 rem 2147483647 = 255
255 rem 4294967295 = 255
255 rem 18446744073709551615 = 255
65535 rem 0 = <<exception>>
65535 rem 1 = 0
65535 rem 2 = 1
65535 rem 8 = 7
65535 rem 10 = 5
65535 rem 16 = 15
65535 rem 255 = 0
65535 rem 65535 = 0
65535 rem 2147483647 = 65535
65535 rem 4294967295 = 65535
65535 rem 18446744073709551615 = 65535
2147483647 rem 0 = <<exception>>
2147483647 rem 1 = 0
2147483647 rem 2 = 1
2147483647 rem 8 = 7
2147483647 rem 10 = 7
2147483647 rem 16 = 15
2147483647 rem 255 = 127
2147483647 rem 65535 = 32767
2147483647 rem 2147483647 = 0
2147483647 rem 4294967295 = 2147483647
2147483647 rem 18446744073709551615 = 2147483647
4294967295 rem 0 = <<exception>>
4294967295 rem 1 = 0
4294967295 rem 2 = 1
4294967295 rem 8 = 7
4294967295 rem 10 = 5
4294967295 rem 16 = 15
4294967295 rem 255 = 0
4294967295 rem 65535 = 0
4294967295 rem 2147483647 = 1
4294967295 rem 4294967295 = 0
4294967295 rem 18446744073709551615 = 4294967295
18446744073709551615 rem 0 = <<exception>>
18446744073709551615 rem 1 = 0
18446744073709551615 rem 2 = 1
18446744073709551615 rem 8 = 7
18446744073709551615 rem 10 = 5
18446744073709551615 rem 16 = 15
18446744073709551615 rem 255 = 0
18446744073709551615 rem 65535 = 0
18446744073709551615 rem 2147483647 = 3
18446744073709551615 rem 4294967295 = 0
18446744073709551615 rem 18446744073709551615 = 0