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

[WIP] ssa: gen wrap code if c func has wrap abi #923

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

visualfc
Copy link
Member

@visualfc visualfc commented Dec 27, 2024

compatible c abi struct calling.

  • link c abi wrap
  • callback abi wrap
  • cgo mode abi wrap
typedef struct {
    int a[2];
    int b;
} info;

typedef struct {
    int a[128];
} info_big;

info demo1(info i, int n);
info_big big1(info_big b, int n);

define { i64, i32 } @demo1(i64 %0, i32 %1, i32 noundef %2) #0 
define void @big1(ptr dead_on_unwind noalias writable sret(%struct.info_big) align 4 %0, ptr noundef byval(%struct.info_big) align 8 %1, i32 noundef %2) #0 

generate wrap c code

extern typ_bff19efe64daa269a3f6dbc9d84697ff demo1(typ_bff19efe64daa269a3f6dbc9d84697ff p0, Int32 p1);
void llgo_wrapabi_demo1(typ_bff19efe64daa269a3f6dbc9d84697ff *p0, Int32 p1, typ_bff19efe64daa269a3f6dbc9d84697ff *r) {
    *r = demo1(*p0, p1);
}
typedef struct {Int32 f0[128];} typ_e34beeb28a63e25393901f28326380b9;
extern typ_e34beeb28a63e25393901f28326380b9 big1(typ_e34beeb28a63e25393901f28326380b9 p0, Int32 p1);
void llgo_wrapabi_big1(typ_e34beeb28a63e25393901f28326380b9 *p0, Int32 p1, typ_e34beeb28a63e25393901f28326380b9 *r) {
    *r = big1(*p0, p1);
}

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 92.48826% with 16 lines in your changes missing coverage. Please review.

Project coverage is 97.48%. Comparing base (97a2824) to head (ff1e70d).

Files with missing lines Patch % Lines
ssa/wrapabi.go 90.00% 13 Missing ⚠️
ssa/type.go 71.42% 2 Missing ⚠️
ssa/expr.go 98.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #923      +/-   ##
==========================================
- Coverage   97.65%   97.48%   -0.17%     
==========================================
  Files          22       23       +1     
  Lines        6313     6487     +174     
==========================================
+ Hits         6165     6324     +159     
- Misses        128      143      +15     
  Partials       20       20              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@visualfc visualfc force-pushed the wrapabi branch 2 times, most recently from 9e03f61 to a4e1a57 Compare December 27, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant