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/Vector/VectorOps.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 23 void arm_sve::ArmSVEDialect::initialize() { 24 addOperations< 25 #define GET_OP_LIST 26 #include "mlir/Dialect/ArmSVE/ArmSVE.cpp.inc" 27 >(); 28 addTypes< 29 #define GET_TYPEDEF_LIST 30 #include "mlir/Dialect/ArmSVE/ArmSVETypes.cpp.inc" 31 >(); 32 } 33 34 #define GET_OP_CLASSES 35 #include "mlir/Dialect/ArmSVE/ArmSVE.cpp.inc" 36 37 #define GET_TYPEDEF_CLASSES 38 #include "mlir/Dialect/ArmSVE/ArmSVETypes.cpp.inc" 39 40 //===----------------------------------------------------------------------===// 41 // ScalableVectorType 42 //===----------------------------------------------------------------------===// 43 44 Type arm_sve::ArmSVEDialect::parseType(DialectAsmParser &parser) const { 45 llvm::SMLoc typeLoc = parser.getCurrentLocation(); 46 { 47 Type genType; 48 auto parseResult = generatedTypeParser(parser.getBuilder().getContext(), 49 parser, "vector", genType); 50 if (parseResult.hasValue()) 51 return genType; 52 } 53 parser.emitError(typeLoc, "unknown type in ArmSVE dialect"); 54 return Type(); 55 } 56 57 void arm_sve::ArmSVEDialect::printType(Type type, DialectAsmPrinter &os) const { 58 if (failed(generatedTypePrinter(type, os))) 59 llvm_unreachable("unexpected 'arm_sve' type kind"); 60 } 61