llvm-capstone/mlir/lib/IR/AffineExprDetail.h
Nicolas Vasilache 8ebb6ff171 [MLIR] Sketch AffineExpr value type
This CL sketches what it takes for AffineExpr to fully have by-value semantics
and not be a not-so-smart pointer anymore.

This essentially makes the underyling class a simple storage struct and
implements the operations on the value type directly. Since there is no
forwarding of operations anymore, we can full isolate the storage class and
make a hard visibility barrier by moving detail::AffineExpr into
AffineExprDetail.h.

AffineExprDetail.h is only included where storage-related information is
needed.

PiperOrigin-RevId: 216385459
2019-03-29 13:25:42 -07:00

71 lines
2.4 KiB
C++

//===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- C++ -*-===//
//
// Copyright 2019 The MLIR Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
//
// This holds implementation details of AffineExpr. Ideally it would not be
// exposed and would be kept local to AffineExpr.cpp however, MLIRContext.cpp
// needs to know the sizes for placement-new style Allocation.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_IR_AFFINEEXPRDETAIL_H_
#define MLIR_IR_AFFINEEXPRDETAIL_H_
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/MLIRContext.h"
#include "llvm/ADT/PointerIntPair.h"
namespace mlir {
class MLIRContext;
namespace detail {
/// Base storage class appearing in an affine expression.
struct AffineExprStorage {
AffineExprStorage(AffineExprKind kind, MLIRContext *context)
: contextAndKind(context, kind) {}
llvm::PointerIntPair<MLIRContext *, 3, AffineExprKind> contextAndKind;
};
/// A binary operation appearing in an affine expression.
struct AffineBinaryOpExprStorage : public AffineExprStorage {
static AffineExpr get(AffineExprKind kind, AffineExpr lhs, AffineExpr rhs);
AffineExpr lhs;
AffineExpr rhs;
};
/// A dimensional identifier appearing in an affine expression.
struct AffineDimExprStorage : public AffineExprStorage {
/// Position of this identifier in the argument list.
unsigned position;
};
/// A symbolic identifier appearing in an affine expression.
struct AffineSymbolExprStorage : public AffineExprStorage {
/// Position of this identifier in the symbol list.
unsigned position;
};
/// An integer constant appearing in affine expression.
struct AffineConstantExprStorage : public AffineExprStorage {
// The constant.
int64_t constant;
};
} // end namespace detail
} // end namespace mlir
#endif // MLIR_IR_AFFINEEXPRDETAIL_H_