MLIR 22.0.0git
BuiltinTypeInterfaces.cpp
Go to the documentation of this file.
1//===- BuiltinTypeInterfaces.cpp ------------------------------------------===//
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
10#include "llvm/ADT/APFloat.h"
11
12using namespace mlir;
13using namespace mlir::detail;
14
15//===----------------------------------------------------------------------===//
16/// Tablegen Interface Definitions
17//===----------------------------------------------------------------------===//
18
19#include "mlir/IR/BuiltinTypeInterfaces.cpp.inc"
20
21//===----------------------------------------------------------------------===//
22// FloatType
23//===----------------------------------------------------------------------===//
24
25unsigned FloatType::getWidth() {
26 return APFloat::semanticsSizeInBits(getFloatSemantics());
27}
28
29unsigned FloatType::getFPMantissaWidth() {
30 return APFloat::semanticsPrecision(getFloatSemantics());
31}
32
33//===----------------------------------------------------------------------===//
34// ShapedType
35//===----------------------------------------------------------------------===//
36
37int64_t ShapedType::getNumElements(ArrayRef<int64_t> shape) {
38 int64_t num = 1;
39 for (int64_t dim : shape) {
40 num *= dim;
41 assert(num >= 0 && "integer overflow in element count computation");
42 }
43 return num;
44}
AttrTypeReplacer.
Include the generated interface declarations.