Nice bit of cleanup, thanks! For the ones I haven't commented on already: Reviewed-by: Leif Lindholm <leif.lindh...@linaro.org>
(And for the BeagleBoardPkg as well, unless Andrew objects.) On Wed, Aug 10, 2016 at 05:17:36PM +0200, Ard Biesheuvel wrote: > 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 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel