Repository navigation
c-variadic: support ppcf128 - #164004
c-variadic: support ppcf128#164004
Conversation
| // POWERPC: stwu 1, -32(1) | ||
| // POWERPC: lbz 5, 1(3) | ||
| // POWERPC-NEXT: cmplwi 5, 6 | ||
| // POWERPC-NEXT: bgt 0, .LBB3_2 | ||
| // POWERPC-NEXT: lwz 4, 8(3) | ||
| // POWERPC-NEXT: rlwinm 6, 5, 3, 24, 28 | ||
| // POWERPC-NEXT: addi 5, 5, 2 | ||
| // POWERPC-NEXT: add 4, 4, 6 | ||
| // POWERPC-NEXT: addi 4, 4, 32 | ||
| // POWERPC-NEXT: b .LBB3_3 | ||
| // POWERPC-NEXT: .LBB3_2: | ||
| // POWERPC-NEXT: lwz 4, 4(3) | ||
| // POWERPC-NEXT: addi 4, 4, 7 | ||
| // POWERPC-NEXT: rlwinm 4, 4, 0, 0, 28 | ||
| // POWERPC-NEXT: addi 5, 4, 16 | ||
| // POWERPC-NEXT: stw 5, 4(3) | ||
| // POWERPC-NEXT: li 5, 8 | ||
| // POWERPC-NEXT: .LBB3_3: | ||
| // POWERPC-NEXT: lwz 6, 4(4) | ||
| // POWERPC-NEXT: stb 5, 1(3) | ||
| // POWERPC-NEXT: stw 6, 28(1) | ||
| // POWERPC-NEXT: lwz 3, 0(4) | ||
| // POWERPC-NEXT: stw 3, 24(1) | ||
| // POWERPC-NEXT: lwz 3, 12(4) | ||
| // POWERPC-NEXT: lfd 1, 24(1) | ||
| // POWERPC-NEXT: stw 3, 20(1) | ||
| // POWERPC-NEXT: lwz 3, 8(4) | ||
| // POWERPC-NEXT: stw 3, 16(1) | ||
| // POWERPC-NEXT: lfd 2, 16(1) | ||
| // POWERPC-NEXT: addi 1, 1, 32 |
There was a problem hiding this comment.
LLVM does a poor job here, GCC produces way fewer instructions https://godbolt.org/z/4xE4e9f5d.
22ec35d to
2d7d726
Compare
|
r? beetrees I've tested this with abi-cafe. Testing e.g. with the roundtrip test we have is inconvenient because we currently don't have any constructors. |
There was a problem hiding this comment.
The 32-bit soft-float case isn't quite right, but the hard-float case LGTM. For the rountrip test, couldn't we use transmute for now and leave a FIXME to replace with from_components once #164021 is merged?
|
|
||
| // "Align" the register count when the type is passed as `i64`. | ||
| if is_i64 || (is_f64 && is_soft_float_abi) { | ||
| if is_i64 || ((is_f64 || is_ppcf128) && is_soft_float_abi) { |
There was a problem hiding this comment.
The ABI spec says that QUAD_GP (which is what ppcf128 falls into on soft float) is not aligned when passed in registers.
There was a problem hiding this comment.
I think that means we can read it as 2 f64 values? Because if it's not aligned it might be split between gpr and the overflow_arg_area?
There was a problem hiding this comment.
It's not aligned, but if there aren't 4 available GPRs the whole thing is passed in the overflow area. It's the same concept as passing it in FPRs, just with 4 registers instead of 2.
There was a problem hiding this comment.
| if is_i64 || ((is_f64 || is_ppcf128) && is_soft_float_abi) { | |
| if is_i64 || (is_f64 && is_soft_float_abi) { |
Since we're leaving soft-float support for later and this is against the specification, may as well not add is_ppcf128 here.
| Float::F16 | Float::F16B | Float::F32 => unreachable!(), | ||
| Float::F64 | Float::F128 | Float::PpcF128 => { /* fall through */ } | ||
| Float::F64 | Float::F128 => { /* fall through */ } | ||
| Float::PpcF128 => return Align::EIGHT, |
There was a problem hiding this comment.
Per the ABI spec, on soft float ppcf128 arguments are only passed with an alignment of 4. 8 is correct for hard float.
There was a problem hiding this comment.
I suspect we'll just read it as two f64 values
|
Reminder, once the PR becomes ready for a review, use |
|
We don't actually support any true softfloat targets (and the So, I guess we try to properly support spe now? Those targets are extremely tier 3 though. I'd kinda rather do it as a follow-up? |
|
Leaving soft-float for later is fine - just leave a |
2d7d726 to
cb3994c
Compare
There was a problem hiding this comment.
We don't even have PartialEq for the type right now. We'll definitely come back to it when adding c_longdouble.
@rustbot ready
| Float::F16 | Float::F16B | Float::F32 => unreachable!(), | ||
| Float::F64 | Float::F128 | Float::PpcF128 => { /* fall through */ } | ||
| Float::F64 | Float::F128 => { /* fall through */ } | ||
| Float::PpcF128 => return Align::EIGHT, |
There was a problem hiding this comment.
I suspect we'll just read it as two f64 values
This comment has been minimized.
This comment has been minimized.
cb3994c to
055d417
Compare
|
|
||
| // "Align" the register count when the type is passed as `i64`. | ||
| if is_i64 || (is_f64 && is_soft_float_abi) { | ||
| if is_i64 || ((is_f64 || is_ppcf128) && is_soft_float_abi) { |
There was a problem hiding this comment.
| if is_i64 || ((is_f64 || is_ppcf128) && is_soft_float_abi) { | |
| if is_i64 || (is_f64 && is_soft_float_abi) { |
Since we're leaving soft-float support for later and this is against the specification, may as well not add is_ppcf128 here.
055d417 to
e21e982
Compare
This comment has been minimized.
This comment has been minimized.
e21e982 to
f851aa9
Compare
|
@rustbot ready |
c441d90 to
8af06b3
Compare
8af06b3 to
24f5f82
Compare
There was a problem hiding this comment.
Sorry about that, that's what I get for doing it manually instead of copying from github.
@rustbot ready
| let max_regs = 8u8; | ||
| let use_regs = bx.icmp(IntPredicate::IntULT, num_regs, bx.const_u8(max_regs)); | ||
| let reg_size = if is_passed_in_fprs { 8 } else { 4 }; | ||
| let reg_incr = layout.size.bytes().div_ceil(u64::from(reg_size)) as u8; |
There was a problem hiding this comment.
I went with naming it reg_incr because we already have num_regs so also having n_reg could cause confusion.
| // POWERPC-NEXT: .LBB2_2: | ||
| // POWERPC-NEXT: lwz 3, 4(5) | ||
| // POWERPC-NEXT: li 6, 8 | ||
| // POWERPC-NEXT: addi 3, 3, 7 | ||
| // POWERPC-NEXT: rlwinm 4, 3, 0, 0, 28 | ||
| // POWERPC-NEXT: addi 3, 4, 8 | ||
| // POWERPC-NEXT: stw 3, 4(5) | ||
| // POWERPC-NEXT: lwz 3, 0(4) | ||
| // POWERPC-NEXT: lwz 4, 4(4) | ||
| // POWERPC-NEXT: stb 6, 0(5) | ||
| // POWERPC-NEXT: blr |
There was a problem hiding this comment.
I noticed some check lines were missing
| // POWERPC-NEXT: clrlwi 4, 3, 24 | ||
| // POWERPC-NEXT: cmplwi 4, 7 | ||
| // POWERPC-NEXT: rlwinm 4, 3, 0, 24, 30 | ||
| // POWERPC-NEXT: cmplwi 4, 6 | ||
| // POWERPC-NEXT: bgt 0, .LBB2_2 | ||
| // POWERPC-NEXT: lwz 4, 8(5) | ||
| // POWERPC-NEXT: rlwinm 6, 3, 0, 29, 30 | ||
| // POWERPC-NEXT: rlwinm 3, 3, 2, 27, 28 | ||
| // POWERPC-NEXT: rlwinm 6, 3, 0, 0, 30 | ||
| // POWERPC-NEXT: rlwinm 3, 3, 2, 24, 28 |
There was a problem hiding this comment.
The assembly changed a bit here, but I believe this is equivalent in practice. At least, the code seems correct, abi-cafe is happy, so this must be right. This is slightly different from clang/gcc though
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 8006091 (parent) -> 02fb0a1 (this PR) Test differencesShow 2 test diffs2 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 02fb0a16311c3411fa373627706da085cd8fbd3c --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (02fb0a1): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 5.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 491.611s -> 489.75s (-0.38%) |
View all comments
tracking issue: #163323
cc #161787
On
powerpc64this needs a change to lower the alignment ofppcf128to only 8 when read from aVaList.On
powerpcthis needs some additional changes to the logic to match GCC. Of course, in clang the ABI of this type is completely broken, we'll see if my fix for that gets merged llvm/llvm-project#225956.