MLIR  19.0.0git
IntegerSetDetail.h
Go to the documentation of this file.
1 //===- IntegerSetDetail.h - MLIR IntegerSet 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 IntegerSet.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef INTEGERSETDETAIL_H_
14 #define INTEGERSETDETAIL_H_
15 
16 #include "mlir/IR/AffineExpr.h"
18 #include "llvm/ADT/ArrayRef.h"
19 
20 namespace mlir {
21 namespace detail {
22 
24  /// The hash key used for uniquing.
25  using KeyTy =
26  std::tuple<unsigned, unsigned, ArrayRef<AffineExpr>, ArrayRef<bool>>;
27 
28  unsigned dimCount;
29  unsigned symbolCount;
30 
31  /// Array of affine constraints: a constraint is either an equality
32  /// (affine_expr == 0) or an inequality (affine_expr >= 0).
34 
35  // Bits to check whether a constraint is an equality or an inequality.
37 
38  bool operator==(const KeyTy &key) const {
39  return std::get<0>(key) == dimCount && std::get<1>(key) == symbolCount &&
40  std::get<2>(key) == constraints && std::get<3>(key) == eqFlags;
41  }
42 
43  static IntegerSetStorage *
45  auto *res =
46  new (allocator.allocate<IntegerSetStorage>()) IntegerSetStorage();
47  res->dimCount = std::get<0>(key);
48  res->symbolCount = std::get<1>(key);
49  res->constraints = allocator.copyInto(std::get<2>(key));
50  res->eqFlags = allocator.copyInto(std::get<3>(key));
51  return res;
52  }
53 };
54 
55 } // namespace detail
56 } // namespace mlir
57 #endif // INTEGERSETDETAIL_H_
This class acts as the base storage that all storage classes must derived from.
This is a utility allocator used to allocate memory for instances of derived types.
ArrayRef< T > copyInto(ArrayRef< T > elements)
Copy the specified array of elements into memory managed by our bump pointer allocator.
T * allocate()
Allocate an instance of the provided type.
Include the generated interface declarations.
static IntegerSetStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
ArrayRef< AffineExpr > constraints
Array of affine constraints: a constraint is either an equality (affine_expr == 0) or an inequality (...
std::tuple< unsigned, unsigned, ArrayRef< AffineExpr >, ArrayRef< bool > > KeyTy
The hash key used for uniquing.
bool operator==(const KeyTy &key) const