-
Notifications
You must be signed in to change notification settings - Fork 165
[CIR][CodeGen][Builtin] Implement bcopy and __builtin_bcopy #1855
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
base: main
Are you sure you want to change the base?
Conversation
char dst[20]; | ||
char src[20]; | ||
int _sz = 20, len = 20; | ||
return (_sz ? ((_sz >= len) ? __builtin_bcopy(src, dst, len) : foo()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this conditional get simplified? Also, we may want some part of the conditional to be passed as an argument so that the test doesn't get overly optimized by constant folding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is actually from the OG. I can add an extra conditional test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say keep this and add an extra one with the added complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcardosolopes I added an extra conditional test.
float f8[8]; | ||
__builtin_bcopy(f4, f8, sizeof(float) * 4); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add at least one test with bcopy
for completeness. That way if anyone tries to separate the handling of the builtin from the function it will show a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wanted to add a test with bcopy
, but it requires <strings.h>
, which I can't (or I'm not sure how to) use in the test directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
bcopy
, but it requires<strings.h>
,
Can you add a mock version that would still trigger codegen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcardosolopes I wasn't able to. I need to somehow trigger memmove
. I'm open to suggestions and can create a follow-up PR if I figure out a way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending nits
Closes #1816