Skip to content

Commit 7fcc8a5

Browse files
committed
[frontend] Expose via a LangOption whether or not the compiler is compiling for a triple that supports AArch64 TBI.
Just breaking down layers of a larger patch to make it easier to review. (cherry picked from commit bfecaa3)
1 parent b4c3a21 commit 7fcc8a5

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ namespace swift {
652652
bool RestrictNonProductionExperimentalFeatures = false;
653653
#endif
654654

655+
/// Set to true if we support AArch64TBI.
656+
bool HasAArch64TBI = false;
657+
655658
bool isConcurrencyModelTaskToThread() const {
656659
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
657660
}

include/swift/Frontend/Frontend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ class CompilerInvocation {
274274
/// C++ stdlib is the default for the specified target.
275275
void computeCXXStdlibOptions();
276276

277+
/// Compute whether or not we support aarch64TBI
278+
void computeAArch64TBIOptions();
279+
277280
/// Computes the runtime resource path relative to the given Swift
278281
/// executable.
279282
static void computeRuntimeResourcePathFromExecutablePath(

lib/DriverTool/sil_opt_main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
816816
Invocation.getLangOptions().UnavailableDeclOptimizationMode =
817817
options.UnavailableDeclOptimization;
818818

819+
Invocation.computeAArch64TBIOptions();
820+
819821
// Enable strict concurrency if we have the feature specified or if it was
820822
// specified via a command line option to sil-opt.
821823
if (Invocation.getLangOptions().hasFeature(Feature::StrictConcurrency)) {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ setBridgingHeaderFromFrontendOptions(ClangImporterOptions &ImporterOpts,
380380
FrontendOpts.InputsAndOutputs.getFilenameOfFirstInput();
381381
}
382382

383+
void CompilerInvocation::computeAArch64TBIOptions() {
384+
auto &LLVMArgs = getFrontendOptions().LLVMArgs;
385+
auto aarch64_use_tbi =
386+
std::find(LLVMArgs.begin(), LLVMArgs.end(), "-aarch64-use-tbi");
387+
LangOpts.HasAArch64TBI = aarch64_use_tbi != LLVMArgs.end();
388+
}
389+
383390
void CompilerInvocation::computeCXXStdlibOptions() {
384391
// The MSVC driver in Clang is not aware of the C++ stdlib, and currently
385392
// always assumes libstdc++, which is incorrect: the Microsoft stdlib is
@@ -4118,6 +4125,8 @@ bool CompilerInvocation::parseArgs(
41184125
setIRGenOutputOptsFromFrontendOptions(IRGenOpts, FrontendOpts);
41194126
setBridgingHeaderFromFrontendOptions(ClangImporterOpts, FrontendOpts);
41204127
computeCXXStdlibOptions();
4128+
computeAArch64TBIOptions();
4129+
41214130
if (LangOpts.hasFeature(Feature::Embedded)) {
41224131
IRGenOpts.InternalizeAtLink = true;
41234132
IRGenOpts.DisableLegacyTypeInfo = true;

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4582,6 +4582,8 @@ int main(int argc, char *argv[]) {
45824582
InitInvok.computeCXXStdlibOptions();
45834583
}
45844584

4585+
InitInvok.computeAArch64TBIOptions();
4586+
45854587
if (!options::InProcessPluginServerPath.empty()) {
45864588
InitInvok.getSearchPathOptions().InProcessPluginServerPath =
45874589
options::InProcessPluginServerPath;

0 commit comments

Comments
 (0)