This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Smith <richard at metafoo dot co dot uk>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, cfe-commits <cfe-commits at lists dot llvm dot org>
- Date: Tue, 9 Feb 2016 06:45:37 -0800
- Subject: Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOofYT89yzF6jxFZFG2=QVQuQpEC7DP0HV_epjeawCf_sA at mail dot gmail dot com> <87d1s8wc4w dot fsf at mid dot deneb dot enyo dot de> <CAMe9rOp_6ZpR1YSJZ7AiLpa+FPRGJoLm5fTPkiH5BgF4Tkg3RA at mail dot gmail dot com> <87r3gouvv2 dot fsf at mid dot deneb dot enyo dot de> <CAMe9rOo2tPZKZEgpgFbbSnkyBiONzS9vfntn_QsxRPbVHZGmUw at mail dot gmail dot com> <87k2mgutzr dot fsf at mid dot deneb dot enyo dot de> <CAMe9rOoMujhjExxKWrz-Dv8uE33X=Upvi_X_HZsfeN0GS+=56A at mail dot gmail dot com> <CAMe9rOruCOvtM2D2AmG94A1_8Og8Kfu7tYF4De=XNfzUG+eh5g at mail dot gmail dot com> <CAH6eHdQci21ZhZ4odOfJRjC8s8HjuJ5X73LfK6oqvxCtOnzK6w at mail dot gmail dot com> <CAMe9rOpJXNUNvusTmwFb3riOxXyXLTGTquSMKqZkBe=nbmt_QQ at mail dot gmail dot com> <CAH6eHdQcvj7EY3jXgtUBQePfikiTbcuqsNFpDH7SWyxD628peQ at mail dot gmail dot com> <CAMe9rOrsV-zohnj=31_DDYSxUDyRDYL0anTi_NJm5vqogF9URQ at mail dot gmail dot com> <CAH6eHdQtnzMO6gLLRsczDdvmx0exkqXxyY-WvZ6RjuM7a3=85A at mail dot gmail dot com> <CAH6eHdQQjpOwD2kNCZVjH+w6N0Wh=gbdaaCcjg21iEbaHaAE5A at mail dot gmail dot com> <CAMe9rOq5QL9J0F-isO1njJyDJcZ08gF4zUk4vXNONWSfUtSzwA at mail dot gmail dot com> <CAH6eHdR0vJkYuYeKU=zyhthOY0KT-m8C=m2AtZ5GfVeyPOA=jw at mail dot gmail dot com> <CAOfiQqmKnONCdEi=coKaAKO_0Ux5X1BdYZ5t98gCU+LN21xKvw at mail dot gmail dot com> <CAH6eHdTxMXA7BEEHB7y6c5dRG_Hur5=CmdrQWMRn3zRGHnGZuA at mail dot gmail dot com> <CAMe9rOr9CCDjVVdYq7SoCDewg6uLnegEvT3Rrf2jg05SSyM_GQ at mail dot gmail dot com> <CAOfiQqnK-MFNhjcnHPPBpFfcJxR5rkdj26x8HcfMOiibCtevXA at mail dot gmail dot com> <CAMe9rOpM5Cs4zthCTAyaBEx3TWAQ7QNKv=k9mrqNzvj-upGcUw at mail dot gmail dot com> <CAOfiQq=EwsG7rLK_Ra+rsncJ2kBJzw7wUuqMqJp_zNH3_n07=A at mail dot gmail dot com> <CAMe9rOogQy01JujPYcGZ3aoFGU69e4=1Xxdn49mrjYNuovRnWQ at mail dot gmail dot com> <CAOfiQqmO-zZziaw_YhsbRcwi8ozt6w0zfEMCBdYAXQVddXj_FA at mail dot gmail dot com> <CAMe9rOoFq3BGF6Hv-6oSzeZrB6uMAiD3183TtSQ2QMf_Shr8cQ at mail dot gmail dot com> <CAOfiQqnyRz=5vZtNjOPi7=E147B+f9CLebf1GKrYVt97Z=7vpQ at mail dot gmail dot com> <CAMe9rOoV_6+QVCC8WwJ1MJ1RZR9TcuaPtomTYoT0GN+96M1+nw at mail dot gmail dot com> <CAOfiQqkH5uSxpAiKQLoFVu_B7=SJwL-VAgWsa48m95gNcj1XEQ at mail dot gmail dot com>
On Mon, Feb 8, 2016 at 3:28 PM, Richard Smith <richard@metafoo.co.uk> wrote:
> On Mon, Feb 8, 2016 at 3:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Feb 8, 2016 at 2:58 PM, Richard Smith <richard@metafoo.co.uk> wrote:
>>> On Mon, Feb 8, 2016 at 2:54 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Mon, Feb 8, 2016 at 2:51 PM, Richard Smith <richard@metafoo.co.uk> wrote:
>>>>> On Mon, Feb 8, 2016 at 2:46 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>> On Mon, Feb 8, 2016 at 2:35 PM, Richard Smith <richard@metafoo.co.uk> wrote:
>>>>>>> On Mon, Feb 8, 2016 at 1:40 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>>>>
>>>>>>>> On Mon, Feb 8, 2016 at 12:38 PM, Richard Smith <richard@metafoo.co.uk> wrote:
>>>>>>>> > On Mon, Feb 8, 2016 at 12:05 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>>>>> >>
>>>>>>>> >> On Mon, Feb 8, 2016 at 11:33 AM, Jonathan Wakely <jwakely.gcc@gmail.com>
>>>>>>>> >> wrote:
>>>>>>>> >> > On 8 February 2016 at 19:23, Richard Smith wrote:
>>>>>>>> >> >> "POD for the purpose of layout" is defined in the Itanium C++ ABI here:
>>>>>>>> >> >>
>>>>>>>> >> >> http://mentorembedded.github.io/cxx-abi/abi.html#definitions
>>>>>>>> >> >
>>>>>>>> >> > Thanks. So there's no problem using "POD for the purposes of layout",
>>>>>>>> >> > and the change to "POD for the purpose of standard-layout" was
>>>>>>>> >> > unnecessary and just confused things.
>>>>>>>> >>
>>>>>>>> >> Here is the revised proposal:
>>>>>>>> >>
>>>>>>>> >> 1. "class type". A class type is a structure, union or C++ class.
>>>>>>>> >> 2. "empty class type". An empty class type is:
>>>>>>>> >> a. A class type without member. Or
>>>>>>>> >> b. A class type with only members of empty class types. Or
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > (a) is a special case of (b).
>>>>>>>> >
>>>>>>>> >> c. An array of empty class types.
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > It seems confusing to call an array a class type. Instead, how about:
>>>>>>>> >
>>>>>>>> > 2. An empty type is either an array of empty types or a class type where
>>>>>>>> > every member is of empty type.
>>>>>>>> >
>>>>>>>> >> 3. "empty record". An empty record is Plain Old Data (POD) for the
>>>>>>>> >> purposes of layout and
>>>>>>>> >> a. A class type without member. Or
>>>>>>>> >> b. A class type with only members of empty class types.
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > (a) is a special case of (b).
>>>>>>>> >
>>>>>>>> >> 4. No memory slot nor register should be used to pass or return an object
>>>>>>>> >> of empty record.
>>>>>>>> >
>>>>>>>> >
>>>>>>>> > Objects of array type are never passed or returned (but if through some
>>>>>>>> > language extension they were, we'd want this rule to apply). So you don't
>>>>>>>> > need rule 3 and this can be just:
>>>>>>>> >
>>>>>>>> > 3. No memory slot nor register should be used to pass or return an object
>>>>>>>> > of empty type.
>>>>>>>>
>>>>>>>> Thanks very much for your inputs. Here is the proposal:
>>>>>>>>
>>>>>>>> 1. "class type". A class type is a structure, union or C++ class.
>>>>>>>> 2. "empty type". An empty type is either an array of empty types or a
>>>>>>>> class type where every member is of empty type.
>>>>>>>> 3. No memory slot nor register should be used to pass or return an object
>>>>>>>> of empty type.
>>>>>>>
>>>>>>> David Majnemer points out that we also need to say something about
>>>>>>> base classes. We could handle that case like this:
>>>>>>>
>>>>>>> 2. "empty type". An empty type is a type where it and all of its
>>>>>>> subobjects are of class or array type.
>>>>>>>
>>>>>>> Following the C++ rules, this also means that a class that contains
>>>>>>> only unnamed bitfields is empty, because unnamed bitfields are not
>>>>>>> subobjects, but might be worth explicitly stating for the C case. That
>>>>>>> also matches Clang's behavior.
>>>>>>
>>>>>> Like this?
>>>>>>
>>>>>> 1. "class type". A class type is a structure, union or C++ class.
>>>>>> 2. "empty type". An empty type is
>>>>>> a. A type where it and all of its subobjects are of class or array
>>>>>> type. And
>>>>>> b. Either an array of empty types or a class type where every member
>>>>>> is of empty type.
>>>>>
>>>>> You don't need (b). It's implied by (a).
>>>>
>>>> Does (a) cover empty type?
>>>
>>> Yes, (a) is a complete definition of "empty type" by itself: the
>>> definition is, essentially, that a complete recursive walk of the type
>>> and all its subobjects never sees anything that would require any
>>> storage (that is, it only sees class types and array types).
>>
>> Is there a definition of subobject?
>
> Yes, the C++ standard defines the term (as an object that is contained
> within another via member, base class, and array element
> relationships). The C standard uses it in 6.7.9 to mean the same thing
> (recursing into class and array elements) but doesn't provide a formal
> definition.
Here is the new one:
1. "class type". A class type is a structure, union or C++ class.
2. "empty type". An empty type is Plain Old Data (POD) for the
purposes of layout, and.a type where it and all of its subobjects
are of class or array type.
I put back " Plain Old Data (POD) for the purposes of layout" to
explicitly exclude array here.
--
H.J.
- References:
- RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct