public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 00/10] consolidate compiler intrinsics
@ 2022-04-12 14:07 Gerd Hoffmann
  2022-04-12 14:07 ` [PATCH v2 01/10] MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg Gerd Hoffmann
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Gerd Hoffmann @ 2022-04-12 14:07 UTC (permalink / raw)
  To: devel
  Cc: Maurice Ma, Andrew Fish, Pawel Polawski, Benjamin You, Yuwei Chen,
	Zhiguang Liu, Rebecca Cran, Xiaoyu Lu, Supreeth Venkatesh,
	Zhichao Gao, Brijesh Singh, Julien Grall, Erdem Aktas,
	Maciej Rabeda, Liming Gao, Michael D Kinney, kilian_kegel,
	Siyuan Fu, Oliver Steffen, Ray Ni, Abner Chang, James Bottomley,
	Sean Brogan, Alexei Fedorov, Tom Lendacky, Guo Dong, Jiewen Yao,
	Sami Mujawar, Sebastien Boeuf, Peter Grehan, Min Xu,
	Anthony Perard, Jordan Justen, Jian J Wang, Gerd Hoffmann,
	Bob Feng, Bret Barkelew, Nickle Wang, Wei6 Xu, Daniel Schaefer,
	Jiaxin Wu, Leif Lindholm, Guomin Jiang, Sami Mujawar,
	Ard Biesheuvel

This is an attept to start cleaning up the messy compiler intrinsics
situation.  Today we don't have a core intrinsics library, resulting
in everybody creating their own.  ArmPkg has one, CryptoPkg has one.
I'm sure there are many more.

This doesn't make sense.  Given we can't avoid compiler intrinsics (as
proven by the existence of those libraries) we should better have them
as core library so we have to maintain a single version only.

Given we already have BaseIoLibIntrinsic in MdePkg we can place the
compiler intrinsics there too.  This little patch series does just that:
It moves over the existing ArmPkg intrinsics, fixes them to build on
non-arm too, and adds additional bits from the CryptoPkg intrinsics.

v2 changes:
 - rebase to latest master.
 - add review tags
 - add patch moving size_t to header file (patch #3).
 - add patches copying over more intrinsics from
   edk2-libc repo (patches #5 -> #10).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3649

take care,
  Gerd

Gerd Hoffmann (10):
  MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg
  MdePkg/CompilerIntrinsicsLib: fix msft sources for x64
  MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file
  MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp
  MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo
  MdePkg/CompilerIntrinsicsLib: add SPDX License tags
  MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c
  MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c
  MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c
  MdePkg/CompilerIntrinsicsLib: add new sources to
    CompilerIntrinsicsLib.inf

 ArmVirtPkg/ArmVirt.dsc.inc                    |   4 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   2 +-
 ArmPkg/ArmPkg.dsc                             |   3 +-
 .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc       |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc             |   2 +-
 CryptoPkg/CryptoPkg.dsc                       |   5 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc         |   2 +-
 EmbeddedPkg/EmbeddedPkg.dsc                   |   2 +-
 EmulatorPkg/EmulatorPkg.dsc                   |   2 +-
 FatPkg/FatPkg.dsc                             |   2 +-
 FmpDevicePkg/FmpDevicePkg.dsc                 |   4 +-
 MdeModulePkg/MdeModulePkg.dsc                 |   2 +-
 MdePkg/MdePkg.dsc                             |   1 +
 NetworkPkg/NetworkPkg.dsc                     |   4 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc                  |   2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc                    |   2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc                |   2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc              |   2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc                |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc                       |   2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   2 +-
 OvmfPkg/OvmfPkgX64.dsc                        |   2 +-
 OvmfPkg/OvmfXen.dsc                           |   2 +-
 RedfishPkg/RedfishPkg.dsc                     |   2 +-
 SecurityPkg/SecurityPkg.dsc                   |  12 +-
 ShellPkg/ShellPkg.dsc                         |   2 +-
 SignedCapsulePkg/SignedCapsulePkg.dsc         |  14 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc           |   2 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc             |   2 +-
 .../Library/IntrinsicLib/IntrinsicLib.inf     |  67 ------
 .../CompilerIntrinsicsLib.inf                 |  35 ++-
 {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h    |   0
 .../Library/CompilerIntrinsicsLib/types_ms.h  |  14 ++
 CryptoPkg/Library/IntrinsicLib/CopyMem.c      |  47 ----
 .../Library/IntrinsicLib/MemoryIntrinsics.c   |  74 ------
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 215 ++++++++++++++++++
 .../CompilerIntrinsicsLib}/Ia32/MathFtol.c    |   0
 .../Ia32/MathLShiftS64.c                      |   0
 .../Ia32/MathRShiftU64.c                      |   0
 .../CompilerIntrinsicsLib/Ia32/lldiv.c        | 100 ++++++++
 .../CompilerIntrinsicsLib/Ia32/lldvrm.c       | 104 +++++++++
 .../CompilerIntrinsicsLib/Ia32/llmul.c        |  84 +++++++
 .../CompilerIntrinsicsLib/Ia32/llrem.c        |  97 ++++++++
 .../CompilerIntrinsicsLib/Ia32/llshl.c        |  10 +-
 .../CompilerIntrinsicsLib/Ia32/llshr.c        |  63 +++++
 .../CompilerIntrinsicsLib/Ia32/ulldiv.c       |  91 ++++++++
 .../CompilerIntrinsicsLib/Ia32/ulldvrm.c      | 104 +++++++++
 .../CompilerIntrinsicsLib/Ia32/ullrem.c       |  97 ++++++++
 .../CompilerIntrinsicsLib/Ia32/ullshr.c       |  10 +-
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c |   2 +-
 .../Library/CompilerIntrinsicsLib/memcpy.c    |   0
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |   6 +-
 .../CompilerIntrinsicsLib/memmove_ms.c        |   6 +-
 .../Library/CompilerIntrinsicsLib/memset.c    |   0
 .../Library/CompilerIntrinsicsLib/memset_ms.c |   6 +-
 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c |  33 +++
 ArmPkg/ArmPkg.ci.yaml                         |   1 -
 .../DEBUG_XCODE31/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../DEBUG_XCODE32/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../Library/IntrinsicLib/BaseIntrinsicLib.uni |  16 --
 .../CompilerIntrinsicsLib/AArch64/Atomics.S   |   0
 .../CompilerIntrinsicsLib/Arm/ashldi3.S       |   0
 .../CompilerIntrinsicsLib/Arm/ashrdi3.S       |   0
 .../CompilerIntrinsicsLib/Arm/clzsi2.S        |   0
 .../CompilerIntrinsicsLib/Arm/ctzsi2.S        |   0
 .../Library/CompilerIntrinsicsLib/Arm/div.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/div.asm |   0
 .../CompilerIntrinsicsLib/Arm/divdi3.S        |   0
 .../CompilerIntrinsicsLib/Arm/divsi3.S        |   0
 .../Library/CompilerIntrinsicsLib/Arm/lasr.S  |   0
 .../CompilerIntrinsicsLib/Arm/lasr.asm        |   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.S       |   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.asm     |   0
 .../Library/CompilerIntrinsicsLib/Arm/llsl.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsl.asm        |   0
 .../Library/CompilerIntrinsicsLib/Arm/llsr.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsr.asm        |   0
 .../CompilerIntrinsicsLib/Arm/lshrdi3.S       |   0
 .../CompilerIntrinsicsLib/Arm/memmove.S       |   0
 .../CompilerIntrinsicsLib/Arm/memmove.asm     |   0
 .../CompilerIntrinsicsLib/Arm/moddi3.S        |   0
 .../CompilerIntrinsicsLib/Arm/modsi3.S        |   0
 .../CompilerIntrinsicsLib/Arm/muldi3.S        |   0
 .../Library/CompilerIntrinsicsLib/Arm/mullu.S |   0
 .../CompilerIntrinsicsLib/Arm/mullu.asm       |   0
 .../CompilerIntrinsicsLib/Arm/sourcery.S      |   0
 .../CompilerIntrinsicsLib/Arm/switch.asm      |   0
 .../CompilerIntrinsicsLib/Arm/switch16.S      |   0
 .../CompilerIntrinsicsLib/Arm/switch32.S      |   0
 .../CompilerIntrinsicsLib/Arm/switch8.S       |   0
 .../CompilerIntrinsicsLib/Arm/switchu8.S      |   0
 .../CompilerIntrinsicsLib/Arm/ucmpdi2.S       |   0
 .../CompilerIntrinsicsLib/Arm/udivdi3.S       |   0
 .../CompilerIntrinsicsLib/Arm/udivmoddi4.S    |   0
 .../CompilerIntrinsicsLib/Arm/udivsi3.S       |   0
 .../Library/CompilerIntrinsicsLib/Arm/uldiv.S |   0
 .../CompilerIntrinsicsLib/Arm/uldiv.asm       |   0
 .../CompilerIntrinsicsLib/Arm/umoddi3.S       |   0
 .../CompilerIntrinsicsLib/Arm/umodsi3.S       |   0
 .../Library/CompilerIntrinsicsLib/Arm/uread.S |   0
 .../CompilerIntrinsicsLib/Arm/uread.asm       |   0
 .../CompilerIntrinsicsLib/Arm/uwrite.S        |   0
 .../CompilerIntrinsicsLib/Arm/uwrite.asm      |   0
 .../Ia32/MathLShiftS64.nasm                   |   0
 .../Ia32/MathRShiftU64.nasm                   |   0
 .../CompilerIntrinsicsLib/Ia32/ashrdi3.S      |  68 ++++++
 .../CompilerIntrinsicsLib/Ia32/mulll.S        |  79 +++++++
 .../CompilerIntrinsicsLib/Ia32/shldi3.S       |  64 ++++++
 .../CompilerIntrinsicsLib/Ia32/udivdi3.S      |  85 +++++++
 .../CompilerIntrinsicsLib/Ia32/umoddi3.S      |  91 ++++++++
 MdePkg/MdePkg.ci.yaml                         |   1 +
 111 files changed, 1490 insertions(+), 269 deletions(-)
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf (66%)
 rename {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h (100%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/CopyMem.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
 rename {CryptoPkg/Library/IntrinsicLib => MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathFtol.c (100%)
 copy {CryptoPkg/Library/IntrinsicLib => MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.c (100%)
 copy {CryptoPkg/Library/IntrinsicLib => MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.c (100%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
 rename CryptoPkg/Library/IntrinsicLib/Ia32/MathLShiftS64.c => MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c (61%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c
 rename CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.c => MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c (62%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c (89%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c (82%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c (83%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c (80%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/BaseIntrinsicLib.uni
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.nasm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.nasm (100%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S

-- 
2.35.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-04-29  8:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-12 14:07 [PATCH v2 00/10] consolidate compiler intrinsics Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 01/10] MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 02/10] MdePkg/CompilerIntrinsicsLib: fix msft sources for x64 Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 03/10] MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 04/10] MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 05/10] MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 06/10] MdePkg/CompilerIntrinsicsLib: add SPDX License tags Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 07/10] MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 08/10] MdePkg/CompilerIntrinsicsLib: drop debug logging " Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 09/10] MdePkg/CompilerIntrinsicsLib: remove duplicate functions " Gerd Hoffmann
2022-04-12 14:07 ` [PATCH v2 10/10] MdePkg/CompilerIntrinsicsLib: add new sources to CompilerIntrinsicsLib.inf Gerd Hoffmann
2022-04-29  6:41 ` 回复: [PATCH v2 00/10] consolidate compiler intrinsics gaoliming
2022-04-29  8:50   ` [edk2-devel] " Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox