1 //===- TileTypeConversionTest.cpp - Tests ArmSME tile type conversion -----===//
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
7 //===----------------------------------------------------------------------===//
9 #include "mlir/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.h"
10 #include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
11 #include "mlir/Conversion/LLVMCommon/Pattern.h"
12 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
13 #include "mlir/Dialect/ArmSME/IR/ArmSME.h"
15 #include "gtest/gtest.h"
19 class ArmSMETest
: public ::testing::Test
{
21 ArmSMETest() { context
.getOrLoadDialect
<mlir::arm_sme::ArmSMEDialect
>(); }
23 mlir::MLIRContext context
;
26 TEST_F(ArmSMETest
, TestTileTypeConversion
) {
27 LLVMTypeConverter
llvmConverter(&context
);
28 LLVMTypeConverter
llvmConverterWithArmSMEConversion(&context
);
30 RewritePatternSet
patterns(&context
);
31 populateArmSMEToLLVMConversionPatterns(llvmConverterWithArmSMEConversion
,
34 Type i32
= IntegerType::get(&context
, 32);
35 auto smeTileType
= VectorType::get({4, 4}, i32
, {true, true});
37 // An unmodified LLVMTypeConverer should fail to convert an ArmSME tile type.
39 SmallVector
<Type
> convertedType
;
40 ASSERT_TRUE(failed(llvmConverter
.convertType(smeTileType
, convertedType
)));
43 // An updated LLVMTypeConverer should return the ArmSME tile vector type
46 SmallVector
<Type
> convertedType
;
47 ASSERT_TRUE(succeeded(llvmConverterWithArmSMEConversion
.convertType(
48 smeTileType
, convertedType
)));
49 ASSERT_EQ(ArrayRef
<Type
>(convertedType
), ArrayRef
<Type
>{smeTileType
});