1 //===- TestLiveness.cpp - Test liveness construction and information ------===// 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 // This file contains test passes for constructing and resolving liveness 10 // information. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "mlir/Analysis/Liveness.h" 15 #include "mlir/IR/SymbolTable.h" 16 #include "mlir/Pass/Pass.h" 17 18 using namespace mlir; 19 20 namespace { 21 22 struct TestLivenessPass 23 : public PassWrapper<TestLivenessPass, InterfacePass<SymbolOpInterface>> { MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID__anon32cb00870111::TestLivenessPass24 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLivenessPass) 25 26 StringRef getArgument() const final { return "test-print-liveness"; } getDescription__anon32cb00870111::TestLivenessPass27 StringRef getDescription() const final { 28 return "Print the contents of a constructed liveness information."; 29 } runOnOperation__anon32cb00870111::TestLivenessPass30 void runOnOperation() override { 31 llvm::errs() << "Testing : " << getOperation().getName() << "\n"; 32 getAnalysis<Liveness>().print(llvm::errs()); 33 } 34 }; 35 36 } // namespace 37 38 namespace mlir { 39 namespace test { registerTestLivenessPass()40void registerTestLivenessPass() { PassRegistration<TestLivenessPass>(); } 41 } // namespace test 42 } // namespace mlir 43