Add support for CSSC instructions (#69)
Add support for CSSC instructions (abs, cnt, ctz, smax, smin, umax, umin) to all
components, and refactor some of the code nearby.
diff --git a/src/utils-vixl.h b/src/utils-vixl.h
index b6c8455..7af9483 100644
--- a/src/utils-vixl.h
+++ b/src/utils-vixl.h
@@ -291,6 +291,17 @@
return ~value + 1;
}
+// An absolute operation for signed integers that is defined for results outside
+// the representable range. Specifically, Abs(MIN_INT) is MIN_INT.
+template <typename T>
+T Abs(T val) {
+ // TODO: this static assertion is for signed integer inputs, as that's the
+ // only type tested. However, the code should work for all numeric inputs.
+ // Remove the assertion and this comment when more tests are available.
+ VIXL_STATIC_ASSERT(std::is_signed<T>::value && std::is_integral<T>::value);
+ return ((val >= -std::numeric_limits<T>::max()) && (val < 0)) ? -val : val;
+}
+
// Convert unsigned to signed numbers in a well-defined way (using two's
// complement representations).
inline int64_t RawbitsToInt64(uint64_t bits) {