Re: [07/23] Add a class that multiplexes two pointer types

2021-01-04 Thread Jeff Law via Gcc-patches
On 12/17/20 8:44 AM, Nathan Sidwell wrote: > On 12/17/20 10:38 AM, Richard Sandiford via Gcc-patches wrote: >> Tom Tromey writes: "Richard" == Richard Sandiford via Gcc-patches writes: >>> >>> Richard> +// A class that stores a choice "A or B", where A has type >>> T1 * and B

Re: [07/23] Add a class that multiplexes two pointer types

2020-12-17 Thread Nathan Sidwell
On 12/17/20 10:38 AM, Richard Sandiford via Gcc-patches wrote: Tom Tromey writes: "Richard" == Richard Sandiford via Gcc-patches writes: Richard> +// A class that stores a choice "A or B", where A has type T1 * and B has Richard> +// type T2 *. Both T1 and T2 must have an alignment greater

Re: [07/23] Add a class that multiplexes two pointer types

2020-12-17 Thread Richard Sandiford via Gcc-patches
Tom Tromey writes: >> "Richard" == Richard Sandiford via Gcc-patches >> writes: > > Richard> +// A class that stores a choice "A or B", where A has type T1 * and > B has > Richard> +// type T2 *. Both T1 and T2 must have an alignment greater than > 1, since > Richard> +// the low bit

Re: [07/23] Add a class that multiplexes two pointer types

2020-12-17 Thread Tom Tromey
> "Richard" == Richard Sandiford via Gcc-patches > writes: Richard> +// A class that stores a choice "A or B", where A has type T1 * and B has Richard> +// type T2 *. Both T1 and T2 must have an alignment greater than 1, since Richard> +// the low bit is used to identify B over A. T1

Re: [07/23] Add a class that multiplexes two pointer types

2020-12-16 Thread Richard Sandiford via Gcc-patches
Martin Sebor writes: > On 11/26/20 10:06 AM, Richard Sandiford wrote: >> Martin Sebor writes: >>> I do have one concern: the tendency to prioritize efficiency >>> over safety (this can be said about most GCC code). Specifically >>> in this class, the address bit twiddling makes me uneasy. I don'

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-29 Thread Jeff Law via Gcc-patches
On 11/26/20 9:15 AM, Richard Sandiford wrote: > Jeff Law writes: >> On 11/13/20 1:14 AM, Richard Sandiford via Gcc-patches wrote: >>> This patch adds a pointer_mux class that provides similar >>> functionality to: >>> >>> union { T1 *a; T2 *b; }; >>> ... >>> bool is_b_rather_than_a;

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-27 Thread Martin Sebor via Gcc-patches
On 11/26/20 10:06 AM, Richard Sandiford wrote: Martin Sebor writes: I do have one concern: the tendency to prioritize efficiency over safety (this can be said about most GCC code). Specifically in this class, the address bit twiddling makes me uneasy. I don't think the object model in either l

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-27 Thread Richard Sandiford via Gcc-patches
Richard Sandiford via Gcc-patches writes: > One thing I'd deliberately tried to avoid was converting integers > “back” to pointers, because that seemed like a more dangerous thing. > That's why: > >>> +template >>> +inline T2 * >>> +pointer_mux::second_or_null () const >>> +{ >>> + // Micro optim

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-26 Thread Richard Sandiford via Gcc-patches
Martin Sebor writes: > I do have one concern: the tendency to prioritize efficiency > over safety (this can be said about most GCC code). Specifically > in this class, the address bit twiddling makes me uneasy. I don't > think the object model in either language (certainly not C but > I don't hav

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-26 Thread Richard Sandiford via Gcc-patches
Jeff Law writes: > On 11/13/20 1:14 AM, Richard Sandiford via Gcc-patches wrote: >> This patch adds a pointer_mux class that provides similar >> functionality to: >> >> union { T1 *a; T2 *b; }; >> ... >> bool is_b_rather_than_a; >> >> except that the is_b_rather_than_a tag is stored in

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-25 Thread Martin Sebor via Gcc-patches
On 11/13/20 1:14 AM, Richard Sandiford via Gcc-patches wrote: This patch adds a pointer_mux class that provides similar functionality to: union { T1 *a; T2 *b; }; ... bool is_b_rather_than_a; except that the is_b_rather_than_a tag is stored in the low bit of the pointer. See the

Re: [07/23] Add a class that multiplexes two pointer types

2020-11-25 Thread Jeff Law via Gcc-patches
On 11/13/20 1:14 AM, Richard Sandiford via Gcc-patches wrote: > This patch adds a pointer_mux class that provides similar > functionality to: > > union { T1 *a; T2 *b; }; > ... > bool is_b_rather_than_a; > > except that the is_b_rather_than_a tag is stored in the low bit > of the poi

[07/23] Add a class that multiplexes two pointer types

2020-11-13 Thread Richard Sandiford via Gcc-patches
This patch adds a pointer_mux class that provides similar functionality to: union { T1 *a; T2 *b; }; ... bool is_b_rather_than_a; except that the is_b_rather_than_a tag is stored in the low bit of the pointer. See the comments in the patch for a comparison between the two approaches