Implement va_arg for Hexagon targets#150008
Conversation
This comment has been minimized.
This comment has been minimized.
|
cc @folkertdev Tested with #150009 #150010, and this |
Implements proper variadic argument handling for hexagon-unknown-linux-musl targets using a 3-pointer VaList structure compatible with LLVM's HexagonBuiltinVaList implementation. * Handles register save area vs overflow area transition * Provides proper 4-byte and 8-byte alignment for arguments * Only activates for hexagon+musl targets via Arch::Hexagon & Env::Musl
961715a to
0c1612e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot reroll |
|
r? folkertdev |
There was a problem hiding this comment.
On its own this will miscompile, so maybe you can copy the changes from #149967 and just add them to this commit.
|
|
||
| // Calculate offset: round up type size to 4-byte boundary (minimum stack slot size) | ||
| let type_size = layout.size.bytes(); | ||
| let offset = ((type_size + 3) / 4) * 4; // align to 4 bytes |
There was a problem hiding this comment.
I believe that is
| let offset = ((type_size + 3) / 4) * 4; // align to 4 bytes | |
| let offset = type_size.next_multiple_of(4); // align to 4 bytes |
There was a problem hiding this comment.
change taken, thanks
| fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( | ||
| bx: &mut Builder<'_, 'll, 'tcx>, | ||
| list: OperandRef<'tcx, &'ll Value>, | ||
| target_ty: Ty<'tcx>, | ||
| ) -> &'ll Value { |
There was a problem hiding this comment.
is this different from emit_ptr_va_arg?
There was a problem hiding this comment.
Like, I know that this is what LLVM does, but unless I'm missing something LLVM implementation could also use emitVoidPtrVAArg
There was a problem hiding this comment.
I think you might be right that clang could use emitVoidPtrVAArg. Do you mind if I take that up separately with the hexagon compiler team and revisit it based on that discussion?
| // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. | ||
| Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), | ||
| Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), | ||
| Arch::Hexagon => emit_hexagon_va_arg(bx, addr, target_ty, target.env == Env::Musl), |
There was a problem hiding this comment.
I'd just inline emit_hexagon_va_arg here
This comment has been minimized.
This comment has been minimized.
fa4a020 to
0a956c5
Compare
|
Some changes occurred in src/tools/cargo cc @ehuss |
This comment has been minimized.
This comment has been minimized.
0a956c5 to
4ff4b25
Compare
| fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( | ||
| bx: &mut Builder<'_, 'll, 'tcx>, | ||
| list: OperandRef<'tcx, &'ll Value>, | ||
| target_ty: Ty<'tcx>, | ||
| ) -> &'ll Value { |
|
@bors r+ rollup |
Rollup merge of #150008 - androm3da:bcain/va_arg_rs, r=folkertdev Implement va_arg for Hexagon targets Implements proper variadic argument handling for hexagon-unknown-linux-musl targets using a 3-pointer VaList structure compatible with LLVM's HexagonBuiltinVaList implementation. * Handles register save area vs overflow area transition * Provides proper 4-byte and 8-byte alignment for arguments * Only activates for hexagon+musl targets via Arch::Hexagon & Env::Musl
Implements proper variadic argument handling for hexagon-unknown-linux-musl targets using a 3-pointer VaList structure compatible with LLVM's HexagonBuiltinVaList implementation.