The side effect infrastructure is based on the Effect and Resource class templates, instances of instantiations of which are constructed as thread-local singletons. With this scheme, it is impossible to further parameterize either of those, or the EffectInstance class that contains pointers to an Effect and Resource instances. Such a parameterization is necessary to express more detailed side effects, e.g. those of a loop or a function call with affine operations inside where it is possible to precisely specify the slices of accessed buffers. Include an additional Attribute to EffectInstance class for further parameterization. This allows to leverage the dialect-specific registration and uniquing capabilities of the attribute infrastructure without requiring Effect or Resource instantiations to be attached to a dialect themselves. Split out the generic part of the side effect Tablegen classes into a separate file to avoid generating built-in MemoryEffect interfaces when processing any .td file that includes SideEffectInterfaceBase.td. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D91493
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
//===- TestInterfaces.h - MLIR interfaces for testing -----------*- 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 declares interfaces for the 'test' dialect that can be used for
|
|
// testing the interface infrastructure.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MLIR_TEST_LIB_DIALECT_TEST_TESTINTERFACES_H
|
|
#define MLIR_TEST_LIB_DIALECT_TEST_TESTINTERFACES_H
|
|
|
|
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
|
|
|
namespace mlir {
|
|
namespace TestEffects {
|
|
struct Effect : public SideEffects::Effect {
|
|
using SideEffects::Effect::Effect;
|
|
|
|
template <typename Derived>
|
|
using Base = SideEffects::Effect::Base<Derived, Effect>;
|
|
|
|
static bool classof(const SideEffects::Effect *effect);
|
|
};
|
|
|
|
using EffectInstance = SideEffects::EffectInstance<Effect>;
|
|
|
|
struct Concrete : public Effect::Base<Concrete> {};
|
|
|
|
} // namespace TestEffects
|
|
} // namespace mlir
|
|
|
|
#endif // MLIR_TEST_LIB_DIALECT_TEST_TESTINTERFACES_H
|