diff --git a/test/float/data.sail b/test/float/data.sail new file mode 100644 index 000000000..48b63bffc --- /dev/null +++ b/test/float/data.sail @@ -0,0 +1,141 @@ +/*==========================================================================*/ +/* Sail */ +/* */ +/* Copyright 2024 Intel Corporation */ +/* Pan Li - pan2.li@intel.com */ +/* */ +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions are */ +/* met: */ +/* */ +/* 1. Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in the */ +/* documentation and/or other materials provided with the distribution. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */ +/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */ +/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ +/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/*==========================================================================*/ + +$ifndef _FLOAT_DATA +$define _FLOAT_DATA + +/* Half floating point */ +let fp16_pos_snan_0 = 0x7c01 +let fp16_pos_snan_1 = 0x7d10 +let fp16_neg_snan_0 = 0xfc01 +let fp16_neg_snan_1 = 0xfd10 + +let fp16_pos_qnan_0 = 0x7e00 +let fp16_pos_qnan_1 = 0x7e01 +let fp16_neg_qnan_0 = 0xfe00 +let fp16_neg_qnan_1 = 0xfe01 + +let fp16_pos_inf = 0x7c00 +let fp16_neg_inf = 0xfc00 + +let fp16_pos_zero = 0x0000 +let fp16_neg_zero = 0x8000 + +let fp16_pos_denormal_0 = 0x0200 +let fp16_pos_denormal_1 = 0x02f0 +let fp16_neg_denormal_0 = 0x8200 +let fp16_neg_denormal_1 = 0x82f0 + +let fp16_pos_normal_0 = 0x7a00 +let fp16_pos_normal_1 = 0x71ff +let fp16_neg_normal_0 = 0xfa00 +let fp16_neg_normal_1 = 0xf1ff + +/* Single floating point */ +let fp32_pos_snan_0 = 0x7f800001 +let fp32_pos_snan_1 = 0x7f8f0000 +let fp32_neg_snan_0 = 0xff800001 +let fp32_neg_snan_1 = 0xff8f0000 + +let fp32_pos_qnan_0 = 0x7fc00000 +let fp32_pos_qnan_1 = 0x7fc00001 +let fp32_neg_qnan_0 = 0xffc00000 +let fp32_neg_qnan_1 = 0xffc00001 + +let fp32_pos_inf = 0x7f800000 +let fp32_neg_inf = 0xff800000 + +let fp32_pos_zero = 0x00000000 +let fp32_neg_zero = 0x80000000 + +let fp32_pos_denormal_0 = 0x00700000 +let fp32_pos_denormal_1 = 0x0010ff01 +let fp32_neg_denormal_0 = 0x80700000 +let fp32_neg_denormal_1 = 0x8010ff01 + +let fp32_pos_normal_0 = 0x1a000000 +let fp32_pos_normal_1 = 0x0100002f +let fp32_neg_normal_0 = 0x9a000000 +let fp32_neg_normal_1 = 0x8100002f + +/* Double floating point */ +let fp64_pos_snan_0 = 0x7ff0000000000001 +let fp64_pos_snan_1 = 0x7ff7000000000000 +let fp64_neg_snan_0 = 0xfff0000000000001 +let fp64_neg_snan_1 = 0xfff7000000000000 + +let fp64_pos_qnan_0 = 0x7ff8000000000000 +let fp64_pos_qnan_1 = 0x7fff000000000000 +let fp64_neg_qnan_0 = 0xfff8000000000000 +let fp64_neg_qnan_1 = 0xffff000000000000 + +let fp64_pos_inf = 0x7ff0000000000000 +let fp64_neg_inf = 0xfff0000000000000 + +let fp64_pos_zero = 0x0000000000000000 +let fp64_neg_zero = 0x8000000000000000 + +let fp64_pos_denormal_0 = 0x000f000000000000 +let fp64_pos_denormal_1 = 0x0000000fff000000 +let fp64_neg_denormal_0 = 0x800f000000000000 +let fp64_neg_denormal_1 = 0x8000000fff000000 + +let fp64_pos_normal_0 = 0x1000000000000000 +let fp64_pos_normal_1 = 0x0100001111000000 +let fp64_neg_normal_0 = 0x9000000000000000 +let fp64_neg_normal_1 = 0x8100001111000000 + +/* Quad floating point */ +let fp128_pos_snan_0 = 0x7fff0000000000000000000000000001 +let fp128_pos_snan_1 = 0x7fff000000000000ff00000000000000 +let fp128_neg_snan_0 = 0xffff0000000000000000000000000001 +let fp128_neg_snan_1 = 0xffff000000000000ff00000000000000 + +let fp128_pos_qnan_0 = 0x7fff8000000000000000000000000001 +let fp128_pos_qnan_1 = 0x7fff8d00000000000000000000000000 +let fp128_neg_qnan_0 = 0xffff8000000000000000000000000001 +let fp128_neg_qnan_1 = 0xffff8d00000000000000000000000000 + +let fp128_pos_inf = 0x7fff0000000000000000000000000000 +let fp128_neg_inf = 0xffff0000000000000000000000000000 + +let fp128_pos_zero = 0x00000000000000000000000000000000 +let fp128_neg_zero = 0x80000000000000000000000000000000 + +let fp128_pos_denormal_0 = 0x0000f000000000000000000000000000 +let fp128_pos_denormal_1 = 0x0000000fff0000000000000000000000 +let fp128_neg_denormal_0 = 0x8000f000000000000000000000000000 +let fp128_neg_denormal_1 = 0x8000000fff0000000000000000000000 + +let fp128_pos_normal_0 = 0x10000000000000000000000000000000 +let fp128_pos_normal_1 = 0x01000011110000000000000000000000 +let fp128_neg_normal_0 = 0x90000000000000000000000000000000 +let fp128_neg_normal_1 = 0x81000011110000000000000000000000 + +$endif diff --git a/test/float/eq_test.sail b/test/float/eq_test.sail index 7b8d2c562..8d5bd9952 100644 --- a/test/float/eq_test.sail +++ b/test/float/eq_test.sail @@ -32,63 +32,64 @@ default Order dec $include $include $include "tuple_equality.sail" +$include "data.sail" function test_float_is_eq () -> unit = { /* Half floating point */ - assert(float_is_eq((0x0001, 0x0001)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0700, 0x0700)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0000, 0x8000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x7c00, 0x7c00)) == (true, fp_eflag_none)); + assert(float_is_eq((fp16_pos_denormal_0, fp16_pos_denormal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp16_neg_normal_0, fp16_neg_normal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp16_neg_inf, fp16_neg_inf)) == (true, fp_eflag_none)); + assert(float_is_eq((fp16_pos_zero, fp16_neg_zero)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0001, 0x8001)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7c00, 0xfc00)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7e01, 0x7a01)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7ef1, 0x7ef1)) == (false, fp_eflag_none)); + assert(float_is_eq((fp16_pos_denormal_0, fp16_neg_normal_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp16_pos_inf, fp16_neg_inf)) == (false, fp_eflag_none)); + assert(float_is_eq((fp16_pos_qnan_0, fp16_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp16_pos_qnan_0, fp16_pos_qnan_1)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7c01, 0x7e0f)) == (false, fp_eflag_invalid)); - assert(float_is_eq((0xf021, 0x7c0f)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp16_pos_snan_0, fp16_pos_normal_0)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp16_pos_snan_1, fp16_neg_zero)) == (false, fp_eflag_invalid)); /* Single floating point */ - assert(float_is_eq((0x00001000, 0x00001000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x80301000, 0x80301000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x00000000, 0x80000000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x7f800000, 0x7f800000)) == (true, fp_eflag_none)); + assert(float_is_eq((fp32_pos_denormal_0, fp32_pos_denormal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp32_neg_normal_0, fp32_neg_normal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp32_neg_inf, fp32_neg_inf)) == (true, fp_eflag_none)); + assert(float_is_eq((fp32_pos_zero, fp32_neg_zero)) == (true, fp_eflag_none)); - assert(float_is_eq((0x00001000, 0x80001000)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7fc00000, 0x80301000)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7fc00001, 0x01234000)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7f800000, 0xff800000)) == (false, fp_eflag_none)); + assert(float_is_eq((fp32_pos_denormal_0, fp32_neg_normal_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp32_pos_inf, fp32_neg_inf)) == (false, fp_eflag_none)); + assert(float_is_eq((fp32_pos_qnan_0, fp32_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp32_pos_qnan_0, fp32_pos_qnan_1)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7f800001, 0x01234000)) == (false, fp_eflag_invalid)); - assert(float_is_eq((0x7c800000, 0xff80000f)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp32_pos_snan_0, fp32_pos_normal_0)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp32_pos_snan_1, fp32_neg_zero)) == (false, fp_eflag_invalid)); /* Double floating point */ - assert(float_is_eq((0x0000000000000001, 0x0000000000000001)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0f0000000000000f, 0x0f0000000000000f)) == (true, fp_eflag_none)); - assert(float_is_eq((0x8000000000000000, 0x0000000000000000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x7ff0000000000000, 0x7ff0000000000000)) == (true, fp_eflag_none)); + assert(float_is_eq((fp64_pos_denormal_0, fp64_pos_denormal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp64_neg_normal_0, fp64_neg_normal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp64_neg_inf, fp64_neg_inf)) == (true, fp_eflag_none)); + assert(float_is_eq((fp64_pos_zero, fp64_neg_zero)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0000000000000001, 0x8000000000000001)) == (false, fp_eflag_none)); - assert(float_is_eq((0x0f0000000000000f, 0x3f0000000000000f)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7ff8000000000000, 0x0000234db0000000)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7ff8000000000000, 0xfff8000000000000)) == (false, fp_eflag_none)); + assert(float_is_eq((fp64_pos_denormal_0, fp64_neg_normal_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp64_pos_inf, fp64_neg_inf)) == (false, fp_eflag_none)); + assert(float_is_eq((fp64_pos_qnan_0, fp64_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp64_pos_qnan_0, fp64_pos_qnan_1)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7ff7000000000000, 0x0000234db0000000)) == (false, fp_eflag_invalid)); - assert(float_is_eq((0x7ff0000000000001, 0xfff0000003000001)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp64_pos_snan_0, fp64_pos_normal_0)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp64_pos_snan_1, fp64_neg_zero)) == (false, fp_eflag_invalid)); /* Quad floating point */ - assert(float_is_eq((0x00000000000000000000000000000001, 0x00000000000000000000000000000001)) == (true, fp_eflag_none)); - assert(float_is_eq((0x0f00000000000000000000000000000f, 0x0f00000000000000000000000000000f)) == (true, fp_eflag_none)); - assert(float_is_eq((0x80000000000000000000000000000000, 0x00000000000000000000000000000000)) == (true, fp_eflag_none)); - assert(float_is_eq((0x7fff0000000000000000000000000000, 0x7fff0000000000000000000000000000)) == (true, fp_eflag_none)); + assert(float_is_eq((fp128_pos_denormal_0, fp128_pos_denormal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp128_neg_normal_0, fp128_neg_normal_0)) == (true, fp_eflag_none)); + assert(float_is_eq((fp128_neg_inf, fp128_neg_inf)) == (true, fp_eflag_none)); + assert(float_is_eq((fp128_pos_zero, fp128_neg_zero)) == (true, fp_eflag_none)); - assert(float_is_eq((0x00000000000000000000000000000001, 0x80000000000000000000000000000001)) == (false, fp_eflag_none)); - assert(float_is_eq((0x0f00000000000000000000000000000f, 0x3f00000000000000000000000000000f)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7fff8000000000000000000000000000, 0x0000234db00000000000000000000000)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7fff8000000000000000000000000000, 0xffff8000000000000000000000000000)) == (false, fp_eflag_none)); + assert(float_is_eq((fp128_pos_denormal_0, fp128_neg_normal_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp128_pos_inf, fp128_neg_inf)) == (false, fp_eflag_none)); + assert(float_is_eq((fp128_pos_qnan_0, fp128_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_eq((fp128_pos_qnan_0, fp128_pos_qnan_1)) == (false, fp_eflag_none)); - assert(float_is_eq((0x7fff7000000000000000000000000000, 0x0000234db00000000000000000000000)) == (false, fp_eflag_invalid)); - assert(float_is_eq((0x7fff0000000000000000000000000001, 0xfff00000030000000000000000000001)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp128_pos_snan_0, fp128_pos_normal_0)) == (false, fp_eflag_invalid)); + assert(float_is_eq((fp128_pos_snan_1, fp128_neg_zero)) == (false, fp_eflag_invalid)); } function main () -> unit = { diff --git a/test/float/inf_test.sail b/test/float/inf_test.sail index 764dc5d69..a225c7191 100644 --- a/test/float/inf_test.sail +++ b/test/float/inf_test.sail @@ -31,51 +31,52 @@ default Order dec $include $include +$include "data.sail" function test_float_is_inf () -> unit = { /* Half floating point */ - assert(float_is_inf(0x7c00)); - assert(float_is_inf(0xfc00)); + assert(float_is_inf(fp16_pos_inf)); + assert(float_is_inf(fp16_neg_inf)); - assert(float_is_inf(0x7a00) == false); - assert(float_is_inf(0x7b00) == false); - assert(float_is_inf(0x7e00) == false); - assert(float_is_inf(0xca00) == false); - assert(float_is_inf(0xdb00) == false); - assert(float_is_inf(0xfe00) == false); + assert(float_is_inf(fp16_pos_snan_0) == false); + assert(float_is_inf(fp16_neg_qnan_0) == false); + assert(float_is_inf(fp16_pos_zero) == false); + assert(float_is_inf(fp16_neg_zero) == false); + assert(float_is_inf(fp16_pos_denormal_0) == false); + assert(float_is_inf(fp16_neg_normal_0) == false); /* Single floating point */ - assert(float_is_inf(0x7f800000)); - assert(float_is_inf(0xff800000)); + assert(float_is_inf(fp32_pos_inf)); + assert(float_is_inf(fp32_neg_inf)); - assert(float_is_inf(0x7fc00000) == false); - assert(float_is_inf(0x7f000001) == false); - assert(float_is_inf(0x7e800000) == false); - assert(float_is_inf(0xffc00000) == false); - assert(float_is_inf(0xff000001) == false); - assert(float_is_inf(0xfe800000) == false); + assert(float_is_inf(fp32_pos_snan_0) == false); + assert(float_is_inf(fp32_neg_qnan_0) == false); + assert(float_is_inf(fp32_pos_zero) == false); + assert(float_is_inf(fp32_neg_zero) == false); + assert(float_is_inf(fp32_pos_denormal_0) == false); + assert(float_is_inf(fp32_neg_normal_0) == false); /* Double floating point */ - assert(float_is_inf(0x7ff0000000000000)); - assert(float_is_inf(0xfff0000000000000)); + assert(float_is_inf(fp64_pos_inf)); + assert(float_is_inf(fp64_neg_inf)); - assert(float_is_inf(0x7ff8000000000000) == false); - assert(float_is_inf(0x7ff0000000000001) == false); - assert(float_is_inf(0x7fc0000000000000) == false); - assert(float_is_inf(0xfff8000000000000) == false); - assert(float_is_inf(0xfff0000000000001) == false); - assert(float_is_inf(0xffc0000000000000) == false); + assert(float_is_inf(fp64_pos_snan_0) == false); + assert(float_is_inf(fp64_neg_qnan_0) == false); + assert(float_is_inf(fp64_pos_zero) == false); + assert(float_is_inf(fp64_neg_zero) == false); + assert(float_is_inf(fp64_pos_denormal_0) == false); + assert(float_is_inf(fp64_neg_normal_0) == false); /* Quad floating point */ - assert(float_is_inf(0x7fff0000000000000000000000000000)); - assert(float_is_inf(0xffff0000000000000000000000000000)); + assert(float_is_inf(fp128_pos_inf)); + assert(float_is_inf(fp128_neg_inf)); - assert(float_is_inf(0x7fff8000000000000000000000000000) == false); - assert(float_is_inf(0x7fff0000000000000000000000000001) == false); - assert(float_is_inf(0x7ffc0000000000000000000000000000) == false); - assert(float_is_inf(0xffff8000000000000000000000000000) == false); - assert(float_is_inf(0xffff0000000000000000000000000001) == false); - assert(float_is_inf(0xfffc0000000000000000000000000000) == false); + assert(float_is_inf(fp128_pos_snan_0) == false); + assert(float_is_inf(fp128_neg_qnan_0) == false); + assert(float_is_inf(fp128_pos_zero) == false); + assert(float_is_inf(fp128_neg_zero) == false); + assert(float_is_inf(fp128_pos_denormal_0) == false); + assert(float_is_inf(fp128_neg_normal_0) == false); } function main () -> unit = { diff --git a/test/float/nan_test.sail b/test/float/nan_test.sail index e86cba966..8546596bc 100644 --- a/test/float/nan_test.sail +++ b/test/float/nan_test.sail @@ -31,172 +31,188 @@ default Order dec $include $include +$include "data.sail" function test_float_is_nan () -> unit = { /* Half floating point */ - assert(float_is_nan(0x7e00)); - assert(float_is_nan(0x7c01)); - assert(float_is_nan(0x7c10)); - assert(float_is_nan(0x7f01)); - - assert(float_is_nan(0xfe00)); - assert(float_is_nan(0xfc01)); - assert(float_is_nan(0xfc10)); - assert(float_is_nan(0xff01)); - - assert(float_is_nan(0x7a00) == false); - assert(float_is_nan(0x7b00) == false); - assert(float_is_nan(0x7c00) == false); - assert(float_is_nan(0xca00) == false); - assert(float_is_nan(0xdb00) == false); - assert(float_is_nan(0xfc00) == false); + assert(float_is_nan(fp16_pos_snan_0)); + assert(float_is_nan(fp16_pos_snan_1)); + assert(float_is_nan(fp16_pos_qnan_0)); + assert(float_is_nan(fp16_pos_qnan_1)); + + assert(float_is_nan(fp16_neg_snan_0)); + assert(float_is_nan(fp16_neg_snan_1)); + assert(float_is_nan(fp16_neg_qnan_0)); + assert(float_is_nan(fp16_neg_qnan_1)); + + assert(float_is_nan(fp16_pos_inf) == false); + assert(float_is_nan(fp16_neg_zero) == false); + assert(float_is_nan(fp16_pos_denormal_0) == false); + assert(float_is_nan(fp16_pos_denormal_1) == false); + assert(float_is_nan(fp16_neg_normal_0) == false); + assert(float_is_nan(fp16_neg_normal_1) == false); /* Single floating point */ - assert(float_is_nan(0x7fc00000)); - assert(float_is_nan(0x7f800001)); - assert(float_is_nan(0x7fc00100)); - assert(float_is_nan(0x7ff10000)); - - assert(float_is_nan(0xffc00000)); - assert(float_is_nan(0xff800001)); - assert(float_is_nan(0xffc00100)); - assert(float_is_nan(0xfff10000)); - - assert(float_is_nan(0x7f800000) == false); - assert(float_is_nan(0x7f000000) == false); - assert(float_is_nan(0x7e800000) == false); - assert(float_is_nan(0xcf800000) == false); - assert(float_is_nan(0xdf000000) == false); - assert(float_is_nan(0xfe800000) == false); + assert(float_is_nan(fp32_pos_snan_0)); + assert(float_is_nan(fp32_pos_snan_1)); + assert(float_is_nan(fp32_pos_qnan_0)); + assert(float_is_nan(fp32_pos_qnan_1)); + + assert(float_is_nan(fp32_neg_snan_0)); + assert(float_is_nan(fp32_neg_snan_1)); + assert(float_is_nan(fp32_neg_qnan_0)); + assert(float_is_nan(fp32_neg_qnan_1)); + + assert(float_is_nan(fp32_pos_inf) == false); + assert(float_is_nan(fp32_neg_zero) == false); + assert(float_is_nan(fp32_pos_denormal_0) == false); + assert(float_is_nan(fp32_pos_denormal_1) == false); + assert(float_is_nan(fp32_neg_normal_0) == false); + assert(float_is_nan(fp32_neg_normal_1) == false); /* Double floating point */ - assert(float_is_nan(0x7ff8000000000000)); - assert(float_is_nan(0x7ff0000000000001)); - assert(float_is_nan(0x7ff8000000000100)); - assert(float_is_nan(0x7ffc000000100000)); - - assert(float_is_nan(0xfff8000000000000)); - assert(float_is_nan(0xfff0000000000001)); - assert(float_is_nan(0xfff8000000000100)); - assert(float_is_nan(0xfffc000000100000)); - - assert(float_is_nan(0x7ff0000000000000) == false); - assert(float_is_nan(0x7fe0000000000000) == false); - assert(float_is_nan(0x7fc0000000000000) == false); - assert(float_is_nan(0xfff0000000000000) == false); - assert(float_is_nan(0xffe0000000000000) == false); - assert(float_is_nan(0xffc0000000000000) == false); + assert(float_is_nan(fp64_pos_snan_0)); + assert(float_is_nan(fp64_pos_snan_1)); + assert(float_is_nan(fp64_pos_qnan_0)); + assert(float_is_nan(fp64_pos_qnan_1)); + + assert(float_is_nan(fp64_neg_snan_0)); + assert(float_is_nan(fp64_neg_snan_1)); + assert(float_is_nan(fp64_neg_qnan_0)); + assert(float_is_nan(fp64_neg_qnan_1)); + + assert(float_is_nan(fp64_pos_inf) == false); + assert(float_is_nan(fp64_neg_zero) == false); + assert(float_is_nan(fp64_pos_denormal_0) == false); + assert(float_is_nan(fp64_pos_denormal_1) == false); + assert(float_is_nan(fp64_neg_normal_0) == false); + assert(float_is_nan(fp64_neg_normal_1) == false); /* Quad floating point */ - assert(float_is_nan(0x7fff8000000000000000000000000000)); - assert(float_is_nan(0x7fff0000000000000000000000000001)); - assert(float_is_nan(0x7fff8000000000000000000000000100)); - assert(float_is_nan(0x7fffc000000000001000000000000000)); - - assert(float_is_nan(0xffff8000000000000000000000000000)); - assert(float_is_nan(0xffff0000000000000000000000000001)); - assert(float_is_nan(0xffff8000000000000000000000000100)); - assert(float_is_nan(0xffffc000000000001000000000000000)); - - assert(float_is_nan(0x7fff0000000000000000000000000000) == false); - assert(float_is_nan(0x7ffe0000000000000000000000000000) == false); - assert(float_is_nan(0x7ffc0000000000000000000000000000) == false); - assert(float_is_nan(0xffff0000000000000000000000000000) == false); - assert(float_is_nan(0xfffe0000000000000000000000000000) == false); - assert(float_is_nan(0xfffc0000000000000000000000000000) == false); + assert(float_is_nan(fp128_pos_snan_0)); + assert(float_is_nan(fp128_pos_snan_1)); + assert(float_is_nan(fp128_pos_qnan_0)); + assert(float_is_nan(fp128_pos_qnan_1)); + + assert(float_is_nan(fp128_neg_snan_0)); + assert(float_is_nan(fp128_neg_snan_1)); + assert(float_is_nan(fp128_neg_qnan_0)); + assert(float_is_nan(fp128_neg_qnan_1)); + + assert(float_is_nan(fp128_pos_inf) == false); + assert(float_is_nan(fp128_neg_zero) == false); + assert(float_is_nan(fp128_pos_denormal_0) == false); + assert(float_is_nan(fp128_pos_denormal_1) == false); + assert(float_is_nan(fp128_neg_normal_0) == false); + assert(float_is_nan(fp128_neg_normal_1) == false); } function test_float_is_snan () -> unit = { /* Half floating point */ - assert(float_is_snan(0x7d00)); - assert(float_is_snan(0x7d01)); - - assert(float_is_snan(0xfd00)); - assert(float_is_snan(0xfd01)); - - assert(float_is_snan(0x7e00) == false); - assert(float_is_snan(0xde01) == false); - assert(float_is_snan(0xff01) == false); + assert(float_is_snan(fp16_pos_snan_0)); + assert(float_is_snan(fp16_pos_snan_1)); + assert(float_is_snan(fp16_neg_snan_0)); + assert(float_is_snan(fp16_neg_snan_1)); + + assert(float_is_snan(fp16_pos_inf) == false); + assert(float_is_snan(fp16_neg_zero) == false); + assert(float_is_snan(fp16_pos_qnan_0) == false); + assert(float_is_snan(fp16_neg_qnan_0) == false); + assert(float_is_snan(fp16_pos_denormal_0) == false); + assert(float_is_snan(fp16_neg_normal_0) == false); /* Single floating point */ - assert(float_is_snan(0x7fa00000)); - assert(float_is_snan(0x7fa00001)); - - assert(float_is_snan(0xffa00000)); - assert(float_is_snan(0xffa00001)); - - assert(float_is_snan(0x7fc00000) == false); - assert(float_is_snan(0xffc00001) == false); - assert(float_is_snan(0xfec00001) == false); + assert(float_is_snan(fp32_pos_snan_0)); + assert(float_is_snan(fp32_pos_snan_1)); + assert(float_is_snan(fp32_neg_snan_0)); + assert(float_is_snan(fp32_neg_snan_1)); + + assert(float_is_snan(fp32_pos_inf) == false); + assert(float_is_snan(fp32_neg_zero) == false); + assert(float_is_snan(fp32_pos_qnan_0) == false); + assert(float_is_snan(fp32_neg_qnan_0) == false); + assert(float_is_snan(fp32_pos_denormal_0) == false); + assert(float_is_snan(fp32_neg_normal_0) == false); /* Double floating point */ - assert(float_is_snan(0x7ff7000000000000)); - assert(float_is_snan(0x7ff7000000000001)); - - assert(float_is_snan(0xfff7000000000000)); - assert(float_is_snan(0xfff7000000000001)); - - assert(float_is_snan(0x7ff8000000000000) == false); - assert(float_is_snan(0xfff8000000000000) == false); - assert(float_is_snan(0xfef8000000000001) == false); + assert(float_is_snan(fp64_pos_snan_0)); + assert(float_is_snan(fp64_pos_snan_1)); + assert(float_is_snan(fp64_neg_snan_0)); + assert(float_is_snan(fp64_neg_snan_1)); + + assert(float_is_snan(fp64_pos_inf) == false); + assert(float_is_snan(fp64_neg_zero) == false); + assert(float_is_snan(fp64_pos_qnan_0) == false); + assert(float_is_snan(fp64_neg_qnan_0) == false); + assert(float_is_snan(fp64_pos_denormal_0) == false); + assert(float_is_snan(fp64_neg_normal_0) == false); /* Quad floating point */ - assert(float_is_snan(0x7fff7000000000000000000000000000)); - assert(float_is_snan(0x7fff7000000000000000000000000001)); - - assert(float_is_snan(0xffff7000000000000000000000000000)); - assert(float_is_snan(0xffff7000000000000000000000000001)); - - assert(float_is_snan(0x7fff8000000000000000000000000000) == false); - assert(float_is_snan(0xffff8000000000000000000000000000) == false); - assert(float_is_snan(0xfeff8000000000000000000000000001) == false); - + assert(float_is_snan(fp128_pos_snan_0)); + assert(float_is_snan(fp128_pos_snan_1)); + assert(float_is_snan(fp128_neg_snan_0)); + assert(float_is_snan(fp128_neg_snan_1)); + + assert(float_is_snan(fp128_pos_inf) == false); + assert(float_is_snan(fp128_neg_zero) == false); + assert(float_is_snan(fp128_pos_qnan_0) == false); + assert(float_is_snan(fp128_neg_qnan_0) == false); + assert(float_is_snan(fp128_pos_denormal_0) == false); + assert(float_is_snan(fp128_neg_normal_0) == false); } function test_float_is_qnan () -> unit = { /* Half floating point */ - assert(float_is_qnan(0x7e00)); - assert(float_is_qnan(0x7e01)); - - assert(float_is_qnan(0xfe00)); - assert(float_is_qnan(0xfe01)); - - assert(float_is_qnan(0x7c00) == false); - assert(float_is_qnan(0xdc01) == false); - assert(float_is_qnan(0xfc01) == false); + assert(float_is_qnan(fp16_pos_qnan_0)); + assert(float_is_qnan(fp16_pos_qnan_1)); + assert(float_is_qnan(fp16_neg_qnan_0)); + assert(float_is_qnan(fp16_neg_qnan_1)); + + assert(float_is_qnan(fp16_pos_inf) == false); + assert(float_is_qnan(fp16_neg_zero) == false); + assert(float_is_qnan(fp16_pos_snan_0) == false); + assert(float_is_qnan(fp16_neg_snan_0) == false); + assert(float_is_qnan(fp16_pos_denormal_0) == false); + assert(float_is_qnan(fp16_neg_normal_0) == false); /* Single floating pont */ - assert(float_is_qnan(0x7fc00000)); - assert(float_is_qnan(0x7fc00001)); - - assert(float_is_qnan(0xffc00000)); - assert(float_is_qnan(0xffc00001)); - - assert(float_is_qnan(0x7fa00000) == false); - assert(float_is_qnan(0xffa00001) == false); - assert(float_is_qnan(0xfea00001) == false); + assert(float_is_qnan(fp32_pos_qnan_0)); + assert(float_is_qnan(fp32_pos_qnan_1)); + assert(float_is_qnan(fp32_neg_qnan_0)); + assert(float_is_qnan(fp32_neg_qnan_1)); + + assert(float_is_qnan(fp32_pos_inf) == false); + assert(float_is_qnan(fp32_neg_zero) == false); + assert(float_is_qnan(fp32_pos_snan_0) == false); + assert(float_is_qnan(fp32_neg_snan_0) == false); + assert(float_is_qnan(fp32_pos_denormal_0) == false); + assert(float_is_qnan(fp32_neg_normal_0) == false); /* Double floating point */ - assert(float_is_qnan(0x7ff8000000000000)); - assert(float_is_qnan(0x7ff8000000000001)); - - assert(float_is_qnan(0xfff8000000000000)); - assert(float_is_qnan(0xfff8000000000001)); - - assert(float_is_qnan(0x7ff7000000000000) == false); - assert(float_is_qnan(0xfff7000000000000) == false); - assert(float_is_qnan(0xfef7000000000001) == false); + assert(float_is_qnan(fp64_pos_qnan_0)); + assert(float_is_qnan(fp64_pos_qnan_1)); + assert(float_is_qnan(fp64_neg_qnan_0)); + assert(float_is_qnan(fp64_neg_qnan_1)); + + assert(float_is_qnan(fp64_pos_inf) == false); + assert(float_is_qnan(fp64_neg_zero) == false); + assert(float_is_qnan(fp64_pos_snan_0) == false); + assert(float_is_qnan(fp64_neg_snan_0) == false); + assert(float_is_qnan(fp64_pos_denormal_0) == false); + assert(float_is_qnan(fp64_neg_normal_0) == false); /* Quad floating point */ - assert(float_is_qnan(0x7fff8000000000000000000000000000)); - assert(float_is_qnan(0x7fff8000000000000000000000000001)); - - assert(float_is_qnan(0xffff8000000000000000000000000000)); - assert(float_is_qnan(0xffff8000000000000000000000000001)); - - assert(float_is_qnan(0x7fff7000000000000000000000000000) == false); - assert(float_is_qnan(0xffff7000000000000000000000000000) == false); - assert(float_is_qnan(0xfeff7000000000000000000000000001) == false); + assert(float_is_qnan(fp128_pos_qnan_0)); + assert(float_is_qnan(fp128_pos_qnan_1)); + assert(float_is_qnan(fp128_neg_qnan_0)); + assert(float_is_qnan(fp128_neg_qnan_1)); + + assert(float_is_qnan(fp128_pos_inf) == false); + assert(float_is_qnan(fp128_neg_zero) == false); + assert(float_is_qnan(fp128_pos_snan_0) == false); + assert(float_is_qnan(fp128_neg_snan_0) == false); + assert(float_is_qnan(fp128_pos_denormal_0) == false); + assert(float_is_qnan(fp128_neg_normal_0) == false); } function main () -> unit = { diff --git a/test/float/ne_test.sail b/test/float/ne_test.sail index fe1aca723..291aae23f 100644 --- a/test/float/ne_test.sail +++ b/test/float/ne_test.sail @@ -32,63 +32,64 @@ default Order dec $include $include $include "tuple_equality.sail" +$include "data.sail" function test_float_is_ne () -> unit = { /* Half floating point */ - assert(float_is_ne((0x0001, 0x0011)) == (true, fp_eflag_none)); - assert(float_is_ne((0x0701, 0x0700)) == (true, fp_eflag_none)); - assert(float_is_ne((0x0000, 0x0001)) == (true, fp_eflag_none)); - assert(float_is_ne((0x7c00, 0xfc00)) == (true, fp_eflag_none)); + assert(float_is_ne((fp16_pos_denormal_0, fp16_pos_denormal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp16_neg_normal_0, fp16_neg_normal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp16_pos_denormal_1, fp16_pos_zero)) == (true, fp_eflag_none)); + assert(float_is_ne((fp16_pos_inf, fp16_neg_inf)) == (true, fp_eflag_none)); - assert(float_is_ne((0x0001, 0x0001)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7c00, 0x7c00)) == (false, fp_eflag_none)); - assert(float_is_ne((0x0000, 0x8000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7ef1, 0x7ef1)) == (false, fp_eflag_none)); + assert(float_is_ne((fp16_pos_denormal_0, fp16_pos_denormal_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp16_neg_qnan_0, fp16_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp16_pos_zero, fp16_neg_zero)) == (false, fp_eflag_none)); + assert(float_is_ne((fp16_pos_inf, fp16_pos_inf)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7c01, 0x7e0f)) == (false, fp_eflag_invalid)); - assert(float_is_ne((0xf021, 0x7c0f)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp16_pos_snan_0, fp16_pos_snan_0)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp16_pos_snan_1, fp16_pos_normal_0)) == (false, fp_eflag_invalid)); /* Single floating point */ - assert(float_is_ne((0x00001000, 0x80001000)) == (true, fp_eflag_none)); - assert(float_is_ne((0x80300000, 0x80301000)) == (true, fp_eflag_none)); - assert(float_is_ne((0x00000001, 0x80000000)) == (true, fp_eflag_none)); - assert(float_is_ne((0x7f800000, 0xff800000)) == (true, fp_eflag_none)); + assert(float_is_ne((fp32_pos_denormal_0, fp32_pos_denormal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp32_neg_normal_0, fp32_neg_normal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp32_pos_denormal_1, fp32_pos_zero)) == (true, fp_eflag_none)); + assert(float_is_ne((fp32_pos_inf, fp32_neg_inf)) == (true, fp_eflag_none)); - assert(float_is_ne((0x00001000, 0x00001000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x80301000, 0x80301000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x00000000, 0x80000000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7fc00000, 0x7fc00000)) == (false, fp_eflag_none)); + assert(float_is_ne((fp32_pos_denormal_0, fp32_pos_denormal_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp32_neg_qnan_0, fp32_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp32_pos_zero, fp32_neg_zero)) == (false, fp_eflag_none)); + assert(float_is_ne((fp32_pos_inf, fp32_pos_inf)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7f800001, 0x01234000)) == (false, fp_eflag_invalid)); - assert(float_is_ne((0x7c800000, 0xff80000f)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp32_pos_snan_0, fp32_pos_snan_0)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp32_pos_snan_1, fp32_pos_normal_0)) == (false, fp_eflag_invalid)); /* Double floating point */ - assert(float_is_ne((0x8000000000000001, 0x0000000000000001)) == (true, fp_eflag_none)); - assert(float_is_ne((0x8f0000000000000f, 0x0f0000000000000f)) == (true, fp_eflag_none)); - assert(float_is_ne((0x8000000000000000, 0x0000000000000001)) == (true, fp_eflag_none)); - assert(float_is_ne((0x7ff0000000000000, 0xfff0000000000000)) == (true, fp_eflag_none)); + assert(float_is_ne((fp64_pos_denormal_0, fp64_pos_denormal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp64_neg_normal_0, fp64_neg_normal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp64_pos_denormal_1, fp64_pos_zero)) == (true, fp_eflag_none)); + assert(float_is_ne((fp64_pos_inf, fp64_neg_inf)) == (true, fp_eflag_none)); - assert(float_is_ne((0x0000000000000011, 0x0000000000000011)) == (false, fp_eflag_none)); - assert(float_is_ne((0x0fff00000000000f, 0x0fff00000000000f)) == (false, fp_eflag_none)); - assert(float_is_ne((0x0000000000000000, 0x8000000000000000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7ff8000000000100, 0x7ff8000000000100)) == (false, fp_eflag_none)); + assert(float_is_ne((fp64_pos_denormal_0, fp64_pos_denormal_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp64_neg_qnan_0, fp64_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp64_pos_zero, fp64_neg_zero)) == (false, fp_eflag_none)); + assert(float_is_ne((fp64_pos_inf, fp64_pos_inf)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7ff7000000000000, 0x0000234db0000000)) == (false, fp_eflag_invalid)); - assert(float_is_ne((0x7ff0000000000001, 0xfff0000003000001)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp64_pos_snan_0, fp64_pos_snan_0)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp64_pos_snan_1, fp64_pos_normal_0)) == (false, fp_eflag_invalid)); /* Quad floating point */ - assert(float_is_ne((0x80000000000000000000000000000001, 0x00000000000000000000000000000001)) == (true, fp_eflag_none)); - assert(float_is_ne((0x8f00000000000000000000000000000f, 0x0f00000000000000000000000000000f)) == (true, fp_eflag_none)); - assert(float_is_ne((0x80000000000000000000000000000000, 0x00000000000000000000000000000001)) == (true, fp_eflag_none)); - assert(float_is_ne((0x7fff0000000000000000000000000000, 0xffff0000000000000000000000000000)) == (true, fp_eflag_none)); + assert(float_is_ne((fp128_pos_denormal_0, fp128_pos_denormal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp128_neg_normal_0, fp128_neg_normal_1)) == (true, fp_eflag_none)); + assert(float_is_ne((fp128_pos_denormal_1, fp128_pos_zero)) == (true, fp_eflag_none)); + assert(float_is_ne((fp128_pos_inf, fp128_neg_inf)) == (true, fp_eflag_none)); - assert(float_is_ne((0x00000000000000000000000000000011, 0x00000000000000000000000000000011)) == (false, fp_eflag_none)); - assert(float_is_ne((0x0ffff00000000000000000000000000f, 0x0ffff00000000000000000000000000f)) == (false, fp_eflag_none)); - assert(float_is_ne((0x00000000000000000000000000000000, 0x80000000000000000000000000000000)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7fff8000000000000000000000000100, 0x7fff8000000000000000000000000100)) == (false, fp_eflag_none)); + assert(float_is_ne((fp128_pos_denormal_0, fp128_pos_denormal_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp128_neg_qnan_0, fp128_neg_qnan_0)) == (false, fp_eflag_none)); + assert(float_is_ne((fp128_pos_zero, fp128_neg_zero)) == (false, fp_eflag_none)); + assert(float_is_ne((fp128_pos_inf, fp128_pos_inf)) == (false, fp_eflag_none)); - assert(float_is_ne((0x7fff7000000000000000000000000000, 0x0000000000000234db00000000000000)) == (false, fp_eflag_invalid)); - assert(float_is_ne((0x7fff0000000000000000000000000001, 0xffff0000000000000000000003000001)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp128_pos_snan_0, fp128_pos_snan_0)) == (false, fp_eflag_invalid)); + assert(float_is_ne((fp128_pos_snan_1, fp128_pos_normal_0)) == (false, fp_eflag_invalid)); } function main () -> unit = { diff --git a/test/float/normal_test.sail b/test/float/normal_test.sail index 35cb59aef..24f5c2c3f 100644 --- a/test/float/normal_test.sail +++ b/test/float/normal_test.sail @@ -31,97 +31,98 @@ default Order dec $include $include +$include "data.sail" function test_float_is_normal () -> unit = { /* Half floating point */ - assert(float_is_normal(0x7a00)); - assert(float_is_normal(0x7801)); - assert(float_is_normal(0xf700)); - assert(float_is_normal(0xf1ff)); + assert(float_is_normal(fp16_pos_normal_0)); + assert(float_is_normal(fp16_pos_normal_1)); + assert(float_is_normal(fp16_neg_normal_0)); + assert(float_is_normal(fp16_neg_normal_1)); - assert(float_is_normal(0x7c00) == false); - assert(float_is_normal(0x7e00) == false); - assert(float_is_normal(0x0300) == false); - assert(float_is_normal(0x8300) == false); + assert(float_is_normal(fp16_pos_inf) == false); + assert(float_is_normal(fp16_neg_zero) == false); + assert(float_is_normal(fp16_pos_snan_0) == false); + assert(float_is_normal(fp16_pos_qnan_0) == false); /* Single floating point */ - assert(float_is_normal(0x7f000000)); - assert(float_is_normal(0x7f003001)); - assert(float_is_normal(0x7effffff)); - assert(float_is_normal(0xff1f0000)); + assert(float_is_normal(fp32_pos_normal_0)); + assert(float_is_normal(fp32_pos_normal_1)); + assert(float_is_normal(fp32_neg_normal_0)); + assert(float_is_normal(fp32_neg_normal_1)); - assert(float_is_normal(0x7fc00000) == false); - assert(float_is_normal(0x7f800000) == false); - assert(float_is_normal(0x0070f000) == false); - assert(float_is_normal(0x8070f000) == false); + assert(float_is_normal(fp32_pos_inf) == false); + assert(float_is_normal(fp32_neg_zero) == false); + assert(float_is_normal(fp32_pos_snan_0) == false); + assert(float_is_normal(fp32_pos_qnan_0) == false); /* Double floating point */ - assert(float_is_normal(0x7fe0000000000000)); - assert(float_is_normal(0x7fe0000000000001)); - assert(float_is_normal(0xffc000000000000f)); - assert(float_is_normal(0x8030000000100000)); + assert(float_is_normal(fp64_pos_normal_0)); + assert(float_is_normal(fp64_pos_normal_1)); + assert(float_is_normal(fp64_neg_normal_0)); + assert(float_is_normal(fp64_neg_normal_1)); - assert(float_is_normal(0x7ff8000000000000) == false); - assert(float_is_normal(0x7ff0000000000000) == false); - assert(float_is_normal(0x0008000000000000) == false); - assert(float_is_normal(0x8008000000000000) == false); + assert(float_is_normal(fp64_pos_inf) == false); + assert(float_is_normal(fp64_neg_zero) == false); + assert(float_is_normal(fp64_pos_snan_0) == false); + assert(float_is_normal(fp64_pos_qnan_0) == false); /* Quad floating point */ - assert(float_is_normal(0x7ffe0000000000000000000000000000)); - assert(float_is_normal(0x7ffe0000000000000000000000000001)); - assert(float_is_normal(0xfffc000000000000000000000000000f)); - assert(float_is_normal(0x80030000000000000001000000000000)); - - assert(float_is_normal(0x7fff8000000000000000000000000000) == false); - assert(float_is_normal(0x7fff0000000000000000000000000000) == false); - assert(float_is_normal(0x00008000000000000000000000000000) == false); - assert(float_is_normal(0x80008000000000000000000000000000) == false); + assert(float_is_normal(fp128_pos_normal_0)); + assert(float_is_normal(fp128_pos_normal_1)); + assert(float_is_normal(fp128_neg_normal_0)); + assert(float_is_normal(fp128_neg_normal_1)); + + assert(float_is_normal(fp128_pos_inf) == false); + assert(float_is_normal(fp128_neg_zero) == false); + assert(float_is_normal(fp128_pos_snan_0) == false); + assert(float_is_normal(fp128_pos_qnan_0) == false); } function test_float_is_denormal () -> unit = { /* Half floating point */ - assert(float_is_denormal(0x0200)); - assert(float_is_denormal(0x8200)); - assert(float_is_denormal(0x02f0)); - assert(float_is_denormal(0x8201)); + assert(float_is_denormal(fp16_pos_denormal_0)); + assert(float_is_denormal(fp16_pos_denormal_1)); + assert(float_is_denormal(fp16_neg_denormal_0)); + assert(float_is_denormal(fp16_neg_denormal_1)); - assert(float_is_denormal(0x7c00) == false); - assert(float_is_denormal(0x7e00) == false); - assert(float_is_denormal(0x7300) == false); - assert(float_is_denormal(0xf300) == false); + assert(float_is_denormal(fp16_pos_inf) == false); + assert(float_is_denormal(fp16_neg_zero) == false); + assert(float_is_denormal(fp16_pos_snan_0) == false); + assert(float_is_denormal(fp16_pos_qnan_0) == false); /* Single floating point */ - assert(float_is_denormal(0x0070f000)); - assert(float_is_denormal(0x8070f000)); - assert(float_is_denormal(0x80400000)); - assert(float_is_denormal(0x00400001)); + assert(float_is_denormal(fp32_pos_denormal_0)); + assert(float_is_denormal(fp32_pos_denormal_1)); + assert(float_is_denormal(fp32_neg_denormal_0)); + assert(float_is_denormal(fp32_neg_denormal_1)); - assert(float_is_denormal(0x7fc00000) == false); - assert(float_is_denormal(0x7f800000) == false); - assert(float_is_denormal(0x7f000000) == false); - assert(float_is_denormal(0xff1f0000) == false); + assert(float_is_denormal(fp32_pos_inf) == false); + assert(float_is_denormal(fp32_neg_zero) == false); + assert(float_is_denormal(fp32_pos_snan_0) == false); + assert(float_is_denormal(fp32_pos_qnan_0) == false); /* Double floating point */ - assert(float_is_denormal(0x0008000000000000)); - assert(float_is_denormal(0x8008000000000000)); - assert(float_is_denormal(0x8000000000000001)); - assert(float_is_denormal(0x8008000000100000)); + assert(float_is_denormal(fp64_pos_denormal_0)); + assert(float_is_denormal(fp64_pos_denormal_1)); + assert(float_is_denormal(fp64_neg_denormal_0)); + assert(float_is_denormal(fp64_neg_denormal_1)); - assert(float_is_denormal(0x7ff8000000000000) == false); - assert(float_is_denormal(0x7ff0000000000000) == false); - assert(float_is_denormal(0xffc000000000000f) == false); - assert(float_is_denormal(0x8030000000100000) == false); + assert(float_is_denormal(fp64_pos_inf) == false); + assert(float_is_denormal(fp64_neg_zero) == false); + assert(float_is_denormal(fp64_pos_snan_0) == false); + assert(float_is_denormal(fp64_pos_qnan_0) == false); /* Quad floating point */ - assert(float_is_denormal(0x00008000000000000000000000000000)); - assert(float_is_denormal(0x80008000000000000000000000000000)); - assert(float_is_denormal(0x80000000000000000000000000000001)); - assert(float_is_denormal(0x80008000000000000001000000000000)); - - assert(float_is_denormal(0x7fff8000000000000000000000000000) == false); - assert(float_is_denormal(0x7fff0000000000000000000000000000) == false); - assert(float_is_denormal(0xfffc000000000000000000000000000f) == false); - assert(float_is_denormal(0x80030000000000000001000000000000) == false); + assert(float_is_denormal(fp128_pos_denormal_0)); + assert(float_is_denormal(fp128_pos_denormal_1)); + assert(float_is_denormal(fp128_neg_denormal_0)); + assert(float_is_denormal(fp128_neg_denormal_1)); + + assert(float_is_denormal(fp128_pos_inf) == false); + assert(float_is_denormal(fp128_neg_zero) == false); + assert(float_is_denormal(fp128_pos_snan_0) == false); + assert(float_is_denormal(fp128_pos_qnan_0) == false); } function main () -> unit = { diff --git a/test/float/run_tests.py b/test/float/run_tests.py index 8e027069d..94376a8bb 100755 --- a/test/float/run_tests.py +++ b/test/float/run_tests.py @@ -25,7 +25,7 @@ def test_float(name, sail_opts, compiler, c_opts): for filename in filenames: basename = os.path.splitext(os.path.basename(filename))[0] - if basename == "tuple_equality": + if not basename.endswith ("_test"): continue tests[filename] = os.fork() diff --git a/test/float/sign_test.sail b/test/float/sign_test.sail index c548c28f5..23713792d 100644 --- a/test/float/sign_test.sail +++ b/test/float/sign_test.sail @@ -31,89 +31,130 @@ default Order dec $include $include +$include "data.sail" function test_float_is_positive () -> unit = { /* Half floating point */ - assert(float_is_positive(0x7e00)); - assert(float_is_positive(0x0011)); - assert(float_is_positive(0x7fff)); - assert(float_is_positive(0x7ff1)); - - assert(float_is_positive(0xc900) == false); - assert(float_is_positive(0xdb00) == false); - assert(float_is_positive(0x802f) == false); + assert(float_is_positive(fp16_pos_snan_0)); + assert(float_is_positive(fp16_pos_qnan_0)); + assert(float_is_positive(fp16_pos_zero)); + assert(float_is_positive(fp16_pos_inf)); + assert(float_is_positive(fp16_pos_denormal_0)); + assert(float_is_positive(fp16_pos_normal_0)); + + assert(float_is_positive(fp16_neg_snan_0) == false); + assert(float_is_positive(fp16_neg_qnan_0) == false); + assert(float_is_positive(fp16_neg_zero) == false); + assert(float_is_positive(fp16_neg_inf) == false); + assert(float_is_positive(fp16_neg_denormal_0) == false); + assert(float_is_positive(fp16_neg_normal_0) == false); /* Single floating point */ - assert(float_is_positive(0x7fc00000)); - assert(float_is_positive(0x00003001)); - assert(float_is_positive(0x7fffffff)); - assert(float_is_positive(0x7f1f0000)); - - assert(float_is_positive(0xc7800000) == false); - assert(float_is_positive(0xdf000000) == false); - assert(float_is_positive(0x8003f000) == false); + assert(float_is_positive(fp32_pos_snan_0)); + assert(float_is_positive(fp32_pos_qnan_0)); + assert(float_is_positive(fp32_pos_zero)); + assert(float_is_positive(fp32_pos_inf)); + assert(float_is_positive(fp32_pos_denormal_0)); + assert(float_is_positive(fp32_pos_normal_0)); + + assert(float_is_positive(fp32_neg_snan_0) == false); + assert(float_is_positive(fp32_neg_qnan_0) == false); + assert(float_is_positive(fp32_neg_zero) == false); + assert(float_is_positive(fp32_neg_inf) == false); + assert(float_is_positive(fp32_neg_denormal_0) == false); + assert(float_is_positive(fp32_neg_normal_0) == false); /* Double floating point */ - assert(float_is_positive(0x7f080000f0f00000)); - assert(float_is_positive(0x00000fedc0000001)); - assert(float_is_positive(0x7fffffffffffffff)); - assert(float_is_positive(0x0000300000100000)); - - assert(float_is_positive(0xf8f0000000023000) == false); - assert(float_is_positive(0xfce0000000000000) == false); - assert(float_is_positive(0xe8c0000000000000) == false); + assert(float_is_positive(fp64_pos_snan_0)); + assert(float_is_positive(fp64_pos_qnan_0)); + assert(float_is_positive(fp64_pos_zero)); + assert(float_is_positive(fp64_pos_inf)); + assert(float_is_positive(fp64_pos_denormal_0)); + assert(float_is_positive(fp64_pos_normal_0)); + + assert(float_is_positive(fp64_neg_snan_0) == false); + assert(float_is_positive(fp64_neg_qnan_0) == false); + assert(float_is_positive(fp64_neg_zero) == false); + assert(float_is_positive(fp64_neg_inf) == false); + assert(float_is_positive(fp64_neg_denormal_0) == false); + assert(float_is_positive(fp64_neg_normal_0) == false); /* Quad floating point */ - assert(float_is_positive(0x7ff080000f0f00000000000000000000)); - assert(float_is_positive(0x0000000000000fedc000000000000001)); - assert(float_is_positive(0x7fffffffffffffffffffffffffffffff)); - assert(float_is_positive(0x00000000003000000000010000000000)); - - assert(float_is_positive(0xf8ff0000000000000023000000000000) == false); - assert(float_is_positive(0xffce0000000000000000000000000000) == false); - assert(float_is_positive(0xe88c0000000000000000000000000000) == false); + assert(float_is_positive(fp128_pos_snan_0)); + assert(float_is_positive(fp128_pos_qnan_0)); + assert(float_is_positive(fp128_pos_zero)); + assert(float_is_positive(fp128_pos_inf)); + assert(float_is_positive(fp128_pos_denormal_0)); + assert(float_is_positive(fp128_pos_normal_0)); + + assert(float_is_positive(fp128_neg_snan_0) == false); + assert(float_is_positive(fp128_neg_qnan_0) == false); + assert(float_is_positive(fp128_neg_zero) == false); + assert(float_is_positive(fp128_neg_inf) == false); + assert(float_is_positive(fp128_neg_denormal_0) == false); + assert(float_is_positive(fp128_neg_normal_0) == false); } function test_float_is_negative () -> unit = { /* Half floating point */ - assert(float_is_negative(0xfe00)); - assert(float_is_negative(0x8011)); - assert(float_is_negative(0xffff)); - assert(float_is_negative(0xfff1)); - - assert(float_is_negative(0x2900) == false); - assert(float_is_negative(0x4b00) == false); - assert(float_is_negative(0x002f) == false); + assert(float_is_negative(fp16_neg_snan_0)); + assert(float_is_negative(fp16_neg_qnan_0)); + assert(float_is_negative(fp16_neg_zero)); + assert(float_is_negative(fp16_neg_inf)); + assert(float_is_negative(fp16_neg_denormal_0)); + assert(float_is_negative(fp16_neg_normal_0)); + + assert(float_is_negative(fp16_pos_snan_0) == false); + assert(float_is_negative(fp16_pos_qnan_0) == false); + assert(float_is_negative(fp16_pos_zero) == false); + assert(float_is_negative(fp16_pos_inf) == false); + assert(float_is_negative(fp16_pos_denormal_0) == false); + assert(float_is_negative(fp16_pos_normal_0) == false); /* Single floating point */ - assert(float_is_negative(0xffc00000)); - assert(float_is_negative(0x80003001)); - assert(float_is_negative(0xffffffff)); - assert(float_is_negative(0xff1f0000)); - - assert(float_is_negative(0x47800000) == false); - assert(float_is_negative(0x5f000000) == false); - assert(float_is_negative(0x0003f000) == false); + assert(float_is_negative(fp32_neg_snan_0)); + assert(float_is_negative(fp32_neg_qnan_0)); + assert(float_is_negative(fp32_neg_zero)); + assert(float_is_negative(fp32_neg_inf)); + assert(float_is_negative(fp32_neg_denormal_0)); + assert(float_is_negative(fp32_neg_normal_0)); + + assert(float_is_negative(fp32_pos_snan_0) == false); + assert(float_is_negative(fp32_pos_qnan_0) == false); + assert(float_is_negative(fp32_pos_zero) == false); + assert(float_is_negative(fp32_pos_inf) == false); + assert(float_is_negative(fp32_pos_denormal_0) == false); + assert(float_is_negative(fp32_pos_normal_0) == false); /* Double floating point */ - assert(float_is_negative(0xff080000f0f00000)); - assert(float_is_negative(0x80000fedc0000001)); - assert(float_is_negative(0xffffffffffffffff)); - assert(float_is_negative(0x8000300000100000)); - - assert(float_is_negative(0x78f0000000023000) == false); - assert(float_is_negative(0x7ce0000000000000) == false); - assert(float_is_negative(0x68c0000000000000) == false); + assert(float_is_negative(fp64_neg_snan_0)); + assert(float_is_negative(fp64_neg_qnan_0)); + assert(float_is_negative(fp64_neg_zero)); + assert(float_is_negative(fp64_neg_inf)); + assert(float_is_negative(fp64_neg_denormal_0)); + assert(float_is_negative(fp64_neg_normal_0)); + + assert(float_is_negative(fp64_pos_snan_0) == false); + assert(float_is_negative(fp64_pos_qnan_0) == false); + assert(float_is_negative(fp64_pos_zero) == false); + assert(float_is_negative(fp64_pos_inf) == false); + assert(float_is_negative(fp64_pos_denormal_0) == false); + assert(float_is_negative(fp64_pos_normal_0) == false); /* Quad floating point */ - assert(float_is_negative(0xfff0000000800000000f0f0000000000)); - assert(float_is_negative(0x8000000000000fedc000000000000001)); - assert(float_is_negative(0xffffffffffffffffffffffffffffffff)); - assert(float_is_negative(0x80000000003000000000010000000000)); - - assert(float_is_negative(0x78ff0000000000000000023000000000) == false); - assert(float_is_negative(0x7fce0000000000000000000000000000) == false); - assert(float_is_negative(0x688c0000000000000000000000000000) == false); + assert(float_is_negative(fp128_neg_snan_0)); + assert(float_is_negative(fp128_neg_qnan_0)); + assert(float_is_negative(fp128_neg_zero)); + assert(float_is_negative(fp128_neg_inf)); + assert(float_is_negative(fp128_neg_denormal_0)); + assert(float_is_negative(fp128_neg_normal_0)); + + assert(float_is_negative(fp128_pos_snan_0) == false); + assert(float_is_negative(fp128_pos_qnan_0) == false); + assert(float_is_negative(fp128_pos_zero) == false); + assert(float_is_negative(fp128_pos_inf) == false); + assert(float_is_negative(fp128_pos_denormal_0) == false); + assert(float_is_negative(fp128_pos_normal_0) == false); } function main () -> unit = { diff --git a/test/float/zero_test.sail b/test/float/zero_test.sail index 64aeb843c..4fc6bd263 100644 --- a/test/float/zero_test.sail +++ b/test/float/zero_test.sail @@ -31,43 +31,48 @@ default Order dec $include $include +$include "data.sail" function test_float_is_zero () -> unit = { /* Half floating point */ - assert(float_is_zero(0x8000)); - assert(float_is_zero(0x0000)); + assert(float_is_zero(fp16_pos_zero)); + assert(float_is_zero(fp16_neg_zero)); - assert(float_is_zero(0x7a00) == false); - assert(float_is_zero(0x7b00) == false); - assert(float_is_zero(0xca00) == false); - assert(float_is_zero(0xfe00) == false); + assert(float_is_zero(fp16_pos_snan_0) == false); + assert(float_is_zero(fp16_neg_qnan_0) == false); + assert(float_is_zero(fp16_pos_inf) == false); + assert(float_is_zero(fp16_pos_denormal_0) == false); + assert(float_is_zero(fp16_neg_normal_0) == false); /* Single floating point */ - assert(float_is_zero(0x80000000)); - assert(float_is_zero(0x00000000)); + assert(float_is_zero(fp32_pos_zero)); + assert(float_is_zero(fp32_neg_zero)); - assert(float_is_zero(0x7fc00000) == false); - assert(float_is_zero(0x7e800000) == false); - assert(float_is_zero(0xffc00000) == false); - assert(float_is_zero(0xfe800000) == false); + assert(float_is_zero(fp32_pos_snan_0) == false); + assert(float_is_zero(fp32_neg_qnan_0) == false); + assert(float_is_zero(fp32_pos_inf) == false); + assert(float_is_zero(fp32_pos_denormal_0) == false); + assert(float_is_zero(fp32_neg_normal_0) == false); /* Double floating point */ - assert(float_is_zero(0x8000000000000000)); - assert(float_is_zero(0x0000000000000000)); + assert(float_is_zero(fp64_pos_zero)); + assert(float_is_zero(fp64_neg_zero)); - assert(float_is_zero(0x7ff8000000000000) == false); - assert(float_is_zero(0x7ff0000000000001) == false); - assert(float_is_zero(0xfff8000000000000) == false); - assert(float_is_zero(0xfff0000000000001) == false); + assert(float_is_zero(fp64_pos_snan_0) == false); + assert(float_is_zero(fp64_neg_qnan_0) == false); + assert(float_is_zero(fp64_pos_inf) == false); + assert(float_is_zero(fp64_pos_denormal_0) == false); + assert(float_is_zero(fp64_neg_normal_0) == false); /* Quad floating point */ - assert(float_is_zero(0x80000000000000000000000000000000)); - assert(float_is_zero(0x00000000000000000000000000000000)); + assert(float_is_zero(fp128_pos_zero)); + assert(float_is_zero(fp128_neg_zero)); - assert(float_is_zero(0x7fff8000000000000000000000000000) == false); - assert(float_is_zero(0x7fff0000000000000000000000000001) == false); - assert(float_is_zero(0xffff8000000000000000000000000000) == false); - assert(float_is_zero(0xffff0000000000000000000000000001) == false); + assert(float_is_zero(fp128_pos_snan_0) == false); + assert(float_is_zero(fp128_neg_qnan_0) == false); + assert(float_is_zero(fp128_pos_inf) == false); + assert(float_is_zero(fp128_pos_denormal_0) == false); + assert(float_is_zero(fp128_neg_normal_0) == false); } function main () -> unit = {