Add the mechanism for TransformState extensions to update the mapping between Transform IR values and Payload IR operations held by the state. The mechanism is intentionally restrictive, similarly to how results of the transform op are handled. Introduce test ops that exercise a simple extension that maintains information across the application of multiple transform ops. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D124778
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
//===- TestTransformStateExtension.h - Test Utility -------------*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines an TransformState extension for the purpose of testing the
|
|
// relevant APIs.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MLIR_TEST_LIB_DIALECT_TRANSFORM_TESTTRANSFORMSTATEEXTENSION_H
|
|
#define MLIR_TEST_LIB_DIALECT_TRANSFORM_TESTTRANSFORMSTATEEXTENSION_H
|
|
|
|
#include "mlir/Dialect/Transform/IR/TransformInterfaces.h"
|
|
|
|
using namespace mlir;
|
|
|
|
namespace mlir {
|
|
namespace test {
|
|
class TestTransformStateExtension
|
|
: public transform::TransformState::Extension {
|
|
public:
|
|
TestTransformStateExtension(transform::TransformState &state,
|
|
StringAttr message)
|
|
: Extension(state), message(message) {}
|
|
|
|
StringRef getMessage() const { return message.getValue(); }
|
|
|
|
LogicalResult updateMapping(Operation *previous, Operation *updated) {
|
|
return replacePayloadOp(previous, updated);
|
|
}
|
|
|
|
private:
|
|
StringAttr message;
|
|
};
|
|
} // namespace test
|
|
} // namespace mlir
|
|
|
|
#endif // MLIR_TEST_LIB_DIALECT_TRANSFORM_TESTTRANSFORMSTATEEXTENSION_H
|