/home/arjun/llvm-project/mlir/lib/IR/AffineExprDetail.h
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | //===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- C++ -*-===// | 
| 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 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" | 
| 19 |  | #include "mlir/Support/StorageUniquer.h" | 
| 20 |  |  | 
| 21 |  | namespace mlir { | 
| 22 |  |  | 
| 23 |  | class MLIRContext; | 
| 24 |  |  | 
| 25 |  | namespace detail { | 
| 26 |  |  | 
| 27 |  | /// Base storage class appearing in an affine expression. | 
| 28 |  | struct AffineExprStorage : public StorageUniquer::BaseStorage { | 
| 29 |  |   MLIRContext *context; | 
| 30 |  | }; | 
| 31 |  |  | 
| 32 |  | /// A binary operation appearing in an affine expression. | 
| 33 |  | struct AffineBinaryOpExprStorage : public AffineExprStorage { | 
| 34 |  |   using KeyTy = std::pair<AffineExpr, AffineExpr>; | 
| 35 |  |  | 
| 36 | 0 |   bool operator==(const KeyTy &key) const { | 
| 37 | 0 |     return key.first == lhs && key.second == rhs; | 
| 38 | 0 |   } | 
| 39 |  |  | 
| 40 |  |   static AffineBinaryOpExprStorage * | 
| 41 | 0 |   construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key) { | 
| 42 | 0 |     auto *result = allocator.allocate<AffineBinaryOpExprStorage>(); | 
| 43 | 0 |     result->lhs = key.first; | 
| 44 | 0 |     result->rhs = key.second; | 
| 45 | 0 |     result->context = result->lhs.getContext(); | 
| 46 | 0 |     return result; | 
| 47 | 0 |   } | 
| 48 |  |  | 
| 49 |  |   AffineExpr lhs; | 
| 50 |  |   AffineExpr rhs; | 
| 51 |  | }; | 
| 52 |  |  | 
| 53 |  | /// A dimensional or symbolic identifier appearing in an affine expression. | 
| 54 |  | struct AffineDimExprStorage : public AffineExprStorage { | 
| 55 |  |   using KeyTy = unsigned; | 
| 56 |  |  | 
| 57 | 0 |   bool operator==(const KeyTy &key) const { return position == key; } | 
| 58 |  |  | 
| 59 |  |   static AffineDimExprStorage * | 
| 60 | 0 |   construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key) { | 
| 61 | 0 |     auto *result = allocator.allocate<AffineDimExprStorage>(); | 
| 62 | 0 |     result->position = key; | 
| 63 | 0 |     return result; | 
| 64 | 0 |   } | 
| 65 |  |  | 
| 66 |  |   /// Position of this identifier in the argument list. | 
| 67 |  |   unsigned position; | 
| 68 |  | }; | 
| 69 |  |  | 
| 70 |  | /// An integer constant appearing in affine expression. | 
| 71 |  | struct AffineConstantExprStorage : public AffineExprStorage { | 
| 72 |  |   using KeyTy = int64_t; | 
| 73 |  |  | 
| 74 | 0 |   bool operator==(const KeyTy &key) const { return constant == key; } | 
| 75 |  |  | 
| 76 |  |   static AffineConstantExprStorage * | 
| 77 | 0 |   construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key) { | 
| 78 | 0 |     auto *result = allocator.allocate<AffineConstantExprStorage>(); | 
| 79 | 0 |     result->constant = key; | 
| 80 | 0 |     return result; | 
| 81 | 0 |   } | 
| 82 |  |  | 
| 83 |  |   // The constant. | 
| 84 |  |   int64_t constant; | 
| 85 |  | }; | 
| 86 |  |  | 
| 87 |  | } // end namespace detail | 
| 88 |  | } // end namespace mlir | 
| 89 |  | #endif // MLIR_IR_AFFINEEXPRDETAIL_H_ |