================
@@ -1277,6 +1277,21 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl 
&gd, unsigned builtinID,
     return RValue::get(cir::ByteSwapOp::create(builder, loc, arg));
   }
 
+  case Builtin::BI__builtin_bswapg: {
+    mlir::Value arg = emitScalarExpr(e->getArg(0));
+    // A bool or any single-byte integer byte-swaps to itself; cir.byte_swap
+    // only accepts an unsigned integer whose width is a multiple of 16 bits.
+    auto argTy = mlir::dyn_cast<cir::IntType>(arg.getType());
+    if (!argTy || argTy.getWidth() <= 8)
----------------
andykaylor wrote:

This is more permissive than classic codegen, which checks for exactly 1 or 8 
here and then asserts the bit width is otherwise a multiple of 16.

https://github.com/llvm/llvm-project/pull/203618
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to