================
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir 
-emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir 
-emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -emit-llvm %s 
-o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
+
+struct B {
+  bool flag : 1;
+  bool other : 1;
+};
+
+void store_bool_bitfield(B *b) {
+  b->flag = true;
+}
+
+// CIR-LABEL: cir.func{{.*}} @_Z19store_bool_bitfieldP1B
+// CIR:         %[[TRUE:.+]] = cir.const #true
+// CIR:         cir.set_bitfield{{.*}}(#{{.+}}, %{{.+}} : !cir.ptr<!u8i>, 
%[[TRUE]] : !cir.bool) -> !cir.bool
+
+// LLVM-LABEL: define {{.*}} void @_Z19store_bool_bitfieldP1B
+// LLVM:         load ptr, ptr %{{.+}}
+// LLVM:         load i8, ptr %{{.+}}
+// LLVM:         %{{.+}} = and i8 %{{.+}}, -2
+// LLVM:         %{{.+}} = or {{.*}}i8 %{{.+}}, 1
+// LLVM:         store i8 %{{.+}}, ptr %{{.+}}
+
+// OGCG-LABEL: define {{.*}} void @_Z19store_bool_bitfieldP1B
+// OGCG:         load ptr, ptr %{{.+}}
+// OGCG:         load i8, ptr %{{.+}}
+// OGCG:         %{{.+}} = and i8 %{{.+}}, -2
+// OGCG:         %{{.+}} = or {{.*}}i8 %{{.+}}, 1
+// OGCG:         store i8 %{{.+}}, ptr %{{.+}}
+
+bool store_bool_bitfield_used(B *b, bool v) {
+  return b->flag = v;
+}
+
+// CIR-LABEL: cir.func{{.*}} @_Z24store_bool_bitfield_usedP1Bb
+// CIR:         %[[V:.+]] = cir.load{{.*}} %{{.+}} : !cir.ptr<!cir.bool>, 
!cir.bool
+// CIR:         cir.set_bitfield{{.*}}, %[[V]] : !cir.bool) -> !cir.bool
+
+// LLVM-LABEL: define {{.*}}i1 @_Z24store_bool_bitfield_usedP1Bb
+// LLVM:         zext i1 %{{.+}} to i8
+// LLVM:         store i8 %{{.+}}, ptr %{{.+}}
+
+// OGCG-LABEL: define {{.*}}i1 @_Z24store_bool_bitfield_usedP1Bb
+// OGCG:         zext i1 %{{.+}} to i8
+// OGCG:         store i8 %{{.+}}, ptr %{{.+}}
+
+bool load_bool_bitfield(B *b) {
+  return b->flag;
+}
+
+// CIR-LABEL: cir.func{{.*}} @_Z18load_bool_bitfieldP1B
+// CIR:         cir.get_bitfield{{.*}}(#{{.+}}, %{{.+}} : !cir.ptr<!u8i>) -> 
!cir.bool
+
+// LLVM-LABEL: define {{.*}}i1 @_Z18load_bool_bitfieldP1B
+// LLVM:         load i8, ptr %{{.+}}
+// LLVM:         and i8 %{{.+}}, 1
+// LLVM:         trunc i8 %{{.+}} to i1
+
+// OGCG-LABEL: define {{.*}}i1 @_Z18load_bool_bitfieldP1B
+// OGCG:         load i8, ptr %{{.+}}
+// OGCG:         and i8 %{{.+}}, 1
+// OGCG:         trunc i8 %{{.+}} to i1
+
+void compound_or_bool_bitfield(B *b, bool v) {
----------------
adams381 wrote:

Added LLVM check blocks for `compound_or_bool_bitfield`, `copy_bool_bitfield`, 
`load_int_bitfield`, and `store_int_bitfield` -- all four functions that 
previously had CIR coverage only.


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

Reply via email to