[PATCH] D72298: Add zero_extendi and sign_extendi to intrinsic namespace

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 01:24:03 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cad8ada4947: Add zero_extendi and sign_extendi to intrinsic namespace (authored by pruthviIntel, committed by ftynse).
Herald added a subscriber: liufengdb.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72298/new/

https://reviews.llvm.org/D72298

Files:
  mlir/include/mlir/EDSC/Intrinsics.h
  mlir/test/EDSC/builder-api-test.cpp


Index: mlir/test/EDSC/builder-api-test.cpp
===================================================================
--- mlir/test/EDSC/builder-api-test.cpp
+++ mlir/test/EDSC/builder-api-test.cpp
@@ -459,6 +459,32 @@
   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;
Index: mlir/include/mlir/EDSC/Intrinsics.h
===================================================================
--- mlir/include/mlir/EDSC/Intrinsics.h
+++ mlir/include/mlir/EDSC/Intrinsics.h
@@ -213,6 +213,8 @@
 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`.
 ///


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72298.237593.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/e669cfcd/attachment.bin>


More information about the llvm-commits mailing list