Message ID | 92507c51-9ff0-4e67-8a6c-7ffb58bc8537@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
Series | rs6000: Fix issue in specifying PTImode as an attribute [PR106895] | expand |
Ping! please review. Thanks & Regards Jeevitha On 23/02/24 3:04 pm, jeevitha wrote: > Hi All, > > The following patch has been bootstrapped and regtested on powerpc64le-linux. > > PTImode attribute assists in generating even/odd register pairs on 128 bits. > When the user specifies PTImode as an attribute, it breaks because there is no > internal type to handle this mode . We have created a tree node with dummy type > to handle PTImode. We are not documenting this dummy type since users are not > allowed to use this type externally. > > 2024-02-23 Jeevitha Palanisamy <jeevitha@linux.ibm.com> > > gcc/ > PR target/106895 > * config/rs6000/rs6000.h (enum rs6000_builtin_type_index): Add fields > to hold PTImode type. > * config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Add node > for PTImode type. > > gcc/testsuite/ > PR target/106895 > * gcc.target/powerpc/pr106895.c: New testcase. > > diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc > index 6698274031b..f553c72779e 100644 > --- a/gcc/config/rs6000/rs6000-builtin.cc > +++ b/gcc/config/rs6000/rs6000-builtin.cc > @@ -756,6 +756,15 @@ rs6000_init_builtins (void) > else > ieee128_float_type_node = NULL_TREE; > > + /* PTImode to get even/odd register pairs. */ > + intPTI_type_internal_node = make_node(INTEGER_TYPE); > + TYPE_PRECISION (intPTI_type_internal_node) = GET_MODE_BITSIZE (PTImode); > + layout_type (intPTI_type_internal_node); > + SET_TYPE_MODE (intPTI_type_internal_node, PTImode); > + t = build_qualified_type (intPTI_type_internal_node, TYPE_QUAL_CONST); > + lang_hooks.types.register_builtin_type (intPTI_type_internal_node, > + "__dummypti"); > + > /* Vector pair and vector quad support. */ > vector_pair_type_node = make_node (OPAQUE_TYPE); > SET_TYPE_MODE (vector_pair_type_node, OOmode); > diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h > index 2291fe8d3a3..77bb937a28b 100644 > --- a/gcc/config/rs6000/rs6000.h > +++ b/gcc/config/rs6000/rs6000.h > @@ -2304,6 +2304,7 @@ enum rs6000_builtin_type_index > RS6000_BTI_ptr_vector_quad, > RS6000_BTI_ptr_long_long, > RS6000_BTI_ptr_long_long_unsigned, > + RS6000_BTI_PTI, > RS6000_BTI_MAX > }; > > @@ -2348,6 +2349,7 @@ enum rs6000_builtin_type_index > #define uintDI_type_internal_node (rs6000_builtin_types[RS6000_BTI_UINTDI]) > #define intTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_INTTI]) > #define uintTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_UINTTI]) > +#define intPTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_PTI]) > #define float_type_internal_node (rs6000_builtin_types[RS6000_BTI_float]) > #define double_type_internal_node (rs6000_builtin_types[RS6000_BTI_double]) > #define long_double_type_internal_node (rs6000_builtin_types[RS6000_BTI_long_double]) > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106895.c b/gcc/testsuite/gcc.target/powerpc/pr106895.c > new file mode 100644 > index 00000000000..56547b7fa9d > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106895.c > @@ -0,0 +1,15 @@ > +/* PR target/106895 */ > +/* { dg-require-effective-target int128 } */ > +/* { dg-options "-O2" } */ > + > +/* Verify the following generates even/odd register pairs. */ > + > +typedef __int128 pti __attribute__((mode(PTI))); > + > +void > +set128 (pti val, pti *mem) > +{ > + asm("stq %1,%0" : "=m"(*mem) : "r"(val)); > +} > + > +/* { dg-final { scan-assembler "stq \[123\]?\[02468\]" } } */ >
Hi! On Fri, Feb 23, 2024 at 03:04:13PM +0530, jeevitha wrote: > PTImode attribute assists in generating even/odd register pairs on 128 bits. It is a mode, not an attribute. Attributes are on declarations, while modes are on a much more fundamental level (every value has a mode, in GCC!) > When the user specifies PTImode as an attribute, it breaks because there is no > internal type to handle this mode . We have created a tree node with dummy type > to handle PTImode. You are talking about the mode attribute. Aha. This attribute says the mode of the datum is something specific; it is the only way a user can specify the mode directly. Not something you want to use normally, but it's a nice escape hatch (like here). > We are not documenting this dummy type since users are not > allowed to use this type externally. Not sure what this is meant to mean? What does "allowed to" mean, even? We do not forbid people from doing anything (we can discourage them though). Or dso you mean something just doesn't work? > gcc/ > PR target/106895 > * config/rs6000/rs6000.h (enum rs6000_builtin_type_index): Add fields > to hold PTImode type. An enum does not have fields. What do you actually mean? > --- a/gcc/config/rs6000/rs6000.h > +++ b/gcc/config/rs6000/rs6000.h > @@ -2304,6 +2304,7 @@ enum rs6000_builtin_type_index > RS6000_BTI_ptr_vector_quad, > RS6000_BTI_ptr_long_long, > RS6000_BTI_ptr_long_long_unsigned, > + RS6000_BTI_PTI, Please call it RS6000_BTI_INTPTI, to be more in line with the naming of other things. With that fixed it should be good. Please repost with a good commit comment and changelog :-) Thanks, Segher
On 3/18/24 9:36 AM, Segher Boessenkool wrote: > Hi! > > On Fri, Feb 23, 2024 at 03:04:13PM +0530, jeevitha wrote: >> PTImode attribute assists in generating even/odd register pairs on 128 bits. > > It is a mode, not an attribute. Attributes are on declarations, while > modes are on a much more fundamental level (every value has a mode, in > GCC!) > >> When the user specifies PTImode as an attribute, it breaks because there is no >> internal type to handle this mode . We have created a tree node with dummy type >> to handle PTImode. > > You are talking about the mode attribute. Aha. Correct. >> We are not documenting this dummy type since users are not >> allowed to use this type externally. > > Not sure what this is meant to mean? What does "allowed to" mean, even? > We do not forbid people from doing anything (we can discourage them > though). Or dso you mean something just doesn't work? The use case is the Linux kernel will use the mode attribute as shown in the test case. The type she created was needed for the code to "work" internally, but we don't want to advertise it to users, so that's why we're not documenting it. Yes, pesky users who go digging through the GCC source could find it and use it, but we don't want to encourage them. :-) >> PR target/106895 >> * config/rs6000/rs6000.h (enum rs6000_builtin_type_index): Add fields >> to hold PTImode type. > > An enum does not have fields. What do you actually mean? Yeah, as per your follow-on comment, I think a simple "Add RS6000_BTI_INTPTI." should suffice. Peter
diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 6698274031b..f553c72779e 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -756,6 +756,15 @@ rs6000_init_builtins (void) else ieee128_float_type_node = NULL_TREE; + /* PTImode to get even/odd register pairs. */ + intPTI_type_internal_node = make_node(INTEGER_TYPE); + TYPE_PRECISION (intPTI_type_internal_node) = GET_MODE_BITSIZE (PTImode); + layout_type (intPTI_type_internal_node); + SET_TYPE_MODE (intPTI_type_internal_node, PTImode); + t = build_qualified_type (intPTI_type_internal_node, TYPE_QUAL_CONST); + lang_hooks.types.register_builtin_type (intPTI_type_internal_node, + "__dummypti"); + /* Vector pair and vector quad support. */ vector_pair_type_node = make_node (OPAQUE_TYPE); SET_TYPE_MODE (vector_pair_type_node, OOmode); diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 2291fe8d3a3..77bb937a28b 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2304,6 +2304,7 @@ enum rs6000_builtin_type_index RS6000_BTI_ptr_vector_quad, RS6000_BTI_ptr_long_long, RS6000_BTI_ptr_long_long_unsigned, + RS6000_BTI_PTI, RS6000_BTI_MAX }; @@ -2348,6 +2349,7 @@ enum rs6000_builtin_type_index #define uintDI_type_internal_node (rs6000_builtin_types[RS6000_BTI_UINTDI]) #define intTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_INTTI]) #define uintTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_UINTTI]) +#define intPTI_type_internal_node (rs6000_builtin_types[RS6000_BTI_PTI]) #define float_type_internal_node (rs6000_builtin_types[RS6000_BTI_float]) #define double_type_internal_node (rs6000_builtin_types[RS6000_BTI_double]) #define long_double_type_internal_node (rs6000_builtin_types[RS6000_BTI_long_double]) diff --git a/gcc/testsuite/gcc.target/powerpc/pr106895.c b/gcc/testsuite/gcc.target/powerpc/pr106895.c new file mode 100644 index 00000000000..56547b7fa9d --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106895.c @@ -0,0 +1,15 @@ +/* PR target/106895 */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2" } */ + +/* Verify the following generates even/odd register pairs. */ + +typedef __int128 pti __attribute__((mode(PTI))); + +void +set128 (pti val, pti *mem) +{ + asm("stq %1,%0" : "=m"(*mem) : "r"(val)); +} + +/* { dg-final { scan-assembler "stq \[123\]?\[02468\]" } } */