1 //===- RegionsFromMetadata.cpp - A helper to test RegionPasses -----------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h" 10 11 #include "llvm/SandboxIR/Region.h" 12 #include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.h" 13 14 namespace llvm::sandboxir { 15 RegionsFromMetadata(StringRef Pipeline)16RegionsFromMetadata::RegionsFromMetadata(StringRef Pipeline) 17 : FunctionPass("regions-from-metadata"), 18 RPM("rpm", Pipeline, SandboxVectorizerPassBuilder::createRegionPass) {} 19 runOnFunction(Function & F,const Analyses & A)20bool RegionsFromMetadata::runOnFunction(Function &F, const Analyses &A) { 21 SmallVector<std::unique_ptr<sandboxir::Region>> Regions = 22 sandboxir::Region::createRegionsFromMD(F, A.getTTI()); 23 bool Change = false; 24 for (auto &R : Regions) { 25 Change |= RPM.runOnRegion(*R, A); 26 } 27 return Change; 28 } 29 30 } // namespace llvm::sandboxir 31