Skip to content

Commit a3e72f5

Browse files
Merge pull request swiftlang#38910 from aschwaighofer/add_option_to_experiment_with_global_isel
Add option to enable global-isel on arm64 archs
2 parents 5b6f183 + 71f64ac commit a3e72f5

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ option(SWIFT_ENABLE_DISPATCH
439439
"Enable use of libdispatch"
440440
TRUE)
441441

442+
option(SWIFT_ENABLE_GLOBAL_ISEL_ARM64
443+
"Enable global isel on arm64, arm64e, arm64_32"
444+
FALSE)
445+
442446
cmake_dependent_option(SWIFT_BUILD_SYNTAXPARSERLIB
443447
"Build the Swift Syntax Parser library" TRUE
444448
"SWIFT_ENABLE_DISPATCH" FALSE)

include/swift/AST/IRGenOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ class IRGenOptions {
343343
/// Whether to disable using mangled names for accessing concrete type metadata.
344344
unsigned DisableConcreteTypeMetadataMangledNameAccessors : 1;
345345

346+
unsigned EnableGlobalISel : 1;
347+
346348
/// The number of threads for multi-threaded code generation.
347349
unsigned NumThreads = 0;
348350

@@ -396,7 +398,8 @@ class IRGenOptions {
396398
UseTypeLayoutValueHandling(true),
397399
GenerateProfile(false), EnableDynamicReplacementChaining(false),
398400
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
399-
DisableConcreteTypeMetadataMangledNameAccessors(false), CmdArgs(),
401+
DisableConcreteTypeMetadataMangledNameAccessors(false),
402+
EnableGlobalISel(false), CmdArgs(),
400403
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
401404
TypeInfoFilter(TypeInfoDumpFilter::All) {}
402405

include/swift/Config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

1313
#cmakedefine01 SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
1414

15+
#cmakedefine01 SWIFT_ENABLE_GLOBAL_ISEL_ARM64
16+
1517
#endif // SWIFT_CONFIG_H

lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,12 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18731873
}
18741874
}
18751875

1876+
if (SWIFT_ENABLE_GLOBAL_ISEL_ARM64 &&
1877+
(Triple.getArch() == llvm::Triple::aarch64 ||
1878+
Triple.getArch() == llvm::Triple::aarch64_32)) {
1879+
Opts.EnableGlobalISel = true;
1880+
}
1881+
18761882
return false;
18771883
}
18781884

lib/IRGen/IRGen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ swift::getIRTargetOptions(const IRGenOptions &Opts, ASTContext &Ctx) {
175175
if (Clang->getTargetInfo().getTriple().isOSBinFormatWasm())
176176
TargetOpts.ThreadModel = llvm::ThreadModel::Single;
177177

178+
if (Opts.EnableGlobalISel)
179+
TargetOpts.EnableGlobalISel = true;
180+
178181
clang::TargetOptions &ClangOpts = Clang->getTargetInfo().getTargetOpts();
179182
return std::make_tuple(TargetOpts, ClangOpts.CPU, ClangOpts.Features, ClangOpts.Triple);
180183
}

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ function(_add_target_variant_c_compile_flags)
138138

139139
set(result ${${CFLAGS_RESULT_VAR_NAME}})
140140

141+
if ("${CFLAGS_ARCH}" STREQUAL "arm64" OR
142+
"${CFLAGS_ARCH}" STREQUAL "arm64e" OR
143+
"${CFLAGS_ARCH}" STREQUAL "arm64_32")
144+
if (SWIFT_ENABLE_GLOBAL_ISEL_ARM64)
145+
list(APPEND result "-fglobal-isel")
146+
endif()
147+
endif()
148+
141149
_add_target_variant_c_compile_link_flags(
142150
SDK "${CFLAGS_SDK}"
143151
ARCH "${CFLAGS_ARCH}"

0 commit comments

Comments
 (0)