[clang] [Clang] Add __builtin_bswapg (PR #162433)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 10 05:49:10 PDT 2025
================
@@ -3622,6 +3622,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
return RValue::get(ArgValue);
}
+ case Builtin::BI__builtin_bswapg: {
+ Value *ArgValue = EmitScalarExpr(E->getArg(0));
+ llvm::IntegerType *IntTy = cast<llvm::IntegerType>(ArgValue->getType());
+ assert(IntTy && "LLVM's __builtin_bswapg only supports integer variants");
----------------
clingfei wrote:
As @philnik777 described in https://github.com/llvm/llvm-project/issues/160266, bswapg should work on any integral types that have a multiple of 16 bits as well as a single byte. Thus, the condition should be (getBitWidth() % 16 == 0 and getBitWidth() > 0) or getBitWidth() == 8?
https://github.com/llvm/llvm-project/pull/162433
More information about the cfe-commits
mailing list