1 //===- ArmSVEDialect.cpp - MLIR ArmSVE dialect implementation -------------===//
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 file implements the ArmSVE dialect and its operations.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "mlir/Dialect/ArmSVE/ArmSVEDialect.h"
14 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
15 #include "mlir/IR/Builders.h"
16 #include "mlir/IR/DialectImplementation.h"
17 #include "mlir/IR/OpImplementation.h"
18 #include "mlir/IR/TypeUtilities.h"
19 #include "llvm/ADT/TypeSwitch.h"
20 
21 using namespace mlir;
22 using namespace mlir::arm_sve;
23 
24 //===----------------------------------------------------------------------===//
25 // ScalableVector versions of general helpers for comparison ops
26 //===----------------------------------------------------------------------===//
27 
28 /// Return the scalable vector of the same shape and containing i1.
getI1SameShape(Type type)29 static Type getI1SameShape(Type type) {
30   auto i1Type = IntegerType::get(type.getContext(), 1);
31   if (auto sVectorType = type.dyn_cast<VectorType>())
32     return VectorType::get(sVectorType.getShape(), i1Type,
33                            sVectorType.getNumScalableDims());
34   return nullptr;
35 }
36 
37 //===----------------------------------------------------------------------===//
38 // Tablegen Definitions
39 //===----------------------------------------------------------------------===//
40 
41 #include "mlir/Dialect/ArmSVE/ArmSVEDialect.cpp.inc"
42 
43 #define GET_OP_CLASSES
44 #include "mlir/Dialect/ArmSVE/ArmSVE.cpp.inc"
45 
46 #define GET_TYPEDEF_CLASSES
47 #include "mlir/Dialect/ArmSVE/ArmSVETypes.cpp.inc"
48 
initialize()49 void ArmSVEDialect::initialize() {
50   addOperations<
51 #define GET_OP_LIST
52 #include "mlir/Dialect/ArmSVE/ArmSVE.cpp.inc"
53       >();
54 }
55