[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 23:53:44 PDT 2024
================
@@ -10,11 +10,229 @@ using FourI128VecSize __attribute__((vector_size(64))) = __int128;
using FourCharsExtVec __attribute__((ext_vector_type(4))) = char;
using FourIntsExtVec __attribute__((ext_vector_type(4))) = int;
+using FourLongLongsExtVec __attribute__((ext_vector_type(4))) = long long;
+using FourFloatsExtVec __attribute__((ext_vector_type(4))) = float;
+using FourDoublesExtVec __attribute__((ext_vector_type(4))) = double;
using FourI128ExtVec __attribute__((ext_vector_type(4))) = __int128;
+
+// Next a series of tests to make sure these operations are usable in
+// constexpr functions. Template instantiations don't emit Winvalid-constexpr,
+// so we have to do these as macros.
+#define MathShiftOps(Type) \
+ constexpr auto MathShiftOps##Type(Type a, Type b) { \
+ a = a + b; \
+ a = a - b; \
+ a = a * b; \
+ a = a / b; \
+ b = a + 1; \
+ b = a - 1; \
+ b = a * 1; \
+ b = a / 1; \
+ a += a; \
+ a -= a; \
+ a *= a; \
+ a /= a; \
+ b += a; \
+ b -= a; \
+ b *= a; \
+ b /= a; \
+ b = (a += a); \
+ b = (a -= a); \
+ b = (a *= a); \
+ b = (a /= a); \
+ b = (b += a); \
+ b = (b -= a); \
+ b = (b *= a); \
+ b = (b /= a); \
+ a < b; \
+ a > b; \
+ a <= b; \
+ a >= b; \
+ a == b; \
+ a != b; \
+ a &&b; \
+ a || b; \
+ auto c = (a, b); \
+ return c; \
+ }
+
+// Ops specific to Integers.
+#define MathShiftOpsInts(Type) \
+ constexpr auto MathShiftopsInts##Type(Type a, Type b) { \
+ a = a << b; \
+ a = a >> b; \
+ a = a << 3; \
+ a = a >> 3; \
+ a = 3 << b; \
+ a = 3 >> b; \
+ a <<= b; \
+ a >>= b; \
+ a <<= 3; \
+ a >>= 3; \
+ b = (a <<= b); \
+ b = (a >>= b); \
+ b = (a <<= 3); \
+ b = (a >>= 3); \
+ a = a % b; \
+ a &b; \
+ a | b; \
+ a ^ b; \
+ return a; \
+ }
+
+MathShiftOps(FourCharsVecSize);
+MathShiftOps(FourIntsVecSize);
+MathShiftOps(FourLongLongsVecSize);
+MathShiftOps(FourFloatsVecSize);
+MathShiftOps(FourDoublesVecSize);
+MathShiftOps(FourCharsExtVec);
+MathShiftOps(FourIntsExtVec);
+MathShiftOps(FourLongLongsExtVec);
+MathShiftOps(FourFloatsExtVec);
+MathShiftOps(FourDoublesExtVec);
+
+MathShiftOpsInts(FourCharsVecSize);
+MathShiftOpsInts(FourIntsVecSize);
+MathShiftOpsInts(FourLongLongsVecSize);
+MathShiftOpsInts(FourCharsExtVec);
+MathShiftOpsInts(FourIntsExtVec);
+MathShiftOpsInts(FourLongLongsExtVec);
----------------
tbaederr wrote:
Can you add tests for with `FourI128ExtVec` as well here? I think that might be broken.
https://github.com/llvm/llvm-project/pull/108949
More information about the cfe-commits
mailing list