Skip to content

Commit 5e83afd

Browse files
committed
Add ArmSME type conversion unit test
1 parent 8b74abf commit 5e83afd

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_mlir_unittest(MLIRArmSMETests
2+
TileTypeConversionTest.cpp)
3+
target_link_libraries(MLIRArmSMETests
4+
PRIVATE
5+
MLIRArmSMEToLLVM)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===- TileTypeConversionTest.cpp - Tests ArmSME tile type conversion -----===//
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+
#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"
14+
15+
#include "gtest/gtest.h"
16+
17+
using namespace mlir;
18+
19+
class ArmSMETest : public ::testing::Test {
20+
protected:
21+
ArmSMETest() { context.getOrLoadDialect<mlir::arm_sme::ArmSMEDialect>(); }
22+
23+
mlir::MLIRContext context;
24+
};
25+
26+
TEST_F(ArmSMETest, TestTileTypeConversion) {
27+
LLVMTypeConverter llvmConverer(&context);
28+
LLVMTypeConverter llvmConvererWithArmSMEConversion(&context);
29+
30+
RewritePatternSet patterns(&context);
31+
populateArmSMEToLLVMConversionPatterns(llvmConvererWithArmSMEConversion,
32+
patterns);
33+
34+
Type i32 = IntegerType::get(&context, 32);
35+
auto smeTileType = VectorType::get({4, 4}, i32, {true, true});
36+
37+
// An unmodified LLVMTypeConverer should fail to convert an ArmSME tile type.
38+
{
39+
SmallVector<Type> convertedType;
40+
ASSERT_TRUE(failed(llvmConverer.convertType(smeTileType, convertedType)));
41+
}
42+
43+
// An updated LLVMTypeConverer should return the ArmSME tile vector type
44+
// unchanged.
45+
{
46+
SmallVector<Type> convertedType;
47+
ASSERT_TRUE(succeeded(llvmConvererWithArmSMEConversion.convertType(
48+
smeTileType, convertedType)));
49+
ASSERT_EQ(ArrayRef<Type>(convertedType), ArrayRef<Type>{smeTileType});
50+
}
51+
}

mlir/unittests/Dialect/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ target_link_libraries(MLIRDialectTests
66
MLIRIR
77
MLIRDialect)
88

9+
add_subdirectory(ArmSME)
910
add_subdirectory(Index)
1011
add_subdirectory(LLVMIR)
1112
add_subdirectory(MemRef)

0 commit comments

Comments
 (0)