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