public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, eugene@hp.com
Cc: lersek@redhat.com, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 00/26] ARM assembler cleanup series
Date: Wed, 10 Aug 2016 17:17:36 +0200	[thread overview]
Message-ID: <1470842282-8415-1-git-send-email-ard.biesheuvel@linaro.org> (raw)

As requested by Eugene, this series introduces a new ASM_FUNC preprocessor
macro that emits functions into separate sections, allowing the linker to
get rid of the code that ends up unused in the module.

Note that using a native GNU as macro turned out to be problematic, due
to our use of Trim, and the fact that not all versions of GNU as honour
the -I option, making both #include (preprocessor) and .include (GNU as)
unusable to include files with shared macro definitions.

Since we're making a clean spot, let's introduce some other utility macros
as well, and clean up the various assembler files to use it. In particular,
clean up various patterns involving LoadConstantToReg(), including the gem

  LoadConstantToReg (_gPcd_FixedAtBuild_xxxx, rN)
  ldr  rN, [rN]

which performs two memory reads, including one that is subject to runtime
relocation, to load a compile time constant into a register. Note that this
is the definition of LoadConstantReg() we use for Clang, even on AARCH64:

  // load _Reg with _Data
  #define LoadConstantToReg(_Data, _Reg)    \
    ldr  _Reg, 1f                         ; \
    b    2f                               ; \
  .align(8)                               ; \
  1:                                        \
    .8byte (_Data)                        ; \
  2:

Other changes involve constant folding, i.e.,

     // Stack for the secondary core = Number of Cores - 1
  -  LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0)
  -  sub   x0, x0, #1
  -  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1)
  -  mul   x1, x1, x0
  +  MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))

and

  -  LoadConstantToReg (FixedPcdGet64(PcdCPUCoresStackBase), r1)
  -  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
  -  add   r1, r1, r2
  +  MOV32 (r1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))

(where r2 is dead after the add)

Code can be found here
https://git.linaro.org/people/ard.biesheuvel/uefi-next.git/shortlog/refs/heads/arm-asm-cleanup2

Ard Biesheuvel (26):
  ArmLib: remove ArmReplaceLiveTranslationEntry() implementation
  ArmPkg: add missing ArmMmuLib resolution to ArmPkg.dsc
  ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros
  ArmPlatformPkg RVCT: drop dependency on GCC macro library
  ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros
  ArmVirt/PrePi: make jump to CEntryPoint relative
  ArmVirtPkg: clean up assembly source files
  ArmPkg/ArmSmcLibNull: move to generic C implementation
  ArmPkg/ArmCpuLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmGicV3: switch to ASM_FUNC() asm macro
  ArmPkg/ArmHvcLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmMmuLib: switch to ASM_FUNC() asm macro
  ArmPkg/ArmSmcLib: switch to ASM_FUNC() asm macro
  ArmPkg/BaseMemoryLibSm: switch to ASM_FUNC() asm macro
  ArmPkg/BaseMemoryLibVstm: switch to ASM_FUNC() asm macro
  ArmPkg/CompilerIntrinsicsLib: switch to ASM_FUNC() asm macro
  ArmPkg/SemihostLib: switch to ASM_FUNC() asm macro
  BeagleBoardPkg: remove unused Sec.inf module
  BeagleBoardPkg: add missing ArmMmuLib resolution
  ArmPlatformPkg/ArmJunoLib: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/PrePi: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/PrePeiCore: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmVExpressPkg: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmPlatformLibNull: switch to ASM_FUNC() asm macro
  ArmPlatformPkg/ArmPlatformStackLib: switch to ASM_FUNC() asm macro

 ArmPkg/ArmPkg.dsc                                                                |   4 +
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA5xLib/AArch64/ArmCortexA5xHelper.S            |   9 +-
 ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Helper.S                      |   9 +-
 ArmPkg/Drivers/ArmGic/GicV3/AArch64/ArmGicV3.S                                   |  28 +-
 ArmPkg/Drivers/ArmGic/GicV3/Arm/ArmGicV3.S                                       |  28 +-
 ArmPkg/Include/AsmMacroIoLib.h                                                   | 232 ++--------------
 ArmPkg/Include/AsmMacroIoLib.inc                                                 |  54 ----
 ArmPkg/Include/AsmMacroIoLibV8.h                                                 |  20 +-
 ArmPkg/Library/ArmHvcLib/AArch64/ArmHvc.S                                        |   9 +-
 ArmPkg/Library/ArmHvcLib/Arm/ArmHvc.S                                            |  10 +-
 ArmPkg/Library/ArmLib/AArch64/AArch64ArchTimerSupport.S                          |  67 ++---
 ArmPkg/Library/ArmLib/AArch64/AArch64Support.S                                   | 181 +++----------
 ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S                                  |  43 +--
 ArmPkg/Library/ArmLib/ArmV7/ArmLibSupportV7.S                                    |  47 +---
 ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimerSupport.S                              |  67 ++---
 ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.S                                       | 113 +++-----
 ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S                             |  78 ++----
 ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.S                                 |  89 ++----
 ArmPkg/Library/ArmLib/Common/Arm/ArmLibSupport.asm                               |   4 +-
 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S                         |   4 +-
 ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S                                        |   7 +-
 ArmPkg/Library/ArmSmcLib/Arm/ArmSmc.S                                            |   8 +-
 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S                                    |  20 --
 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm                                  |  20 --
 ArmPkg/Library/ArmSmcLibNull/{AArch64/ArmSmcNull.S => ArmSmcLibNull.c}           |  42 +--
 ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf                                   |   8 +-
 ArmPkg/Library/BaseMemoryLibStm/Arm/CopyMem.S                                    |   8 +-
 ArmPkg/Library/BaseMemoryLibStm/Arm/SetMem.S                                     |   7 +-
 ArmPkg/Library/BaseMemoryLibVstm/Arm/CopyMem.S                                   |   8 +-
 ArmPkg/Library/BaseMemoryLibVstm/Arm/SetMem.S                                    |   9 +-
 ArmPkg/Library/CompilerIntrinsicsLib/AArch64/memcpy.S                            |  10 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S                                   |  13 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S                               |   7 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S                                  |   7 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S                                  |   8 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S                                |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S                              |   8 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S                              |   8 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S                               |   8 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S                              |   9 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S                            |   7 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S                               |   7 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S                               |   6 +-
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S                               |   6 +-
 ArmPkg/Library/SemihostLib/AArch64/GccSemihost.S                                 |   7 +-
 ArmPkg/Library/SemihostLib/Arm/GccSemihost.S                                     |   8 +-
 ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/AArch64/ArmJunoHelper.S             |  37 +--
 ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/Arm/ArmJunoHelper.S                 |  36 +--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S    |  22 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm  |   7 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S        |  28 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm      |   8 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/AArch64/RTSMHelper.S    |  38 +--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S        |  41 +--
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm      |  12 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Boot.S       |  23 +-
 ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Boot.asm     |   5 +-
 ArmPlatformPkg/Library/ArmPlatformLibNull/AArch64/ArmPlatformHelper.S            |  28 +-
 ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S                |  28 +-
 ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm              |  10 +-
 ArmPlatformPkg/Library/ArmPlatformStackLib/AArch64/ArmPlatformStackLib.S         |  35 +--
 ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.S             |  25 +-
 ArmPlatformPkg/Library/ArmPlatformStackLib/Arm/ArmPlatformStackLib.asm           |   4 +-
 ArmPlatformPkg/PrePeiCore/AArch64/Helper.S                                       |  11 +-
 ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S                         |  30 +--
 ArmPlatformPkg/PrePeiCore/AArch64/SwitchStack.S                                  |   9 +-
 ArmPlatformPkg/PrePeiCore/Arm/Exception.asm                                      |   2 -
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S                             |  30 +--
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm                           |  14 +-
 ArmPlatformPkg/PrePeiCore/Arm/SwitchStack.S                                      |   9 +-
 ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S                                  |  49 ++--
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S                                      |  50 +---
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm                                    |  27 +-
 ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S |  36 +--
 ArmVirtPkg/Library/ArmQemuRelocatablePlatformLib/ARM/RelocatableVirtHelper.S     |  50 ++--
 ArmVirtPkg/Library/ArmVirtPlatformLib/AARCH64/VirtHelper.S                       |  30 +--
 ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.S                           |  31 +--
 ArmVirtPkg/Library/ArmVirtPlatformLib/ARM/VirtHelper.asm                         |  10 +-
 ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S  |  36 +--
 ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S      |  47 ++--
 ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S                                      |  48 +---
 ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S                                          |  73 ++---
 BeagleBoardPkg/BeagleBoardPkg.dsc                                                |   1 +
 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S                                        |  85 ------
 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm                                      |  89 ------
 BeagleBoardPkg/Sec/Cache.c                                                       |  79 ------
 BeagleBoardPkg/Sec/Clock.c                                                       |  70 -----
 BeagleBoardPkg/Sec/LzmaDecompress.h                                              | 103 -------
 BeagleBoardPkg/Sec/PadConfiguration.c                                            | 282 --------------------
 BeagleBoardPkg/Sec/Sec.c                                                         | 186 -------------
 BeagleBoardPkg/Sec/Sec.inf                                                       |  73 -----
 103 files changed, 647 insertions(+), 2730 deletions(-)
 delete mode 100644 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.S
 delete mode 100644 ArmPkg/Library/ArmSmcLibNull/Arm/ArmSmcNull.asm
 rename ArmPkg/Library/ArmSmcLibNull/{AArch64/ArmSmcNull.S => ArmSmcLibNull.c} (73%)
 delete mode 100644 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S
 delete mode 100644 BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.asm
 delete mode 100644 BeagleBoardPkg/Sec/Cache.c
 delete mode 100644 BeagleBoardPkg/Sec/Clock.c
 delete mode 100644 BeagleBoardPkg/Sec/LzmaDecompress.h
 delete mode 100644 BeagleBoardPkg/Sec/PadConfiguration.c
 delete mode 100644 BeagleBoardPkg/Sec/Sec.c
 delete mode 100644 BeagleBoardPkg/Sec/Sec.inf

-- 
2.7.4



             reply	other threads:[~2016-08-10 15:18 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 15:17 Ard Biesheuvel [this message]
2016-08-10 15:17 ` [PATCH 01/26] ArmLib: remove ArmReplaceLiveTranslationEntry() implementation Ard Biesheuvel
2016-08-10 16:56   ` Leif Lindholm
2016-08-10 17:31     ` Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 02/26] ArmPkg: add missing ArmMmuLib resolution to ArmPkg.dsc Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 03/26] ArmPkg/AsmMacroIoLib: remove unused obsolete MMIO and other asm macros Ard Biesheuvel
2016-08-10 17:04   ` Leif Lindholm
2016-08-10 17:26     ` Ard Biesheuvel
2016-08-11  8:23       ` Leif Lindholm
2016-08-10 15:17 ` [PATCH 04/26] ArmPlatformPkg RVCT: drop dependency on GCC macro library Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 05/26] ArmPkg: introduce ASM_FUNC, MOV32/MOV64 and ADRL/LDRL macros Ard Biesheuvel
2016-08-10 18:26   ` Cohen, Eugene
2016-08-10 18:29     ` Ard Biesheuvel
2016-08-10 18:48       ` Cohen, Eugene
2016-08-10 15:17 ` [PATCH 06/26] ArmVirt/PrePi: make jump to CEntryPoint relative Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 07/26] ArmVirtPkg: clean up assembly source files Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 08/26] ArmPkg/ArmSmcLibNull: move to generic C implementation Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 09/26] ArmPkg/ArmCpuLib: switch to ASM_FUNC() asm macro Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 10/26] ArmPkg/ArmGicV3: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 11/26] ArmPkg/ArmHvcLib: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 12/26] ArmPkg/ArmLib: " Ard Biesheuvel
2016-08-10 19:00   ` Leif Lindholm
2016-08-10 15:17 ` [PATCH 13/26] ArmPkg/ArmMmuLib: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 14/26] ArmPkg/ArmSmcLib: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 15/26] ArmPkg/BaseMemoryLibSm: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 16/26] ArmPkg/BaseMemoryLibVstm: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 17/26] ArmPkg/CompilerIntrinsicsLib: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 18/26] ArmPkg/SemihostLib: " Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 19/26] BeagleBoardPkg: remove unused Sec.inf module Ard Biesheuvel
2016-08-11  8:34   ` Leif Lindholm
2016-08-10 15:17 ` [PATCH 20/26] BeagleBoardPkg: add missing ArmMmuLib resolution Ard Biesheuvel
2016-08-10 15:17 ` [PATCH 21/26] ArmPlatformPkg/ArmJunoLib: switch to ASM_FUNC() asm macro Ard Biesheuvel
2016-08-11  8:37   ` Leif Lindholm
2016-08-10 15:17 ` [PATCH 22/26] ArmPlatformPkg/PrePi: " Ard Biesheuvel
2016-08-11  8:38   ` Leif Lindholm
2016-08-31  4:33     ` Michael Zimmermann
2016-08-31  9:14       ` Ard Biesheuvel
2016-08-31  9:43         ` Michael Zimmermann
2016-08-31  9:45           ` Ard Biesheuvel
2016-08-31  9:47       ` Evan Lloyd
2016-08-31  9:52         ` Michael Zimmermann
2016-08-31  9:53           ` Ard Biesheuvel
2016-09-07 11:10       ` Ryan Harkin
2016-09-07 11:59         ` Ard Biesheuvel
2016-09-07 12:18           ` Ryan Harkin
2016-08-10 15:17 ` [PATCH 23/26] ArmPlatformPkg/PrePeiCore: " Ard Biesheuvel
2016-08-11  8:38   ` Leif Lindholm
2016-08-10 15:18 ` [PATCH 24/26] ArmPlatformPkg/ArmVExpressPkg: " Ard Biesheuvel
2016-08-11  8:39   ` Leif Lindholm
2016-08-10 15:18 ` [PATCH 25/26] ArmPlatformPkg/ArmPlatformLibNull: " Ard Biesheuvel
2016-08-11  8:39   ` Leif Lindholm
2016-08-10 15:18 ` [PATCH 26/26] ArmPlatformPkg/ArmPlatformStackLib: " Ard Biesheuvel
2016-08-11  8:42   ` Leif Lindholm
2016-08-11 10:18 ` [PATCH 00/26] ARM assembler cleanup series Leif Lindholm
2016-08-11 11:27   ` Ard Biesheuvel
2016-08-11 11:31     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470842282-8415-1-git-send-email-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox