diff options
author | Eric Kunze <eric.kunze@arm.com> | 2022-04-07 16:54:46 -0700 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2022-06-17 20:38:16 +0000 |
commit | 42229d03fe55c45f0ad2ba68f190f3d68a78ae79 (patch) | |
tree | fde2487db3fe2c4e8257beec9b54044fac9da931 /chapters/pseudocode.adoc | |
parent | f9e5ba94f12a71f088c790f532cd62d33b8d25d0 (diff) | |
download | specification-42229d03fe55c45f0ad2ba68f190f3d68a78ae79.tar.gz |
Initial work on floating-point type definition
Define operations in terms of common floating-point data
types. Definitions for the data types are in the introduction.
Added a section to describe status of the different profiles.
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: Iac57026806acfb7913f40af61176322fb02b7cc1
Diffstat (limited to 'chapters/pseudocode.adoc')
-rw-r--r-- | chapters/pseudocode.adoc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc index 0747387..1d6c2f2 100644 --- a/chapters/pseudocode.adoc +++ b/chapters/pseudocode.adoc @@ -152,7 +152,7 @@ The following functions provide arithmetic while defining requirements such that [source,c++] ---- in_t apply_add<in_t>(in_t a, in_t b) { - if (<in_t> == float_t) return a + b; + if (is_floating_point(in_t)) return a + b; int64_t c = (int64_t)a + (int64_t)b; REQUIRE(c >= minimum<in_t> && c <= maximum<in_t>); return (in_t)c; @@ -188,7 +188,7 @@ in_t apply_log<in_t>(in_t input) { } in_t apply_max<in_t>(in_t a, in_t b) { - if (in_t == float_t) { + if (is_floating_point(in_t)) { if (isNaN(a) || isNaN(b)) { return NaN; } @@ -197,7 +197,7 @@ in_t apply_max<in_t>(in_t a, in_t b) { } in_t apply_min<in_t>(in_t a, in_t b) { - if (in_t == float_t) { + if (is_floating_point(in_t)) { if (isNaN(a) || isNaN(b)) { return NaN; } @@ -214,7 +214,7 @@ in_t apply_sqrt<in_t>(in_t input) { } in_t apply_sub<in_t>(in_t a, in_t b) { - if (in_t == float_t) return a - b; + if (is_floating_point(in_t)) return a - b; int64_t c = (int64_t)a - (int64_t)b; REQUIRE(c >= minimum<in_t> && c <= maximum<in_t>); return (in_t)c; @@ -238,6 +238,8 @@ int32_t count_leading_zeros(int32_t a) { ==== Numeric Conversion Helpers The following definitions are used in pseudocode to do numeric conversions. +Where the *float_t* type is used, it represents all of the floating-point data types supported by the given profile. +See <<Number formats>> for details on the floating-point formats. [source,c++] ---- @@ -276,6 +278,12 @@ Generic helper functions used to keep the pseudocode concise. [source,c++] ---- +bool_t is_floating_point(type) { + if (type == fp16_t || type == fp32_t || type == bf16_t) + return true; + return false; +} + int32_t idiv(int32_t input1, int32_t input2) { return input1 / input2; // Integer divide that truncates towards zero } |