diff options
author | Tyker <tyker1@outlook.com> | 2022-09-09 08:26:06 -0700 |
---|---|---|
committer | Tyker <tyker1@outlook.com> | 2022-09-09 08:55:05 -0700 |
commit | fa40fd40e055630c34890de84eb048796133fe03 (patch) | |
tree | b6ace49239c748af9dea154b0a4c75f4a4c8ecf4 /mlir/unittests/IR | |
parent | d1fe5cf5224ee1ee0498533f5a299e3b49bcde45 (diff) | |
download | llvm-fa40fd40e055630c34890de84eb048796133fe03.tar.gz |
[MLIR] Improve interaction of TypedValue with BlockAndValueMapping
Diffstat (limited to 'mlir/unittests/IR')
-rw-r--r-- | mlir/unittests/IR/BlockAndValueMapping.cpp | 34 | ||||
-rw-r--r-- | mlir/unittests/IR/CMakeLists.txt | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/mlir/unittests/IR/BlockAndValueMapping.cpp b/mlir/unittests/IR/BlockAndValueMapping.cpp new file mode 100644 index 000000000000..dad3c915c5b9 --- /dev/null +++ b/mlir/unittests/IR/BlockAndValueMapping.cpp @@ -0,0 +1,34 @@ +//===- BlockAndValueMapping.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/IR/BlockAndValueMapping.h" +#include "mlir/IR/Builders.h" +#include "gtest/gtest.h" + +#include "../../test/lib/Dialect/Test/TestDialect.h" + +using namespace mlir; + +TEST(BlockAndValueMapping, TypedValue) { + MLIRContext context; + + context.loadDialect<test::TestDialect>(); + + OpBuilder builder(&context); + Location loc = builder.getUnknownLoc(); + + Value i64Val = builder.create<test::TestOpConstant>( + loc, builder.getI64Type(), builder.getI64IntegerAttr(0)); + Value f64Val = builder.create<test::TestOpConstant>( + loc, builder.getF64Type(), builder.getF64FloatAttr(0.0)); + + BlockAndValueMapping mapping; + mapping.map(i64Val, f64Val); + TypedValue<IntegerType> typedI64Val = i64Val; + mapping.lookup(typedI64Val); +} diff --git a/mlir/unittests/IR/CMakeLists.txt b/mlir/unittests/IR/CMakeLists.txt index 51978aea6e88..904ea13447bb 100644 --- a/mlir/unittests/IR/CMakeLists.txt +++ b/mlir/unittests/IR/CMakeLists.txt @@ -1,5 +1,6 @@ add_mlir_unittest(MLIRIRTests AttributeTest.cpp + BlockAndValueMapping.cpp DialectTest.cpp InterfaceTest.cpp InterfaceAttachmentTest.cpp |