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"
17#include "mlir/Support/StorageUniquer.h"
18#include "llvm/ADT/ArrayRef.h"
19
20namespace mlir {
21namespace detail {
22
23struct IntegerSetStorage : public StorageUniquer::BaseStorage {
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).
33 ArrayRef<AffineExpr> constraints;
34
35 // Bits to check whether a constraint is an equality or an inequality.
36 ArrayRef<bool> eqFlags;
37
38 bool operator==(const KeyTy &key) const {
39 return std::get<0>(t: key) == dimCount && std::get<1>(t: key) == symbolCount &&
40 std::get<2>(t: key) == constraints && std::get<3>(t: key) == eqFlags;
41 }
42
43 static IntegerSetStorage *
44 construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key) {
45 auto *res =
46 new (allocator.allocate<IntegerSetStorage>()) IntegerSetStorage();
47 res->dimCount = std::get<0>(t: key);
48 res->symbolCount = std::get<1>(t: key);
49 res->constraints = allocator.copyInto(elements: std::get<2>(t: key));
50 res->eqFlags = allocator.copyInto(elements: std::get<3>(t: key));
51 return res;
52 }
53};
54
55} // namespace detail
56} // namespace mlir
57#endif // INTEGERSETDETAIL_H_
58

source code of mlir/lib/IR/IntegerSetDetail.h