[PATCH] D128120: [Clang][VE] Add missing intrinsics

Kazushi Marukawa via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 18 07:22:21 PDT 2022


kaz7 created this revision.
kaz7 added reviewers: efocht, simoll.
kaz7 added projects: clang, VE.
Herald added a project: All.
kaz7 requested review of this revision.
Herald added a subscriber: cfe-commits.

Add missing intrinsics and tests for them.  An expanding  macro
from _vel_pack_f32p to __builtin_ve_vl_pack_f32p and others is
already defined in clang/lib/Headers/velintrin.h.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128120

Files:
  clang/include/clang/Basic/BuiltinsVE.def
  clang/test/CodeGen/VE/ve-velintrin.c


Index: clang/test/CodeGen/VE/ve-velintrin.c
===================================================================
--- clang/test/CodeGen/VE/ve-velintrin.c
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include <velintrin.h>
 
@@ -8811,3 +8811,48 @@
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void __attribute__((noinline))
+test_extract_vm512l() {
+  // CHECK-LABEL: @test_extract_vm512l
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512l(vm1_512);
+}
+
+void __attribute__((noinline))
+test_insert_vm512u() {
+  // CHECK-LABEL: @test_insert_vm512u
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1> %{{.*}}, <256 x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512u(vm1_512, vm1);
+}
+
+void __attribute__((noinline))
+test_insert_vm512l() {
+  // CHECK-LABEL: @test_insert_vm512l
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1> %{{.*}}, <256 x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512l(vm1_512, vm1);
+}
Index: clang/include/clang/Basic/BuiltinsVE.def
===================================================================
--- clang/include/clang/Basic/BuiltinsVE.def
+++ clang/include/clang/Basic/BuiltinsVE.def
@@ -15,6 +15,16 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+// The format of this database is decribed in clang/Basic/Builtins.def.
+
+BUILTIN(__builtin_ve_vl_pack_f32p, "ULifC*fC*", "n")
+BUILTIN(__builtin_ve_vl_pack_f32a, "ULifC*", "n")
+
+BUILTIN(__builtin_ve_vl_extract_vm512u, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_extract_vm512l, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512u, "V512bV512bV256b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512l, "V512bV512bV256b", "n")
+
 // Use generated BUILTIN definitions
 #include "clang/Basic/BuiltinsVEVL.gen.def"
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128120.438125.patch
Type: text/x-patch
Size: 2996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220618/85a8e2df/attachment-0001.bin>


More information about the cfe-commits mailing list