From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CFBF61A1DF8 for ; Wed, 10 Aug 2016 08:18:11 -0700 (PDT) Received: by mail-wm0-x230.google.com with SMTP id o80so110978470wme.1 for ; Wed, 10 Aug 2016 08:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=OsxS6b2apL58apJbW321Pucmqlxzsxj6WpXIdsDINFI=; b=Gwcu4vhOpjZhSD9JgwAgutNUhX28QmiiSJ9GdLdDRj3X0yWRi1Sk7jLkM7sIJEeZS0 nRY+a4Vh58+1w1/2GsNRA8UhNFlLzqD/q1PeAwIjiENmvX3J5D69wQUC6lIZ8E8Fui6q Bjest24ixyZoq/RUkic7zVjHzQ7rdlb3xhp2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OsxS6b2apL58apJbW321Pucmqlxzsxj6WpXIdsDINFI=; b=kMEk6w4ryXOEpjlEeiZwzjUPOJpCalBeZDt6kfs512o9JlzeelBlvlvulfyC60hPH/ 73QL+jVyCt3gC/Kh1nfs4S0ZQ+X0kuQh3ZbM63Cm/tGdK8S2UY3FUkHwNCBzJbS8wVUP tobfUrOrrgQEwdn+2GSlKPJJ1oslNbjcvMi33upXOubZWBQyuWFFSDhNcQjGrywOtRf1 qSlcvdF4/XSnsMGKnyNPFCbqZlm651vwaUCWJVy5Zv8Qm6kfHtxc/sqsFerD5UJPvMm/ J8Tz+itl4FfgZXrG519DSER1Nt084yng5oFXPh8fTUyTqIpKdpPlr/hN5hyOulC7F8IB gxPg== X-Gm-Message-State: AEkoous2iAzAlc1Xhweaab6mFyuMyaqmMCcUB/4iucbsr5xJcLp2vwmqyXOwZw89kSKzK4Hw X-Received: by 10.28.104.137 with SMTP id d131mr3955491wmc.7.1470842290004; Wed, 10 Aug 2016 08:18:10 -0700 (PDT) Received: from localhost.localdomain (46.red-81-37-107.dynamicip.rima-tde.net. [81.37.107.46]) by smtp.gmail.com with ESMTPSA id c16sm8908374wme.4.2016.08.10.08.18.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 08:18:09 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, eugene@hp.com Cc: lersek@redhat.com, Ard Biesheuvel Date: Wed, 10 Aug 2016 17:17:36 +0200 Message-Id: <1470842282-8415-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 00/26] ARM assembler cleanup series X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2016 15:18:12 -0000 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