Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support asm on armcc5 #2533

Closed
wants to merge 1 commit into from
Closed

support asm on armcc5 #2533

wants to merge 1 commit into from

Conversation

liudongmiao
Copy link

Description

armcc5 use a different asm syntax, it uses c/c++ variable directly.

Status

READY

Requires Backporting

NO

Migrations

NO

Additional comments

I have used this on Brevent Booster (USB Dongle to simulate ADB) since 2018.
However, I don't know whether armcc5 should be supported.

Steps to test or reproduce

This is a rewrite for current gnu version of umlal.
However, some codes are rearranged.

MULADDC_INIT of gnu version

ldr    r0, %3   /* s */
ldr    r1, %4   /* d */
ldr    r2, %5   /* c */
ldr    r3, %6   /* b */

No need for armcc5.

MULADDC_CORE of gnu version

ldr    r4, [r0], #4             /* r0 = s, r4 = *s, then ++s */
mov    r5, #0
ldr    r6, [r1]                 /* r1 = d, r6 = *d */
umlal  r2, r5, r3, r4           /* r2 = c, r3 = b, r4 = *s => umlal c, r5, b, *s */
adds   r7, r6, r2               /* r6 = *d, r2 = c => adds r7, *d, c */
adc    r2, r5, #0               /* r2 = c => adc c, r5, #0 */
str    r7, [r1], #4             /* r1 = d, *d = r7, then ++d */

So, armcc5 is the same with gnu's syntax.
However, we defined a tmp r.

MULADDC_STOP of gnu version

str    r2, %0           /* store r2 (c) to c */
str    r1, %1           /* store r1 (d) to d */
str    r0, %2           /* store r0 (s) to s */

No need for armcc5.

@RonEld
Copy link
Contributor

RonEld commented Mar 31, 2019

Hi @liudongmiao
Thank you for your contribution!
In addition, unfortunately our policy is to not accept contributions, without a Contributor’s Licence Agreement (CLA) signed or authorised by yourself or your employer.

If this is a personal contribution, the easiest way to do this is if you create an mbed account and accept this click through agreement. Alternatively, you can find a slightly different agreement to sign here, which can be signed and returned to us, and is applicable if you don't want to create an mbed account or alternatively if this is a corporate contribution.

Thanks for your understanding and again, thanks for the contribution!

@RonEld RonEld added enhancement CLA requested needs-review Every commit must be reviewed by at least two team members, component-crypto Crypto primitives and low-level interfaces labels Mar 31, 2019
@liudongmiao
Copy link
Author

it seems some checks were not successful. and I cannot visit the details.

@RonEld could you help to check this?
https://jenkins-internal.mbed.com/job/mbedtls-pr-multibranch/job/PR-2533-head/1/display/redirect

If you want to accept this pull request, then I will register for CLA.

@RonEld
Copy link
Contributor

RonEld commented Mar 31, 2019

@liudongmiao The failure is in the following test:

test_asan_remove_peer_certificate: test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE

As mentioned, In order for us to review and accept this PR, we would need to ask you to accept the CLA.

@liudongmiao
Copy link
Author

@RonEld Thanks, just sent scanned cla in pdf via email.

@RonEld
Copy link
Contributor

RonEld commented Apr 1, 2019

@liudongmiao Thank you for submitting the CLA!
As mentioned in Email, it has been sent for processing, and will probably be approved in the near future

@liudongmiao
Copy link
Author

liudongmiao commented Apr 2, 2019

Finally, I move __ARMCC_VERSION to outside of __GNUC__, and merge umaal from #1618.

Currently, the asm for arm in __GNUC__ is three variants:

  • non-thumb2
  • umaal, defined by __ARM_FEATURE_DSP
  • umlal, defined by __thumb2__

I have check the macro, then see the difference.

For armcc6, use command:

armclang --target=arm-arm-none-eabi -mcpu=cortex-m1 -E -dM - </dev/null
# for umlal
armclang --target=arm-arm-none-eabi -mcpu=cortex-m3 -E -dM - </dev/null
# for umaal
armclang --target=arm-arm-none-eabi -mcpu=cortex-m4 -E -dM - </dev/null

For armcc5, use command:

armcc --cpu=Cortex-M1 --list-macros - </dev/null
# for umlal
armcc --cpu=Cortex-M3 --list-macros - </dev/null
# for umaal
armcc --cpu=Cortex-M4 --list-macros - </dev/null

In the output, there is no __thumb2__ nor __ARM_FEATURE_DSP macros, but there are:

  • m3, __TARGET_FEATURE_MULTIPLY(armcc5) vs __thumb2__ (armcc6, gnuc or armclang)
  • m4, __TARGET_FEATURE_DSPMUL(armcc5) vs __ARM_FEATURE_DSP (armcc6, gnuc or armclang)

And the public documents show __TARGET_FEATURE_MULTIPLY is related with umlal (MULAL seems be a typo for UMLAL in reference), __TARGET_FEATURE_DSPMUL is related with DSP-enhanced multiplier.

I have explained the umlal and use in product since 2018.
For umaal, I only checked the asm output with gnuc, don't use in product now.
(umaal was merged in 2018.10, at that time I have finished the product.
And the product is m4 using RSA 2048 encrypt, from #1618, there seems be little enhance 3%.)

armcc5 asm use c variables directly, which is different from gnuc.

For syntax and rules, refer Chapter 7 of ARM Compiler armcc User Guide
[Inline assembler rules for compiler keywords __asm and asm]:

- ARM Compiler armcc User Guide: https://developer.arm.com/docs/dui0472/latest
- keil: http://www.keil.com/support/man/docs/armcc/armcc_chr1359124247402.htm
@daverodgman daverodgman added the historical-reviewing Currently reviewing (for legacy PR/issues) label Mar 4, 2022
@daverodgman
Copy link
Contributor

Closing; armcc 5 is now out of support.

@daverodgman daverodgman closed this Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-crypto Crypto primitives and low-level interfaces enhancement historical-reviewing Currently reviewing (for legacy PR/issues) needs-review Every commit must be reviewed by at least two team members,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants