Commit d6de5f12 authored by Francesco Petrogalli's avatar Francesco Petrogalli
Browse files

[SVFS] Inject TLI Mappings in VFABI attribute.

This patch introduces a function pass to inject the scalar-to-vector
mappings stored in the TargetLIbraryInfo (TLI) into the Vector
Function ABI (VFABI) variants attribute.

The test is testing the injection for three vector libraries supported
by the TLI (Accelerate, SVML, MASSV).

The pass does not change any of the analysis associated to the
function.

Differential Revision: https://reviews.llvm.org/D70107
parent 209e30b7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -197,6 +197,10 @@ public:
  /// Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
  /// This queries the 'wchar_size' metadata.
  unsigned getWCharSize(const Module &M) const;

  /// Returns the largest vectorization factor used in the list of
  /// vector functions.
  unsigned getWidestVF(StringRef ScalarF) const;
};

/// Provides information about what library functions are available for
@@ -337,6 +341,12 @@ public:
                  FunctionAnalysisManager::Invalidator &) {
    return false;
  }

  /// Returns the largest vectorization factor used in the list of
  /// vector functions.
  unsigned getWidestVF(StringRef ScalarF) const {
    return Impl->getWidestVF(ScalarF);
  }
};

/// Analysis pass providing the \c TargetLibraryInfo.
+1 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ void initializeIndVarSimplifyLegacyPassPass(PassRegistry&);
void initializeIndirectBrExpandPassPass(PassRegistry&);
void initializeInferAddressSpacesPass(PassRegistry&);
void initializeInferFunctionAttrsLegacyPassPass(PassRegistry&);
void initializeInjectTLIMappingsLegacyPass(PassRegistry &);
void initializeInlineCostAnalysisPass(PassRegistry&);
void initializeInstCountPass(PassRegistry&);
void initializeInstNamerPass(PassRegistry&);
+1 −0
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ namespace {
      (void) llvm::createScalarizeMaskedMemIntrinPass();
      (void) llvm::createWarnMissedTransformationsPass();
      (void) llvm::createHardwareLoopsPass();
      (void)llvm::createInjectTLIMappingsLegacyPass();

      (void)new llvm::IntervalPartition();
      (void)new llvm::ScalarEvolutionWrapperPass();
+7 −0
Original line number Diff line number Diff line
@@ -119,6 +119,13 @@ ModulePass *createStripNonLineTableDebugInfoPass();
// number of conditional branches in the hot paths based on profiles.
//
FunctionPass *createControlHeightReductionLegacyPass();

//===----------------------------------------------------------------------===//
//
// InjectTLIMappingsLegacy - populates the VFABI attribute with the
// scalar-to-vector mappings from the TargetLibraryInfo.
//
FunctionPass *createInjectTLIMappingsLegacyPass();
}

#endif
+37 −0
Original line number Diff line number Diff line
//===- InjectTLIMAppings.h - TLI to VFABI attribute injection  ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Populates the VFABI attribute with the scalar-to-vector mappings
// from the TargetLibraryInfo.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_UTILS_INJECTTLIMAPPINGS_H
#define LLVM_TRANSFORMS_UTILS_INJECTTLIMAPPINGS_H

#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"

namespace llvm {
class InjectTLIMappings : public PassInfoMixin<InjectTLIMappings> {
public:
  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};

// Legacy pass
class InjectTLIMappingsLegacy : public FunctionPass {
public:
  static char ID;
  InjectTLIMappingsLegacy() : FunctionPass(ID) {
    initializeInjectTLIMappingsLegacyPass(*PassRegistry::getPassRegistry());
  }
  void getAnalysisUsage(AnalysisUsage &AU) const override;
  bool runOnFunction(Function &F) override;
};

} // End namespace llvm
#endif // LLVM_TRANSFORMS_UTILS_INJECTTLIMAPPINGS_H
Loading