diff options
author | Pruthvi <pruthvi.gowda.thorehosur.appajigowda@intel.com> | 2020-01-13 10:16:44 +0100 |
---|---|---|
committer | Alex Zinenko <zinenko@google.com> | 2020-01-13 10:23:21 +0100 |
commit | 3cad8ada4947dc6793e5af56d6dd0e6eed9e570f (patch) | |
tree | 1be91465e4cf3aa55081e056d09a2d5f89695c94 /mlir | |
parent | 9d3e78e704fa6201bceb48f45fb061f572c5aa2e (diff) | |
download | bcm5719-llvm-3cad8ada4947dc6793e5af56d6dd0e6eed9e570f.tar.gz bcm5719-llvm-3cad8ada4947dc6793e5af56d6dd0e6eed9e570f.zip |
Add zero_extendi and sign_extendi to intrinsic namespace
Summary:
- update zero_extendi and sign_extendi in edsc/intrinsic namespace
- Builder API test for zero_extendi and sign_extendi
Differential Revision: https://reviews.llvm.org/D72298
Diffstat (limited to 'mlir')
-rw-r--r-- | mlir/include/mlir/EDSC/Intrinsics.h | 2 | ||||
-rw-r--r-- | mlir/test/EDSC/builder-api-test.cpp | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index af620a7e545..4e0cda41620 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -213,6 +213,8 @@ using std_store = OperationBuilder<StoreOp>; using subi = ValueBuilder<SubIOp>; using tanh = ValueBuilder<TanhOp>; using view = ValueBuilder<ViewOp>; +using zero_extendi = ValueBuilder<ZeroExtendIOp>; +using sign_extendi = ValueBuilder<SignExtendIOp>; /// Branches into the mlir::Block* captured by BlockHandle `b` with `operands`. /// diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 64e1b7094df..fcd5e37e4ef 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -459,6 +459,32 @@ TEST_FUNC(insertion_in_block) { f.erase(); } +TEST_FUNC(zero_and_sign_extendi_op_i1_to_i8) { + using namespace edsc; + using namespace edsc::intrinsics; + using namespace edsc::op; + auto i1Type = IntegerType::get(1, &globalContext()); + auto i8Type = IntegerType::get(8, &globalContext()); + auto memrefType = MemRefType::get({}, i1Type, {}, 0); + auto f = makeFunction("zero_and_sign_extendi_op", {}, {memrefType, memrefType}); + + OpBuilder builder(f.getBody()); + ScopedContext scope(builder, f.getLoc()); + IndexedValue A(f.getArgument(0)); + IndexedValue B(f.getArgument(1)); + // clang-format off + edsc::intrinsics::zero_extendi(*A, i8Type); + edsc::intrinsics::sign_extendi(*B, i8Type); + // CHECK-LABEL: @zero_and_sign_extendi_op + // CHECK: %[[SRC1:.*]] = affine.load + // CHECK: zexti %[[SRC1]] : i1 to i8 + // CHECK: %[[SRC2:.*]] = affine.load + // CHECK: sexti %[[SRC2]] : i1 to i8 + // clang-format on + f.print(llvm::outs()); + f.erase(); +} + TEST_FUNC(select_op_i32) { using namespace edsc; using namespace edsc::intrinsics; |