Add option to enable global-isel on arm64 archs

LLVM will eventually switch over to using global-isel on arm64 archs.
Setting this option (SWIFT_ENABLE_GLOBAL_ISEL_ARM64) can be used to experiment
with that in Swift before the switch happens.
This commit is contained in:
Arnold Schwaighofer
2021-08-17 12:58:09 -07:00
parent 5ea28a7d3a
commit 71f64ac348
6 changed files with 27 additions and 1 deletions

View File

@@ -439,6 +439,10 @@ option(SWIFT_ENABLE_DISPATCH
"Enable use of libdispatch"
TRUE)
option(SWIFT_ENABLE_GLOBAL_ISEL_ARM64
"Enable global isel on arm64, arm64e, arm64_32"
FALSE)
cmake_dependent_option(SWIFT_BUILD_SYNTAXPARSERLIB
"Build the Swift Syntax Parser library" TRUE
"SWIFT_ENABLE_DISPATCH" FALSE)

View File

@@ -343,6 +343,8 @@ public:
/// Whether to disable using mangled names for accessing concrete type metadata.
unsigned DisableConcreteTypeMetadataMangledNameAccessors : 1;
unsigned EnableGlobalISel : 1;
/// The number of threads for multi-threaded code generation.
unsigned NumThreads = 0;
@@ -396,7 +398,8 @@ public:
UseTypeLayoutValueHandling(true),
GenerateProfile(false), EnableDynamicReplacementChaining(false),
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
DisableConcreteTypeMetadataMangledNameAccessors(false), CmdArgs(),
DisableConcreteTypeMetadataMangledNameAccessors(false),
EnableGlobalISel(false), CmdArgs(),
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
TypeInfoFilter(TypeInfoDumpFilter::All) {}

View File

@@ -12,4 +12,6 @@
#cmakedefine01 SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
#cmakedefine01 SWIFT_ENABLE_GLOBAL_ISEL_ARM64
#endif // SWIFT_CONFIG_H

View File

@@ -1873,6 +1873,12 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
}
}
if (SWIFT_ENABLE_GLOBAL_ISEL_ARM64 &&
(Triple.getArch() == llvm::Triple::aarch64 ||
Triple.getArch() == llvm::Triple::aarch64_32)) {
Opts.EnableGlobalISel = true;
}
return false;
}

View File

@@ -175,6 +175,9 @@ swift::getIRTargetOptions(const IRGenOptions &Opts, ASTContext &Ctx) {
if (Clang->getTargetInfo().getTriple().isOSBinFormatWasm())
TargetOpts.ThreadModel = llvm::ThreadModel::Single;
if (Opts.EnableGlobalISel)
TargetOpts.EnableGlobalISel = true;
clang::TargetOptions &ClangOpts = Clang->getTargetInfo().getTargetOpts();
return std::make_tuple(TargetOpts, ClangOpts.CPU, ClangOpts.Features, ClangOpts.Triple);
}

View File

@@ -138,6 +138,14 @@ function(_add_target_variant_c_compile_flags)
set(result ${${CFLAGS_RESULT_VAR_NAME}})
if ("${CFLAGS_ARCH}" STREQUAL "arm64" OR
"${CFLAGS_ARCH}" STREQUAL "arm64e" OR
"${CFLAGS_ARCH}" STREQUAL "arm64_32")
if (SWIFT_ENABLE_GLOBAL_ISEL_ARM64)
list(APPEND result "-fglobal-isel")
endif()
endif()
_add_target_variant_c_compile_link_flags(
SDK "${CFLAGS_SDK}"
ARCH "${CFLAGS_ARCH}"