Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mlir-sycl/include/mlir/Dialect/SYCL/IR/SYCLOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def SYCLMemref : AnyTypeOf<[
VecMemRef,
]>;
def IndexType : AnyTypeOf<[I32, I64, Index]>;
def IntMemrefType : AnyTypeOf<[MemRefOf<[I32]>]>;
def SYCLGetResult : AnyTypeOf<[I64, MemRefOf<[I64]>]>;
def SYCLGetIDResult : AnyTypeOf<[I64, SYCL_IDType]>;
def SYCLGetRangeResult : AnyTypeOf<[I64, SYCL_RangeType]>;
Expand All @@ -142,7 +143,7 @@ def SYCLGetRangeResult : AnyTypeOf<[I64, SYCL_RangeType]>;
// CONSTRUCTOR OPERATION
////////////////////////////////////////////////////////////////////////////////

def ConstructorArgs : AnyTypeOf<[SYCLMemref, IndexType, SYCL_IDType, SYCL_RangeType]>;
def ConstructorArgs : AnyTypeOf<[SYCLMemref, IndexType, IntMemrefType, SYCL_IDType, SYCL_RangeType]>;
def SYCLConstructorOp : SYCL_Op<"constructor", []> {
let summary = "Generic constructor operation";
let description = [{
Expand All @@ -156,6 +157,8 @@ def SYCLConstructorOp : SYCL_Op<"constructor", []> {
);
let results = (outs);

let hasVerifier = 1;

let assemblyFormat = [{
`(` $Args `)` attr-dict `:` functional-type($Args, results)
}];
Expand Down
10 changes: 10 additions & 0 deletions mlir-sycl/lib/Dialect/IR/SYCLOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "mlir/Dialect/SYCL/IR/SYCLOps.h"

#include "mlir/Dialect/SYCL/IR/SYCLOpsTypes.h"
#include "mlir/IR/OpImplementation.h"
#include "llvm/ADT/TypeSwitch.h"

Expand Down Expand Up @@ -57,6 +58,15 @@ bool mlir::sycl::SYCLCastOp::areCastCompatible(::mlir::TypeRange Inputs,
return false;
}

mlir::LogicalResult mlir::sycl::SYCLConstructorOp::verify() {
auto MT = getOperand(0).getType().dyn_cast<mlir::MemRefType>();
if (MT && isSYCLType(MT.getElementType()))
return success();

return emitOpError("The first argument of a sycl::constructor op has to be a "
"MemRef to a SYCL type");
}

mlir::LogicalResult mlir::sycl::SYCLAccessorSubscriptOp::verify() {
// Available only when: (Dimensions > 0)
// reference operator[](id<Dimensions> index) const;
Expand Down
7 changes: 7 additions & 0 deletions mlir-sycl/test/Dialect/IR/SYCL/constructor.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ func.func @AccessorImplDevice(%arg0: memref<?x!sycl.accessor_impl_device<[1], (!
sycl.constructor(%arg0, %arg1, %arg2, %arg2) {MangledFunctionName = @_ZN4sycl3_V16detail18AccessorImplDeviceILi1EEC1ENS0_2idILi1EEENS0_5rangeILi1EEES7_, TypeName = @AccessorImplDevice} : (memref<?x!sycl.accessor_impl_device<[1], (!sycl.id<1>, !sycl.range<1>, !sycl.range<1>)>>, !sycl.id<1>, !sycl.range<1>, !sycl.range<1>) -> ()
return
}

// Ensure integer pointer can be arguments of sycl.constructor.
// CHECK-LABEL: func.func @TestConstructorII32Ptr
func.func @TestConstructorII32Ptr(%arg0: memref<?x!sycl.id<1>, 4>, %arg1: memref<?xi32, 1>) {
sycl.constructor(%arg0, %arg1) {MangledFunctionName = @_ZN4sycl3_V19multi_ptrIjLNS0_6access13address_spaceE1ELNS2_9decoratedE1EEC1EPU3AS1j, TypeName = @multi_ptr} : (memref<?x!sycl.id<1>, 4>, memref<?xi32, 1>) -> ()
return
}