RFR: aarch32: softfp patch for template interpreter

yangyongyong yangyongyong at huawei.com
Thu Oct 27 12:27:59 UTC 2016


Hi, all,

The patch showed at http://cr.openjdk.java.net/~fyang/161024-softfp.hg.diff is a new patch of [1] for ARM pure-softfp platform. Thanks to Ed, Chi Vo, and Andrey, I make a few fixups for the old one [2].

ARM pure-softfp platform means on this platform arguments are passed via general registers and floating point operations are simulated via library calls (which is usually implemented by integer operation sequences like add/sub/mul/and/or/not etc). Details on how we code this patch is as below:


1.    ARM hardfp/softfp platforms:
There are 2 factors in consideration of hardfp and softfp on ARM platforms:
(1) calling convention, which is about how arguments are passed, i.e. via floating-pointer registers(i.e. hardfp calling convention) or general registers (softfp calling convention).
(2) how floating point operations are performed:
floating point operations can be performed via simulation (softfp) or native hardfp instructions.


2.    How does compiler handle these variants?
According to [4], gcc uses -mfloat-abi=name to distinguish all 3 variants: hard, softfp, and soft, and buitin macros __ARM_PCS, __ARM_PCS_VFP, __SOFTFP__ are defined to distinguish all these 3 configurations:


(1) -mfloat-abi=hard means hardfp calling conventions is chosen and hardfp instructions are generated for floating-point operations. If gcc defaults to this configuration or runs with “-mfloat-abi=hard”, the macro __ARM_PCS_VFP is defined when checking builtin defined macros with “echo | gcc -E -dM -”.


(2) -mfloat-abi=soft means softfp calling conventions is chosen , and floating-point operations are performed by library calls. If gcc defaults to this configuration or runs with “-mfloat-abi=soft”, both macros __ARM_PCS and __SOFTFP__ are defined when checking builtin defined macros with “echo | gcc -E -dM -”.


(3) -mfloat-abi=softfp means softfp calling conventions is chosen , but hardfp instructions are generated for floating-point operations. If gcc defaults to this configuration or runs with “-mfloat-abi=softfp”, the macro __ARM_PCS is defined when checking builtin defined macros with “echo | gcc -E -dM -”, however __SOFTFP__ is not defined for this configuration.


3.    How do we isolate softfp code from hardfp code?
We defined two pairs of macros HARD_FLOAT_CC/SOFT_FLOAT_CC and HARD_FLOAT/ SOFT_FLOAT for convenience as well as in consideration of code base. HARD_FLOAT_CC/SOFT_FLOAT_CC is for the calling convention part as the suffix “_CC” says, which is short for Calling Convention. HARD_FLOAT/ SOFT_FLOAT indicates whether or not native hardfp instructions are generated for floating point operations. These macros are defined in file globalDefinitions_aarch32.hpp.


4.    Usage
Please configure using “--with-jvm-variants=core --with-jvm-interpreter=template” for openjdk build after you patch the code, other configuration options might be the same.


5.    Limitation
Right now, the patch implement only configuration (2), so gcc should run with -mfloat-abi=soft if it does not default to this configuration. C1 port for configuration (2) is on the way, but we do not have any specific plan for configuration (3). Since we already have hardfp and soft implementation, things get easier for this configuration. Good news is that configuration (3) is already included in [4].

Best wishes!

[1] http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-October/000546.html

[2] http://cr.openjdk.java.net/~enevill/softfp/161014-softfp.hg.diff
[3] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
[4] http://mail.openjdk.java.net/pipermail/aarch32-port-dev/2016-October/000565.html


More information about the aarch32-port-dev mailing list