ARM float abi softfp support
We want to support such code generation in coreclr that the applications could work with the native libraries built with ARM softfp. it's easier first to implement that not just for the boundaries between native and managed code, but to force all the code generation work with soft fp.
The return argument part seems to be easy since it follows the same pattern as it's already present in code for vararg support in codegenlegacy.cpp and registerfp.cpp.
As for the call arguments.
passUsingFloatRegs = false
in morph.cpp seems to be the place to go for passing them for a call.
Is CodeGen::genFnPrologCalleeRegArgs in codegencommon.cpp the function in charge of argument reading inside the function?
We believe we should also reorient the functions genMapRegNumToRegArgNum to correctly map the state for softfp.
Does the plan make sense in general? Are there other places in code important for argument abi support?
pushed the proposed changes to arm_softfp
cc @cmckinsey @dotnet/jit-contrib
@briansull, can you take a look?
So, there're problems which are seen in the testing with the generated code.
First, a call from C# to C# with a float argument seems to be reading the arguments from stack. G_M43710_IG01: 000000 E92D 4800 push {r11,lr} 000004 ED2D 8B04 vpush {d16-d19} 000008 F10D 0B10 add r11, sp, 16 00000C EDDD 8A06 vldr s17, [sp+0x18] 000010 ED9D 9A07 vldr s18, [sp+0x1c]
G_M43710_IG02: 000014 F24C 3010 movw r0, 0xc310 000018 F2C7 40F7 movt r0, 0x74f7 00001C F243 23C5 movw r3, 0x32c5 000020 F2C7 6332 movt r3, 0x7632 000024 4798 blx r3 // CORINFO_HELP_NEWSFAST
Probably max floating argument register which we made equal to 0 is in play here.
As we pass the arguments from C# to the native code, the arguments seem to be passed correctly, but the native code gets non correct values. So apparently we should also fix passing of the arguments in the intermediate layer.
Which probably means we didn't correctly calculate the mask: call->gtCall.gtCallRegUsedMask
Upd: indeed the mask was incorrectly calculated in Compiler::fgMorphArgs, but the issue seems to be still remaining in testing.
According to the testing by fixing jitted function accepting arguments we actually fix the PInvokes as well.
Can you share us patch and testcase? or with PR?
I'm just building a cleaner patch and will share once I test that as well. Some assertions are returned back so, probably they might complain on test.
The test is in the zip file here: a.zip
Also we need to setup a way to properly build arm with softfp support with a command like: ./build.sh arm cross so that the cmake change here: https://github.com/papaslavik/coreclr/commit/506a926a0ca48c1bbcd6a9a13fbe63ab15478db3 could be replaced with a change depending on arm-softfp target and not just for any arm.
\CC: @watere , @lemmaa , @myungjoo The above engineers are also interested in this issue. : )
Added mixed passing arguments complex function to the test: a.zip
The last commits are better logically split and also there's some small refactoring to the previous ones in them.
@papaslavik I tested a.zip and it was successful. :)
Seems like it works fine for both P/Invokes and C# calling C#.
So we added the arm-softfp target, but we're having troubles trying to build it like: ./build arm-softfp cross
@brucehoult @leemgs
So we've pushed a new version of the feature implementation which meets the reviewer comments to the new branch arm_softfp_v2
I will re-push that to arm_softfp for the pull request in a while after some testing/review
Actually the version pushed previously had an older version of the last commit. I'll test one more time and confirm if what we have now pushed to arm_softfp_v2 is OK
Yes, the last version of arm_softfp_v2 is OK according to my quick testing
In /CMakeList.txt:178, we now try to find OBJCOPY with gnueabihf. We need additional condition there for gnueabi as well. Maybe you need additional patch to submit.