Skip to content

Commit

Permalink
Avoid explicit indirect return pointers for ARM64.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Nov 10, 2024
1 parent ee4f946 commit 944cfe3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ public unsafe partial class BlockCommandComment : global::CppSharp.Parser.AST.Bl
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST19BlockCommandComment12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.BlockCommandComment.Argument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST19BlockCommandComment12addArgumentsERNS2_8ArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -1208,8 +1208,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.BlockCommandComment.Argument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.BlockCommandComment.Argument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.BlockCommandComment.Argument.__CreateInstance(___ret);
global::CppSharp.Parser.AST.BlockCommandComment.Argument.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand Down Expand Up @@ -2000,7 +1999,7 @@ public unsafe partial class InlineCommandComment : global::CppSharp.Parser.AST.I
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST20InlineCommandComment12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.InlineCommandComment.Argument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST20InlineCommandComment12addArgumentsERNS2_8ArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -2243,8 +2242,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.InlineCommandComment.Argument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.InlineCommandComment.Argument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.InlineCommandComment.Argument.__CreateInstance(___ret);
global::CppSharp.Parser.AST.InlineCommandComment.Argument.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand Down Expand Up @@ -2423,7 +2421,7 @@ public unsafe partial class HTMLStartTagComment : global::CppSharp.Parser.AST.HT
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST19HTMLStartTagComment13getAttributesEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetAttributes(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.HTMLStartTagComment.Attribute.__Internal GetAttributes(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST19HTMLStartTagComment13addAttributesERNS2_9AttributeE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddAttributes(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -2686,8 +2684,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.HTMLStartTagComment.Attribute GetAttributes(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.HTMLStartTagComment.Attribute.__Internal();
__Internal.GetAttributes(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetAttributes(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.HTMLStartTagComment.Attribute.__CreateInstance(___ret);
global::CppSharp.Parser.AST.HTMLStartTagComment.Attribute.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand Down Expand Up @@ -5201,7 +5198,7 @@ public unsafe partial class TemplateSpecializationType : global::CppSharp.Parser
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST26TemplateSpecializationType12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.TemplateArgument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST26TemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -5294,8 +5291,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.TemplateArgument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.TemplateArgument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(___ret);
}

Expand Down Expand Up @@ -5378,7 +5374,7 @@ public unsafe partial class DependentTemplateSpecializationType : global::CppSha
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.TemplateArgument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -5471,8 +5467,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.TemplateArgument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.TemplateArgument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(___ret);
}

Expand Down Expand Up @@ -12814,7 +12809,7 @@ public partial struct __Internal
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout11getVFTablesEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetVFTables(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.VFTableInfo.__Internal GetVFTables(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout11addVFTablesERNS1_11VFTableInfoE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddVFTables(__IntPtr __instance, __IntPtr s);
Expand All @@ -12823,7 +12818,7 @@ public partial struct __Internal
internal static extern void ClearVFTables(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout9getFieldsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetFields(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.LayoutField.__Internal GetFields(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout9addFieldsERNS1_11LayoutFieldE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddFields(__IntPtr __instance, __IntPtr s);
Expand All @@ -12832,7 +12827,7 @@ public partial struct __Internal
internal static extern void ClearFields(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout8getBasesEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetBases(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.LayoutBase.__Internal GetBases(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST11ClassLayout8addBasesERNS1_10LayoutBaseE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddBases(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -12954,8 +12949,7 @@ internal protected virtual void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.VFTableInfo GetVFTables(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.VFTableInfo.__Internal();
__Internal.GetVFTables(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetVFTables(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.VFTableInfo.__CreateInstance(___ret);
global::CppSharp.Parser.AST.VFTableInfo.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand All @@ -12976,8 +12970,7 @@ public void ClearVFTables()

public global::CppSharp.Parser.AST.LayoutField GetFields(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.LayoutField.__Internal();
__Internal.GetFields(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetFields(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.LayoutField.__CreateInstance(___ret);
global::CppSharp.Parser.AST.LayoutField.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand All @@ -12998,8 +12991,7 @@ public void ClearFields()

public global::CppSharp.Parser.AST.LayoutBase GetBases(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.LayoutBase.__Internal();
__Internal.GetBases(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetBases(__Instance, i);
var _____ret = global::CppSharp.Parser.AST.LayoutBase.__CreateInstance(___ret);
global::CppSharp.Parser.AST.LayoutBase.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand Down Expand Up @@ -15396,7 +15388,7 @@ public unsafe partial class ClassTemplateSpecialization : global::CppSharp.Parse
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST27ClassTemplateSpecialization12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.TemplateArgument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST27ClassTemplateSpecialization12addArgumentsERNS1_16TemplateArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -15489,8 +15481,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.TemplateArgument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.TemplateArgument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(___ret);
}

Expand Down Expand Up @@ -16079,7 +16070,7 @@ public partial struct __Internal
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST30FunctionTemplateSpecialization12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.TemplateArgument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST30FunctionTemplateSpecialization12addArgumentsERNS1_16TemplateArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -16195,8 +16186,7 @@ internal protected virtual void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.TemplateArgument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.TemplateArgument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(___ret);
}

Expand Down Expand Up @@ -16578,7 +16568,7 @@ public unsafe partial class VarTemplateSpecialization : global::CppSharp.Parser.
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST25VarTemplateSpecialization12getArgumentsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetArguments(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.AST.TemplateArgument.__Internal GetArguments(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser3AST25VarTemplateSpecialization12addArgumentsERNS1_16TemplateArgumentE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddArguments(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -16671,8 +16661,7 @@ internal protected override void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.AST.TemplateArgument GetArguments(uint i)
{
var ___ret = new global::CppSharp.Parser.AST.TemplateArgument.__Internal();
__Internal.GetArguments(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetArguments(__Instance, i);
return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(___ret);
}

Expand Down Expand Up @@ -49486,7 +49475,7 @@ public partial struct __Internal
internal static extern __IntPtr dtor(__IntPtr __instance);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser12ParserResult14getDiagnosticsEj", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void GetDiagnostics(__IntPtr @return, __IntPtr __instance, uint i);
internal static extern global::CppSharp.Parser.ParserDiagnostic.__Internal GetDiagnostics(__IntPtr __instance, uint i);

[SuppressUnmanagedCodeSecurity, DllImport("CppSharp.CppParser", EntryPoint = "_ZN8CppSharp9CppParser12ParserResult14addDiagnosticsERNS0_16ParserDiagnosticE", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void AddDiagnostics(__IntPtr __instance, __IntPtr s);
Expand Down Expand Up @@ -49614,8 +49603,7 @@ internal protected virtual void Dispose(bool disposing, bool callNativeDtor)

public global::CppSharp.Parser.ParserDiagnostic GetDiagnostics(uint i)
{
var ___ret = new global::CppSharp.Parser.ParserDiagnostic.__Internal();
__Internal.GetDiagnostics(new IntPtr(&___ret), __Instance, i);
var ___ret = __Internal.GetDiagnostics(__Instance, i);
var _____ret = global::CppSharp.Parser.ParserDiagnostic.__CreateInstance(___ret);
global::CppSharp.Parser.ParserDiagnostic.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/Passes/CheckAbiParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public override bool VisitFunctionDecl(Function function)
returnTypeDecl.IsPOD &&
returnTypeDecl.Layout.Size <= 8);

if (isReturnIndirect)
var triple = Context.ParserOptions.TargetTriple;
var isArm64 = triple.Contains("arm64") || triple.Contains("aarch64");
if (isReturnIndirect && !isArm64)
{
var indirectParam = new Parameter()
{
Expand Down

0 comments on commit 944cfe3

Please sign in to comment.