[clang] [Clang] Add __builtin_bswapg (PR #162433)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 8 21:55:06 PDT 2025
================
@@ -3288,7 +3288,15 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
case Builtin::BI__builtin_elementwise_ctzg:
return interp__builtin_elementwise_countzeroes(S, OpPC, Frame, Call,
BuiltinID);
-
+ case Builtin::BI__builtin_bswapg: {
+ const APSInt &Val = popToAPSInt(S, Call->getArg(0));
+ assert(Val.getActiveBits() <= 64);
+ if (Val.getBitWidth() == 8)
+ pushInteger(S, Val, Call->getType());
+ else
+ pushInteger(S, Val.byteSwap(), Call->getType());
+ return true;
+ }
----------------
tbaederr wrote:
Don't add the implementation in the switch. We already have `interp__builtin_swap` which you can just use here, provided the special case for 8 doesn't break anything.
https://github.com/llvm/llvm-project/pull/162433
More information about the cfe-commits
mailing list