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

gu: Add clang-friendly codepath #149

Merged
merged 3 commits into from
Dec 23, 2023
Merged

gu: Add clang-friendly codepath #149

merged 3 commits into from
Dec 23, 2023

Conversation

Beyley
Copy link
Contributor

@Beyley Beyley commented Sep 15, 2023

Clang refuses to assemble the asm macro, stating the instruction is "unavailable with your current feature set", and im not sure why, ive tried enabling a bunch of features, and nothing seems to make it happy. So i enabled the non-accelerated codepath on clang, which makes it compile, and allows most of gu (at least all thats needed for a cube sample) to be compiled using the LLVM/Clang 16 shipped with the Zig compiler

@IridescentRose
Copy link
Contributor

IridescentRose commented Sep 16, 2023

Can you not use __builtin_clz()?

Edit: Since you're using zig you could just export the zig-ified version of this function and use the @clz() builtin

@Beyley
Copy link
Contributor Author

Beyley commented Sep 17, 2023

Can you not use __builtin_clz()?

Edit: Since you're using zig you could just export the zig-ified version of this function and use the @clz() builtin

I was able to use __builtin_clz yes, good catch

And my zig PSP SDK is trying to re-use as much of the C SDK as possible (since i dont have nearly as much time/resources/experience). Which is why im re-using the pspsdk C implementations of gu and gum (and calling into those using the standard C headers with @cImport), rather than using the Zig implementations provided by zpsp-dev/zig-psp, since those ports are outdated and would have been a large effort to bring up to Zig 0.12.0-dev
So id rather reuse the C implementations of this, since __builtin_clz and @clz will compile down to the same LLVM IR anyway

@fjtrujy
Copy link
Member

fjtrujy commented Oct 3, 2023

@davidgfnet could you take a look at this change?

@davidgfnet
Copy link
Contributor

Can you please use __builtin_clz for both gcc and clang? gcc should generate the CLZ instruction natively. clang won't since it doesn't support it (AFAIK). In any case, should work for most compilers and gcc should still emit the faster asm.

@sharkwouter
Copy link
Member

@Beyley are you still planning on updating this with the feedback given? I'd like to be able to merge this.

@Beyley
Copy link
Contributor Author

Beyley commented Dec 22, 2023

@Beyley are you still planning on updating this with the feedback given? I'd like to be able to merge this.

My bad, i got busy and completely forgot! I'll switch it to use __builtin_clz on GCC aswell

@Beyley
Copy link
Contributor Author

Beyley commented Dec 22, 2023

Done

@sharkwouter
Copy link
Member

Thanks, if the ci passes I'll merge this.

@sharkwouter sharkwouter merged commit 8fc8beb into pspdev:master Dec 23, 2023
1 check passed
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.

5 participants