Skip to content

[frontend] Expose via a LangOption whether or not the compiler is compiling for a triple that supports AArch64 TBI. #83856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ namespace swift {
bool RestrictNonProductionExperimentalFeatures = false;
#endif

/// Set to true if we support AArch64TBI.
bool HasAArch64TBI = false;

bool isConcurrencyModelTaskToThread() const {
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
}
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ class CompilerInvocation {
/// C++ stdlib is the default for the specified target.
void computeCXXStdlibOptions();

/// Compute whether or not we support aarch64TBI
void computeAArch64TBIOptions();

/// Computes the runtime resource path relative to the given Swift
/// executable.
static void computeRuntimeResourcePathFromExecutablePath(
Expand Down
2 changes: 2 additions & 0 deletions lib/DriverTool/sil_opt_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,8 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
Invocation.getLangOptions().UnavailableDeclOptimizationMode =
options.UnavailableDeclOptimization;

Invocation.computeAArch64TBIOptions();

// Enable strict concurrency if we have the feature specified or if it was
// specified via a command line option to sil-opt.
if (Invocation.getLangOptions().hasFeature(Feature::StrictConcurrency)) {
Expand Down
9 changes: 9 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ setBridgingHeaderFromFrontendOptions(ClangImporterOptions &ImporterOpts,
FrontendOpts.InputsAndOutputs.getFilenameOfFirstInput();
}

void CompilerInvocation::computeAArch64TBIOptions() {
auto &LLVMArgs = getFrontendOptions().LLVMArgs;
auto aarch64_use_tbi =
std::find(LLVMArgs.begin(), LLVMArgs.end(), "-aarch64-use-tbi");
LangOpts.HasAArch64TBI = aarch64_use_tbi != LLVMArgs.end();
}

void CompilerInvocation::computeCXXStdlibOptions() {
// The MSVC driver in Clang is not aware of the C++ stdlib, and currently
// always assumes libstdc++, which is incorrect: the Microsoft stdlib is
Expand Down Expand Up @@ -4099,6 +4106,8 @@ bool CompilerInvocation::parseArgs(
setIRGenOutputOptsFromFrontendOptions(IRGenOpts, FrontendOpts);
setBridgingHeaderFromFrontendOptions(ClangImporterOpts, FrontendOpts);
computeCXXStdlibOptions();
computeAArch64TBIOptions();

if (LangOpts.hasFeature(Feature::Embedded)) {
IRGenOpts.InternalizeAtLink = true;
IRGenOpts.DisableLegacyTypeInfo = true;
Expand Down
2 changes: 2 additions & 0 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4614,6 +4614,8 @@ int main(int argc, char *argv[]) {
InitInvok.computeCXXStdlibOptions();
}

InitInvok.computeAArch64TBIOptions();

if (!options::InProcessPluginServerPath.empty()) {
InitInvok.getSearchPathOptions().InProcessPluginServerPath =
options::InProcessPluginServerPath;
Expand Down