-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PowerPC] Implement trap and conversion builtins for XL compatibility
This patch implements trap and FP to and from double conversions. The builtins generate code that mirror what is generated from the XL compiler. Intrinsics are named conventionally with builtin_ppc, but are aliased to provide the same builtin names as the XL compiler. Differential Revision: https://reviews.llvm.org/D103668
- Loading branch information
Showing
13 changed files
with
676 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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
121 changes: 121 additions & 0 deletions
121
clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
This file contains 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,121 @@ | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s | ||
|
||
extern double da; | ||
double test_fcfid() { | ||
// CHECK-LABEL: test_fcfid | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fcfid(double %0) | ||
return __builtin_ppc_fcfid(da); | ||
} | ||
|
||
double test_xl_fcfid() { | ||
// CHECK-LABEL: test_xl_fcfid | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fcfid(double %0) | ||
return __fcfid(da); | ||
} | ||
|
||
double test_fcfud() { | ||
// CHECK-LABEL: test_fcfud | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fcfud(double %0) | ||
return __builtin_ppc_fcfud(da); | ||
} | ||
|
||
double test_xl_fcfud() { | ||
// CHECK-LABEL: test_xl_fcfud | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fcfud(double %0) | ||
return __fcfud(da); | ||
} | ||
|
||
double test_fctid() { | ||
// CHECK-LABEL: test_fctid | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctid(double %0) | ||
return __builtin_ppc_fctid(da); | ||
} | ||
|
||
double test_xl_fctid() { | ||
// CHECK-LABEL: test_xl_fctid | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctid(double %0) | ||
return __fctid(da); | ||
} | ||
|
||
double test_fctidz() { | ||
// CHECK-LABEL: test_fctidz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctidz(double %0) | ||
return __builtin_ppc_fctidz(da); | ||
} | ||
|
||
double test_xl_fctidz() { | ||
// CHECK-LABEL: test_xl_fctidz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctidz(double %0) | ||
return __fctidz(da); | ||
} | ||
|
||
double test_fctiw() { | ||
// CHECK-LABEL: test_fctiw | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctiw(double %0) | ||
return __builtin_ppc_fctiw(da); | ||
} | ||
|
||
double test_xl_fctiw() { | ||
// CHECK-LABEL: test_xl_fctiw | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctiw(double %0) | ||
return __fctiw(da); | ||
} | ||
|
||
double test_fctiwz() { | ||
// CHECK-LABEL: test_fctiwz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctiwz(double %0) | ||
return __builtin_ppc_fctiwz(da); | ||
} | ||
|
||
double test_xl_fctiwz() { | ||
// CHECK-LABEL: test_xl_fctiwz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctiwz(double %0) | ||
return __fctiwz(da); | ||
} | ||
|
||
double test_fctudz() { | ||
// CHECK-LABEL: test_fctudz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctudz(double %0) | ||
return __builtin_ppc_fctudz(da); | ||
} | ||
|
||
double test_xl_fctudz() { | ||
// CHECK-LABEL: test_xl_fctudz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctudz(double %0) | ||
return __fctudz(da); | ||
} | ||
|
||
double test_fctuwz() { | ||
// CHECK-LABEL: test_fctuwz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctuwz(double %0) | ||
return __builtin_ppc_fctuwz(da); | ||
} | ||
|
||
double test_xl_fctuwz() { | ||
// CHECK-LABEL: test_xl_fctuwz | ||
// CHECK-NEXT: entry: | ||
// CHECK: double @llvm.ppc.fctuwz(double %0) | ||
return __fctuwz(da); | ||
} |
This file contains 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,19 @@ | ||
// REQUIRES: powerpc-registered-target | ||
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \ | ||
// RUN: -Wall -Werror -verify %s | ||
// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \ | ||
// RUN: -Wall -Werror -verify %s | ||
// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only \ | ||
// RUN: -Wall -Werror -verify %s | ||
// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only \ | ||
// RUN: -Wall -Werror -verify %s | ||
|
||
extern long long lla, llb; | ||
extern int ia, ib; | ||
|
||
void test_trap(void) { | ||
#ifdef __PPC64__ | ||
__tdw(lla, llb, 50); //expected-error {{argument value 50 is outside the valid range [0, 31]}} | ||
#endif | ||
__tw(ia, ib, 50); //expected-error {{argument value 50 is outside the valid range [0, 31]}} | ||
} |
41 changes: 41 additions & 0 deletions
41
clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
This file contains 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,41 @@ | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | \ | ||
// RUN: FileCheck %s --check-prefixes=CHECK64 | ||
// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr8 | \ | ||
// RUN: FileCheck %s --check-prefixes=CHECK64 | ||
// RUN: not %clang_cc1 -O2 -triple powerpc-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 2>&1 | \ | ||
// RUN: FileCheck %s -check-prefixes=CHECK32-ERROR | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | \ | ||
// RUN: FileCheck %s --check-prefixes=CHECK64 | ||
|
||
extern long long lla, llb; | ||
extern double da; | ||
|
||
// tdw | ||
void test_xl_tdw(void) { | ||
// CHECK64: void @llvm.ppc.tdw(i64 %0, i64 %1, i32 1) | ||
// CHECK32-ERROR: error: this builtin is only available on 64-bit targets | ||
__tdw(lla, llb, 1); | ||
} | ||
|
||
void test_tdw(void) { | ||
// CHECK64: void @llvm.ppc.tdw(i64 %0, i64 %1, i32 13) | ||
// CHECK32-ERROR: error: this builtin is only available on 64-bit targets | ||
__builtin_ppc_tdw(lla, llb, 13); | ||
} | ||
|
||
// trapd | ||
void test_trapd(void) { | ||
// CHECK64: void @llvm.ppc.trapd(i64 %conv) | ||
// CHECK32-ERROR: error: this builtin is only available on 64-bit targets | ||
__builtin_ppc_trapd(da); | ||
} | ||
|
||
void test_xl_trapd(void) { | ||
// CHECK64: void @llvm.ppc.trapd(i64 %conv) | ||
// CHECK32-ERROR: error: this builtin is only available on 64-bit targets | ||
__trapd(da); | ||
} |
This file contains 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,38 @@ | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | \ | ||
// RUN: FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr8 | \ | ||
// RUN: FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | \ | ||
// RUN: FileCheck %s | ||
// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \ | ||
// RUN: -emit-llvm %s -o - -target-cpu pwr7 | \ | ||
// RUN: FileCheck %s | ||
|
||
extern int ia, ib; | ||
|
||
// td | ||
void test_tw(void) { | ||
// CHECK: void @llvm.ppc.tw(i32 %0, i32 %1, i32 1) | ||
|
||
__builtin_ppc_tw(ia, ib, 1); | ||
} | ||
|
||
void test_xl_tw(void) { | ||
// CHECK: void @llvm.ppc.tw(i32 %0, i32 %1, i32 1) | ||
|
||
__tw(ia, ib, 1); | ||
} | ||
|
||
// trap | ||
void test_trap(void) { | ||
// CHECK: void @llvm.ppc.trap(i32 %0) | ||
__builtin_ppc_trap(ia); | ||
} | ||
|
||
void test_xl_trap(void) { | ||
// CHECK: void @llvm.ppc.trap(i32 %0) | ||
__trap(ia); | ||
} |
This file contains 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 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 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
Oops, something went wrong.