Replace node level check ASSERT_MSG_NODE()/FATAL_ERROR_NODE() with REQUIRE() or ERROR_IF()

- Adding return code enum class: {VALID, UNPREDICTABLE, ERROR}
- Runtime errors (e.g. memory allocation failure) will abort immediately, or will return one of the three return codes
  Part of the codes are re-written to pass REQUIRE() to the top-level (e.g. apply_scale_32/16())
- Update setExpectedFailure() to setExpectedReturnCode() on test generation script
- Update test regression script to interface with reference model change

Signed-off-by: Kevin Cheng <kevin.cheng@arm.com>
Change-Id: Ia063c936bcb2a54d6e379a5bb6801aa72d1186f1
diff --git a/reference_model/src/quant_util.h b/reference_model/src/quant_util.h
index c595869..4f6a525 100644
--- a/reference_model/src/quant_util.h
+++ b/reference_model/src/quant_util.h
@@ -44,9 +44,17 @@
 
     static int32_t apply_scale_32(int32_t value, int32_t multiplier, int32_t shift, bool double_round = true)
     {
-        ASSERT_MSG(multiplier >= 0, "apply_scale_32() error: multiplier should >= 0 but is %d", multiplier);
-        ASSERT_MSG(shift >= 2 && shift <= 62, "apply_scale_32() error: shift should be within [2, 62] but is %d",
-                   shift);
+        if (multiplier < 0)
+        {
+            std::string desc = "apply_scale_32() error: multiplier should >= 0 but is " + std::to_string(multiplier);
+            throw desc;
+        }
+        if (shift < 2 || shift > 62)
+        {
+            std::string desc =
+                "apply_scale_32(): shift value should stay within [2, 62] but is " + std::to_string(shift);
+            throw desc;
+        }
         int64_t round = 1L << (shift - 1);
         if (double_round)
         {
@@ -57,21 +65,35 @@
         }
         int64_t result = (int64_t)value * multiplier + round;
         result         = result >> shift;
-        ASSERT_MSG(result >= -(1L << 31) && result < (1L << 31),
-                   "apply_scale_32() error: scaled result exceed int32 numeric range");
+        if (result < -(1L << 31) || result >= (1L << 31))
+        {
+            std::string desc = "apply_scale_32() error: scaled result exceeds int32 numeric range";
+            throw desc;
+        }
         return static_cast<int32_t>(result);
     }
 
     static int32_t apply_scale_16(int64_t value, int16_t multiplier, int32_t shift)
     {
-        ASSERT_MSG(multiplier >= 0, "apply_scale_16() error: multiplier should >= 0 but is %d", multiplier);
-        ASSERT_MSG(shift >= 2 && shift <= 62, "apply_scale_16() error: shift should be within [2, 62] but is %d",
-                   shift);
+        if (multiplier < 0)
+        {
+            std::string desc = "apply_scale_16() error: multiplier should >= 0 but is " + std::to_string(multiplier);
+            throw desc;
+        }
+        if (shift < 2 || shift > 62)
+        {
+            std::string desc =
+                "apply_scale_16(): shift value should stay within [2, 62] but is " + std::to_string(shift);
+            throw desc;
+        }
         int64_t round  = 1L << (shift - 1);
         int64_t result = value * (int64_t)multiplier + round;
         result         = result >> shift;
-        ASSERT_MSG(result >= -(1L << 31) && result < (1L << 31),
-                   "apply_scale_16() error: scaled result exceed int32 numeric range");
+        if (result < -(1L << 31) || result >= (1L << 31))
+        {
+            std::string desc = "apply_scale_16() error: scaled result exceeds int32 numeric range";
+            throw desc;
+        }
         return static_cast<int32_t>(result);
     }
 };