-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[PowerPC] Support for Packed BCD conversion builtins #142723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Himadhith
wants to merge
2
commits into
llvm:main
Choose a base branch
from
Himadhith:himadhith/BCD_builtins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+232
−4
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
// Testfile that verifies positive cases (0 or 1 only) for BCD builtins national2packed, packed2zoned and zoned2packed. | ||
// REQUIRES: powerpc-registered-target | ||
// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -O2 -target-cpu pwr9 \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -O2 -target-cpu pwr9 \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -triple powerpc-unknown-unknown -O2 -target-cpu pwr9 \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_National2packed_imm1( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.national2packed(<16 x i8> [[A]], i32 1) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_National2packed_imm1(vector unsigned char a) { | ||
return __builtin_ppc_national2packed (a,'\1'); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_National2packed_imm0( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.national2packed(<16 x i8> [[A]], i32 0) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_National2packed_imm0(vector unsigned char a) { | ||
return __builtin_ppc_national2packed (a,'\0'); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_Packed2national( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.packed2national(<16 x i8> [[A]]) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_Packed2national(vector unsigned char a){ | ||
return __builtin_ppc_packed2national(a); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_Packed2zoned_imm0( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.packed2zoned(<16 x i8> [[A]], i32 0) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_Packed2zoned_imm0(vector unsigned char a){ | ||
return __builtin_ppc_packed2zoned(a,'\0'); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_Packed2zoned_imm1( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.packed2zoned(<16 x i8> [[A]], i32 1) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_Packed2zoned_imm1(vector unsigned char a){ | ||
return __builtin_ppc_packed2zoned(a,'\1'); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_Zoned2packed_imm0( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.zoned2packed(<16 x i8> [[A]], i32 0) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_Zoned2packed_imm0(vector unsigned char a){ | ||
return __builtin_ppc_zoned2packed(a,'\0'); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @tBcd_Zoned2packed_imm1( | ||
// CHECK-SAME: <16 x i8> noundef [[A:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call <16 x i8> @llvm.ppc.zoned2packed(<16 x i8> [[A]], i32 1) | ||
// CHECK-NEXT: ret <16 x i8> [[TMP0]] | ||
// | ||
vector unsigned char tBcd_Zoned2packed_imm1(vector unsigned char a){ | ||
return __builtin_ppc_zoned2packed(a,'\1'); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Testfile to verify the semantics and the error handling for BCD builtins national2packed, packed2zoned and zoned2packed. | ||
// REQUIRES: powerpc-registered-target | ||
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -fsyntax-only -verify %s | ||
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -fsyntax-only -verify %s | ||
// RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown -fsyntax-only -verify %s | ||
|
||
#include <altivec.h> | ||
vector unsigned char test_national2packed(void) | ||
{ | ||
vector unsigned char a = {1,2,3,4}; | ||
vector unsigned char res_a = __builtin_ppc_national2packed(a, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
vector unsigned char res_b = __builtin_ppc_national2packed(a, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
return __builtin_ppc_national2packed(a, 0); | ||
} | ||
|
||
vector unsigned char test_packed2zoned(void) | ||
{ | ||
vector unsigned char a = {1,2,3,4}; | ||
vector unsigned char res_a = __builtin_ppc_packed2zoned(a,2); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
vector unsigned char res_b = __builtin_ppc_packed2zoned(a, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
return __builtin_ppc_packed2zoned(a,1); | ||
} | ||
|
||
vector unsigned char test_zoned2packed(void) | ||
{ | ||
vector unsigned char a = {1,2,3,4}; | ||
vector unsigned char res_a = __builtin_ppc_zoned2packed(a,2); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
vector unsigned char res_b = __builtin_ppc_zoned2packed(a, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}} | ||
return __builtin_ppc_zoned2packed(a,0); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; Testfile that verifies positive case (0 or 1 only) for BCD builtins national2packed, packed2zoned and zoned2packed. | ||
Himadhith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \ | ||
; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s | ||
|
||
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple=powerpc64-unknown-unknown \ | ||
; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s | ||
|
||
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple=powerpc-unknown-unknown \ | ||
; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s | ||
|
||
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -mtriple=powerpc64-ibm-aix-xcoff \ | ||
; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s | ||
|
||
declare <16 x i8> @llvm.ppc.national2packed(<16 x i8>, i32 immarg) | ||
|
||
define <16 x i8> @tBcd_National2packed_imm0(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_National2packed_imm0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdcfn. v2, v2, 0 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.national2packed(<16 x i8> %a, i32 0) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
define <16 x i8> @tBcd_National2packed_imm1(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_National2packed_imm1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdcfn. v2, v2, 1 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.national2packed(<16 x i8> %a, i32 1) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
declare <16 x i8> @llvm.ppc.packed2national(<16 x i8>) | ||
|
||
define <16 x i8> @tBcd_Packed2national(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_Packed2national: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdctn. v2, v2 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.packed2national(<16 x i8> %a) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
declare <16 x i8> @llvm.ppc.packed2zoned(<16 x i8>, i32 immarg) | ||
|
||
define <16 x i8> @tBcd_Packed2zoned_imm0(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_Packed2zoned_imm0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdctz. v2, v2, 0 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.packed2zoned(<16 x i8> %a, i32 0) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
define <16 x i8> @tBcd_Packed2zoned_imm1(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_Packed2zoned_imm1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdctz. v2, v2, 1 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.packed2zoned(<16 x i8> %a, i32 1) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
declare <16 x i8> @llvm.ppc.zoned2packed(<16 x i8>, i32 immarg) | ||
|
||
define <16 x i8> @tBcd_Zoned2packed_imm0(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_Zoned2packed_imm0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdcfz. v2, v2, 0 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.zoned2packed(<16 x i8> %a, i32 0) | ||
ret <16 x i8> %0 | ||
} | ||
|
||
define <16 x i8> @tBcd_Zoned2packed_imm1(<16 x i8> %a) { | ||
; CHECK-LABEL: tBcd_Zoned2packed_imm1: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: bcdcfz. v2, v2, 1 | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = call <16 x i8> @llvm.ppc.zoned2packed(<16 x i8> %a, i32 1) | ||
ret <16 x i8> %0 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.