SAIFIINDUSTRIES commited on
Commit
8d6d734
·
verified ·
1 Parent(s): 5e13d71

Add Repo: compsec-snu_difuzz-rtl (part 4)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_eq.c +73 -0
  2. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_eq_signaling.c +67 -0
  3. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_isSignalingNaN.c +51 -0
  4. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_le.c +72 -0
  5. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_le_quiet.c +78 -0
  6. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_lt.c +72 -0
  7. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_lt_quiet.c +78 -0
  8. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_mul.c +163 -0
  9. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_mulAdd.c +63 -0
  10. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_rem.c +190 -0
  11. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_roundToInt.c +160 -0
  12. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_sqrt.c +201 -0
  13. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_sub.c +78 -0
  14. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f16.c +95 -0
  15. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f32.c +95 -0
  16. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f64.c +100 -0
  17. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i32.c +85 -0
  18. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i32_r_minMag.c +100 -0
  19. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i64.c +95 -0
  20. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i64_r_minMag.c +113 -0
  21. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui32.c +86 -0
  22. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui32_r_minMag.c +89 -0
  23. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui64.c +96 -0
  24. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui64_r_minMag.c +105 -0
  25. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_add.c +70 -0
  26. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_classify.c +36 -0
  27. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_div.c +186 -0
  28. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_eq.c +66 -0
  29. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_eq_signaling.c +61 -0
  30. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_isSignalingNaN.c +51 -0
  31. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_le.c +66 -0
  32. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_le_quiet.c +71 -0
  33. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_lt.c +66 -0
  34. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_lt_quiet.c +71 -0
  35. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_mul.c +140 -0
  36. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_mulAdd.c +60 -0
  37. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_rem.c +171 -0
  38. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_roundToInt.c +112 -0
  39. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_sqrt.c +136 -0
  40. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_sub.c +70 -0
  41. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f128.c +96 -0
  42. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f32.c +93 -0
  43. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f64.c +93 -0
  44. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i16.c +57 -0
  45. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i32.c +87 -0
  46. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i32_r_minMag.c +88 -0
  47. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i64.c +87 -0
  48. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i64_r_minMag.c +88 -0
  49. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i8.c +57 -0
  50. compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_ui16.c +54 -0
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_eq.c ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f128_eq( float128_t a, float128_t b )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ union ui128_f128 uB;
49
+ uint_fast64_t uiB64, uiB0;
50
+
51
+ uA.f = a;
52
+ uiA64 = uA.ui.v64;
53
+ uiA0 = uA.ui.v0;
54
+ uB.f = b;
55
+ uiB64 = uB.ui.v64;
56
+ uiB0 = uB.ui.v0;
57
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58
+ if (
59
+ softfloat_isSigNaNF128UI( uiA64, uiA0 )
60
+ || softfloat_isSigNaNF128UI( uiB64, uiB0 )
61
+ ) {
62
+ softfloat_raiseFlags( softfloat_flag_invalid );
63
+ }
64
+ return false;
65
+ }
66
+ return
67
+ (uiA0 == uiB0)
68
+ && ( (uiA64 == uiB64)
69
+ || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
70
+ );
71
+
72
+ }
73
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_eq_signaling.c ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f128_eq_signaling( float128_t a, float128_t b )
44
+ {
45
+ union ui128_f128 uA;
46
+ uint_fast64_t uiA64, uiA0;
47
+ union ui128_f128 uB;
48
+ uint_fast64_t uiB64, uiB0;
49
+
50
+ uA.f = a;
51
+ uiA64 = uA.ui.v64;
52
+ uiA0 = uA.ui.v0;
53
+ uB.f = b;
54
+ uiB64 = uB.ui.v64;
55
+ uiB0 = uB.ui.v0;
56
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
57
+ softfloat_raiseFlags( softfloat_flag_invalid );
58
+ return false;
59
+ }
60
+ return
61
+ (uiA0 == uiB0)
62
+ && ( (uiA64 == uiB64)
63
+ || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
64
+ );
65
+
66
+ }
67
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_isSignalingNaN.c ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include "platform.h"
39
+ #include "internals.h"
40
+ #include "specialize.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f128_isSignalingNaN( float128_t a )
44
+ {
45
+ union ui128_f128 uA;
46
+
47
+ uA.f = a;
48
+ return softfloat_isSigNaNF128UI( uA.ui.v64, uA.ui.v0 );
49
+
50
+ }
51
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_le.c ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f128_le( float128_t a, float128_t b )
44
+ {
45
+ union ui128_f128 uA;
46
+ uint_fast64_t uiA64, uiA0;
47
+ union ui128_f128 uB;
48
+ uint_fast64_t uiB64, uiB0;
49
+ bool signA, signB;
50
+
51
+ uA.f = a;
52
+ uiA64 = uA.ui.v64;
53
+ uiA0 = uA.ui.v0;
54
+ uB.f = b;
55
+ uiB64 = uB.ui.v64;
56
+ uiB0 = uB.ui.v0;
57
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58
+ softfloat_raiseFlags( softfloat_flag_invalid );
59
+ return false;
60
+ }
61
+ signA = signF128UI64( uiA64 );
62
+ signB = signF128UI64( uiB64 );
63
+ return
64
+ (signA != signB)
65
+ ? signA
66
+ || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67
+ | uiA0 | uiB0)
68
+ : ((uiA64 == uiB64) && (uiA0 == uiB0))
69
+ || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
+
71
+ }
72
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_le_quiet.c ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f128_le_quiet( float128_t a, float128_t b )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ union ui128_f128 uB;
49
+ uint_fast64_t uiB64, uiB0;
50
+ bool signA, signB;
51
+
52
+ uA.f = a;
53
+ uiA64 = uA.ui.v64;
54
+ uiA0 = uA.ui.v0;
55
+ uB.f = b;
56
+ uiB64 = uB.ui.v64;
57
+ uiB0 = uB.ui.v0;
58
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59
+ if (
60
+ softfloat_isSigNaNF128UI( uiA64, uiA0 )
61
+ || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62
+ ) {
63
+ softfloat_raiseFlags( softfloat_flag_invalid );
64
+ }
65
+ return false;
66
+ }
67
+ signA = signF128UI64( uiA64 );
68
+ signB = signF128UI64( uiB64 );
69
+ return
70
+ (signA != signB)
71
+ ? signA
72
+ || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73
+ | uiA0 | uiB0)
74
+ : ((uiA64 == uiB64) && (uiA0 == uiB0))
75
+ || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
+
77
+ }
78
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_lt.c ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f128_lt( float128_t a, float128_t b )
44
+ {
45
+ union ui128_f128 uA;
46
+ uint_fast64_t uiA64, uiA0;
47
+ union ui128_f128 uB;
48
+ uint_fast64_t uiB64, uiB0;
49
+ bool signA, signB;
50
+
51
+ uA.f = a;
52
+ uiA64 = uA.ui.v64;
53
+ uiA0 = uA.ui.v0;
54
+ uB.f = b;
55
+ uiB64 = uB.ui.v64;
56
+ uiB0 = uB.ui.v0;
57
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58
+ softfloat_raiseFlags( softfloat_flag_invalid );
59
+ return false;
60
+ }
61
+ signA = signF128UI64( uiA64 );
62
+ signB = signF128UI64( uiB64 );
63
+ return
64
+ (signA != signB)
65
+ ? signA
66
+ && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67
+ | uiA0 | uiB0)
68
+ : ((uiA64 != uiB64) || (uiA0 != uiB0))
69
+ && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
+
71
+ }
72
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_lt_quiet.c ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f128_lt_quiet( float128_t a, float128_t b )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ union ui128_f128 uB;
49
+ uint_fast64_t uiB64, uiB0;
50
+ bool signA, signB;
51
+
52
+ uA.f = a;
53
+ uiA64 = uA.ui.v64;
54
+ uiA0 = uA.ui.v0;
55
+ uB.f = b;
56
+ uiB64 = uB.ui.v64;
57
+ uiB0 = uB.ui.v0;
58
+ if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59
+ if (
60
+ softfloat_isSigNaNF128UI( uiA64, uiA0 )
61
+ || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62
+ ) {
63
+ softfloat_raiseFlags( softfloat_flag_invalid );
64
+ }
65
+ return false;
66
+ }
67
+ signA = signF128UI64( uiA64 );
68
+ signB = signF128UI64( uiB64 );
69
+ return
70
+ (signA != signB)
71
+ ? signA
72
+ && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73
+ | uiA0 | uiB0)
74
+ : ((uiA64 != uiB64) || (uiA0 != uiB0))
75
+ && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
+
77
+ }
78
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_mul.c ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float128_t f128_mul( float128_t a, float128_t b )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool signA;
49
+ int_fast32_t expA;
50
+ struct uint128 sigA;
51
+ union ui128_f128 uB;
52
+ uint_fast64_t uiB64, uiB0;
53
+ bool signB;
54
+ int_fast32_t expB;
55
+ struct uint128 sigB;
56
+ bool signZ;
57
+ uint_fast64_t magBits;
58
+ struct exp32_sig128 normExpSig;
59
+ int_fast32_t expZ;
60
+ uint64_t sig256Z[4];
61
+ uint_fast64_t sigZExtra;
62
+ struct uint128 sigZ;
63
+ struct uint128_extra sig128Extra;
64
+ struct uint128 uiZ;
65
+ union ui128_f128 uZ;
66
+
67
+ /*------------------------------------------------------------------------
68
+ *------------------------------------------------------------------------*/
69
+ uA.f = a;
70
+ uiA64 = uA.ui.v64;
71
+ uiA0 = uA.ui.v0;
72
+ signA = signF128UI64( uiA64 );
73
+ expA = expF128UI64( uiA64 );
74
+ sigA.v64 = fracF128UI64( uiA64 );
75
+ sigA.v0 = uiA0;
76
+ uB.f = b;
77
+ uiB64 = uB.ui.v64;
78
+ uiB0 = uB.ui.v0;
79
+ signB = signF128UI64( uiB64 );
80
+ expB = expF128UI64( uiB64 );
81
+ sigB.v64 = fracF128UI64( uiB64 );
82
+ sigB.v0 = uiB0;
83
+ signZ = signA ^ signB;
84
+ /*------------------------------------------------------------------------
85
+ *------------------------------------------------------------------------*/
86
+ if ( expA == 0x7FFF ) {
87
+ if (
88
+ (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
89
+ ) {
90
+ goto propagateNaN;
91
+ }
92
+ magBits = expB | sigB.v64 | sigB.v0;
93
+ goto infArg;
94
+ }
95
+ if ( expB == 0x7FFF ) {
96
+ if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
97
+ magBits = expA | sigA.v64 | sigA.v0;
98
+ goto infArg;
99
+ }
100
+ /*------------------------------------------------------------------------
101
+ *------------------------------------------------------------------------*/
102
+ if ( ! expA ) {
103
+ if ( ! (sigA.v64 | sigA.v0) ) goto zero;
104
+ normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105
+ expA = normExpSig.exp;
106
+ sigA = normExpSig.sig;
107
+ }
108
+ if ( ! expB ) {
109
+ if ( ! (sigB.v64 | sigB.v0) ) goto zero;
110
+ normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
111
+ expB = normExpSig.exp;
112
+ sigB = normExpSig.sig;
113
+ }
114
+ /*------------------------------------------------------------------------
115
+ *------------------------------------------------------------------------*/
116
+ expZ = expA + expB - 0x4000;
117
+ sigA.v64 |= UINT64_C( 0x0001000000000000 );
118
+ sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 16 );
119
+ softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
120
+ sigZExtra = sig256Z[indexWord( 4, 1 )] | (sig256Z[indexWord( 4, 0 )] != 0);
121
+ sigZ =
122
+ softfloat_add128(
123
+ sig256Z[indexWord( 4, 3 )], sig256Z[indexWord( 4, 2 )],
124
+ sigA.v64, sigA.v0
125
+ );
126
+ if ( UINT64_C( 0x0002000000000000 ) <= sigZ.v64 ) {
127
+ ++expZ;
128
+ sig128Extra =
129
+ softfloat_shortShiftRightJam128Extra(
130
+ sigZ.v64, sigZ.v0, sigZExtra, 1 );
131
+ sigZ = sig128Extra.v;
132
+ sigZExtra = sig128Extra.extra;
133
+ }
134
+ return
135
+ softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
136
+ /*------------------------------------------------------------------------
137
+ *------------------------------------------------------------------------*/
138
+ propagateNaN:
139
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
140
+ goto uiZ;
141
+ /*------------------------------------------------------------------------
142
+ *------------------------------------------------------------------------*/
143
+ infArg:
144
+ if ( ! magBits ) {
145
+ softfloat_raiseFlags( softfloat_flag_invalid );
146
+ uiZ.v64 = defaultNaNF128UI64;
147
+ uiZ.v0 = defaultNaNF128UI0;
148
+ goto uiZ;
149
+ }
150
+ uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
151
+ goto uiZ0;
152
+ /*------------------------------------------------------------------------
153
+ *------------------------------------------------------------------------*/
154
+ zero:
155
+ uiZ.v64 = packToF128UI64( signZ, 0, 0 );
156
+ uiZ0:
157
+ uiZ.v0 = 0;
158
+ uiZ:
159
+ uZ.ui = uiZ;
160
+ return uZ.f;
161
+
162
+ }
163
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_mulAdd.c ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdint.h>
38
+ #include "platform.h"
39
+ #include "internals.h"
40
+ #include "softfloat.h"
41
+
42
+ float128_t f128_mulAdd( float128_t a, float128_t b, float128_t c )
43
+ {
44
+ union ui128_f128 uA;
45
+ uint_fast64_t uiA64, uiA0;
46
+ union ui128_f128 uB;
47
+ uint_fast64_t uiB64, uiB0;
48
+ union ui128_f128 uC;
49
+ uint_fast64_t uiC64, uiC0;
50
+
51
+ uA.f = a;
52
+ uiA64 = uA.ui.v64;
53
+ uiA0 = uA.ui.v0;
54
+ uB.f = b;
55
+ uiB64 = uB.ui.v64;
56
+ uiB0 = uB.ui.v0;
57
+ uC.f = c;
58
+ uiC64 = uC.ui.v64;
59
+ uiC0 = uC.ui.v0;
60
+ return softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
61
+
62
+ }
63
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_rem.c ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float128_t f128_rem( float128_t a, float128_t b )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool signA;
49
+ int_fast32_t expA;
50
+ struct uint128 sigA;
51
+ union ui128_f128 uB;
52
+ uint_fast64_t uiB64, uiB0;
53
+ int_fast32_t expB;
54
+ struct uint128 sigB;
55
+ struct exp32_sig128 normExpSig;
56
+ struct uint128 rem;
57
+ int_fast32_t expDiff;
58
+ uint_fast32_t q, recip32;
59
+ uint_fast64_t q64;
60
+ struct uint128 term, altRem, meanRem;
61
+ bool signRem;
62
+ struct uint128 uiZ;
63
+ union ui128_f128 uZ;
64
+
65
+ /*------------------------------------------------------------------------
66
+ *------------------------------------------------------------------------*/
67
+ uA.f = a;
68
+ uiA64 = uA.ui.v64;
69
+ uiA0 = uA.ui.v0;
70
+ signA = signF128UI64( uiA64 );
71
+ expA = expF128UI64( uiA64 );
72
+ sigA.v64 = fracF128UI64( uiA64 );
73
+ sigA.v0 = uiA0;
74
+ uB.f = b;
75
+ uiB64 = uB.ui.v64;
76
+ uiB0 = uB.ui.v0;
77
+ expB = expF128UI64( uiB64 );
78
+ sigB.v64 = fracF128UI64( uiB64 );
79
+ sigB.v0 = uiB0;
80
+ /*------------------------------------------------------------------------
81
+ *------------------------------------------------------------------------*/
82
+ if ( expA == 0x7FFF ) {
83
+ if (
84
+ (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
85
+ ) {
86
+ goto propagateNaN;
87
+ }
88
+ goto invalid;
89
+ }
90
+ if ( expB == 0x7FFF ) {
91
+ if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
92
+ return a;
93
+ }
94
+ /*------------------------------------------------------------------------
95
+ *------------------------------------------------------------------------*/
96
+ if ( ! expB ) {
97
+ if ( ! (sigB.v64 | sigB.v0) ) goto invalid;
98
+ normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
99
+ expB = normExpSig.exp;
100
+ sigB = normExpSig.sig;
101
+ }
102
+ if ( ! expA ) {
103
+ if ( ! (sigA.v64 | sigA.v0) ) return a;
104
+ normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105
+ expA = normExpSig.exp;
106
+ sigA = normExpSig.sig;
107
+ }
108
+ /*------------------------------------------------------------------------
109
+ *------------------------------------------------------------------------*/
110
+ sigA.v64 |= UINT64_C( 0x0001000000000000 );
111
+ sigB.v64 |= UINT64_C( 0x0001000000000000 );
112
+ rem = sigA;
113
+ expDiff = expA - expB;
114
+ if ( expDiff < 1 ) {
115
+ if ( expDiff < -1 ) return a;
116
+ if ( expDiff ) {
117
+ --expB;
118
+ sigB = softfloat_add128( sigB.v64, sigB.v0, sigB.v64, sigB.v0 );
119
+ q = 0;
120
+ } else {
121
+ q = softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 );
122
+ if ( q ) {
123
+ rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
124
+ }
125
+ }
126
+ } else {
127
+ recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
128
+ expDiff -= 30;
129
+ for (;;) {
130
+ q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
131
+ if ( expDiff < 0 ) break;
132
+ q = (q64 + 0x80000000)>>32;
133
+ rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
134
+ term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
135
+ rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
136
+ if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
137
+ rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
138
+ }
139
+ expDiff -= 29;
140
+ }
141
+ /*--------------------------------------------------------------------
142
+ | (`expDiff' cannot be less than -29 here.)
143
+ *--------------------------------------------------------------------*/
144
+ q = (uint32_t) (q64>>32)>>(~expDiff & 31);
145
+ rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
146
+ term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
147
+ rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148
+ if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149
+ altRem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
150
+ goto selectRem;
151
+ }
152
+ }
153
+ /*------------------------------------------------------------------------
154
+ *------------------------------------------------------------------------*/
155
+ do {
156
+ altRem = rem;
157
+ ++q;
158
+ rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
159
+ } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
160
+ selectRem:
161
+ meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
162
+ if (
163
+ (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
164
+ || (! (meanRem.v64 | meanRem.v0) && (q & 1))
165
+ ) {
166
+ rem = altRem;
167
+ }
168
+ signRem = signA;
169
+ if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
170
+ signRem = ! signRem;
171
+ rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
172
+ }
173
+ return softfloat_normRoundPackToF128( signRem, expB - 1, rem.v64, rem.v0 );
174
+ /*------------------------------------------------------------------------
175
+ *------------------------------------------------------------------------*/
176
+ propagateNaN:
177
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
178
+ goto uiZ;
179
+ /*------------------------------------------------------------------------
180
+ *------------------------------------------------------------------------*/
181
+ invalid:
182
+ softfloat_raiseFlags( softfloat_flag_invalid );
183
+ uiZ.v64 = defaultNaNF128UI64;
184
+ uiZ.v0 = defaultNaNF128UI0;
185
+ uiZ:
186
+ uZ.ui = uiZ;
187
+ return uZ.f;
188
+
189
+ }
190
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_roundToInt.c ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float128_t
45
+ f128_roundToInt( float128_t a, uint_fast8_t roundingMode, bool exact )
46
+ {
47
+ union ui128_f128 uA;
48
+ uint_fast64_t uiA64, uiA0;
49
+ int_fast32_t exp;
50
+ struct uint128 uiZ;
51
+ uint_fast64_t lastBitMask, roundBitsMask;
52
+ bool roundNearEven;
53
+ union ui128_f128 uZ;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ exp = expF128UI64( uiA64 );
61
+ /*------------------------------------------------------------------------
62
+ *------------------------------------------------------------------------*/
63
+ if ( 0x402F <= exp ) {
64
+ /*--------------------------------------------------------------------
65
+ *--------------------------------------------------------------------*/
66
+ if ( 0x406F <= exp ) {
67
+ if ( (exp == 0x7FFF) && (fracF128UI64( uiA64 ) | uiA0) ) {
68
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
69
+ goto uiZ;
70
+ }
71
+ return a;
72
+ }
73
+ /*--------------------------------------------------------------------
74
+ *--------------------------------------------------------------------*/
75
+ lastBitMask = (uint_fast64_t) 2<<(0x406E - exp);
76
+ roundBitsMask = lastBitMask - 1;
77
+ uiZ.v64 = uiA64;
78
+ uiZ.v0 = uiA0;
79
+ roundNearEven = (roundingMode == softfloat_round_near_even);
80
+ if ( roundNearEven || (roundingMode == softfloat_round_near_maxMag) ) {
81
+ if ( exp == 0x402F ) {
82
+ if ( UINT64_C( 0x8000000000000000 ) <= uiZ.v0 ) {
83
+ ++uiZ.v64;
84
+ if (
85
+ roundNearEven
86
+ && (uiZ.v0 == UINT64_C( 0x8000000000000000 ))
87
+ ) {
88
+ uiZ.v64 &= ~1;
89
+ }
90
+ }
91
+ } else {
92
+ uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, lastBitMask>>1 );
93
+ if ( roundNearEven && ! (uiZ.v0 & roundBitsMask) ) {
94
+ uiZ.v0 &= ~lastBitMask;
95
+ }
96
+ }
97
+ } else if (
98
+ roundingMode
99
+ == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
100
+ : softfloat_round_max)
101
+ ) {
102
+ uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, roundBitsMask );
103
+ }
104
+ uiZ.v0 &= ~roundBitsMask;
105
+ } else {
106
+ /*--------------------------------------------------------------------
107
+ *--------------------------------------------------------------------*/
108
+ if ( exp < 0x3FFF ) {
109
+ if ( ! ((uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF )) | uiA0) ) {
110
+ return a;
111
+ }
112
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
113
+ uiZ.v64 = uiA64 & packToF128UI64( 1, 0, 0 );
114
+ uiZ.v0 = 0;
115
+ switch ( roundingMode ) {
116
+ case softfloat_round_near_even:
117
+ if ( ! (fracF128UI64( uiA64 ) | uiA0) ) break;
118
+ case softfloat_round_near_maxMag:
119
+ if ( exp == 0x3FFE ) uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
120
+ break;
121
+ case softfloat_round_min:
122
+ if ( uiZ.v64 ) uiZ.v64 = packToF128UI64( 1, 0x3FFF, 0 );
123
+ break;
124
+ case softfloat_round_max:
125
+ if ( ! uiZ.v64 ) uiZ.v64 = packToF128UI64( 0, 0x3FFF, 0 );
126
+ break;
127
+ }
128
+ goto uiZ;
129
+ }
130
+ /*--------------------------------------------------------------------
131
+ *--------------------------------------------------------------------*/
132
+ uiZ.v64 = uiA64;
133
+ uiZ.v0 = 0;
134
+ lastBitMask = (uint_fast64_t) 1<<(0x402F - exp);
135
+ roundBitsMask = lastBitMask - 1;
136
+ if ( roundingMode == softfloat_round_near_maxMag ) {
137
+ uiZ.v64 += lastBitMask>>1;
138
+ } else if ( roundingMode == softfloat_round_near_even ) {
139
+ uiZ.v64 += lastBitMask>>1;
140
+ if ( ! ((uiZ.v64 & roundBitsMask) | uiA0) ) {
141
+ uiZ.v64 &= ~lastBitMask;
142
+ }
143
+ } else if (
144
+ roundingMode
145
+ == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
146
+ : softfloat_round_max)
147
+ ) {
148
+ uiZ.v64 = (uiZ.v64 | (uiA0 != 0)) + roundBitsMask;
149
+ }
150
+ uiZ.v64 &= ~roundBitsMask;
151
+ }
152
+ if ( exact && ((uiZ.v64 != uiA64) || (uiZ.v0 != uiA0)) ) {
153
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
154
+ }
155
+ uiZ:
156
+ uZ.ui = uiZ;
157
+ return uZ.f;
158
+
159
+ }
160
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_sqrt.c ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float128_t f128_sqrt( float128_t a )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool signA;
49
+ int_fast32_t expA;
50
+ struct uint128 sigA, uiZ;
51
+ struct exp32_sig128 normExpSig;
52
+ int_fast32_t expZ;
53
+ uint_fast32_t sig32A, recipSqrt32, sig32Z;
54
+ struct uint128 rem;
55
+ uint32_t qs[3];
56
+ uint_fast32_t q;
57
+ uint_fast64_t x64, sig64Z;
58
+ struct uint128 y, term;
59
+ uint_fast64_t sigZExtra;
60
+ struct uint128 sigZ;
61
+ union ui128_f128 uZ;
62
+
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ uA.f = a;
66
+ uiA64 = uA.ui.v64;
67
+ uiA0 = uA.ui.v0;
68
+ signA = signF128UI64( uiA64 );
69
+ expA = expF128UI64( uiA64 );
70
+ sigA.v64 = fracF128UI64( uiA64 );
71
+ sigA.v0 = uiA0;
72
+ /*------------------------------------------------------------------------
73
+ *------------------------------------------------------------------------*/
74
+ if ( expA == 0x7FFF ) {
75
+ if ( sigA.v64 | sigA.v0 ) {
76
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
77
+ goto uiZ;
78
+ }
79
+ if ( ! signA ) return a;
80
+ goto invalid;
81
+ }
82
+ /*------------------------------------------------------------------------
83
+ *------------------------------------------------------------------------*/
84
+ if ( signA ) {
85
+ if ( ! (expA | sigA.v64 | sigA.v0) ) return a;
86
+ goto invalid;
87
+ }
88
+ /*------------------------------------------------------------------------
89
+ *------------------------------------------------------------------------*/
90
+ if ( ! expA ) {
91
+ if ( ! (sigA.v64 | sigA.v0) ) return a;
92
+ normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
93
+ expA = normExpSig.exp;
94
+ sigA = normExpSig.sig;
95
+ }
96
+ /*------------------------------------------------------------------------
97
+ | (`sig32Z' is guaranteed to be a lower bound on the square root of
98
+ | `sig32A', which makes `sig32Z' also a lower bound on the square root of
99
+ | `sigA'.)
100
+ *------------------------------------------------------------------------*/
101
+ expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
102
+ expA &= 1;
103
+ sigA.v64 |= UINT64_C( 0x0001000000000000 );
104
+ sig32A = sigA.v64>>17;
105
+ recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106
+ sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
107
+ if ( expA ) {
108
+ sig32Z >>= 1;
109
+ rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 12 );
110
+ } else {
111
+ rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 13 );
112
+ }
113
+ qs[2] = sig32Z;
114
+ rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
115
+ /*------------------------------------------------------------------------
116
+ *------------------------------------------------------------------------*/
117
+ q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
118
+ x64 = (uint_fast64_t) sig32Z<<32;
119
+ sig64Z = x64 + ((uint_fast64_t) q<<3);
120
+ y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
121
+ /*------------------------------------------------------------------------
122
+ | (Repeating this loop is a rare occurrence.)
123
+ *------------------------------------------------------------------------*/
124
+ for (;;) {
125
+ term = softfloat_mul64ByShifted32To128( x64 + sig64Z, q );
126
+ rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
127
+ if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
128
+ --q;
129
+ sig64Z -= 1<<3;
130
+ }
131
+ qs[1] = q;
132
+ /*------------------------------------------------------------------------
133
+ *------------------------------------------------------------------------*/
134
+ q = ((rem.v64>>2) * recipSqrt32)>>32;
135
+ y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
136
+ sig64Z <<= 1;
137
+ /*------------------------------------------------------------------------
138
+ | (Repeating this loop is a rare occurrence.)
139
+ *------------------------------------------------------------------------*/
140
+ for (;;) {
141
+ term = softfloat_shortShiftLeft128( 0, sig64Z, 32 );
142
+ term = softfloat_add128( term.v64, term.v0, 0, (uint_fast64_t) q<<6 );
143
+ term = softfloat_mul128By32( term.v64, term.v0, q );
144
+ rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
145
+ if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
146
+ --q;
147
+ }
148
+ qs[0] = q;
149
+ /*------------------------------------------------------------------------
150
+ *------------------------------------------------------------------------*/
151
+ q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
152
+ sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
153
+ term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
154
+ sigZ =
155
+ softfloat_add128(
156
+ (uint_fast64_t) qs[2]<<18, ((uint_fast64_t) qs[0]<<24) + (q>>5),
157
+ term.v64, term.v0
158
+ );
159
+ /*------------------------------------------------------------------------
160
+ *------------------------------------------------------------------------*/
161
+ if ( (q & 0xF) <= 2 ) {
162
+ q &= ~3;
163
+ sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
164
+ y = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, 6 );
165
+ y.v0 |= sigZExtra>>58;
166
+ term = softfloat_sub128( y.v64, y.v0, 0, q );
167
+ y = softfloat_mul64ByShifted32To128( term.v0, q );
168
+ term = softfloat_mul64ByShifted32To128( term.v64, q );
169
+ term = softfloat_add128( term.v64, term.v0, 0, y.v64 );
170
+ rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 20 );
171
+ term = softfloat_sub128( term.v64, term.v0, rem.v64, rem.v0 );
172
+ /*--------------------------------------------------------------------
173
+ | The concatenation of `term' and `y.v0' is now the negative remainder
174
+ | (3 words altogether).
175
+ *--------------------------------------------------------------------*/
176
+ if ( term.v64 & UINT64_C( 0x8000000000000000 ) ) {
177
+ sigZExtra |= 1;
178
+ } else {
179
+ if ( term.v64 | term.v0 | y.v0 ) {
180
+ if ( sigZExtra ) {
181
+ --sigZExtra;
182
+ } else {
183
+ sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
184
+ sigZExtra = ~0;
185
+ }
186
+ }
187
+ }
188
+ }
189
+ return softfloat_roundPackToF128( 0, expZ, sigZ.v64, sigZ.v0, sigZExtra );
190
+ /*------------------------------------------------------------------------
191
+ *------------------------------------------------------------------------*/
192
+ invalid:
193
+ softfloat_raiseFlags( softfloat_flag_invalid );
194
+ uiZ.v64 = defaultNaNF128UI64;
195
+ uiZ.v0 = defaultNaNF128UI0;
196
+ uiZ:
197
+ uZ.ui = uiZ;
198
+ return uZ.f;
199
+
200
+ }
201
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_sub.c ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8
+ All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ float128_t f128_sub( float128_t a, float128_t b )
44
+ {
45
+ union ui128_f128 uA;
46
+ uint_fast64_t uiA64, uiA0;
47
+ bool signA;
48
+ union ui128_f128 uB;
49
+ uint_fast64_t uiB64, uiB0;
50
+ bool signB;
51
+ #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52
+ float128_t
53
+ (*magsFuncPtr)(
54
+ uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
55
+ #endif
56
+
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ signA = signF128UI64( uiA64 );
61
+ uB.f = b;
62
+ uiB64 = uB.ui.v64;
63
+ uiB0 = uB.ui.v0;
64
+ signB = signF128UI64( uiB64 );
65
+ #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66
+ if ( signA == signB ) {
67
+ return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68
+ } else {
69
+ return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70
+ }
71
+ #else
72
+ magsFuncPtr =
73
+ (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
74
+ return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75
+ #endif
76
+
77
+ }
78
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f16.c ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float16_t f128_to_f16( float128_t a )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t frac64;
51
+ struct commonNaN commonNaN;
52
+ uint_fast16_t uiZ, frac16;
53
+ union ui16_f16 uZ;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ sign = signF128UI64( uiA64 );
61
+ exp = expF128UI64( uiA64 );
62
+ frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ if ( exp == 0x7FFF ) {
66
+ if ( frac64 ) {
67
+ softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
69
+ } else {
70
+ uiZ = packToF16UI( sign, 0x1F, 0 );
71
+ }
72
+ goto uiZ;
73
+ }
74
+ /*------------------------------------------------------------------------
75
+ *------------------------------------------------------------------------*/
76
+ frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
77
+ if ( ! (exp | frac16) ) {
78
+ uiZ = packToF16UI( sign, 0, 0 );
79
+ goto uiZ;
80
+ }
81
+ /*------------------------------------------------------------------------
82
+ *------------------------------------------------------------------------*/
83
+ exp -= 0x3FF1;
84
+ if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85
+ if ( exp < -0x40 ) exp = -0x40;
86
+ }
87
+ return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
88
+ /*------------------------------------------------------------------------
89
+ *------------------------------------------------------------------------*/
90
+ uiZ:
91
+ uZ.ui = uiZ;
92
+ return uZ.f;
93
+
94
+ }
95
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f32.c ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float32_t f128_to_f32( float128_t a )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t frac64;
51
+ struct commonNaN commonNaN;
52
+ uint_fast32_t uiZ, frac32;
53
+ union ui32_f32 uZ;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ sign = signF128UI64( uiA64 );
61
+ exp = expF128UI64( uiA64 );
62
+ frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ if ( exp == 0x7FFF ) {
66
+ if ( frac64 ) {
67
+ softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68
+ uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69
+ } else {
70
+ uiZ = packToF32UI( sign, 0xFF, 0 );
71
+ }
72
+ goto uiZ;
73
+ }
74
+ /*------------------------------------------------------------------------
75
+ *------------------------------------------------------------------------*/
76
+ frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
77
+ if ( ! (exp | frac32) ) {
78
+ uiZ = packToF32UI( sign, 0, 0 );
79
+ goto uiZ;
80
+ }
81
+ /*------------------------------------------------------------------------
82
+ *------------------------------------------------------------------------*/
83
+ exp -= 0x3F81;
84
+ if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85
+ if ( exp < -0x1000 ) exp = -0x1000;
86
+ }
87
+ return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
88
+ /*------------------------------------------------------------------------
89
+ *------------------------------------------------------------------------*/
90
+ uiZ:
91
+ uZ.ui = uiZ;
92
+ return uZ.f;
93
+
94
+ }
95
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_f64.c ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float64_t f128_to_f64( float128_t a )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t frac64, frac0;
51
+ struct commonNaN commonNaN;
52
+ uint_fast64_t uiZ;
53
+ struct uint128 frac128;
54
+ union ui64_f64 uZ;
55
+
56
+ /*------------------------------------------------------------------------
57
+ *------------------------------------------------------------------------*/
58
+ uA.f = a;
59
+ uiA64 = uA.ui.v64;
60
+ uiA0 = uA.ui.v0;
61
+ sign = signF128UI64( uiA64 );
62
+ exp = expF128UI64( uiA64 );
63
+ frac64 = fracF128UI64( uiA64 );
64
+ frac0 = uiA0;
65
+ /*------------------------------------------------------------------------
66
+ *------------------------------------------------------------------------*/
67
+ if ( exp == 0x7FFF ) {
68
+ if ( frac64 | frac0 ) {
69
+ softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
70
+ uiZ = softfloat_commonNaNToF64UI( &commonNaN );
71
+ } else {
72
+ uiZ = packToF64UI( sign, 0x7FF, 0 );
73
+ }
74
+ goto uiZ;
75
+ }
76
+ /*------------------------------------------------------------------------
77
+ *------------------------------------------------------------------------*/
78
+ frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
79
+ frac64 = frac128.v64 | (frac128.v0 != 0);
80
+ if ( ! (exp | frac64) ) {
81
+ uiZ = packToF64UI( sign, 0, 0 );
82
+ goto uiZ;
83
+ }
84
+ /*------------------------------------------------------------------------
85
+ *------------------------------------------------------------------------*/
86
+ exp -= 0x3C01;
87
+ if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
88
+ if ( exp < -0x1000 ) exp = -0x1000;
89
+ }
90
+ return
91
+ softfloat_roundPackToF64(
92
+ sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
93
+ /*------------------------------------------------------------------------
94
+ *------------------------------------------------------------------------*/
95
+ uiZ:
96
+ uZ.ui = uiZ;
97
+ return uZ.f;
98
+
99
+ }
100
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i32.c ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t sig64, sig0;
51
+ int_fast32_t shiftDist;
52
+
53
+ /*------------------------------------------------------------------------
54
+ *------------------------------------------------------------------------*/
55
+ uA.f = a;
56
+ uiA64 = uA.ui.v64;
57
+ uiA0 = uA.ui.v0;
58
+ sign = signF128UI64( uiA64 );
59
+ exp = expF128UI64( uiA64 );
60
+ sig64 = fracF128UI64( uiA64 );
61
+ sig0 = uiA0;
62
+ /*------------------------------------------------------------------------
63
+ *------------------------------------------------------------------------*/
64
+ #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
65
+ if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
66
+ #if (i32_fromNaN == i32_fromPosOverflow)
67
+ sign = 0;
68
+ #elif (i32_fromNaN == i32_fromNegOverflow)
69
+ sign = 1;
70
+ #else
71
+ softfloat_raiseFlags( softfloat_flag_invalid );
72
+ return i32_fromNaN;
73
+ #endif
74
+ }
75
+ #endif
76
+ /*------------------------------------------------------------------------
77
+ *------------------------------------------------------------------------*/
78
+ if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79
+ sig64 |= (sig0 != 0);
80
+ shiftDist = 0x4023 - exp;
81
+ if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82
+ return softfloat_roundToI32( sign, sig64, roundingMode, exact );
83
+
84
+ }
85
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i32_r_minMag.c ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast32_t f128_to_i32_r_minMag( float128_t a, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ int_fast32_t exp;
49
+ uint_fast64_t sig64;
50
+ int_fast32_t shiftDist;
51
+ bool sign;
52
+ int_fast32_t absZ;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA64 = uA.ui.v64;
58
+ uiA0 = uA.ui.v0;
59
+ exp = expF128UI64( uiA64 );
60
+ sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61
+ /*------------------------------------------------------------------------
62
+ *------------------------------------------------------------------------*/
63
+ shiftDist = 0x402F - exp;
64
+ if ( 49 <= shiftDist ) {
65
+ if ( exact && (exp | sig64) ) {
66
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
67
+ }
68
+ return 0;
69
+ }
70
+ /*------------------------------------------------------------------------
71
+ *------------------------------------------------------------------------*/
72
+ sign = signF128UI64( uiA64 );
73
+ if ( shiftDist < 18 ) {
74
+ if (
75
+ sign && (shiftDist == 17)
76
+ && (sig64 < UINT64_C( 0x0000000000020000 ))
77
+ ) {
78
+ if ( exact && sig64 ) {
79
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
80
+ }
81
+ return -0x7FFFFFFF - 1;
82
+ }
83
+ softfloat_raiseFlags( softfloat_flag_invalid );
84
+ return
85
+ (exp == 0x7FFF) && sig64 ? i32_fromNaN
86
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
87
+ }
88
+ /*------------------------------------------------------------------------
89
+ *------------------------------------------------------------------------*/
90
+ sig64 |= UINT64_C( 0x0001000000000000 );
91
+ absZ = sig64>>shiftDist;
92
+ if (
93
+ exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig64)
94
+ ) {
95
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
96
+ }
97
+ return sign ? -absZ : absZ;
98
+
99
+ }
100
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i64.c ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast64_t f128_to_i64( float128_t a, uint_fast8_t roundingMode, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t sig64, sig0;
51
+ int_fast32_t shiftDist;
52
+ struct uint128 sig128;
53
+ struct uint64_extra sigExtra;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ sign = signF128UI64( uiA64 );
61
+ exp = expF128UI64( uiA64 );
62
+ sig64 = fracF128UI64( uiA64 );
63
+ sig0 = uiA0;
64
+ /*------------------------------------------------------------------------
65
+ *------------------------------------------------------------------------*/
66
+ shiftDist = 0x402F - exp;
67
+ if ( shiftDist <= 0 ) {
68
+ /*--------------------------------------------------------------------
69
+ *--------------------------------------------------------------------*/
70
+ if ( shiftDist < -15 ) {
71
+ softfloat_raiseFlags( softfloat_flag_invalid );
72
+ return
73
+ (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
74
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75
+ }
76
+ /*--------------------------------------------------------------------
77
+ *--------------------------------------------------------------------*/
78
+ sig64 |= UINT64_C( 0x0001000000000000 );
79
+ if ( shiftDist ) {
80
+ sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
81
+ sig64 = sig128.v64;
82
+ sig0 = sig128.v0;
83
+ }
84
+ } else {
85
+ /*--------------------------------------------------------------------
86
+ *--------------------------------------------------------------------*/
87
+ if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
88
+ sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
89
+ sig64 = sigExtra.v;
90
+ sig0 = sigExtra.extra;
91
+ }
92
+ return softfloat_roundToI64( sign, sig64, sig0, roundingMode, exact );
93
+
94
+ }
95
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_i64_r_minMag.c ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast64_t f128_to_i64_r_minMag( float128_t a, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t sig64, sig0;
51
+ int_fast32_t shiftDist;
52
+ int_fast8_t negShiftDist;
53
+ int_fast64_t absZ;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ sign = signF128UI64( uiA64 );
61
+ exp = expF128UI64( uiA64 );
62
+ sig64 = fracF128UI64( uiA64 );
63
+ sig0 = uiA0;
64
+ /*------------------------------------------------------------------------
65
+ *------------------------------------------------------------------------*/
66
+ shiftDist = 0x402F - exp;
67
+ if ( shiftDist < 0 ) {
68
+ /*--------------------------------------------------------------------
69
+ *--------------------------------------------------------------------*/
70
+ if ( shiftDist < -14 ) {
71
+ if (
72
+ (uiA64 == UINT64_C( 0xC03E000000000000 ))
73
+ && (sig0 < UINT64_C( 0x0002000000000000 ))
74
+ ) {
75
+ if ( exact && sig0 ) {
76
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
77
+ }
78
+ return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
79
+ }
80
+ softfloat_raiseFlags( softfloat_flag_invalid );
81
+ return
82
+ (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
83
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
84
+ }
85
+ /*--------------------------------------------------------------------
86
+ *--------------------------------------------------------------------*/
87
+ sig64 |= UINT64_C( 0x0001000000000000 );
88
+ negShiftDist = -shiftDist;
89
+ absZ = sig64<<negShiftDist | sig0>>(shiftDist & 63);
90
+ if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
91
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
92
+ }
93
+ } else {
94
+ /*--------------------------------------------------------------------
95
+ *--------------------------------------------------------------------*/
96
+ if ( 49 <= shiftDist ) {
97
+ if ( exact && (exp | sig64 | sig0) ) {
98
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
99
+ }
100
+ return 0;
101
+ }
102
+ /*--------------------------------------------------------------------
103
+ *--------------------------------------------------------------------*/
104
+ sig64 |= UINT64_C( 0x0001000000000000 );
105
+ absZ = sig64>>shiftDist;
106
+ if ( exact && (sig0 || (absZ<<shiftDist != sig64)) ) {
107
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
108
+ }
109
+ }
110
+ return sign ? -absZ : absZ;
111
+
112
+ }
113
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui32.c ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ uint_fast32_t
45
+ f128_to_ui32( float128_t a, uint_fast8_t roundingMode, bool exact )
46
+ {
47
+ union ui128_f128 uA;
48
+ uint_fast64_t uiA64, uiA0;
49
+ bool sign;
50
+ int_fast32_t exp;
51
+ uint_fast64_t sig64;
52
+ int_fast32_t shiftDist;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA64 = uA.ui.v64;
58
+ uiA0 = uA.ui.v0;
59
+ sign = signF128UI64( uiA64 );
60
+ exp = expF128UI64( uiA64 );
61
+ sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
62
+ /*------------------------------------------------------------------------
63
+ *------------------------------------------------------------------------*/
64
+ #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
65
+ if ( (exp == 0x7FFF) && sig64 ) {
66
+ #if (ui32_fromNaN == ui32_fromPosOverflow)
67
+ sign = 0;
68
+ #elif (ui32_fromNaN == ui32_fromNegOverflow)
69
+ sign = 1;
70
+ #else
71
+ softfloat_raiseFlags( softfloat_flag_invalid );
72
+ return ui32_fromNaN;
73
+ #endif
74
+ }
75
+ #endif
76
+ /*------------------------------------------------------------------------
77
+ *------------------------------------------------------------------------*/
78
+ if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79
+ shiftDist = 0x4023 - exp;
80
+ if ( 0 < shiftDist ) {
81
+ sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82
+ }
83
+ return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
84
+
85
+ }
86
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui32_r_minMag.c ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ uint_fast32_t f128_to_ui32_r_minMag( float128_t a, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ int_fast32_t exp;
49
+ uint_fast64_t sig64;
50
+ int_fast32_t shiftDist;
51
+ bool sign;
52
+ uint_fast32_t z;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA64 = uA.ui.v64;
58
+ uiA0 = uA.ui.v0;
59
+ exp = expF128UI64( uiA64 );
60
+ sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61
+ /*------------------------------------------------------------------------
62
+ *------------------------------------------------------------------------*/
63
+ shiftDist = 0x402F - exp;
64
+ if ( 49 <= shiftDist ) {
65
+ if ( exact && (exp | sig64) ) {
66
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
67
+ }
68
+ return 0;
69
+ }
70
+ /*------------------------------------------------------------------------
71
+ *------------------------------------------------------------------------*/
72
+ sign = signF128UI64( uiA64 );
73
+ if ( sign || (shiftDist < 17) ) {
74
+ softfloat_raiseFlags( softfloat_flag_invalid );
75
+ return
76
+ (exp == 0x7FFF) && sig64 ? ui32_fromNaN
77
+ : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78
+ }
79
+ /*------------------------------------------------------------------------
80
+ *------------------------------------------------------------------------*/
81
+ sig64 |= UINT64_C( 0x0001000000000000 );
82
+ z = sig64>>shiftDist;
83
+ if ( exact && ((uint_fast64_t) z<<shiftDist != sig64) ) {
84
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
85
+ }
86
+ return z;
87
+
88
+ }
89
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui64.c ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ uint_fast64_t
45
+ f128_to_ui64( float128_t a, uint_fast8_t roundingMode, bool exact )
46
+ {
47
+ union ui128_f128 uA;
48
+ uint_fast64_t uiA64, uiA0;
49
+ bool sign;
50
+ int_fast32_t exp;
51
+ uint_fast64_t sig64, sig0;
52
+ int_fast32_t shiftDist;
53
+ struct uint128 sig128;
54
+ struct uint64_extra sigExtra;
55
+
56
+ /*------------------------------------------------------------------------
57
+ *------------------------------------------------------------------------*/
58
+ uA.f = a;
59
+ uiA64 = uA.ui.v64;
60
+ uiA0 = uA.ui.v0;
61
+ sign = signF128UI64( uiA64 );
62
+ exp = expF128UI64( uiA64 );
63
+ sig64 = fracF128UI64( uiA64 );
64
+ sig0 = uiA0;
65
+ /*------------------------------------------------------------------------
66
+ *------------------------------------------------------------------------*/
67
+ shiftDist = 0x402F - exp;
68
+ if ( shiftDist <= 0 ) {
69
+ /*--------------------------------------------------------------------
70
+ *--------------------------------------------------------------------*/
71
+ if ( shiftDist < -15 ) {
72
+ softfloat_raiseFlags( softfloat_flag_invalid );
73
+ return
74
+ (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
75
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
76
+ }
77
+ /*--------------------------------------------------------------------
78
+ *--------------------------------------------------------------------*/
79
+ sig64 |= UINT64_C( 0x0001000000000000 );
80
+ if ( shiftDist ) {
81
+ sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
82
+ sig64 = sig128.v64;
83
+ sig0 = sig128.v0;
84
+ }
85
+ } else {
86
+ /*--------------------------------------------------------------------
87
+ *--------------------------------------------------------------------*/
88
+ if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
89
+ sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
90
+ sig64 = sigExtra.v;
91
+ sig0 = sigExtra.extra;
92
+ }
93
+ return softfloat_roundToUI64( sign, sig64, sig0, roundingMode, exact );
94
+
95
+ }
96
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f128_to_ui64_r_minMag.c ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ uint_fast64_t f128_to_ui64_r_minMag( float128_t a, bool exact )
45
+ {
46
+ union ui128_f128 uA;
47
+ uint_fast64_t uiA64, uiA0;
48
+ bool sign;
49
+ int_fast32_t exp;
50
+ uint_fast64_t sig64, sig0;
51
+ int_fast32_t shiftDist;
52
+ int_fast8_t negShiftDist;
53
+ uint_fast64_t z;
54
+
55
+ /*------------------------------------------------------------------------
56
+ *------------------------------------------------------------------------*/
57
+ uA.f = a;
58
+ uiA64 = uA.ui.v64;
59
+ uiA0 = uA.ui.v0;
60
+ sign = signF128UI64( uiA64 );
61
+ exp = expF128UI64( uiA64 );
62
+ sig64 = fracF128UI64( uiA64 );
63
+ sig0 = uiA0;
64
+ /*------------------------------------------------------------------------
65
+ *------------------------------------------------------------------------*/
66
+ shiftDist = 0x402F - exp;
67
+ if ( shiftDist < 0 ) {
68
+ /*--------------------------------------------------------------------
69
+ *--------------------------------------------------------------------*/
70
+ if ( sign || (shiftDist < -15) ) goto invalid;
71
+ sig64 |= UINT64_C( 0x0001000000000000 );
72
+ negShiftDist = -shiftDist;
73
+ z = sig64<<negShiftDist | sig0>>(shiftDist & 63);
74
+ if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
75
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
76
+ }
77
+ } else {
78
+ /*--------------------------------------------------------------------
79
+ *--------------------------------------------------------------------*/
80
+ if ( 49 <= shiftDist ) {
81
+ if ( exact && (exp | sig64 | sig0) ) {
82
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
83
+ }
84
+ return 0;
85
+ }
86
+ /*--------------------------------------------------------------------
87
+ *--------------------------------------------------------------------*/
88
+ if ( sign ) goto invalid;
89
+ sig64 |= UINT64_C( 0x0001000000000000 );
90
+ z = sig64>>shiftDist;
91
+ if ( exact && (sig0 || (z<<shiftDist != sig64)) ) {
92
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
93
+ }
94
+ }
95
+ return z;
96
+ /*------------------------------------------------------------------------
97
+ *------------------------------------------------------------------------*/
98
+ invalid:
99
+ softfloat_raiseFlags( softfloat_flag_invalid );
100
+ return
101
+ (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
102
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
103
+
104
+ }
105
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_add.c ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ float16_t f16_add( float16_t a, float16_t b )
44
+ {
45
+ union ui16_f16 uA;
46
+ uint_fast16_t uiA;
47
+ union ui16_f16 uB;
48
+ uint_fast16_t uiB;
49
+ #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51
+ #endif
52
+
53
+ uA.f = a;
54
+ uiA = uA.ui;
55
+ uB.f = b;
56
+ uiB = uB.ui;
57
+ #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58
+ if ( signF16UI( uiA ^ uiB ) ) {
59
+ return softfloat_subMagsF16( uiA, uiB );
60
+ } else {
61
+ return softfloat_addMagsF16( uiA, uiB );
62
+ }
63
+ #else
64
+ magsFuncPtr =
65
+ signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
66
+ return (*magsFuncPtr)( uiA, uiB );
67
+ #endif
68
+
69
+ }
70
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_classify.c ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #include <stdbool.h>
3
+ #include <stdint.h>
4
+ #include "platform.h"
5
+ #include "internals.h"
6
+ #include "specialize.h"
7
+ #include "softfloat.h"
8
+
9
+ uint_fast16_t f16_classify( float16_t a )
10
+ {
11
+ union ui16_f16 uA;
12
+ uint_fast16_t uiA;
13
+
14
+ uA.f = a;
15
+ uiA = uA.ui;
16
+
17
+ uint_fast16_t infOrNaN = expF16UI( uiA ) == 0x1F;
18
+ uint_fast16_t subnormalOrZero = expF16UI( uiA ) == 0;
19
+ bool sign = signF16UI( uiA );
20
+ bool fracZero = fracF16UI( uiA ) == 0;
21
+ bool isNaN = isNaNF16UI( uiA );
22
+ bool isSNaN = softfloat_isSigNaNF16UI( uiA );
23
+
24
+ return
25
+ ( sign && infOrNaN && fracZero ) << 0 |
26
+ ( sign && !infOrNaN && !subnormalOrZero ) << 1 |
27
+ ( sign && subnormalOrZero && !fracZero ) << 2 |
28
+ ( sign && subnormalOrZero && fracZero ) << 3 |
29
+ ( !sign && infOrNaN && fracZero ) << 7 |
30
+ ( !sign && !infOrNaN && !subnormalOrZero ) << 6 |
31
+ ( !sign && subnormalOrZero && !fracZero ) << 5 |
32
+ ( !sign && subnormalOrZero && fracZero ) << 4 |
33
+ ( isNaN && isSNaN ) << 8 |
34
+ ( isNaN && !isSNaN ) << 9;
35
+ }
36
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_div.c ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ extern const uint16_t softfloat_approxRecip_1k0s[];
45
+ extern const uint16_t softfloat_approxRecip_1k1s[];
46
+
47
+ float16_t f16_div( float16_t a, float16_t b )
48
+ {
49
+ union ui16_f16 uA;
50
+ uint_fast16_t uiA;
51
+ bool signA;
52
+ int_fast8_t expA;
53
+ uint_fast16_t sigA;
54
+ union ui16_f16 uB;
55
+ uint_fast16_t uiB;
56
+ bool signB;
57
+ int_fast8_t expB;
58
+ uint_fast16_t sigB;
59
+ bool signZ;
60
+ struct exp8_sig16 normExpSig;
61
+ int_fast8_t expZ;
62
+ #ifdef SOFTFLOAT_FAST_DIV32TO16
63
+ uint_fast32_t sig32A;
64
+ uint_fast16_t sigZ;
65
+ #else
66
+ int index;
67
+ uint16_t r0;
68
+ uint_fast16_t sigZ, rem;
69
+ #endif
70
+ uint_fast16_t uiZ;
71
+ union ui16_f16 uZ;
72
+
73
+ /*------------------------------------------------------------------------
74
+ *------------------------------------------------------------------------*/
75
+ uA.f = a;
76
+ uiA = uA.ui;
77
+ signA = signF16UI( uiA );
78
+ expA = expF16UI( uiA );
79
+ sigA = fracF16UI( uiA );
80
+ uB.f = b;
81
+ uiB = uB.ui;
82
+ signB = signF16UI( uiB );
83
+ expB = expF16UI( uiB );
84
+ sigB = fracF16UI( uiB );
85
+ signZ = signA ^ signB;
86
+ /*------------------------------------------------------------------------
87
+ *------------------------------------------------------------------------*/
88
+ if ( expA == 0x1F ) {
89
+ if ( sigA ) goto propagateNaN;
90
+ if ( expB == 0x1F ) {
91
+ if ( sigB ) goto propagateNaN;
92
+ goto invalid;
93
+ }
94
+ goto infinity;
95
+ }
96
+ if ( expB == 0x1F ) {
97
+ if ( sigB ) goto propagateNaN;
98
+ goto zero;
99
+ }
100
+ /*------------------------------------------------------------------------
101
+ *------------------------------------------------------------------------*/
102
+ if ( ! expB ) {
103
+ if ( ! sigB ) {
104
+ if ( ! (expA | sigA) ) goto invalid;
105
+ softfloat_raiseFlags( softfloat_flag_infinite );
106
+ goto infinity;
107
+ }
108
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
109
+ expB = normExpSig.exp;
110
+ sigB = normExpSig.sig;
111
+ }
112
+ if ( ! expA ) {
113
+ if ( ! sigA ) goto zero;
114
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
115
+ expA = normExpSig.exp;
116
+ sigA = normExpSig.sig;
117
+ }
118
+ /*------------------------------------------------------------------------
119
+ *------------------------------------------------------------------------*/
120
+ expZ = expA - expB + 0xE;
121
+ sigA |= 0x0400;
122
+ sigB |= 0x0400;
123
+ #ifdef SOFTFLOAT_FAST_DIV32TO16
124
+ if ( sigA < sigB ) {
125
+ --expZ;
126
+ sig32A = (uint_fast32_t) sigA<<15;
127
+ } else {
128
+ sig32A = (uint_fast32_t) sigA<<14;
129
+ }
130
+ sigZ = sig32A / sigB;
131
+ if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
132
+ #else
133
+ if ( sigA < sigB ) {
134
+ --expZ;
135
+ sigA <<= 5;
136
+ } else {
137
+ sigA <<= 4;
138
+ }
139
+ index = sigB>>6 & 0xF;
140
+ r0 = softfloat_approxRecip_1k0s[index]
141
+ - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
142
+ * (sigB & 0x3F))
143
+ >>10);
144
+ sigZ = ((uint_fast32_t) sigA * r0)>>16;
145
+ rem = (sigA<<10) - sigZ * sigB;
146
+ sigZ += (rem * (uint_fast32_t) r0)>>26;
147
+ /*------------------------------------------------------------------------
148
+ *------------------------------------------------------------------------*/
149
+ ++sigZ;
150
+ if ( ! (sigZ & 7) ) {
151
+ sigZ &= ~1;
152
+ rem = (sigA<<10) - sigZ * sigB;
153
+ if ( rem & 0x8000 ) {
154
+ sigZ -= 2;
155
+ } else {
156
+ if ( rem ) sigZ |= 1;
157
+ }
158
+ }
159
+ #endif
160
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
161
+ /*------------------------------------------------------------------------
162
+ *------------------------------------------------------------------------*/
163
+ propagateNaN:
164
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
165
+ goto uiZ;
166
+ /*------------------------------------------------------------------------
167
+ *------------------------------------------------------------------------*/
168
+ invalid:
169
+ softfloat_raiseFlags( softfloat_flag_invalid );
170
+ uiZ = defaultNaNF16UI;
171
+ goto uiZ;
172
+ /*------------------------------------------------------------------------
173
+ *------------------------------------------------------------------------*/
174
+ infinity:
175
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
176
+ goto uiZ;
177
+ /*------------------------------------------------------------------------
178
+ *------------------------------------------------------------------------*/
179
+ zero:
180
+ uiZ = packToF16UI( signZ, 0, 0 );
181
+ uiZ:
182
+ uZ.ui = uiZ;
183
+ return uZ.f;
184
+
185
+ }
186
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_eq.c ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f16_eq( float16_t a, float16_t b )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ union ui16_f16 uB;
49
+ uint_fast16_t uiB;
50
+
51
+ uA.f = a;
52
+ uiA = uA.ui;
53
+ uB.f = b;
54
+ uiB = uB.ui;
55
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56
+ if (
57
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
58
+ ) {
59
+ softfloat_raiseFlags( softfloat_flag_invalid );
60
+ }
61
+ return false;
62
+ }
63
+ return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
64
+
65
+ }
66
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_eq_signaling.c ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f16_eq_signaling( float16_t a, float16_t b )
44
+ {
45
+ union ui16_f16 uA;
46
+ uint_fast16_t uiA;
47
+ union ui16_f16 uB;
48
+ uint_fast16_t uiB;
49
+
50
+ uA.f = a;
51
+ uiA = uA.ui;
52
+ uB.f = b;
53
+ uiB = uB.ui;
54
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
55
+ softfloat_raiseFlags( softfloat_flag_invalid );
56
+ return false;
57
+ }
58
+ return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
59
+
60
+ }
61
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_isSignalingNaN.c ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include "platform.h"
39
+ #include "internals.h"
40
+ #include "specialize.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f16_isSignalingNaN( float16_t a )
44
+ {
45
+ union ui16_f16 uA;
46
+
47
+ uA.f = a;
48
+ return softfloat_isSigNaNF16UI( uA.ui );
49
+
50
+ }
51
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_le.c ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f16_le( float16_t a, float16_t b )
44
+ {
45
+ union ui16_f16 uA;
46
+ uint_fast16_t uiA;
47
+ union ui16_f16 uB;
48
+ uint_fast16_t uiB;
49
+ bool signA, signB;
50
+
51
+ uA.f = a;
52
+ uiA = uA.ui;
53
+ uB.f = b;
54
+ uiB = uB.ui;
55
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56
+ softfloat_raiseFlags( softfloat_flag_invalid );
57
+ return false;
58
+ }
59
+ signA = signF16UI( uiA );
60
+ signB = signF16UI( uiB );
61
+ return
62
+ (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
63
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
64
+
65
+ }
66
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_le_quiet.c ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f16_le_quiet( float16_t a, float16_t b )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ union ui16_f16 uB;
49
+ uint_fast16_t uiB;
50
+ bool signA, signB;
51
+
52
+ uA.f = a;
53
+ uiA = uA.ui;
54
+ uB.f = b;
55
+ uiB = uB.ui;
56
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57
+ if (
58
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59
+ ) {
60
+ softfloat_raiseFlags( softfloat_flag_invalid );
61
+ }
62
+ return false;
63
+ }
64
+ signA = signF16UI( uiA );
65
+ signB = signF16UI( uiB );
66
+ return
67
+ (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
68
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
69
+
70
+ }
71
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_lt.c ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ bool f16_lt( float16_t a, float16_t b )
44
+ {
45
+ union ui16_f16 uA;
46
+ uint_fast16_t uiA;
47
+ union ui16_f16 uB;
48
+ uint_fast16_t uiB;
49
+ bool signA, signB;
50
+
51
+ uA.f = a;
52
+ uiA = uA.ui;
53
+ uB.f = b;
54
+ uiB = uB.ui;
55
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56
+ softfloat_raiseFlags( softfloat_flag_invalid );
57
+ return false;
58
+ }
59
+ signA = signF16UI( uiA );
60
+ signB = signF16UI( uiB );
61
+ return
62
+ (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
63
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
64
+
65
+ }
66
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_lt_quiet.c ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ bool f16_lt_quiet( float16_t a, float16_t b )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ union ui16_f16 uB;
49
+ uint_fast16_t uiB;
50
+ bool signA, signB;
51
+
52
+ uA.f = a;
53
+ uiA = uA.ui;
54
+ uB.f = b;
55
+ uiB = uB.ui;
56
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57
+ if (
58
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59
+ ) {
60
+ softfloat_raiseFlags( softfloat_flag_invalid );
61
+ }
62
+ return false;
63
+ }
64
+ signA = signF16UI( uiA );
65
+ signB = signF16UI( uiB );
66
+ return
67
+ (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
68
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
69
+
70
+ }
71
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_mul.c ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float16_t f16_mul( float16_t a, float16_t b )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool signA;
49
+ int_fast8_t expA;
50
+ uint_fast16_t sigA;
51
+ union ui16_f16 uB;
52
+ uint_fast16_t uiB;
53
+ bool signB;
54
+ int_fast8_t expB;
55
+ uint_fast16_t sigB;
56
+ bool signZ;
57
+ uint_fast16_t magBits;
58
+ struct exp8_sig16 normExpSig;
59
+ int_fast8_t expZ;
60
+ uint_fast32_t sig32Z;
61
+ uint_fast16_t sigZ, uiZ;
62
+ union ui16_f16 uZ;
63
+
64
+ /*------------------------------------------------------------------------
65
+ *------------------------------------------------------------------------*/
66
+ uA.f = a;
67
+ uiA = uA.ui;
68
+ signA = signF16UI( uiA );
69
+ expA = expF16UI( uiA );
70
+ sigA = fracF16UI( uiA );
71
+ uB.f = b;
72
+ uiB = uB.ui;
73
+ signB = signF16UI( uiB );
74
+ expB = expF16UI( uiB );
75
+ sigB = fracF16UI( uiB );
76
+ signZ = signA ^ signB;
77
+ /*------------------------------------------------------------------------
78
+ *------------------------------------------------------------------------*/
79
+ if ( expA == 0x1F ) {
80
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
81
+ magBits = expB | sigB;
82
+ goto infArg;
83
+ }
84
+ if ( expB == 0x1F ) {
85
+ if ( sigB ) goto propagateNaN;
86
+ magBits = expA | sigA;
87
+ goto infArg;
88
+ }
89
+ /*------------------------------------------------------------------------
90
+ *------------------------------------------------------------------------*/
91
+ if ( ! expA ) {
92
+ if ( ! sigA ) goto zero;
93
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
94
+ expA = normExpSig.exp;
95
+ sigA = normExpSig.sig;
96
+ }
97
+ if ( ! expB ) {
98
+ if ( ! sigB ) goto zero;
99
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
100
+ expB = normExpSig.exp;
101
+ sigB = normExpSig.sig;
102
+ }
103
+ /*------------------------------------------------------------------------
104
+ *------------------------------------------------------------------------*/
105
+ expZ = expA + expB - 0xF;
106
+ sigA = (sigA | 0x0400)<<4;
107
+ sigB = (sigB | 0x0400)<<5;
108
+ sig32Z = (uint_fast32_t) sigA * sigB;
109
+ sigZ = sig32Z>>16;
110
+ if ( sig32Z & 0xFFFF ) sigZ |= 1;
111
+ if ( sigZ < 0x4000 ) {
112
+ --expZ;
113
+ sigZ <<= 1;
114
+ }
115
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
116
+ /*------------------------------------------------------------------------
117
+ *------------------------------------------------------------------------*/
118
+ propagateNaN:
119
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
120
+ goto uiZ;
121
+ /*------------------------------------------------------------------------
122
+ *------------------------------------------------------------------------*/
123
+ infArg:
124
+ if ( ! magBits ) {
125
+ softfloat_raiseFlags( softfloat_flag_invalid );
126
+ uiZ = defaultNaNF16UI;
127
+ } else {
128
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
129
+ }
130
+ goto uiZ;
131
+ /*------------------------------------------------------------------------
132
+ *------------------------------------------------------------------------*/
133
+ zero:
134
+ uiZ = packToF16UI( signZ, 0, 0 );
135
+ uiZ:
136
+ uZ.ui = uiZ;
137
+ return uZ.f;
138
+
139
+ }
140
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_mulAdd.c ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdint.h>
38
+ #include "platform.h"
39
+ #include "internals.h"
40
+ #include "softfloat.h"
41
+
42
+ float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
43
+ {
44
+ union ui16_f16 uA;
45
+ uint_fast16_t uiA;
46
+ union ui16_f16 uB;
47
+ uint_fast16_t uiB;
48
+ union ui16_f16 uC;
49
+ uint_fast16_t uiC;
50
+
51
+ uA.f = a;
52
+ uiA = uA.ui;
53
+ uB.f = b;
54
+ uiB = uB.ui;
55
+ uC.f = c;
56
+ uiC = uC.ui;
57
+ return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
58
+
59
+ }
60
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_rem.c ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float16_t f16_rem( float16_t a, float16_t b )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool signA;
49
+ int_fast8_t expA;
50
+ uint_fast16_t sigA;
51
+ union ui16_f16 uB;
52
+ uint_fast16_t uiB;
53
+ int_fast8_t expB;
54
+ uint_fast16_t sigB;
55
+ struct exp8_sig16 normExpSig;
56
+ uint16_t rem;
57
+ int_fast8_t expDiff;
58
+ uint_fast16_t q;
59
+ uint32_t recip32, q32;
60
+ uint16_t altRem, meanRem;
61
+ bool signRem;
62
+ uint_fast16_t uiZ;
63
+ union ui16_f16 uZ;
64
+
65
+ /*------------------------------------------------------------------------
66
+ *------------------------------------------------------------------------*/
67
+ uA.f = a;
68
+ uiA = uA.ui;
69
+ signA = signF16UI( uiA );
70
+ expA = expF16UI( uiA );
71
+ sigA = fracF16UI( uiA );
72
+ uB.f = b;
73
+ uiB = uB.ui;
74
+ expB = expF16UI( uiB );
75
+ sigB = fracF16UI( uiB );
76
+ /*------------------------------------------------------------------------
77
+ *------------------------------------------------------------------------*/
78
+ if ( expA == 0x1F ) {
79
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
80
+ goto invalid;
81
+ }
82
+ if ( expB == 0x1F ) {
83
+ if ( sigB ) goto propagateNaN;
84
+ return a;
85
+ }
86
+ /*------------------------------------------------------------------------
87
+ *------------------------------------------------------------------------*/
88
+ if ( ! expB ) {
89
+ if ( ! sigB ) goto invalid;
90
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
91
+ expB = normExpSig.exp;
92
+ sigB = normExpSig.sig;
93
+ }
94
+ if ( ! expA ) {
95
+ if ( ! sigA ) return a;
96
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
97
+ expA = normExpSig.exp;
98
+ sigA = normExpSig.sig;
99
+ }
100
+ /*------------------------------------------------------------------------
101
+ *------------------------------------------------------------------------*/
102
+ rem = sigA | 0x0400;
103
+ sigB |= 0x0400;
104
+ expDiff = expA - expB;
105
+ if ( expDiff < 1 ) {
106
+ if ( expDiff < -1 ) return a;
107
+ sigB <<= 3;
108
+ if ( expDiff ) {
109
+ rem <<= 2;
110
+ q = 0;
111
+ } else {
112
+ rem <<= 3;
113
+ q = (sigB <= rem);
114
+ if ( q ) rem -= sigB;
115
+ }
116
+ } else {
117
+ recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
118
+ /*--------------------------------------------------------------------
119
+ | Changing the shift of `rem' here requires also changing the initial
120
+ | subtraction from `expDiff'.
121
+ *--------------------------------------------------------------------*/
122
+ rem <<= 4;
123
+ expDiff -= 31;
124
+ /*--------------------------------------------------------------------
125
+ | The scale of `sigB' affects how many bits are obtained during each
126
+ | cycle of the loop. Currently this is 29 bits per loop iteration,
127
+ | which is believed to be the maximum possible.
128
+ *--------------------------------------------------------------------*/
129
+ sigB <<= 3;
130
+ for (;;) {
131
+ q32 = (rem * (uint_fast64_t) recip32)>>16;
132
+ if ( expDiff < 0 ) break;
133
+ rem = -((uint_fast16_t) q32 * sigB);
134
+ expDiff -= 29;
135
+ }
136
+ /*--------------------------------------------------------------------
137
+ | (`expDiff' cannot be less than -30 here.)
138
+ *--------------------------------------------------------------------*/
139
+ q32 >>= ~expDiff & 31;
140
+ q = q32;
141
+ rem = (rem<<(expDiff + 30)) - q * sigB;
142
+ }
143
+ /*------------------------------------------------------------------------
144
+ *------------------------------------------------------------------------*/
145
+ do {
146
+ altRem = rem;
147
+ ++q;
148
+ rem -= sigB;
149
+ } while ( ! (rem & 0x8000) );
150
+ meanRem = rem + altRem;
151
+ if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
152
+ signRem = signA;
153
+ if ( 0x8000 <= rem ) {
154
+ signRem = ! signRem;
155
+ rem = -rem;
156
+ }
157
+ return softfloat_normRoundPackToF16( signRem, expB, rem );
158
+ /*------------------------------------------------------------------------
159
+ *------------------------------------------------------------------------*/
160
+ propagateNaN:
161
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
162
+ goto uiZ;
163
+ invalid:
164
+ softfloat_raiseFlags( softfloat_flag_invalid );
165
+ uiZ = defaultNaNF16UI;
166
+ uiZ:
167
+ uZ.ui = uiZ;
168
+ return uZ.f;
169
+
170
+ }
171
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_roundToInt.c ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ int_fast8_t exp;
49
+ uint_fast16_t uiZ, lastBitMask, roundBitsMask;
50
+ union ui16_f16 uZ;
51
+
52
+ /*------------------------------------------------------------------------
53
+ *------------------------------------------------------------------------*/
54
+ uA.f = a;
55
+ uiA = uA.ui;
56
+ exp = expF16UI( uiA );
57
+ /*------------------------------------------------------------------------
58
+ *------------------------------------------------------------------------*/
59
+ if ( exp <= 0xE ) {
60
+ if ( ! (uint16_t) (uiA<<1) ) return a;
61
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62
+ uiZ = uiA & packToF16UI( 1, 0, 0 );
63
+ switch ( roundingMode ) {
64
+ case softfloat_round_near_even:
65
+ if ( ! fracF16UI( uiA ) ) break;
66
+ case softfloat_round_near_maxMag:
67
+ if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
68
+ break;
69
+ case softfloat_round_min:
70
+ if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
71
+ break;
72
+ case softfloat_round_max:
73
+ if ( ! uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
74
+ break;
75
+ }
76
+ goto uiZ;
77
+ }
78
+ /*------------------------------------------------------------------------
79
+ *------------------------------------------------------------------------*/
80
+ if ( 0x19 <= exp ) {
81
+ if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
82
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
83
+ goto uiZ;
84
+ }
85
+ return a;
86
+ }
87
+ /*------------------------------------------------------------------------
88
+ *------------------------------------------------------------------------*/
89
+ uiZ = uiA;
90
+ lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
91
+ roundBitsMask = lastBitMask - 1;
92
+ if ( roundingMode == softfloat_round_near_maxMag ) {
93
+ uiZ += lastBitMask>>1;
94
+ } else if ( roundingMode == softfloat_round_near_even ) {
95
+ uiZ += lastBitMask>>1;
96
+ if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
97
+ } else if (
98
+ roundingMode
99
+ == (signF16UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
100
+ ) {
101
+ uiZ += roundBitsMask;
102
+ }
103
+ uiZ &= ~roundBitsMask;
104
+ if ( exact && (uiZ != uiA) ) {
105
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
106
+ }
107
+ uiZ:
108
+ uZ.ui = uiZ;
109
+ return uZ.f;
110
+
111
+ }
112
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_sqrt.c ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
45
+ extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
46
+
47
+ float16_t f16_sqrt( float16_t a )
48
+ {
49
+ union ui16_f16 uA;
50
+ uint_fast16_t uiA;
51
+ bool signA;
52
+ int_fast8_t expA;
53
+ uint_fast16_t sigA, uiZ;
54
+ struct exp8_sig16 normExpSig;
55
+ int_fast8_t expZ;
56
+ int index;
57
+ uint_fast16_t r0;
58
+ uint_fast32_t ESqrR0;
59
+ uint16_t sigma0;
60
+ uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
61
+ uint16_t negRem;
62
+ union ui16_f16 uZ;
63
+
64
+ /*------------------------------------------------------------------------
65
+ *------------------------------------------------------------------------*/
66
+ uA.f = a;
67
+ uiA = uA.ui;
68
+ signA = signF16UI( uiA );
69
+ expA = expF16UI( uiA );
70
+ sigA = fracF16UI( uiA );
71
+ /*------------------------------------------------------------------------
72
+ *------------------------------------------------------------------------*/
73
+ if ( expA == 0x1F ) {
74
+ if ( sigA ) {
75
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
76
+ goto uiZ;
77
+ }
78
+ if ( ! signA ) return a;
79
+ goto invalid;
80
+ }
81
+ /*------------------------------------------------------------------------
82
+ *------------------------------------------------------------------------*/
83
+ if ( signA ) {
84
+ if ( ! (expA | sigA) ) return a;
85
+ goto invalid;
86
+ }
87
+ /*------------------------------------------------------------------------
88
+ *------------------------------------------------------------------------*/
89
+ if ( ! expA ) {
90
+ if ( ! sigA ) return a;
91
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
92
+ expA = normExpSig.exp;
93
+ sigA = normExpSig.sig;
94
+ }
95
+ /*------------------------------------------------------------------------
96
+ *------------------------------------------------------------------------*/
97
+ expZ = ((expA - 0xF)>>1) + 0xE;
98
+ expA &= 1;
99
+ sigA |= 0x0400;
100
+ index = (sigA>>6 & 0xE) + expA;
101
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
102
+ - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
103
+ * (sigA & 0x7F))
104
+ >>11);
105
+ ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
106
+ if ( expA ) ESqrR0 >>= 1;
107
+ sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
108
+ recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
109
+ if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
110
+ sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
111
+ if ( expA ) sigZ >>= 1;
112
+ /*------------------------------------------------------------------------
113
+ *------------------------------------------------------------------------*/
114
+ ++sigZ;
115
+ if ( ! (sigZ & 7) ) {
116
+ shiftedSigZ = sigZ>>1;
117
+ negRem = shiftedSigZ * shiftedSigZ;
118
+ sigZ &= ~1;
119
+ if ( negRem & 0x8000 ) {
120
+ sigZ |= 1;
121
+ } else {
122
+ if ( negRem ) --sigZ;
123
+ }
124
+ }
125
+ return softfloat_roundPackToF16( 0, expZ, sigZ );
126
+ /*------------------------------------------------------------------------
127
+ *------------------------------------------------------------------------*/
128
+ invalid:
129
+ softfloat_raiseFlags( softfloat_flag_invalid );
130
+ uiZ = defaultNaNF16UI;
131
+ uiZ:
132
+ uZ.ui = uiZ;
133
+ return uZ.f;
134
+
135
+ }
136
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_sub.c ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "softfloat.h"
42
+
43
+ float16_t f16_sub( float16_t a, float16_t b )
44
+ {
45
+ union ui16_f16 uA;
46
+ uint_fast16_t uiA;
47
+ union ui16_f16 uB;
48
+ uint_fast16_t uiB;
49
+ #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51
+ #endif
52
+
53
+ uA.f = a;
54
+ uiA = uA.ui;
55
+ uB.f = b;
56
+ uiB = uB.ui;
57
+ #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58
+ if ( signF16UI( uiA ^ uiB ) ) {
59
+ return softfloat_addMagsF16( uiA, uiB );
60
+ } else {
61
+ return softfloat_subMagsF16( uiA, uiB );
62
+ }
63
+ #else
64
+ magsFuncPtr =
65
+ signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
66
+ return (*magsFuncPtr)( uiA, uiB );
67
+ #endif
68
+
69
+ }
70
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f128.c ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float128_t f16_to_f128( float16_t a )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool sign;
49
+ int_fast8_t exp;
50
+ uint_fast16_t frac;
51
+ struct commonNaN commonNaN;
52
+ struct uint128 uiZ;
53
+ struct exp8_sig16 normExpSig;
54
+ union ui128_f128 uZ;
55
+
56
+ /*------------------------------------------------------------------------
57
+ *------------------------------------------------------------------------*/
58
+ uA.f = a;
59
+ uiA = uA.ui;
60
+ sign = signF16UI( uiA );
61
+ exp = expF16UI( uiA );
62
+ frac = fracF16UI( uiA );
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ if ( exp == 0x1F ) {
66
+ if ( frac ) {
67
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68
+ uiZ = softfloat_commonNaNToF128UI( &commonNaN );
69
+ } else {
70
+ uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71
+ uiZ.v0 = 0;
72
+ }
73
+ goto uiZ;
74
+ }
75
+ /*------------------------------------------------------------------------
76
+ *------------------------------------------------------------------------*/
77
+ if ( ! exp ) {
78
+ if ( ! frac ) {
79
+ uiZ.v64 = packToF128UI64( sign, 0, 0 );
80
+ uiZ.v0 = 0;
81
+ goto uiZ;
82
+ }
83
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
84
+ exp = normExpSig.exp - 1;
85
+ frac = normExpSig.sig;
86
+ }
87
+ /*------------------------------------------------------------------------
88
+ *------------------------------------------------------------------------*/
89
+ uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
90
+ uiZ.v0 = 0;
91
+ uiZ:
92
+ uZ.ui = uiZ;
93
+ return uZ.f;
94
+
95
+ }
96
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f32.c ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float32_t f16_to_f32( float16_t a )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool sign;
49
+ int_fast8_t exp;
50
+ uint_fast16_t frac;
51
+ struct commonNaN commonNaN;
52
+ uint_fast32_t uiZ;
53
+ struct exp8_sig16 normExpSig;
54
+ union ui32_f32 uZ;
55
+
56
+ /*------------------------------------------------------------------------
57
+ *------------------------------------------------------------------------*/
58
+ uA.f = a;
59
+ uiA = uA.ui;
60
+ sign = signF16UI( uiA );
61
+ exp = expF16UI( uiA );
62
+ frac = fracF16UI( uiA );
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ if ( exp == 0x1F ) {
66
+ if ( frac ) {
67
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68
+ uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69
+ } else {
70
+ uiZ = packToF32UI( sign, 0xFF, 0 );
71
+ }
72
+ goto uiZ;
73
+ }
74
+ /*------------------------------------------------------------------------
75
+ *------------------------------------------------------------------------*/
76
+ if ( ! exp ) {
77
+ if ( ! frac ) {
78
+ uiZ = packToF32UI( sign, 0, 0 );
79
+ goto uiZ;
80
+ }
81
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
82
+ exp = normExpSig.exp - 1;
83
+ frac = normExpSig.sig;
84
+ }
85
+ /*------------------------------------------------------------------------
86
+ *------------------------------------------------------------------------*/
87
+ uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
88
+ uiZ:
89
+ uZ.ui = uiZ;
90
+ return uZ.f;
91
+
92
+ }
93
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_f64.c ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ float64_t f16_to_f64( float16_t a )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool sign;
49
+ int_fast8_t exp;
50
+ uint_fast16_t frac;
51
+ struct commonNaN commonNaN;
52
+ uint_fast64_t uiZ;
53
+ struct exp8_sig16 normExpSig;
54
+ union ui64_f64 uZ;
55
+
56
+ /*------------------------------------------------------------------------
57
+ *------------------------------------------------------------------------*/
58
+ uA.f = a;
59
+ uiA = uA.ui;
60
+ sign = signF16UI( uiA );
61
+ exp = expF16UI( uiA );
62
+ frac = fracF16UI( uiA );
63
+ /*------------------------------------------------------------------------
64
+ *------------------------------------------------------------------------*/
65
+ if ( exp == 0x1F ) {
66
+ if ( frac ) {
67
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68
+ uiZ = softfloat_commonNaNToF64UI( &commonNaN );
69
+ } else {
70
+ uiZ = packToF64UI( sign, 0x7FF, 0 );
71
+ }
72
+ goto uiZ;
73
+ }
74
+ /*------------------------------------------------------------------------
75
+ *------------------------------------------------------------------------*/
76
+ if ( ! exp ) {
77
+ if ( ! frac ) {
78
+ uiZ = packToF64UI( sign, 0, 0 );
79
+ goto uiZ;
80
+ }
81
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
82
+ exp = normExpSig.exp - 1;
83
+ frac = normExpSig.sig;
84
+ }
85
+ /*------------------------------------------------------------------------
86
+ *------------------------------------------------------------------------*/
87
+ uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
88
+ uiZ:
89
+ uZ.ui = uiZ;
90
+ return uZ.f;
91
+
92
+ }
93
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i16.c ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdint.h>
38
+ #include "specialize.h"
39
+ #include "softfloat.h"
40
+
41
+ int_fast16_t f16_to_i16( float16_t a, uint_fast8_t roundingMode, bool exact )
42
+ {
43
+ uint_fast8_t old_flags = softfloat_exceptionFlags;
44
+
45
+ int_fast32_t sig32 = f16_to_i32(a, roundingMode, exact);
46
+
47
+ if (sig32 > INT16_MAX) {
48
+ softfloat_exceptionFlags = old_flags | softfloat_flag_invalid;
49
+ return i16_fromPosOverflow;
50
+ } else if (sig32 < INT16_MIN) {
51
+ softfloat_exceptionFlags = old_flags | softfloat_flag_invalid;
52
+ return i16_fromNegOverflow;
53
+ } else {
54
+ return sig32;
55
+ }
56
+ }
57
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i32.c ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool sign;
49
+ int_fast8_t exp;
50
+ uint_fast16_t frac;
51
+ int_fast32_t sig32;
52
+ int_fast8_t shiftDist;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA = uA.ui;
58
+ sign = signF16UI( uiA );
59
+ exp = expF16UI( uiA );
60
+ frac = fracF16UI( uiA );
61
+ /*------------------------------------------------------------------------
62
+ *------------------------------------------------------------------------*/
63
+ if ( exp == 0x1F ) {
64
+ softfloat_raiseFlags( softfloat_flag_invalid );
65
+ return
66
+ frac ? i32_fromNaN
67
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
68
+ }
69
+ /*------------------------------------------------------------------------
70
+ *------------------------------------------------------------------------*/
71
+ sig32 = frac;
72
+ if ( exp ) {
73
+ sig32 |= 0x0400;
74
+ shiftDist = exp - 0x19;
75
+ if ( 0 <= shiftDist ) {
76
+ sig32 <<= shiftDist;
77
+ return sign ? -sig32 : sig32;
78
+ }
79
+ shiftDist = exp - 0x0D;
80
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
81
+ }
82
+ return
83
+ softfloat_roundToI32(
84
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
85
+
86
+ }
87
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i32_r_minMag.c ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ int_fast8_t exp;
49
+ uint_fast16_t frac;
50
+ int_fast8_t shiftDist;
51
+ bool sign;
52
+ int_fast32_t alignedSig;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA = uA.ui;
58
+ exp = expF16UI( uiA );
59
+ frac = fracF16UI( uiA );
60
+ /*------------------------------------------------------------------------
61
+ *------------------------------------------------------------------------*/
62
+ shiftDist = exp - 0x0F;
63
+ if ( shiftDist < 0 ) {
64
+ if ( exact && (exp | frac) ) {
65
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
66
+ }
67
+ return 0;
68
+ }
69
+ /*------------------------------------------------------------------------
70
+ *------------------------------------------------------------------------*/
71
+ sign = signF16UI( uiA );
72
+ if ( exp == 0x1F ) {
73
+ softfloat_raiseFlags( softfloat_flag_invalid );
74
+ return
75
+ (exp == 0x1F) && frac ? i32_fromNaN
76
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
77
+ }
78
+ /*------------------------------------------------------------------------
79
+ *------------------------------------------------------------------------*/
80
+ alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81
+ if ( exact && (alignedSig & 0x3FF) ) {
82
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
83
+ }
84
+ alignedSig >>= 10;
85
+ return sign ? -alignedSig : alignedSig;
86
+
87
+ }
88
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i64.c ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ bool sign;
49
+ int_fast8_t exp;
50
+ uint_fast16_t frac;
51
+ int_fast32_t sig32;
52
+ int_fast8_t shiftDist;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA = uA.ui;
58
+ sign = signF16UI( uiA );
59
+ exp = expF16UI( uiA );
60
+ frac = fracF16UI( uiA );
61
+ /*------------------------------------------------------------------------
62
+ *------------------------------------------------------------------------*/
63
+ if ( exp == 0x1F ) {
64
+ softfloat_raiseFlags( softfloat_flag_invalid );
65
+ return
66
+ frac ? i64_fromNaN
67
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
68
+ }
69
+ /*------------------------------------------------------------------------
70
+ *------------------------------------------------------------------------*/
71
+ sig32 = frac;
72
+ if ( exp ) {
73
+ sig32 |= 0x0400;
74
+ shiftDist = exp - 0x19;
75
+ if ( 0 <= shiftDist ) {
76
+ sig32 <<= shiftDist;
77
+ return sign ? -sig32 : sig32;
78
+ }
79
+ shiftDist = exp - 0x0D;
80
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
81
+ }
82
+ return
83
+ softfloat_roundToI32(
84
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
85
+
86
+ }
87
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i64_r_minMag.c ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8
+ California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdbool.h>
38
+ #include <stdint.h>
39
+ #include "platform.h"
40
+ #include "internals.h"
41
+ #include "specialize.h"
42
+ #include "softfloat.h"
43
+
44
+ int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
45
+ {
46
+ union ui16_f16 uA;
47
+ uint_fast16_t uiA;
48
+ int_fast8_t exp;
49
+ uint_fast16_t frac;
50
+ int_fast8_t shiftDist;
51
+ bool sign;
52
+ int_fast32_t alignedSig;
53
+
54
+ /*------------------------------------------------------------------------
55
+ *------------------------------------------------------------------------*/
56
+ uA.f = a;
57
+ uiA = uA.ui;
58
+ exp = expF16UI( uiA );
59
+ frac = fracF16UI( uiA );
60
+ /*------------------------------------------------------------------------
61
+ *------------------------------------------------------------------------*/
62
+ shiftDist = exp - 0x0F;
63
+ if ( shiftDist < 0 ) {
64
+ if ( exact && (exp | frac) ) {
65
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
66
+ }
67
+ return 0;
68
+ }
69
+ /*------------------------------------------------------------------------
70
+ *------------------------------------------------------------------------*/
71
+ sign = signF16UI( uiA );
72
+ if ( exp == 0x1F ) {
73
+ softfloat_raiseFlags( softfloat_flag_invalid );
74
+ return
75
+ (exp == 0x1F) && frac ? i64_fromNaN
76
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
77
+ }
78
+ /*------------------------------------------------------------------------
79
+ *------------------------------------------------------------------------*/
80
+ alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81
+ if ( exact && (alignedSig & 0x3FF) ) {
82
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
83
+ }
84
+ alignedSig >>= 10;
85
+ return sign ? -alignedSig : alignedSig;
86
+
87
+ }
88
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_i8.c ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdint.h>
38
+ #include "specialize.h"
39
+ #include "softfloat.h"
40
+
41
+ int_fast8_t f16_to_i8( float16_t a, uint_fast8_t roundingMode, bool exact )
42
+ {
43
+ uint_fast8_t old_flags = softfloat_exceptionFlags;
44
+
45
+ int_fast32_t sig32 = f16_to_i32(a, roundingMode, exact);
46
+
47
+ if (sig32 > INT8_MAX) {
48
+ softfloat_exceptionFlags = old_flags | softfloat_flag_invalid;
49
+ return i8_fromPosOverflow;
50
+ } else if (sig32 < INT8_MIN) {
51
+ softfloat_exceptionFlags = old_flags | softfloat_flag_invalid;
52
+ return i8_fromNegOverflow;
53
+ } else {
54
+ return sig32;
55
+ }
56
+ }
57
+
compsec-snu_difuzz-rtl/Fuzzer/ISASim/riscv-isa-sim/softfloat/f16_to_ui16.c ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*============================================================================
3
+
4
+ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5
+ Package, Release 3d, by John R. Hauser.
6
+
7
+ Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8
+ University of California. All rights reserved.
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice,
14
+ this list of conditions, and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions, and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the University nor the names of its contributors may
21
+ be used to endorse or promote products derived from this software without
22
+ specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ =============================================================================*/
36
+
37
+ #include <stdint.h>
38
+ #include "specialize.h"
39
+ #include "softfloat.h"
40
+
41
+ uint_fast16_t f16_to_ui16( float16_t a, uint_fast8_t roundingMode, bool exact )
42
+ {
43
+ uint_fast8_t old_flags = softfloat_exceptionFlags;
44
+
45
+ uint_fast32_t sig32 = f16_to_ui32(a, roundingMode, exact);
46
+
47
+ if (sig32 > UINT16_MAX) {
48
+ softfloat_exceptionFlags = old_flags | softfloat_flag_invalid;
49
+ return ui16_fromPosOverflow;
50
+ } else {
51
+ return sig32;
52
+ }
53
+ }
54
+