-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] add fveclib flag #71734
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
Merged
Merged
[flang] add fveclib flag #71734
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -850,11 +850,13 @@ getOutputStream(CompilerInstance &ci, llvm::StringRef inFile, | |
/// \param [in] tm Target machine to aid the code-gen pipeline set-up | ||
/// \param [in] act Backend act to run (assembly vs machine-code generation) | ||
/// \param [in] llvmModule LLVM module to lower to assembly/machine-code | ||
/// \param [in] codeGenOpts options configuring codegen pipeline | ||
/// \param [out] os Output stream to emit the generated code to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Add the new option here. May be good to have the stream as the last option. |
||
static void generateMachineCodeOrAssemblyImpl(clang::DiagnosticsEngine &diags, | ||
llvm::TargetMachine &tm, | ||
BackendActionTy act, | ||
llvm::Module &llvmModule, | ||
const CodeGenOptions &codeGenOpts, | ||
llvm::raw_pwrite_stream &os) { | ||
assert(((act == BackendActionTy::Backend_EmitObj) || | ||
(act == BackendActionTy::Backend_EmitAssembly)) && | ||
|
@@ -868,9 +870,8 @@ static void generateMachineCodeOrAssemblyImpl(clang::DiagnosticsEngine &diags, | |
createTargetTransformInfoWrapperPass(tm.getTargetIRAnalysis())); | ||
|
||
llvm::Triple triple(llvmModule.getTargetTriple()); | ||
std::unique_ptr<llvm::TargetLibraryInfoImpl> tlii = | ||
std::make_unique<llvm::TargetLibraryInfoImpl>(triple); | ||
assert(tlii && "Failed to create TargetLibraryInfo"); | ||
llvm::TargetLibraryInfoImpl *tlii = | ||
llvm::driver::createTLII(triple, codeGenOpts.getVecLib()); | ||
codeGenPasses.add(new llvm::TargetLibraryInfoWrapperPass(*tlii)); | ||
|
||
llvm::CodeGenFileType cgft = (act == BackendActionTy::Backend_EmitAssembly) | ||
|
@@ -923,6 +924,13 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) { | |
get##Ext##PluginInfo().RegisterPassBuilderCallbacks(pb); | ||
#include "llvm/Support/Extension.def" | ||
|
||
// Register the target library analysis directly and give it a customized | ||
// preset TLI depending on -fveclib | ||
llvm::Triple triple(llvmModule->getTargetTriple()); | ||
llvm::TargetLibraryInfoImpl *tlii = | ||
llvm::driver::createTLII(triple, opts.getVecLib()); | ||
fam.registerPass([&] { return llvm::TargetLibraryAnalysis(*tlii); }); | ||
|
||
// Register all the basic analyses with the managers. | ||
pb.registerModuleAnalyses(mam); | ||
pb.registerCGSCCAnalyses(cgam); | ||
|
@@ -1227,7 +1235,7 @@ void CodeGenAction::executeAction() { | |
if (action == BackendActionTy::Backend_EmitAssembly || | ||
action == BackendActionTy::Backend_EmitObj) { | ||
generateMachineCodeOrAssemblyImpl( | ||
diags, *tm, action, *llvmModule, | ||
diags, *tm, action, *llvmModule, codeGenOpts, | ||
ci.isOutputStreamNull() ? *os : ci.getOutputStream()); | ||
return; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
! test that -fveclib= is passed to the backend | ||
! -target aarch64 so that ArmPL is available | ||
! RUN: %flang -S -Ofast -fveclib=LIBMVEC -o - %s | FileCheck %s | ||
! RUN: %flang -S -Ofast -fveclib=NoLibrary -o - %s | FileCheck %s --check-prefix=NOLIB | ||
|
||
tblah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
subroutine sb(a, b) | ||
real :: a(:), b(:) | ||
integer :: i | ||
do i=1,100 | ||
! check that we used a vectorized call to powf() | ||
! CHECK: _ZGVbN4vv_powf | ||
! NOLIB: powf | ||
a(i) = a(i) ** b(i) | ||
end do | ||
end subroutine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
! RUN: %flang -### -c -fveclib=none %s 2>&1 | FileCheck -check-prefix CHECK-NOLIB %s | ||
! RUN: %flang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck -check-prefix CHECK-ACCELERATE %s | ||
! RUN: %flang -### -c -fveclib=libmvec %s 2>&1 | FileCheck -check-prefix CHECK-libmvec %s | ||
! RUN: %flang -### -c -fveclib=MASSV %s 2>&1 | FileCheck -check-prefix CHECK-MASSV %s | ||
! RUN: %flang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck -check-prefix CHECK-DARWIN_LIBSYSTEM_M %s | ||
! RUN: %flang -### -c --target=aarch64-none-none -fveclib=SLEEF %s 2>&1 | FileCheck -check-prefix CHECK-SLEEF %s | ||
! RUN: %flang -### -c --target=aarch64-none-none -fveclib=ArmPL %s 2>&1 | FileCheck -check-prefix CHECK-ARMPL %s | ||
! RUN: not %flang -c -fveclib=something %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s | ||
|
||
! CHECK-NOLIB: "-fveclib=none" | ||
! CHECK-ACCELERATE: "-fveclib=Accelerate" | ||
! CHECK-libmvec: "-fveclib=libmvec" | ||
! CHECK-MASSV: "-fveclib=MASSV" | ||
! CHECK-DARWIN_LIBSYSTEM_M: "-fveclib=Darwin_libsystem_m" | ||
! CHECK-SLEEF: "-fveclib=SLEEF" | ||
! CHECK-ARMPL: "-fveclib=ArmPL" | ||
|
||
! CHECK-INVALID: error: invalid value 'something' in '-fveclib=something' | ||
|
||
! RUN: not %flang --target=x86-none-none -c -fveclib=SLEEF %s 2>&1 | FileCheck -check-prefix CHECK-ERROR %s | ||
! RUN: not %flang --target=x86-none-none -c -fveclib=ArmPL %s 2>&1 | FileCheck -check-prefix CHECK-ERROR %s | ||
! RUN: not %flang --target=aarch64-none-none -c -fveclib=LIBMVEC-X86 %s 2>&1 | FileCheck -check-prefix CHECK-ERROR %s | ||
! RUN: not %flang --target=aarch64-none-none -c -fveclib=SVML %s 2>&1 | FileCheck -check-prefix CHECK-ERROR %s | ||
! CHECK-ERROR: unsupported option {{.*}} for target | ||
|
||
! RUN: %flang -fveclib=Accelerate %s -target arm64-apple-ios8.0.0 -### 2>&1 | FileCheck --check-prefix=CHECK-LINK %s | ||
! CHECK-LINK: "-framework" "Accelerate" | ||
|
||
! TODO: if we add support for -nostdlib or -nodefaultlibs we need to test that | ||
! these prevent "-framework Accelerate" being added on Darwin |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these clang prefixes required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file imports both the
clang
andllvm
namespaces. So now that I have addedllvm::driver
,driver::Driver
is ambiguous.