MLIR  20.0.0git
PtrAttrs.cpp
Go to the documentation of this file.
1 //===- PtrAttrs.cpp - Pointer dialect attributes ----------------*- C++ -*-===//
2 //
3 // This file is licensed 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 file defines the Ptr dialect attributes.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/TypeSwitch.h"
15 
16 using namespace mlir;
17 using namespace mlir::ptr;
18 
19 constexpr const static unsigned kBitsInByte = 8;
20 
21 //===----------------------------------------------------------------------===//
22 // SpecAttr
23 //===----------------------------------------------------------------------===//
24 
26  uint32_t size, uint32_t abi, uint32_t preferred,
27  uint32_t index) {
28  if (size % kBitsInByte != 0)
29  return emitError() << "size entry must be divisible by 8";
30  if (abi % kBitsInByte != 0)
31  return emitError() << "abi entry must be divisible by 8";
32  if (preferred % kBitsInByte != 0)
33  return emitError() << "preferred entry must be divisible by 8";
34  if (index != kOptionalSpecValue && index % kBitsInByte != 0)
35  return emitError() << "index entry must be divisible by 8";
36  if (abi > preferred)
37  return emitError() << "preferred alignment is expected to be at least "
38  "as large as ABI alignment";
39  return success();
40 }
constexpr static const unsigned kBitsInByte
Definition: PtrAttrs.cpp:19
This class represents a diagnostic that is inflight and set to be reported.
Definition: Diagnostics.h:314
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
Definition: Verifier.cpp:426