From d2ca22c2af5e5a9c6c7279d0578c2b1f9620d5df Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Thu, 8 Feb 2024 11:04:26 +0000 Subject: pseudocode: move defintions of apply_clip_{s,u} after the functions they call They need apply_{max,min}_{s,u}. Signed-off-by: Kevin Petit Change-Id: I67cdfcd0eb9d7a25223b2ebb86219a21bbf9f2f6 --- pseudocode/library/arithmetic_helpers.tosac | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pseudocode/library/arithmetic_helpers.tosac b/pseudocode/library/arithmetic_helpers.tosac index a50ab43..d2a4c46 100644 --- a/pseudocode/library/arithmetic_helpers.tosac +++ b/pseudocode/library/arithmetic_helpers.tosac @@ -35,25 +35,6 @@ in_t apply_intdiv_s(in_t a, in_t b) { // return input value rounded up to nearest integer in_t apply_ceil(in_t input); -in_t apply_clip_s(in_t value, in_t min_val, in_t max_val) { - if (is_floating_point()) { - REQUIRE(min_val <= max_val); - } - else { - REQUIRE(sign_extend(min_val) <= sign_extend(max_val)); - } - value = apply_max_s(value, min_val); - value = apply_min_s(value, max_val); - return value; -} - -in_t apply_clip_u(in_t value, in_t min_val, in_t max_val) { - REQUIRE(zero_extend(min_val) <= zero_extend(max_val)); - value = apply_max_u(value, min_val); - value = apply_min_u(value, max_val); - return value; -} - // return e to the power input in_t apply_exp(in_t input); @@ -108,6 +89,25 @@ in_t apply_min_u(in_t a, in_t b) { if (zero_extend(a) < zero_extend(b)) return a; else return b; } +in_t apply_clip_s(in_t value, in_t min_val, in_t max_val) { + if (is_floating_point()) { + REQUIRE(min_val <= max_val); + } + else { + REQUIRE(sign_extend(min_val) <= sign_extend(max_val)); + } + value = apply_max_s(value, min_val); + value = apply_min_s(value, max_val); + return value; +} + +in_t apply_clip_u(in_t value, in_t min_val, in_t max_val) { + REQUIRE(zero_extend(min_val) <= zero_extend(max_val)); + value = apply_max_u(value, min_val); + value = apply_min_u(value, max_val); + return value; +} + in_t apply_mul_s(in_t a, in_t b) { if (is_floating_point()) return a * b; int64_t c = sign_extend(a) * sign_extend(b); -- cgit v1.2.1