Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve implicit calling convention parameter handling #53

Closed
2 tasks done
PathogenDavid opened this issue Sep 14, 2020 · 0 comments
Closed
2 tasks done

Improve implicit calling convention parameter handling #53

PathogenDavid opened this issue Sep 14, 2020 · 0 comments
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Area-Translation Issues concerning the translation from libclang into Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective

Comments

@PathogenDavid
Copy link
Member

PathogenDavid commented Sep 14, 2020

Right now the handling of implicit parameters is done in multiple different places in two different ways and neither strategy is ideal for resolving future issues. (The current behavior is basically hard-coded for Microsoft x64.)

It's currently handled in:

  • CSharpLibraryGenerator.EmitFunctionParameterList -- the implicit parameters/arguments are emitted as appropriate.
  • TranslatedVTableEntry -- the FunctionPointerTypeReference is modified to add the parameters. Removed, essentially handled by EmitFunctionParameterList now.
  • CSharpLibraryGenerator.WriteType -- there's a special case for FunctionPointerTypeReference to add out to the retbuf parameter in the context of a vTable entry. This specific hack was removed in e498d90, but regardless this function was reworked to handle ABI stuff correctly. It is still separate from EmityFunctionParameterList for simplicity's sake, but the information all comes from a single source now (PathogenArrangedFunction.)
@PathogenDavid PathogenDavid added Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Area-Translation Issues concerning the translation from libclang into Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective labels Sep 21, 2020
PathogenDavid added a commit that referenced this issue Jun 21, 2021
…ge of Clang's code generation module.

In short, this change replaces ClangSharpExtensions.[Record]MustBePassedByReference with ClangSharp.Pathogen.PathogenArrangedFunction, which uses Clang's code generation module to determine how a function call should be constructed. This moves Biohazrd's handling of whether a type is returned/passed by reference from TranslatedRecord to TranslatedFunction and TranslatedParameter.

This change does not include support for function pointers or vtable entries as those will require extra effort.
(VTables need to be reworked to fix #147 first. Function pointers don't support most ABI concerns in general #186.)

Fixes #35 (Fixed leaking return buffer semantics on global functions and static methods. Fixed as a side-effect.)
Contributes to #53 (Cleaning up ABI handling.)
Contributed to #108 (Linux support.)
Fixes #187 (Records with constructors not being returned by reference on Microsoft x64.)
Fixes #135 (Indirectly since this problematic method was obsoleted.)
PathogenDavid added a commit that referenced this issue Jun 21, 2021
…ge of Clang's code generation module.

In short, this change replaces ClangSharpExtensions.[Record]MustBePassedByReference with ClangSharp.Pathogen.PathogenArrangedFunction, which uses Clang's code generation module to determine how a function call should be constructed. This moves Biohazrd's handling of whether a type is returned/passed by reference from TranslatedRecord to TranslatedFunction and TranslatedParameter.

This change does not include support for function pointers or vtable entries as those will require extra effort.
(VTables need to be reworked to fix #147 first. Function pointers don't support most ABI concerns in general #186.)

Fixes #35 (Fixed leaking return buffer semantics on global functions and static methods. Fixed as a side-effect.)
Contributes to #53 (Cleaning up ABI handling.)
Contributes to #108 (Linux support.)
Fixes #187 (Records with constructors not being returned by reference on Microsoft x64.)
Fixes #135 (Indirectly since this problematic method was obsoleted.)
PathogenDavid added a commit that referenced this issue Jul 4, 2021
…ge of Clang's code generation module.

In short, this change replaces ClangSharpExtensions.[Record]MustBePassedByReference with ClangSharp.Pathogen.PathogenArrangedFunction, which uses Clang's code generation module to determine how a function call should be constructed. This moves Biohazrd's handling of whether a type is returned/passed by reference from TranslatedRecord to TranslatedFunction and TranslatedParameter.

This change does not include support for function pointers or vtable entries as those will require extra effort.
(VTables need to be reworked to fix #147 first. Function pointers don't support most ABI concerns in general #186.)

Fixes #35 (Fixed leaking return buffer semantics on global functions and static methods. Fixed as a side-effect.)
Contributes to #53 (Cleaning up ABI handling.)
Contributes to #108 (Linux support.)
Fixes #187 (Records with constructors not being returned by reference on Microsoft x64.)
Fixes #135 (Indirectly since this problematic method was obsoleted.)
PathogenDavid added a commit that referenced this issue Jul 4, 2021
…d reworked things to use the corresponding TranslatedFunction instead.

Fixes #147 (Type information redundant between TranslatedFunction and TranslatedVTableEntry.)
Contributes to #53 (ABI handling in TranslatedVTableEntry was elimintated.)
Fixes #103 (VTable entries using the base type for this in child vtables.)
PathogenDavid added a commit that referenced this issue Jul 5, 2021
…ge of Clang's code generation module.

In short, this change replaces ClangSharpExtensions.[Record]MustBePassedByReference with ClangSharp.Pathogen.PathogenArrangedFunction, which uses Clang's code generation module to determine how a function call should be constructed. This moves Biohazrd's handling of whether a type is returned/passed by reference from TranslatedRecord to TranslatedFunction and TranslatedParameter.

This change does not include support for function pointers or vtable entries as those will require extra effort.
(VTables need to be reworked to fix #147 first. Function pointers don't support most ABI concerns in general #186.)

Fixes #35 (Fixed leaking return buffer semantics on global functions and static methods. Fixed as a side-effect.)
Contributes to #53 (Cleaning up ABI handling.)
Contributes to #108 (Linux support.)
Fixes #187 (Records with constructors not being returned by reference on Microsoft x64.)
Fixes #135 (Indirectly since this problematic method was obsoleted.)
PathogenDavid added a commit that referenced this issue Jul 5, 2021
…d reworked things to use the corresponding TranslatedFunction instead.

Fixes #147 (Type information redundant between TranslatedFunction and TranslatedVTableEntry.)
Contributes to #53 (ABI handling in TranslatedVTableEntry was elimintated.)
Fixes #103 (VTable entries using the base type for this in child vtables.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Area-Translation Issues concerning the translation from libclang into Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective
Projects
None yet
Development

No branches or pull requests

1 participant