xref: /llvm-project/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp (revision eb9f4756bc3daaa4b19f4f46521dc05180814de4)
1 //===- Legality.cpp -------------------------------------------------------===//
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/Legality.h"
10 #include "llvm/SandboxIR/Value.h"
11 #include "llvm/Support/Debug.h"
12 
13 namespace llvm::sandboxir {
14 
15 #ifndef NDEBUG
16 void LegalityResult::dump() const {
17   print(dbgs());
18   dbgs() << "\n";
19 }
20 #endif // NDEBUG
21 
22 std::optional<ResultReason>
23 LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(
24     ArrayRef<Value *> Bndl) {
25   // TODO: Unimplemented.
26   return std::nullopt;
27 }
28 
29 LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl) {
30   if (auto ReasonOpt = notVectorizableBasedOnOpcodesAndTypes(Bndl))
31     return createLegalityResult<Pack>(*ReasonOpt);
32 
33   // TODO: Check for existing vectors containing values in Bndl.
34 
35   // TODO: Check with scheduler.
36 
37   return createLegalityResult<Widen>();
38 }
39 } // namespace llvm::sandboxir
40