Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arm-software/embedded/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ set(LLVM_TARGETS_TO_BUILD AArch64;ARM CACHE STRING "")
set(LLVM_DEFAULT_TARGET_TRIPLE aarch64-linux-gnu CACHE STRING "")
set(LLVM_APPEND_VC_REV OFF CACHE BOOL "")
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
set(LLVM_ENABLE_ZSTD OFF CACHE BOOL "")
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")

# Default to a release build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main():
help="optional arguments for the image",
)
args = parser.parse_args()
return run_fvp(
ret_code = run_fvp(
args.fvp_install_dir,
args.fvp_config_dir,
args.fvp_model,
Expand Down
104 changes: 92 additions & 12 deletions arm-software/embedded/arm-runtimes/test-support/run_fvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,51 @@

# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>

import re
import subprocess
import sys
from os import environ
from os import path
from dataclasses import dataclass
from platform import uname
import shlex


@dataclass
class FVP:
model_exe: str
tarmac_plugin: str
crypto_plugin: str
cmdline_param: str


# The location of files within the FVP install directory can differ
# between the packages for different platforms.
uname_machine = uname().machine.lower()
if uname_machine == "x86_64":
platform_dir = "Linux64_GCC-9.3"
elif uname_machine == "aarch64":
platform_dir = "Linux64_armv8l_GCC-9.3"
else:
raise Exception(f"{uname_machine} is not a recognised uname machine")

MODELS = {
"corstone-310": FVP(
"Corstone-310/models/Linux64_GCC-9.3/FVP_Corstone_SSE-310",
"Corstone-310/plugins/Linux64_GCC-9.3/TarmacTrace.so",
"FastModelsPortfolio_11.27/plugins/Linux64_GCC-9.3/Crypto.so",
f"Corstone-310/models/{platform_dir}/FVP_Corstone_SSE-310",
f"Corstone-310/plugins/{platform_dir}/TarmacTrace.so",
f"FastModelsPortfolio_11.27/plugins/{platform_dir}/Crypto.so",
"cpu0.semihosting-cmd_line",
),
"aem-a": FVP(
"Base_RevC_AEMvA_pkg/models/Linux64_GCC-9.3/FVP_Base_RevC-2xAEMvA",
"Base_RevC_AEMvA_pkg/plugins/Linux64_GCC-9.3/TarmacTrace.so",
"FastModelsPortfolio_11.27/plugins/Linux64_GCC-9.3/Crypto.so",
f"Base_RevC_AEMvA_pkg/models/{platform_dir}/FVP_Base_RevC-2xAEMvA",
f"Base_RevC_AEMvA_pkg/plugins/{platform_dir}/TarmacTrace.so",
f"FastModelsPortfolio_11.27/plugins/{platform_dir}/Crypto.so",
"cluster0.cpu0.semihosting-cmd_line",
),
"aem-r": FVP(
"AEMv8R_base_pkg/models/Linux64_GCC-9.3/FVP_BaseR_AEMv8R",
"AEMv8R_base_pkg/plugins/Linux64_GCC-9.3/TarmacTrace.so",
"FastModelsPortfolio_11.27/plugins/Linux64_GCC-9.3/Crypto.so",
f"AEMv8R_base_pkg/models/{platform_dir}/FVP_BaseR_AEMv8R",
f"AEMv8R_base_pkg/plugins/{platform_dir}/TarmacTrace.so",
f"FastModelsPortfolio_11.27/plugins/{platform_dir}/Crypto.so",
"cluster0.cpu0.semihosting-cmd_line",
),
}
Expand All @@ -54,11 +69,41 @@ def run_fvp(
raise Exception(f"{fvp_model} is not a recognised model name")
model = MODELS[fvp_model]

env = environ.copy()
if fvp_model == "corstone-310":
# Corstone-310 v11.27 requires PYTHONHOME to be set to the version of
# python included in the install, and fmtplib and python/lib to be found
# in LD_LIBRARY_PATH. If the installed version include these, then add
# them to the environment.
fmtplib_dir = path.join(fvp_install_dir, "Corstone-310", "fmtplib")
python_dir = path.join(fvp_install_dir, "Corstone-310", "python")
ld_library_paths = []
if path.exists(fmtplib_dir):
ld_library_paths.append(fmtplib_dir)
if path.exists(python_dir):
ld_library_paths.append(path.join(python_dir, "lib"))
env["PYTHONHOME"] = python_dir
if len(ld_library_paths) > 0:
if "LD_LIBRARY_PATH" in env:
ld_library_paths.append(env["LD_LIBRARY_PATH"])
env["LD_LIBRARY_PATH"] = ":".join(ld_library_paths)

command = [path.join(fvp_install_dir, model.model_exe)]
command.extend(["--quiet"])
for config in fvp_configs:
command.extend(["--config-file", path.join(fvp_config_dir, config + ".cfg")])
command.extend(["--application", image])

if fvp_model == "corstone-310":
command.extend(["--application", f"cpu0={image}"])
elif fvp_model == "aem-a" or fvp_model == "aem-r":
# In case we ever need to run multiprocessor images, the instance name below
# can be renamed to "cluster0.cpu*" (wildcard).
command.extend(["--application", f"cluster0.cpu0={image}"])
else:
raise RuntimeError(
f"FVP model {fvp_model} not covered in --application definition"
)

command.extend(["--parameter", f"{model.cmdline_param}={shlex.join(arguments)}"])
command.extend(["--plugin", path.join(fvp_install_dir, model.crypto_plugin)])
if tarmac_file is not None:
Expand Down Expand Up @@ -91,7 +136,42 @@ def run_fvp(
timeout=timeout,
cwd=working_directory,
check=False,
env=env,
)
sys.stdout.buffer.write(result.stdout)
return result.returncode

# Corstone-310 prints out boilerplate text on stdout alongside the actual
# output of the image. Some tests, for instance in libcxx, check the
# contents of stdout, and may treat the unexpected text as a condition for
# failure. To work around this, we cut out the model's boilerplate output.
if fvp_model == "corstone-310":
decoded_stdout = result.stdout.decode()
boilerplate_pattern = r"""
Ethos-U rev [0-9a-z]+ --- \w{3} {1,2}\d{1,2} \d{4} \d{2}:\d{2}:\d{2}
\(C\) COPYRIGHT (?:\d{4}|\d{4}-\d{4})(?:,\s?(?:\d{4}|\d{4}-\d{4}))* Arm Limited
ALL RIGHTS RESERVED
"""
# Not all Corstone-310 versions print the "Info" message.
stop_info_pattern = "\nInfo: /OSCI/SystemC: Simulation stopped by user.\n"
stop_warning_pattern = r"""\[warning \]\[main@0\]\[\d+ ns\] Simulation stopped by user
"""
expected_stdout_format = (
f"{boilerplate_pattern}(.*?)(?:{stop_info_pattern})?{stop_warning_pattern}"
)
regex_result = re.fullmatch(
expected_stdout_format, decoded_stdout, flags=re.DOTALL
)
if not regex_result:
error_msg = (
f"Corstone's output format is different than expected\n"
f"Expected (regex): {expected_stdout_format}\n"
f"Got: {decoded_stdout}"
)
raise RuntimeError(error_msg)

relevant_stdout = regex_result[1]
result_stdout = relevant_stdout.encode()
else:
result_stdout = result.stdout

sys.stdout.buffer.write(result_stdout)
return result.returncode
1 change: 0 additions & 1 deletion arm-software/embedded/fvp/config/m-pacbti.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

# Enable M-profile PAC and BTI
cpu0.CFGPACBTI=1
cpu0.ID_ISAR5.PACBTI=1
44 changes: 35 additions & 9 deletions arm-software/embedded/fvp/get_fvps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,36 @@ while true; do
esac
done

URL_CORSTONE_310='https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-310/FVP_Corstone_SSE-310_11.24_13_Linux64.tgz?rev=c370b571bdff42d3a0152471eca3d798&hash=1E388EE3B6E8F675D02D2832DBE61946DEC0386A'
URL_BASE_AEM_A='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_RevC-2xAEMvA_11.27_19_Linux64.tgz'
URL_BASE_AEM_R='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_AEMv8R_11.27_19_Linux64.tgz'
URL_CRYPTO='https://developer.arm.com/-/cdn-downloads/permalink/Fast-Models-Crypto-Plug-in/FM-11.27/FastModels_crypto_11.27.019_Linux64.tgz'
# Downloads are currently found on the following pages:
# Corstone:
# https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms/IoT%20FVPs
# AEMv8A and AEMv8R:
# https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms/Arm%20Architecture%20FVPs
# Crypto plug-in:
# https://developer.arm.com/Tools%20and%20Software/Fast%20Models#Downloads

MACHINE_HARDWARE=$(uname -m)

if [ "$MACHINE_HARDWARE" == 'x86_64' ]; then
URL_CORSTONE_310='https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-310/FVP_Corstone_SSE-310_11.27_42_Linux64.tgz'
URL_BASE_AEM_A='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_RevC-2xAEMvA_11.27_19_Linux64.tgz'
URL_BASE_AEM_R='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_AEMv8R_11.27_19_Linux64.tgz'
URL_CRYPTO='https://developer.arm.com/-/cdn-downloads/permalink/Fast-Models-Crypto-Plug-in/FM-11.27/FastModels_crypto_11.27.019_Linux64.tgz'
elif [ "$MACHINE_HARDWARE" == 'aarch64' ]; then
URL_CORSTONE_310='https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-310/FVP_Corstone_SSE-310_11.27_42_Linux64_armv8l.tgz'
URL_BASE_AEM_A='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_RevC-2xAEMvA_11.27_19_Linux64_armv8l.tgz'
URL_BASE_AEM_R='https://developer.arm.com/-/cdn-downloads/permalink/Fixed-Virtual-Platforms/FM-11.27/FVP_Base_AEMv8R_11.27_19_Linux64_armv8l.tgz'
URL_CRYPTO='https://developer.arm.com/-/cdn-downloads/permalink/Fast-Models-Crypto-Plug-in/FM-11.27/FastModels_crypto_11.27.019_Linux64_armv8l.tgz'
else
echo Unknown architecture: $MACHINE_HARDWARE
exit 1
fi

FILENAME_CORSTONE_310=$(basename "$URL_CORSTONE_310")
FILENAME_BASE_AEM_A=$(basename "$URL_BASE_AEM_A")
FILENAME_BASE_AEM_R=$(basename "$URL_BASE_AEM_R")
FILENAME_CRYPTO=$(basename "$URL_CRYPTO")
EXTRACTEDNAME_CRYPTO=$(basename "$URL_CRYPTO" .tgz)

mkdir -p download
pushd download
Expand All @@ -56,24 +82,24 @@ mkdir -p install
pushd install

if [ ! -d "Corstone-310" ]; then
tar -xf ${DOWNLOAD_DIR}/FVP_Corstone_SSE-310_11.24_13_Linux64.tgz
tar -xf ${DOWNLOAD_DIR}/${FILENAME_CORSTONE_310}
./FVP_Corstone_SSE-310.sh --destination ./Corstone-310 "${INSTALLER_FLAGS_CORSTONE[@]}"
fi

if [ ! -d "Base_RevC_AEMvA_pkg" ]; then
tar -xf ${DOWNLOAD_DIR}/FVP_Base_RevC-2xAEMvA_11.27_19_Linux64.tgz
tar -xf ${DOWNLOAD_DIR}/${FILENAME_BASE_AEM_A}
# (Extracted directly into ./Base_RevC_AEMvA_pkg/, no installer)
fi

if [ ! -d "AEMv8R_base_pkg" ]; then
tar -xf ${DOWNLOAD_DIR}/FVP_Base_AEMv8R_11.27_19_Linux64.tgz
tar -xf ${DOWNLOAD_DIR}/${FILENAME_BASE_AEM_R}
# (Extracted directly into ./AEMv8R_base_pkg/, no installer)
fi

if [ ! -d "FastModelsPortfolio_11.27" ]; then
tar -xf ${DOWNLOAD_DIR}/FastModels_crypto_11.27.019_Linux64.tgz
tar -xf ${DOWNLOAD_DIR}/${FILENAME_CRYPTO}
# SDDKW-93582: Non-interactive installation fails if cwd is different.
pushd FastModels_crypto_11.27.019_Linux64
pushd ${EXTRACTEDNAME_CRYPTO}
# This installer doesn't allow providing a default path for
# interactive installation. The user will have to enter the install
# directory as the target by hand.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From 4adfc5231d2c0182d6278b4aa75eec57648e5dd4 Mon Sep 17 00:00:00 2001
From 47dd90545df09ec7f74a9a617cf3b63e9cf8f26b Mon Sep 17 00:00:00 2001
From: Vladi Krapp <vladi.krapp@arm.com>
Date: Tue, 3 Sep 2024 14:12:48 +0100
Subject: [Pipelines] Additional unrolling in LTO
Subject: [Pipelines] Additional unrolling in LTO

Some workloads require specific sequences of events to happen
to fully simplify. This adds an extra full unrolling pass to help these
cases on the cores with branch predictors. It helps produce simplified
loops, which can then be SROA'd allowing further simplification, which
can be important for performance.
Feature adds extra compile time to get extra performance and
Feature adds extra compile time to get extra performance and
is enabled by the opt flag 'extra-LTO-loop-unroll' (off by default).

Original patch by David Green (david.green@arm.com)
Expand All @@ -17,7 +17,7 @@ Original patch by David Green (david.green@arm.com)
1 file changed, 16 insertions(+)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 1184123c7710..6dc45d85927a 100644
index 4632a0e46908..c625e2424f8b 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -332,6 +332,10 @@ namespace llvm {
Expand All @@ -31,8 +31,8 @@ index 1184123c7710..6dc45d85927a 100644
void PassBuilder::invokePeepholeEPCallbacks(FunctionPassManager &FPM,
OptimizationLevel Level) {
for (auto &C : PeepholeEPCallbacks)
@@ -1940,6 +1944,18 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass()));
@@ -2018,6 +2022,18 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));

FunctionPassManager FPM;
+
Expand All @@ -51,5 +51,5 @@ index 1184123c7710..6dc45d85927a 100644
FPM.addPass(InstCombinePass());
invokePeepholeEPCallbacks(FPM, Level);
--
2.34.1
2.43.0

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
From 411bab1ff439215c060127b6a5188ed0c9ed5d65 Mon Sep 17 00:00:00 2001
From: Vrukesh V Panse <vrukesh.panse@arm.com>
Date: Thu, 2 Jan 2025 10:29:56 +0000
Subject: [NFC]: Update the patch file with upstream changes of SelectionDAG
From 56b1d9becf044649a759129b986de71cc43b4c29 Mon Sep 17 00:00:00 2001
From: Scott Douglass <scott.douglass@arm.com>
Date: Tue, 13 Aug 2024 10:55:51 +0100
Subject: [ARM][CodeGen]Prefer MEMCPY LDM/STM inlining for v7-m

This patch changes the behaviour of memcpy inlining on v7m targets.
The old behaviour was to inline memcpys with LDM/STM instructions.
Alternatively, using LD/ST instructions for memcpy inlining allowed
for performance gains of 1% to 2% on selected benchmarks.

Co-authored-by: Nashe Mncube <nashe.mncube@arm.com>
---
llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp | 120 +++++++++++++++
llvm/lib/Target/ARM/ARMSelectionDAGInfo.h | 6 +
Expand Down Expand Up @@ -340,5 +346,5 @@ index 000000000000..e549958494dc
+ ret void
+}
--
2.34.1
2.43.0

4 changes: 4 additions & 0 deletions arm-software/embedded/scripts/build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A Powershell script to build the Arm Toolchain for Embedded

Expand Down
15 changes: 14 additions & 1 deletion arm-software/embedded/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash

# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A bash script to build the Arm Toolchain for Embedded

# The script creates a build of the toolchain in the 'build' directory, inside
# the repository tree.

# If FVPs have been installed, the environment variable `FVP_INSTALL_DIR`
# should be set to their install location to enable their use in tests.

set -ex

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand All @@ -15,8 +23,13 @@ clang --version
export CC=clang
export CXX=clang++

EXTRA_CMAKE_ARGS=""
if [[ ! -z "${FVP_INSTALL_DIR}" ]]; then
EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DENABLE_FVP_TESTING=ON -DFVP_INSTALL_DIR=${FVP_INSTALL_DIR}"
fi

mkdir -p ${REPO_ROOT}/build
cd ${REPO_ROOT}/build

cmake ../arm-software/embedded -GNinja -DFETCHCONTENT_QUIET=OFF
cmake ../arm-software/embedded -GNinja -DFETCHCONTENT_QUIET=OFF ${EXTRA_CMAKE_ARGS}
ninja package-llvm-toolchain
5 changes: 5 additions & 0 deletions arm-software/embedded/scripts/build_llvmlibc_overlay.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A bash script to build the llvmlibc overlay for the Arm Toolchain for Embedded

# The script creates a build of the toolchain in the 'build_llvmlibc_overlay'
Expand Down
5 changes: 5 additions & 0 deletions arm-software/embedded/scripts/build_newlib_overlay.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A bash script to build the newlib overlay for the Arm Toolchain for Embedded

# The script creates a build of the toolchain in the 'build_newlib_overlay'
Expand Down
4 changes: 4 additions & 0 deletions arm-software/embedded/scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A Powershell script to run the tests from the Arm Toolchain for Embedded

Expand Down
5 changes: 5 additions & 0 deletions arm-software/embedded/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# Copyright (c) 2025, Arm Limited and affiliates.
# Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# A bash script to run the tests from the Arm Toolchain for Embedded.

# The script assumes a successful build of the toolchain exists in the 'build'
Expand Down
Loading