================
@@ -2878,6 +2878,60 @@ static bool
interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_vec_ext(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call, unsigned ID) {
+ assert(Call->getNumArgs() == 2);
+
+ APSInt ImmAPS = popToAPSInt(S, Call->getArg(1));
+ const Pointer &Vec = S.Stk.pop<Pointer>();
+ if (!Vec.getFieldDesc()->isPrimitiveArray())
+ return false;
+
+ unsigned NumElts = Vec.getNumElems();
+ unsigned Index = static_cast<unsigned>(ImmAPS.getZExtValue() & (NumElts -
1));
+
+ switch (ID) {
----------------
AdityaC4 wrote:
I tried using TYPE_SWITCH, but even with `if constexpr` gurad it expands to
pointer/member-pointer cases which don’t have toAPSInt(), so the shared body
fails to compile and I get `E No member named 'toAPSInt' in
'clang::interp::MemberPointer' clang (no_member) [2903, 37]` and `No member
named 'toAPSInt' in 'clang::interp::Pointer' clang (no_member) [2903, 37]`
I could split the logic: handle PT_Float explicitly and use
INT_TYPE_SWITCH_NO_BOOL for the integer cases.
https://github.com/llvm/llvm-project/pull/161302
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits