-
Notifications
You must be signed in to change notification settings - Fork 165
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
[RFC] Add int_xlen_t and uint_xlen_t to psabi #158
Comments
@jim-wilson @knightsifive @asb @lenary @clairexen |
Agreed, we want to avoid proliferation of the assumption that unsigned long, size_t, uintptr_t, etc. are XLEN-sized, in anticipation of a future RV64 ILP32 ABI. |
I'm certainly opposed to using
But when writing C code to be portable across RV32 and RV64, I've found that I need XLEN in other places than just variable declarations, e.g., when bit-twiddling. So I'm wondering if it might be simpler just to standardize Along this same line of thought, other macros, like |
Both of those macros are already part of the toolchain conventions doc (as are related macros that describe the calling convention): https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions It's possible that this document is a more appropriate place for such things, since they really are part of the RISC-V C API, not merely "conventions". |
We also have https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md that defines command line options, predefined macros, etc. Looks like a lot of overlap between riscv-toolchain-conventions and riscv-c-api-doc. |
"C API" sounds like the right place for this stuff. I guess at some point we should merge the toolchain conventions document into the C API doc and deprecate the toolchain conventions repo. |
I don't think the compiler can introduce these types without leading underscores since they may conflict with user code. It may be easier to standardize on a |
I'm not sure why Does it make sense to define a @PkmX is right about needing a prefix for non-standard built-in types. It does make sense to have a header, and that's something we need to work out as we work out what we're doing about other intrinsic headers like @aswaterman I'm not convinced we should deprecate the toolchain conventions repo - a lot of those conventions extend beyond C to assemblers (in terms of things like |
I also consider about the int_flen_t and uint_flen_t before, but I am not sure the use case for that, so I would like to introduce XLEN-width integer type this time only, let me know if you found @PkmX Thanks you point out this, introducing new types by header file sounds good idea. |
We already have |
psABI only defines widths/alignments of fundamental types. https://github.com/riscv/riscv-c-api-doc may be a good place. POSIX reserves |
|
@sorear [1] https://github.com/riscv/riscv-gcc/blob/riscv-bitmanip/gcc/config/riscv/rvintrin.h @MaskRay Yeah, I agree https://github.com/riscv/riscv-c-api-doc is a good place :) |
I would think this type is not about intrinsic. Define it in a In addition, maybe it should be named like About whether it should have a Finally, I usually see these types with |
I'd avoid using the term "UXLEN", which also means the "effective XLEN in U-mode" (defined in Vol. II, Sec. 3.1.6.2). |
I don't think that there's an architecture float type. Surely, with the F extension it's |
Hi everyone: Thanks all your inputs, I create an PR on |
I saw there is similar request/needs for XLEN-width integer type in several intrinsic function design, including V-extension, P-extension and B-extension, current solution is using
long
andunsigned long
as XLEN-width integer type.It's work correctly, but it might not work if we have ilp32 for RV64,
long
could be defined as 32-bits.So I think we could propose add int_xlen_t and uint_xlen_t to RISC-V standard type, however there will be a transition period, some compiler support, and some compiler not support that, add a macro like __riscv_xlen_int might help that.
New Types
New Predefined Macro
__riscv_xlen_int
will defined if compiler has provide int_xlen_t and uint_xlen_t.The text was updated successfully, but these errors were encountered: