My Project
AffineExprDetail.h
Go to the documentation of this file.
1 //===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- C++ -*-===//
2 //
3 // Part of the MLIR 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 holds implementation details of AffineExpr. Ideally it would not be
10 // exposed and would be kept local to AffineExpr.cpp however, MLIRContext.cpp
11 // needs to know the sizes for placement-new style Allocation.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef MLIR_IR_AFFINEEXPRDETAIL_H_
15 #define MLIR_IR_AFFINEEXPRDETAIL_H_
16 
17 #include "mlir/IR/AffineExpr.h"
18 #include "mlir/IR/MLIRContext.h"
20 
21 namespace mlir {
22 
23 class MLIRContext;
24 
25 namespace detail {
26 
30 };
31 
34  using KeyTy = std::pair<AffineExpr, AffineExpr>;
35 
36  bool operator==(const KeyTy &key) const {
37  return key.first == lhs && key.second == rhs;
38  }
39 
42  auto *result = allocator.allocate<AffineBinaryOpExprStorage>();
43  result->lhs = key.first;
44  result->rhs = key.second;
45  result->context = result->lhs.getContext();
46  return result;
47  }
48 
51 };
52 
55  using KeyTy = unsigned;
56 
57  bool operator==(const KeyTy &key) const { return position == key; }
58 
59  static AffineDimExprStorage *
61  auto *result = allocator.allocate<AffineDimExprStorage>();
62  result->position = key;
63  return result;
64  }
65 
67  unsigned position;
68 };
69 
72  using KeyTy = int64_t;
73 
74  bool operator==(const KeyTy &key) const { return constant == key; }
75 
78  auto *result = allocator.allocate<AffineConstantExprStorage>();
79  result->constant = key;
80  return result;
81  }
82 
83  // The constant.
84  int64_t constant;
85 };
86 
87 } // end namespace detail
88 } // end namespace mlir
89 #endif // MLIR_IR_AFFINEEXPRDETAIL_H_
Definition: InferTypeOpInterface.cpp:20
bool operator==(const KeyTy &key) const
Definition: AffineExprDetail.h:57
Base storage class appearing in an affine expression.
Definition: AffineExprDetail.h:28
Definition: StorageUniquer.h:89
A binary operation appearing in an affine expression.
Definition: AffineExprDetail.h:33
static AffineBinaryOpExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: AffineExprDetail.h:41
AffineExpr rhs
Definition: AffineExprDetail.h:50
bool operator==(const KeyTy &key) const
Definition: AffineExprDetail.h:36
T * allocate()
Allocate an instance of the provided type.
Definition: StorageUniquer.h:109
MLIRContext * context
Definition: AffineExprDetail.h:29
unsigned position
Position of this identifier in the argument list.
Definition: AffineExprDetail.h:67
Definition: AffineExpr.h:66
MLIRContext * getContext() const
Definition: AffineExpr.cpp:21
unsigned KeyTy
Definition: AffineExprDetail.h:55
std::pair< AffineExpr, AffineExpr > KeyTy
Definition: AffineExprDetail.h:34
ValueBuilder< mlir::LLVM::ConstantOp > constant
Definition: LinalgToLLVM.cpp:56
int64_t constant
Definition: AffineExprDetail.h:84
static AffineConstantExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: AffineExprDetail.h:77
A dimensional or symbolic identifier appearing in an affine expression.
Definition: AffineExprDetail.h:54
Definition: StorageUniquer.h:71
static AffineDimExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: AffineExprDetail.h:60
Definition: MLIRContext.h:34
An integer constant appearing in affine expression.
Definition: AffineExprDetail.h:71
int64_t KeyTy
Definition: AffineExprDetail.h:72
AffineExpr lhs
Definition: AffineExprDetail.h:49
bool operator==(const KeyTy &key) const
Definition: AffineExprDetail.h:74