riscv-non-isa / riscv-elf-psabi-doc

A RISC-V ELF psABI Document
https://jira.riscv.org/browse/RVG-4
Creative Commons Attribution 4.0 International
697 stars 163 forks source link

C's (Optional) Named Integer Types #169

Open lenary opened 3 years ago

lenary commented 3 years ago

I think clang and gcc currently disagree on the size and alignment of int_fastN_t and int_leastN_t in some places. GCC is likely correct, as clang will always match those two.

Do we want to codify this in the psABI?

I looked at making the Clang changes required, and they were fairly involved - https://reviews.llvm.org/D80963 was the initial bit, but clang also has a stdint.h implementation for freestanding mode which is not very much fun to edit and improve.

If we don't want to codify it, we should also say that, maybe. I don't know what people feel is reasonable.

aswaterman commented 3 years ago

These affect the calling convention, struct layout, etc., so I think we basically have to codify them.

It looks like, for GCC, all glibc targets use the same definitions: fast8 is char; the others are long. I can't say I understand why fast8 is the way that it is--maybe they felt that in this case potential for memory waste outweighed the perf gain from using a register-sized type?--but the rest are sensible. https://github.com/gcc-mirror/gcc/blob/master/gcc/config/glibc-stdint.h

nick-knight commented 3 years ago

My opinion is that this stuff really belongs in the C API. See, e.g., https://github.com/riscv/riscv-c-api-doc/pull/14 However, there is (apparently) now a psABI working group, whereas I don't think the same is true for the C API.

aswaterman commented 3 years ago

Ah, yeah, I agree; I suppose my point is that it should be standardized, not that it should be standardized in this doc.