ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds

Introduce CRT assembly replacements for __rt_sdiv, __rt_udiv,
__rt_udiv64, __rt_sdiv64, __rt_srsh (by reusing the RVCT code)
as well as memcpy and memset.
For MSFT compatibility, some of the code needs to be explicitly
forced to ARM, and the /oldit assembly flag needs to be added.
Also, while RVCT_ASM_EXPORT macro invocations have been removed,
the replacement code is designed to be as close as possible to
the one that would have been generated if using the macros.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
Pete Batard
2018-01-12 21:33:29 +08:00
committed by Liming Gao
parent 30939ff2bc
commit e58427e396
7 changed files with 185 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
// Copyright (c) 2018, Pete Batard. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -17,18 +18,19 @@
EXPORT __aeabi_uidivmod
EXPORT __aeabi_idiv
EXPORT __aeabi_idivmod
EXPORT __rt_udiv
EXPORT __rt_sdiv
AREA Math, CODE, READONLY
;
;UINT32
;EFIAPI
;__aeabi_uidivmode (
; IN UINT32 Dividen
;__aeabi_uidivmod (
; IN UINT32 Dividend
; IN UINT32 Divisor
; );
;
__aeabi_uidiv
__aeabi_uidivmod
RSBS r12, r1, r0, LSR #4
@@ -39,11 +41,41 @@ __aeabi_uidivmod
MOV r3, #0
B __arm_div_large
;
;UINT64
;EFIAPI
;__rt_udiv (
; IN UINT32 Divisor,
; IN UINT32 Dividend
; );
;
__rt_udiv
; Swap R0 and R1
MOV r12, r0
MOV r0, r1
MOV r1, r12
B __aeabi_uidivmod
;
;UINT64
;EFIAPI
;__rt_sdiv (
; IN INT32 Divisor,
; IN INT32 Dividend
; );
;
__rt_sdiv
; Swap R0 and R1
MOV r12, r0
MOV r0, r1
MOV r1, r12
B __aeabi_idivmod
;
;INT32
;EFIAPI
;__aeabi_idivmode (
; IN INT32 Dividen
;__aeabi_idivmod (
; IN INT32 Dividend
; IN INT32 Divisor
; );
;
@@ -152,4 +184,3 @@ __aeabi_idiv0
BX r14
END