diff options
author | Kelvin Nilsen <kelvin@gcc.gnu.org> | 2017-04-26 15:41:23 +0000 |
---|---|---|
committer | Kelvin Nilsen <kelvin@gcc.gnu.org> | 2017-04-26 15:41:23 +0000 |
commit | eb05a210f66518dd5981c62d0821e3dfc6d6dc03 (patch) | |
tree | 7465e5574d1794a35eeeeba8039eb8b4422365c5 | |
parent | 54dd4425a4b2f089811fa029d9d5108a34fe47ae (diff) |
progress
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ibm/bz139777@247279 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/config/rs6000/rs6000-builtin.def | 25 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 1 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.h | 1 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.md | 2 | ||||
-rw-r--r-- | gcc/doc/extend.texi | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/cmpb-1.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/cmpb-2.c | 36 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/cmpb-3.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/cmpb32-1.c | 27 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/cmpb32-2.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/vsu/vec-any-eqz-7.c | 1 |
11 files changed, 202 insertions, 0 deletions
diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index a39f9363515..f3ceb7a1834 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -339,6 +339,27 @@ | RS6000_BTC_SPECIAL), \ CODE_FOR_nothing) /* ICODE */ +/* ISA 2.05 (power6) convenience macros. */ +/* For functions that depend on the CMPB instruction */ +#define BU_P6_CMPB_2(ENUM, NAME, ATTR, ICODE) \ + RS6000_BUILTIN_2 (P6_BUILTIN_ ## ENUM, /* ENUM */ \ + "__builtin_" NAME, /* NAME */ \ + RS6000_BTM_CMPB, /* MASK */ \ + (RS6000_BTC_ ## ATTR /* ATTR */ \ + | RS6000_BTC_BINARY), \ + CODE_FOR_ ## ICODE) /* ICODE */ + +/* For functions that depend on 64-BIT support and on the CMPB instruction */ +#define BU_P6_64BIT_CMPB_2(ENUM, NAME, ATTR, ICODE) \ + RS6000_BUILTIN_2 (P6_BUILTIN_ ## ENUM, /* ENUM */ \ + "__builtin_" NAME, /* NAME */ \ + RS6000_BTM_CMPB \ + | RS6000_BTM_64BIT, /* MASK */ \ + (RS6000_BTC_ ## ATTR /* ATTR */ \ + | RS6000_BTC_BINARY), \ + CODE_FOR_ ## ICODE) /* ICODE */ + + /* ISA 2.07 (power8) vector convenience macros. */ /* For the instructions that are encoded as altivec instructions use __builtin_altivec_ as the builtin name. */ @@ -1778,6 +1799,10 @@ BU_VSX_OVERLOAD_X (ST, "st") BU_VSX_OVERLOAD_X (XL, "xl") BU_VSX_OVERLOAD_X (XST, "xst") +/* 2 argument CMPB instructions added in ISA 2.05. */ +BU_P6_CMPB_2 (CMPB_32, "cmpb_32", CONST, cmpbsi3) +BU_P6_64BIT_CMPB_2 (CMPB, "cmpb", CONST, cmpbdi3) + /* 1 argument VSX instructions added in ISA 2.07. */ BU_P8V_VSX_1 (XSCVSPDPN, "xscvspdpn", CONST, vsx_xscvspdpn) BU_P8V_VSX_1 (XSCVDPSPN, "xscvdpspn", CONST, vsx_xscvdpspn) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 8f68d84a8fe..7b1f39e5dc8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3788,6 +3788,7 @@ HOST_WIDE_INT rs6000_builtin_mask_calculate (void) { return (((TARGET_ALTIVEC) ? RS6000_BTM_ALTIVEC : 0) + | ((TARGET_CMPB) ? RS6000_BTM_CMPB : 0) | ((TARGET_VSX) ? RS6000_BTM_VSX : 0) | ((TARGET_SPE) ? RS6000_BTM_SPE : 0) | ((TARGET_PAIRED_FLOAT) ? RS6000_BTM_PAIRED : 0) diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 3780a49d902..54d2ea99d4f 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2717,6 +2717,7 @@ extern int frame_pointer_needed; aren't in target_flags. */ #define RS6000_BTM_ALWAYS 0 /* Always enabled. */ #define RS6000_BTM_ALTIVEC MASK_ALTIVEC /* VMX/altivec vectors. */ +#define RS6000_BTM_CMPB MASK_CMPB /* ISA 2.05: cmopare bytes. */ #define RS6000_BTM_VSX MASK_VSX /* VSX (vector/scalar). */ #define RS6000_BTM_P8_VECTOR MASK_P8_VECTOR /* ISA 2.07 vector. */ #define RS6000_BTM_P9_VECTOR MASK_P9_VECTOR /* ISA 3.0 vector. */ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 6e73f9d9524..40554c02962 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -1609,6 +1609,7 @@ emit_insn (gen_addsi3 (result, result, constm1_rtx)); DONE; }) + ;; Fixed-point arithmetic insns. @@ -2340,6 +2341,7 @@ "prty<wd> %0,%1" [(set_attr "type" "popcnt")]) +;; kelvin wants to replace with this (define_insn "cmpb<mode>3" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r") diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index f7cbe447307..9adac19f35a 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -15107,6 +15107,22 @@ Similar to @code{__builtin_nans}, except the return type is @code{__float128}. @end table The following built-in functions are available for the PowerPC family +of processors, starting with ISA 2.05 or later (@option{-mcpu=power6} +or @option{-mcmpb}): +@smallexample +long long __builtin_cmpb (long long, long long); +int __builtin_cmpb_32 (int, int); +@end smallexample + +The @code{__builtin_cmpb} and @code{__builtin_cmpb_32} functions +perform a byte-wise compare on the contents of their two arguments, +returning the result of the byte-wise comparison as the returned +value. For each byte comparison, the corresponding byte of the return +value holds 0xff if input bytes are equal, and 0 if the input bytes +are not equal. The @code{__builtin_cmpb} function requires a +64-bit environment. + +The following built-in functions are available for the PowerPC family of processors, starting with ISA 2.06 or later (@option{-mcpu=power7} or @option{-mpopcntd}): @smallexample diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb-1.c b/gcc/testsuite/gcc.target/powerpc/cmpb-1.c new file mode 100644 index 00000000000..53e25b1d73f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cmpb-1.c @@ -0,0 +1,31 @@ +/* { dg-do run { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target dfp_hw } */ +/* { dg-options "-mcpu=power6" } */ + +void abort (); + +long long int +do_compare (long long int a, long long int b) +{ + return __builtin_cmpb (a, b); +} + +void +expect (long long int pattern, long long int value) +{ + if (pattern != value) + abort (); +} + +int +main (int argc, char *argv[]) +{ + expect (0xff00000000000000, + do_compare (0x0123456789abcdef, 0x0100000000000000)); + expect (0x00ffffffffffffff, + do_compare (0x0123456789abcdef, 0x0023456789abcdef)); + expect (0x00000000000000ff, + do_compare (0x00000000000000ef, 0x0123456789abcdef)); +} diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb-2.c b/gcc/testsuite/gcc.target/powerpc/cmpb-2.c new file mode 100644 index 00000000000..6f890216948 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cmpb-2.c @@ -0,0 +1,36 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power5" } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target powerpc_popcntb_ok } */ +/* { dg-options "-mcpu=power5" } */ +/* { dg-excess-errors "expect error due to unresolved reference" } */ +/* Since the error message is not associated with a particular line + number, we cannot use the dg-error directive and cannot specify a + regexp to describe the expected error message. The expected error + message is: "undefined reference to `__builtin_cmpb'" */ + +void abort (); + +long long int +do_compare (long long int a, long long int b) +{ + return __builtin_cmpb (a, b); /* { dg-warning "implicit declaration of function '__builtin_cmpb'" } */ +} + +void +expect (long long int pattern, long long int value) +{ + if (pattern != value) + abort (); +} + +int +main (int argc, char *argv[]) +{ + expect (0xff00000000000000, + do_compare (0x0123456789abcdef, 0x0100000000000000)); + expect (0x00ffffffffffffff, + do_compare (0x0123456789abcdef, 0x0023456789abcdef)); + expect (0x00000000000000ff, + do_compare (0x00000000000000ef, 0x0123456789abcdef)); +} diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb-3.c b/gcc/testsuite/gcc.target/powerpc/cmpb-3.c new file mode 100644 index 00000000000..a0ae98fb237 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cmpb-3.c @@ -0,0 +1,30 @@ +/* { dg-do cmopile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_popcntb_ok } */ +/* { dg-options "-mcpu=power6" } */ + +void abort (); + +long long int +do_compare (long long int a, long long int b) +{ + return __builtin_cmpb (a, b); /* { dg-error "Builtin function __builtin_cmpb not supported in this compiler configuration" } */ +} + +void expect (long long int pattern, long long int value) +{ + if (pattern != value) + abort (); +} + +int +main (int argc, char *argv[]) +{ + expect (0xff00000000000000, + do_compare (0x123456789abcdef, 0x1200000000000000)); + expect (0x00ffffffffffffff, + do_compare (0x123456789abcdefg, 0x003456789abcdefg)); + expect (0x00000000000000ff, + do_compare (0x00000000000000fg, 0x123456789abcdefg)); +} diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb32-1.c b/gcc/testsuite/gcc.target/powerpc/cmpb32-1.c new file mode 100644 index 00000000000..8af1bc0f430 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cmpb32-1.c @@ -0,0 +1,27 @@ +/* { dg-do run { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */ +/* { dg-require-effective-target dfp_hw } */ +/* { dg-options "-mcpu=power6" } */ + +void abort (); + +int +do_compare (int a, int b) +{ + return __builtin_cmpb_32 (a, b); +} + +void +expect (int pattern, int value) +{ + if (pattern != value) + abort (); +} + +int +main (int argc, char *argv[]) +{ + expect (0xff000000, do_compare (0x12345678, 0x12000000)); + expect (0x00ffffff, do_compare (0x12345678, 0x00345678)); + expect (0x000000ff, do_compare (0x00000078, 0x12345678)); +} diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb32-2.c b/gcc/testsuite/gcc.target/powerpc/cmpb32-2.c new file mode 100644 index 00000000000..0c556606991 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cmpb32-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power5" } } */ +/* { dg-require-effective-target powerpc_popcntb_ok } */ +/* { dg-options "-mcpu=power5" } */ +/* { dg-excess-errors "expect error due to unresolved reference" } */ +/* Since the error message is not associated with a particular line + number, we cannot use the dg-error directive and cannot specify a + regexp to describe the expected error message. The expected error + message is: "undefined reference to `__builtin_cmpb_32'" */ + +void abort (); + +int +do_compare (int a, int b) +{ + return __builtin_cmpb_32 (a, b); +} + +void +expect (int pattern, int value) +{ + if (pattern != value) + abort (); +} + +int +main (int argc, char *argv[]) +{ + expect (0xff000000, do_compare (0x12345678, 0x12000000)); + expect (0x00ffffff, do_compare (0x12345678, 0x00345678)); + expect (0x000000ff, do_compare (0x00000078, 0x12345678)); +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsu/vec-any-eqz-7.c b/gcc/testsuite/gcc.target/powerpc/vsu/vec-any-eqz-7.c index 7b2d4ddf49b..b46008a5730 100644 --- a/gcc/testsuite/gcc.target/powerpc/vsu/vec-any-eqz-7.c +++ b/gcc/testsuite/gcc.target/powerpc/vsu/vec-any-eqz-7.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-require-effective-target ilp32 } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ /* { dg-options "-mcpu=power8" } */ |