1 //===- TestLiveness.cpp - Test liveness construction and information
2 //-------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains test passes for constructing and resolving liveness
11 // information.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "mlir/Analysis/Liveness.h"
16 #include "mlir/Pass/Pass.h"
17 
18 using namespace mlir;
19 
20 namespace {
21 
22 struct TestLivenessPass : public PassWrapper<TestLivenessPass, FunctionPass> {
23   StringRef getArgument() const final { return "test-print-liveness"; }
24   StringRef getDescription() const final {
25     return "Print the contents of a constructed liveness information.";
26   }
27   void runOnFunction() override {
28     llvm::errs() << "Testing : " << getFunction().getName() << "\n";
29     getAnalysis<Liveness>().print(llvm::errs());
30   }
31 };
32 
33 } // end anonymous namespace
34 
35 namespace mlir {
36 namespace test {
37 void registerTestLivenessPass() { PassRegistration<TestLivenessPass>(); }
38 } // namespace test
39 } // namespace mlir
40