llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangir

Author: Kunal Dubey  (xakep8)

<details>
<summary>Changes</summary>

Added case for stdc_rotate_left, stdc_rotate_right and stdc_memreverse8 so that 
they don't fall through to isLibFunction path. Now they emit NYI.

Added test for the same.

Reference to discussion in PR #<!-- -->214931 
[here](https://github.com/llvm/llvm-project/pull/214931#discussion_r3769544573)

---
Full diff: https://github.com/llvm/llvm-project/pull/218852.diff


2 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+19) 
- (added) clang/test/CIR/CodeGenBuiltins/builtin-stdc-bit-c2y-nyi.c (+35) 


``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 27dc8b1c7d889..7b2d757c8605b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -1369,12 +1369,31 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl 
&gd, unsigned builtinID,
   case Builtin::BI__builtin_rotateleft32:
   case Builtin::BI__builtin_rotateleft64:
     return emitRotate(e, /*isRotateLeft=*/true);
+  case Builtin::BI__builtin_stdc_rotate_left:
+  case Builtin::BIstdc_rotate_left_uc:
+  case Builtin::BIstdc_rotate_left_us:
+  case Builtin::BIstdc_rotate_left_ui:
+  case Builtin::BIstdc_rotate_left_ul:
+  case Builtin::BIstdc_rotate_left_ull:
+    return errorBuiltinNYI(*this, e, builtinID);
 
   case Builtin::BI__builtin_rotateright8:
   case Builtin::BI__builtin_rotateright16:
   case Builtin::BI__builtin_rotateright32:
   case Builtin::BI__builtin_rotateright64:
     return emitRotate(e, /*isRotateLeft=*/false);
+  case Builtin::BI__builtin_stdc_rotate_right:
+  case Builtin::BIstdc_rotate_right_uc:
+  case Builtin::BIstdc_rotate_right_us:
+  case Builtin::BIstdc_rotate_right_ui:
+  case Builtin::BIstdc_rotate_right_ul:
+  case Builtin::BIstdc_rotate_right_ull:
+  case Builtin::BIstdc_memreverse8:
+  case Builtin::BIstdc_memreverse8u8:
+  case Builtin::BIstdc_memreverse8u16:
+  case Builtin::BIstdc_memreverse8u32:
+  case Builtin::BIstdc_memreverse8u64:
+    return errorBuiltinNYI(*this, e, builtinID);
 
   case Builtin::BI__builtin_coro_id:
     return RValue::get(emitCoroIDBuiltinCall(e).getResult());
diff --git a/clang/test/CIR/CodeGenBuiltins/builtin-stdc-bit-c2y-nyi.c 
b/clang/test/CIR/CodeGenBuiltins/builtin-stdc-bit-c2y-nyi.c
new file mode 100644
index 0000000000000..f6dd75f8cbe21
--- /dev/null
+++ b/clang/test/CIR/CodeGenBuiltins/builtin-stdc-bit-c2y-nyi.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c2y -fclangir 
-emit-cir -verify -DSTDC_ROTATE_LEFT %s -o -
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c2y -fclangir 
-emit-cir -verify -DSTDC_ROTATE_RIGHT %s -o -
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c2y -fclangir 
-emit-cir -verify -DSTDC_MEMREVERSE8 %s -o -
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c2y -emit-llvm %s -o 
- | FileCheck %s --check-prefix=OGCG
+
+unsigned stdc_rotate_left_ui(unsigned, unsigned);
+unsigned stdc_rotate_right_ui(unsigned, unsigned);
+unsigned stdc_memreverse8u32(unsigned);
+
+#if !defined(STDC_ROTATE_RIGHT) && !defined(STDC_MEMREVERSE8)
+unsigned test_stdc_rotate_left_ui(unsigned x) {
+  return stdc_rotate_left_ui(x, 1); // expected-error {{ClangIR code gen Not 
Yet Implemented: unimplemented X86 builtin call: stdc_rotate_left_ui}}
+}
+
+// OGCG-LABEL: define{{.*}} i32 @test_stdc_rotate_left_ui(
+// OGCG: call i32 @llvm.fshl.i32(
+#endif
+
+#if !defined(STDC_ROTATE_LEFT) && !defined(STDC_MEMREVERSE8)
+unsigned test_stdc_rotate_right_ui(unsigned x) {
+  return stdc_rotate_right_ui(x, 1); // expected-error {{ClangIR code gen Not 
Yet Implemented: unimplemented X86 builtin call: stdc_rotate_right_ui}}
+}
+
+// OGCG-LABEL: define{{.*}} i32 @test_stdc_rotate_right_ui(
+// OGCG: call i32 @llvm.fshr.i32(
+#endif
+
+#if !defined(STDC_ROTATE_LEFT) && !defined(STDC_ROTATE_RIGHT)
+unsigned test_stdc_memreverse8u32(unsigned x) {
+  return stdc_memreverse8u32(x); // expected-error {{ClangIR code gen Not Yet 
Implemented: unimplemented X86 builtin call: stdc_memreverse8u32}}
+}
+
+// OGCG-LABEL: define{{.*}} i32 @test_stdc_memreverse8u32(
+// OGCG: call i32 @llvm.bswap.i32(
+#endif

``````````

</details>


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

Reply via email to