diff --git a/bindings/python/pyiree/status_utils.cc b/bindings/python/pyiree/status_utils.cc index 9e3e91dd2cc9..09dcdeadeda4 100644 --- a/bindings/python/pyiree/status_utils.cc +++ b/bindings/python/pyiree/status_utils.cc @@ -57,7 +57,7 @@ pybind11::error_already_set StatusToPyExc(const Status& status) { pybind11::error_already_set ApiStatusToPyExc(iree_status_t status, const char* message) { - assert(status != IREE_STATUS_OK); + assert(!iree_status_is_ok(status)); auto full_message = absl::StrCat(message, ": ", static_cast(status)); PyErr_SetString(ApiStatusToPyExcClass(status), full_message.c_str()); return pybind11::error_already_set(); diff --git a/bindings/python/pyiree/status_utils.h b/bindings/python/pyiree/status_utils.h index 34d77a668f53..23559b506a5a 100644 --- a/bindings/python/pyiree/status_utils.h +++ b/bindings/python/pyiree/status_utils.h @@ -57,7 +57,7 @@ pybind11::error_already_set ApiStatusToPyExc(iree_status_t status, const char* message); inline void CheckApiStatus(iree_status_t status, const char* message) { - if (status == IREE_STATUS_OK) { + if (iree_status_is_ok(status)) { return; } throw ApiStatusToPyExc(status, message); diff --git a/bindings/python/pyiree/vm.cc b/bindings/python/pyiree/vm.cc index 620ccff35bdc..a969159c8322 100644 --- a/bindings/python/pyiree/vm.cc +++ b/bindings/python/pyiree/vm.cc @@ -99,7 +99,7 @@ std::unique_ptr VmContext::CreateFunctionAbi( attrs.push_back({}); auto status = iree_vm_get_function_reflection_attr( f, i, &attrs.back().first, &attrs.back().second); - if (status == IREE_STATUS_NOT_FOUND) { + if (iree_status_is_not_found(status)) { attrs.pop_back(); break; } @@ -137,7 +137,7 @@ VmModule VmModule::FromFlatbufferBlob( {static_cast(flatbuffer_blob->data()), flatbuffer_blob->size()}, deallocator, IREE_ALLOCATOR_SYSTEM, &module); - if (status != IREE_STATUS_OK) { + if (!iree_status_is_ok(status)) { deallocator.free(deallocator.self, nullptr); } @@ -150,7 +150,7 @@ absl::optional VmModule::LookupFunction( iree_vm_function_t f; auto status = iree_vm_module_lookup_function_by_name( raw_ptr(), linkage, {name.data(), name.size()}, &f); - if (status == IREE_STATUS_NOT_FOUND) { + if (iree_status_is_not_found(status)) { return absl::nullopt; } CheckApiStatus(status, "Error looking up function"); @@ -194,8 +194,8 @@ std::string VmVariantList::DebugString() const { } void SetupVmBindings(pybind11::module m) { - CHECK_EQ(IREE_STATUS_OK, iree_vm_register_builtin_types()); - CHECK_EQ(IREE_STATUS_OK, iree_hal_module_register_types()); + IREE_CHECK_OK(iree_vm_register_builtin_types()); + IREE_CHECK_OK(iree_hal_module_register_types()); // Built-in module creation. m.def("create_hal_module", &CreateHalModule); diff --git a/iree/base/api.h b/iree/base/api.h index b5dfe3ab6cf7..4cf13035155f 100644 --- a/iree/base/api.h +++ b/iree/base/api.h @@ -39,7 +39,7 @@ // iree_status_t status = \ // ((PFN_iree_api_version_check)dlsym(library, "iree_api_version_check"))( // IREE_API_VERSION_LATEST, &actual_version); -// if (status != IREE_STATUS_OK) { +// if (!iree_status_is_ok(status)) { // LOG(FATAL) << "Unsupported runtime API version " << actual_version; // } // dlclose(library); @@ -230,6 +230,52 @@ typedef struct iree_file_mapping iree_file_mapping_t; // Error handling macros //===----------------------------------------------------------------------===// +// TODO(GH-265): string formatting constructors. +// TODO(GH-265): payload support (custom stack traces, etc). + +// TODO(GH-265): replace status with a composite struct. +#define iree_status_code(value) (value) + +// Macros to check the value of a status code. +#define iree_status_is_ok(value) (iree_status_code(value) == IREE_STATUS_OK) +#define iree_status_is_cancelled(value) \ + (iree_status_code(value) == IREE_STATUS_CANCELLED) +#define iree_status_is_unknown(value) \ + (iree_status_code(value) == IREE_STATUS_UNKNOWN) +#define iree_status_is_invalid_argument(value) \ + (iree_status_code(value) == IREE_STATUS_INVALID_ARGUMENT) +#define iree_status_is_deadline_exceeded(value) \ + (iree_status_code(value) == IREE_STATUS_DEADLINE_EXCEEDED) +#define iree_status_is_not_found(value) \ + (iree_status_code(value) == IREE_STATUS_NOT_FOUND) +#define iree_status_is_already_exists(value) \ + (iree_status_code(value) == IREE_STATUS_ALREADY_EXISTS) +#define iree_status_is_permission_denied(value) \ + (iree_status_code(value) == IREE_STATUS_PERMISSION_DENIED) +#define iree_status_is_resource_exhausted(value) \ + (iree_status_code(value) == IREE_STATUS_RESOURCE_EXHAUSTED) +#define iree_status_is_failed_precondition(value) \ + (iree_status_code(value) == IREE_STATUS_FAILED_PRECONDITION) +#define iree_status_is_aborted(value) \ + (iree_status_code(value) == IREE_STATUS_ABORTED) +#define iree_status_is_out_of_range(value) \ + (iree_status_code(value) == IREE_STATUS_OUT_OF_RANGE) +#define iree_status_is_unimplemented(value) \ + (iree_status_code(value) == IREE_STATUS_UNIMPLEMENTED) +#define iree_status_is_internal(value) \ + (iree_status_code(value) == IREE_STATUS_INTERNAL) +#define iree_status_is_unavailable(value) \ + (iree_status_code(value) == IREE_STATUS_UNAVAILABLE) +#define iree_status_is_data_loss(value) \ + (iree_status_code(value) == IREE_STATUS_DATA_LOSS) +#define iree_status_is_unauthenticated(value) \ + (iree_status_code(value) == IREE_STATUS_UNAUTHENTICATED) + +// TODO(GH-265): better logging of status checks. +#define IREE_CHECK_OK(expr) CHECK_EQ(IREE_STATUS_OK, iree_status_code(expr)) +#define IREE_ASSERT_OK(expr) ASSERT_EQ(IREE_STATUS_OK, iree_status_code(expr)) +#define IREE_EXPECT_OK(expr) EXPECT_EQ(IREE_STATUS_OK, iree_status_code(expr)) + #define IREE_API_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) x##y #define IREE_API_STATUS_MACROS_IMPL_CONCAT_(x, y) \ IREE_API_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) @@ -237,16 +283,17 @@ typedef struct iree_file_mapping iree_file_mapping_t; iree_status_t var = (expr); \ if (var) return var; +// TODO(GH-265): variadic arguments to support appending strings. // Propagates the error returned by (expr) by returning from the current // function on non-OK status. // // Example: // iree_status_t OtherFunc(...); // iree_status_t MyFunc(...) { -// IREE_API_RETURN_IF_API_ERROR(OtherFunc(...)); +// IREE_RETURN_IF_ERROR(OtherFunc(...)); // return IREE_STATUS_OK; // } -#define IREE_API_RETURN_IF_API_ERROR(expr) \ +#define IREE_RETURN_IF_ERROR(expr) \ IREE_API_STATUS_MACROS_IMPL_RETURN_IF_API_ERROR_( \ IREE_API_STATUS_MACROS_IMPL_CONCAT_(__status_, __COUNTER__), (expr)) @@ -333,12 +380,6 @@ IREE_API_EXPORT int IREE_API_CALL iree_string_view_split( #endif // IREE_API_NO_PROTOTYPES -//===----------------------------------------------------------------------===// -// iree::Shape -//===----------------------------------------------------------------------===// - -// TODO(benvanik): shape functions. - //===----------------------------------------------------------------------===// // iree::FileMapping //===----------------------------------------------------------------------===// diff --git a/iree/base/api_util.h b/iree/base/api_util.h index a25085d868e2..9baa1ab4b5fb 100644 --- a/iree/base/api_util.h +++ b/iree/base/api_util.h @@ -131,10 +131,10 @@ absl::InlinedVector QueryListValues( absl::InlinedVector values(4); iree_host_size_t count = 0; iree_status_t status = fn(args..., values.size(), values.data(), &count); - if (status == IREE_STATUS_OUT_OF_RANGE) { + if (iree_status_is_out_of_range(status)) { values.resize(count); status = fn(args..., values.size(), values.data(), &count); - } else if (status != IREE_STATUS_OK) { + } else if (!iree_status_is_ok(status)) { return {}; } values.resize(count); diff --git a/iree/compiler/CMakeLists.txt b/iree/compiler/CMakeLists.txt index d929bc298c43..f2aa4ed134aa 100644 --- a/iree/compiler/CMakeLists.txt +++ b/iree/compiler/CMakeLists.txt @@ -13,8 +13,5 @@ # limitations under the License. add_subdirectory(Dialect) -add_subdirectory(IR) -add_subdirectory(Serialization) -add_subdirectory(Transforms) add_subdirectory(Translation) add_subdirectory(Utils) diff --git a/iree/compiler/Dialect/CMakeLists.txt b/iree/compiler/Dialect/CMakeLists.txt index c226c7c7dec2..c8a2dbd202d6 100644 --- a/iree/compiler/Dialect/CMakeLists.txt +++ b/iree/compiler/Dialect/CMakeLists.txt @@ -15,5 +15,4 @@ add_subdirectory(Flow) add_subdirectory(HAL) add_subdirectory(IREE) -#add_subdirectory(Interpreter) add_subdirectory(VM) diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/stream_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/stream_ops.mlir index 95b6e9dddb40..e2dd431b4369 100644 --- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/stream_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/stream_ops.mlir @@ -15,16 +15,16 @@ func @multipleDispatches(%arg0: tensor<128xf32>) -> tensor<128xf32> { %cst = constant dense<[128, 1, 1]> : vector<3xi32> // CHECK: [[RET_BUF:%.+]] = hal.allocator.allocate.shaped {{.+}}, "HostVisible|DeviceVisible|DeviceLocal", "Constant|Transfer|Mapping|Dispatch", shape=[ // CHECK-SAME: [[C128]] - // CHECK-SAME: ], element_size=4 : !ireex.ref + // CHECK-SAME: ], element_size=4 : !iree.ref // CHECK-NEXT: hal.ex.defer_release [[RET_BUF]] // CHECK-NEXT: [[TMP_BUF:%.+]] = hal.allocator.allocate.shaped {{.+}}, "DeviceVisible|DeviceLocal", "Transfer|Dispatch", shape=[ // CHECK-SAME: [[C128]] - // CHECK-SAME: ], element_size=4 : !ireex.ref + // CHECK-SAME: ], element_size=4 : !iree.ref // CHECK-NEXT: hal.ex.defer_release [[TMP_BUF]] // CHECK-NEXT: [[CMD:%.+]] = hal.command_buffer.create {{.+}}, "OneShot", "Transfer|Dispatch" // CHECK-NEXT: hal.command_buffer.begin [[CMD]] %0 = flow.ex.stream.fragment(%arg1 = %cst : vector<3xi32>, %arg2 = %arg0 : tensor<128xf32>) -> tensor<128xf32> { - // CHECK: [[EXE:%.+]] = hal.ex.cache_executable {{.+}}, @ex0 : !ireex.ref + // CHECK: [[EXE:%.+]] = hal.ex.cache_executable {{.+}}, @ex0 : !iree.ref // CHECK-NEXT: hal.ex.push_binding [[CMD]], 0, %arg0, shape=[ // CHECK-SAME: [[C128]] // CHECK-SAME: ], element_size=4 diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/structural_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/structural_ops.mlir index 79d512ec4c60..252d89643a74 100644 --- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/structural_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/structural_ops.mlir @@ -1,11 +1,11 @@ // RUN: iree-opt -split-input-file -iree-convert-flow-to-hal %s | IreeFileCheck %s -// CHECK-LABEL: func @tensorIO(%arg0: !ireex.ref) -> !ireex.ref +// CHECK-LABEL: func @tensorIO(%arg0: !iree.ref) -> !iree.ref func @tensorIO(%arg0 : tensor<1x1xi32>) -> tensor<1x1xi32> { - // CHECK-NEXT: br ^bb1(%arg0 : !ireex.ref) + // CHECK-NEXT: br ^bb1(%arg0 : !iree.ref) br ^bb1(%arg0 : tensor<1x1xi32>) -// CHECK-NEXT: ^bb1([[BB0:%.+]]: !ireex.ref) +// CHECK-NEXT: ^bb1([[BB0:%.+]]: !iree.ref) ^bb1(%0 : tensor<1x1xi32>): - // CHECK-NEXT: return [[BB0]] : !ireex.ref + // CHECK-NEXT: return [[BB0]] : !iree.ref return %0 : tensor<1x1xi32> } diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/variable_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/variable_ops.mlir index 1d3039d8f3eb..964ada0e6a59 100644 --- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/variable_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/variable_ops.mlir @@ -1,23 +1,23 @@ // RUN: iree-opt -split-input-file -iree-convert-flow-to-hal -verify-diagnostics %s | IreeFileCheck %s -// CHECK-LABEL: hal.variable @var_i32 mutable : !ireex.ref +// CHECK-LABEL: hal.variable @var_i32 mutable : !iree.ref flow.variable @var_i32 mutable : tensor func @fn() { - // CHECK: [[V:%.+]] = hal.variable.load @var_i32 : !ireex.ref + // CHECK: [[V:%.+]] = hal.variable.load @var_i32 : !iree.ref %0 = flow.variable.load @var_i32 : tensor - // CHECK-NEXT: hal.variable.store [[V]], @var_i32 : !ireex.ref + // CHECK-NEXT: hal.variable.store [[V]], @var_i32 : !iree.ref flow.variable.store %0, @var_i32 : tensor return } // ----- -// CHECK-LABEL: hal.variable @var_i1 mutable : !ireex.ref +// CHECK-LABEL: hal.variable @var_i1 mutable : !iree.ref flow.variable @var_i1 mutable : tensor func @fn() { - // CHECK: [[V:%.+]] = hal.variable.load @var_i1 : !ireex.ref + // CHECK: [[V:%.+]] = hal.variable.load @var_i1 : !iree.ref %0 = flow.variable.load @var_i1 : tensor - // CHECK-NEXT: hal.variable.store [[V]], @var_i1 : !ireex.ref + // CHECK-NEXT: hal.variable.store [[V]], @var_i1 : !iree.ref flow.variable.store %0, @var_i1 : tensor return } @@ -25,10 +25,10 @@ func @fn() { // ----- // Checks that an initializer function is generated, used and operates on // a hal.buffer (versus tensor). -// CHECK-LABEL: func @__var_with_tensor_initializer_initializer() -> !ireex.ref +// CHECK-LABEL: func @__var_with_tensor_initializer_initializer() -> !iree.ref // CHECK: hal.variable @var_with_tensor_initializer // CHECK-SAME: init(@__var_with_tensor_initializer_initializer) -// CHECK-SAME: : !ireex.ref +// CHECK-SAME: : !iree.ref flow.variable @var_with_tensor_initializer mutable dense<0.000000e+00> : tensor func @fn() { %0 = flow.variable.load @var_with_tensor_initializer : tensor diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir index b1b05285efdb..471ab95ffde1 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir @@ -1,9 +1,9 @@ // RUN: iree-opt -split-input-file -iree-convert-hal-to-vm %s | IreeFileCheck %s // CHECK-LABEL: @allocatorComputeSize -func @allocatorComputeSize(%arg0 : !ireex.ref) -> i32 { +func @allocatorComputeSize(%arg0 : !iree.ref) -> i32 { %c1024_i32 = constant 1024 : i32 - // CHECK: %0 = vm.call.variadic @hal.allocator.compute_size(%arg0, %c6, %c15, [%c1024, %c1024], %c4) : (!ireex.ref, i32, i32, i32..., i32) -> i32 + // CHECK: %0 = vm.call.variadic @hal.allocator.compute_size(%arg0, %c6, %c15, [%c1024, %c1024], %c4) : (!iree.ref, i32, i32, i32..., i32) -> i32 %0 = hal.allocator.compute_size %arg0, "HostLocal", "All", shape=[%c1024_i32, %c1024_i32], element_size=4 return %0 : i32 } @@ -11,31 +11,31 @@ func @allocatorComputeSize(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @allocatorAllocate -func @allocatorAllocate(%arg0 : !ireex.ref) -> !ireex.ref { +func @allocatorAllocate(%arg0 : !iree.ref) -> !iree.ref { %c1024_i32 = constant 1024 : i32 - // CHECK: %ref = vm.call @hal.allocator.allocate(%arg0, %c6, %c15, %c1024) : (!ireex.ref, i32, i32, i32) -> !ireex.ref - %0 = hal.allocator.allocate %arg0, "HostLocal", "All", %c1024_i32 : !ireex.ref - return %0 : !ireex.ref + // CHECK: %ref = vm.call @hal.allocator.allocate(%arg0, %c6, %c15, %c1024) : (!iree.ref, i32, i32, i32) -> !iree.ref + %0 = hal.allocator.allocate %arg0, "HostLocal", "All", %c1024_i32 : !iree.ref + return %0 : !iree.ref } // ----- // CHECK: vm.rodata @allocatorAllocateConst_const_0 dense<123> : tensor<4x4xi32> // CHECK-LABEL: func @allocatorAllocateConst -func @allocatorAllocateConst() -> !ireex.ref { - %allocator = "test_hal.allocator"() : () -> !ireex.ref - // CHECK: %allocatorAllocateConst_const_0 = vm.const.ref.rodata @allocatorAllocateConst_const_0 : !ireex.byte_buffer_ref - // CHECK: %ref = vm.call.variadic @hal.allocator.allocate.const(%0, %c6, %c2, [%c4, %c4_0], %c4_1, %allocatorAllocateConst_const_0) : (!ireex.ref, i32, i32, i32..., i32, !ireex.byte_buffer_ref) -> !ireex.ref - %buffer = hal.allocator.allocate.const %allocator, "HostVisible|HostCoherent", "Transfer" : !ireex.ref = dense<123> : tensor<4x4xi32> - return %buffer : !ireex.ref +func @allocatorAllocateConst() -> !iree.ref { + %allocator = "test_hal.allocator"() : () -> !iree.ref + // CHECK: %allocatorAllocateConst_const_0 = vm.const.ref.rodata @allocatorAllocateConst_const_0 : !iree.byte_buffer_ref + // CHECK: %ref = vm.call.variadic @hal.allocator.allocate.const(%0, %c6, %c2, [%c4, %c4_0], %c4_1, %allocatorAllocateConst_const_0) : (!iree.ref, i32, i32, i32..., i32, !iree.byte_buffer_ref) -> !iree.ref + %buffer = hal.allocator.allocate.const %allocator, "HostVisible|HostCoherent", "Transfer" : !iree.ref = dense<123> : tensor<4x4xi32> + return %buffer : !iree.ref } // ----- // CHECK-LABEL: @allocatorAllocateShaped -func @allocatorAllocateShaped(%arg0 : !ireex.ref) -> !ireex.ref { +func @allocatorAllocateShaped(%arg0 : !iree.ref) -> !iree.ref { %c1024_i32 = constant 1024 : i32 - // CHECK: %ref = vm.call.variadic @hal.allocator.allocate.shaped(%arg0, %c6, %c15, [%c1024, %c1024], %c4) : (!ireex.ref, i32, i32, i32..., i32) -> !ireex.ref - %0 = hal.allocator.allocate.shaped %arg0, "HostLocal", "All", shape=[%c1024_i32, %c1024_i32], element_size=4 : !ireex.ref - return %0 : !ireex.ref + // CHECK: %ref = vm.call.variadic @hal.allocator.allocate.shaped(%arg0, %c6, %c15, [%c1024, %c1024], %c4) : (!iree.ref, i32, i32, i32..., i32) -> !iree.ref + %0 = hal.allocator.allocate.shaped %arg0, "HostLocal", "All", shape=[%c1024_i32, %c1024_i32], element_size=4 : !iree.ref + return %0 : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/buffer_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/buffer_ops.mlir index ff5705bf8b25..f571176a175a 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/buffer_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/buffer_ops.mlir @@ -1,23 +1,23 @@ // RUN: iree-opt -split-input-file -iree-convert-hal-to-vm %s | IreeFileCheck %s // CHECK-LABEL: @buffer_subspan -func @buffer_subspan() -> !ireex.ref { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @buffer_subspan() -> !iree.ref { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 - // CHECK: %ref = vm.call @hal.buffer.subspan(%0, %1, %2) : (!ireex.ref, i32, i32) -> !ireex.ref - %buffer = hal.buffer.subspan %0, %1, %2 : !ireex.ref - return %buffer : !ireex.ref + // CHECK: %ref = vm.call @hal.buffer.subspan(%0, %1, %2) : (!iree.ref, i32, i32) -> !iree.ref + %buffer = hal.buffer.subspan %0, %1, %2 : !iree.ref + return %buffer : !iree.ref } // ----- // CHECK-LABEL: @buffer_fill -func @buffer_fill(%arg0 : !ireex.ref) { +func @buffer_fill(%arg0 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.pattern"() : () -> i32 - // CHECK: vm.call @hal.buffer.fill(%arg0, %0, %1, %2) : (!ireex.ref, i32, i32, i32) -> () + // CHECK: vm.call @hal.buffer.fill(%arg0, %0, %1, %2) : (!iree.ref, i32, i32, i32) -> () hal.buffer.fill %arg0, %0, %1, %2 return } @@ -25,37 +25,37 @@ func @buffer_fill(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @buffer_read_data -func @buffer_read_data(%arg0 : !ireex.ref) { +func @buffer_read_data(%arg0 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 - %1 = "test_hal.mutable_data"() : () -> !ireex.mutable_byte_buffer_ref + %1 = "test_hal.mutable_data"() : () -> !iree.mutable_byte_buffer_ref %2 = "test_hal.device_size"() : () -> i32 %3 = "test_hal.device_size"() : () -> i32 - // CHECK: vm.call @hal.buffer.read_data(%arg0, %0, %1, %2, %3) : (!ireex.ref, i32, !ireex.mutable_byte_buffer_ref, i32, i32) -> () - hal.buffer.read_data %arg0, %0, %1, %2, %3 : !ireex.mutable_byte_buffer_ref + // CHECK: vm.call @hal.buffer.read_data(%arg0, %0, %1, %2, %3) : (!iree.ref, i32, !iree.mutable_byte_buffer_ref, i32, i32) -> () + hal.buffer.read_data %arg0, %0, %1, %2, %3 : !iree.mutable_byte_buffer_ref return } // ----- // CHECK-LABEL: @buffer_write_data -func @buffer_write_data(%arg0 : !ireex.ref) { - %0 = "test_hal.mutable_data"() : () -> !ireex.mutable_byte_buffer_ref +func @buffer_write_data(%arg0 : !iree.ref) { + %0 = "test_hal.mutable_data"() : () -> !iree.mutable_byte_buffer_ref %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 %3 = "test_hal.device_size"() : () -> i32 - // CHECK: vm.call @hal.buffer.write_data(%0, %1, %arg0, %2, %3) : (!ireex.mutable_byte_buffer_ref, i32, !ireex.ref, i32, i32) -> () - hal.buffer.write_data %0, %1, %arg0, %2, %3 : !ireex.mutable_byte_buffer_ref + // CHECK: vm.call @hal.buffer.write_data(%0, %1, %arg0, %2, %3) : (!iree.mutable_byte_buffer_ref, i32, !iree.ref, i32, i32) -> () + hal.buffer.write_data %0, %1, %arg0, %2, %3 : !iree.mutable_byte_buffer_ref return } // ----- // CHECK-LABEL: @buffer_copy_data -func @buffer_copy_data(%arg0 : !ireex.ref, %arg1 : !ireex.ref) { +func @buffer_copy_data(%arg0 : !iree.ref, %arg1 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 - // CHECK: vm.call @hal.buffer.copy_data(%arg0, %0, %arg1, %1, %2) : (!ireex.ref, i32, !ireex.ref, i32, i32) -> () + // CHECK: vm.call @hal.buffer.copy_data(%arg0, %0, %arg1, %1, %2) : (!iree.ref, i32, !iree.ref, i32, i32) -> () hal.buffer.copy_data %arg0, %0, %arg1, %1, %2 return } @@ -63,13 +63,13 @@ func @buffer_copy_data(%arg0 : !ireex.ref, %arg1 : !ireex.ref) -> (i8, i16, i32) { +func @buffer_load(%arg0 : !iree.ref) -> (i8, i16, i32) { %0 = "test_hal.device_size"() : () -> i32 - // CHECK: %1 = vm.call @hal.buffer.load(%arg0, %0, %c1) : (!ireex.ref, i32, i32) -> i32 + // CHECK: %1 = vm.call @hal.buffer.load(%arg0, %0, %c1) : (!iree.ref, i32, i32) -> i32 %1 = hal.buffer.load %arg0[%0] : i8 - // CHECK: %2 = vm.call @hal.buffer.load(%arg0, %0, %c2) : (!ireex.ref, i32, i32) -> i32 + // CHECK: %2 = vm.call @hal.buffer.load(%arg0, %0, %c2) : (!iree.ref, i32, i32) -> i32 %2 = hal.buffer.load %arg0[%0] : i16 - // CHECK: %3 = vm.call @hal.buffer.load(%arg0, %0, %c4) : (!ireex.ref, i32, i32) -> i32 + // CHECK: %3 = vm.call @hal.buffer.load(%arg0, %0, %c4) : (!iree.ref, i32, i32) -> i32 %3 = hal.buffer.load %arg0[%0] : i32 return %1, %2, %3 : i8, i16, i32 } @@ -77,13 +77,13 @@ func @buffer_load(%arg0 : !ireex.ref) -> (i8, i16, i32) { // ----- // CHECK-LABEL: @buffer_store -func @buffer_store(%arg0 : !ireex.ref, %arg1 : i8, %arg2 : i16, %arg3 : i32) { +func @buffer_store(%arg0 : !iree.ref, %arg1 : i8, %arg2 : i16, %arg3 : i32) { %0 = "test_hal.device_size"() : () -> i32 - // CHECK: vm.call @hal.buffer.store(%arg1, %arg0, %0, %c1) : (i32, !ireex.ref, i32, i32) -> () + // CHECK: vm.call @hal.buffer.store(%arg1, %arg0, %0, %c1) : (i32, !iree.ref, i32, i32) -> () hal.buffer.store %arg1, %arg0[%0] : i8 - // CHECK: vm.call @hal.buffer.store(%arg2, %arg0, %0, %c2) : (i32, !ireex.ref, i32, i32) -> () + // CHECK: vm.call @hal.buffer.store(%arg2, %arg0, %0, %c2) : (i32, !iree.ref, i32, i32) -> () hal.buffer.store %arg2, %arg0[%0] : i16 - // CHECK: vm.call @hal.buffer.store(%arg3, %arg0, %0, %c4) : (i32, !ireex.ref, i32, i32) -> () + // CHECK: vm.call @hal.buffer.store(%arg3, %arg0, %0, %c4) : (i32, !iree.ref, i32, i32) -> () hal.buffer.store %arg3, %arg0[%0] : i32 return } @@ -91,10 +91,10 @@ func @buffer_store(%arg0 : !ireex.ref, %arg1 : i8, %arg2 : i16, %ar // ----- // CHECK-LABEL: @buffer_view_compute_offset -func @buffer_view_compute_offset(%arg0 : !ireex.ref) -> i32 { +func @buffer_view_compute_offset(%arg0 : !iree.ref) -> i32 { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) - // CHECK: %2 = vm.call.variadic @hal.buffer_view.compute_offset(%arg0, [%0#0, %0#1], [%1#0, %1#1], %c4) : (!ireex.ref, i32..., i32..., i32) -> i32 + // CHECK: %2 = vm.call.variadic @hal.buffer_view.compute_offset(%arg0, [%0#0, %0#1], [%1#0, %1#1], %c4) : (!iree.ref, i32..., i32..., i32) -> i32 %off = hal.buffer_view.compute_offset %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], element_size=4 return %off : i32 } @@ -102,9 +102,9 @@ func @buffer_view_compute_offset(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @buffer_view_compute_length -func @buffer_view_compute_length(%arg0 : !ireex.ref) -> i32 { +func @buffer_view_compute_length(%arg0 : !iree.ref) -> i32 { %0:2 = "test_hal.shape"() : () -> (i32, i32) - // CHECK: %1 = vm.call.variadic @hal.buffer_view.compute_length(%arg0, [%0#0, %0#1], %c4) : (!ireex.ref, i32..., i32) -> i32 + // CHECK: %1 = vm.call.variadic @hal.buffer_view.compute_length(%arg0, [%0#0, %0#1], %c4) : (!iree.ref, i32..., i32) -> i32 %len = hal.buffer_view.compute_length %arg0, shape=[%0#0, %0#1], element_size=4 return %len : i32 } @@ -112,11 +112,11 @@ func @buffer_view_compute_length(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @buffer_view_compute_range -func @buffer_view_compute_range(%arg0 : !ireex.ref) -> (i32, i32) { +func @buffer_view_compute_range(%arg0 : !iree.ref) -> (i32, i32) { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) %2:2 = "test_hal.lengths"() : () -> (i32, i32) - // CHECK: %3:2 = vm.call.variadic @hal.buffer_view.compute_range(%arg0, [%0#0, %0#1], [%1#0, %1#1], [%2#0, %2#1], %c4) : (!ireex.ref, i32..., i32..., i32..., i32) -> (i32, i32) + // CHECK: %3:2 = vm.call.variadic @hal.buffer_view.compute_range(%arg0, [%0#0, %0#1], [%1#0, %1#1], [%2#0, %2#1], %c4) : (!iree.ref, i32..., i32..., i32..., i32) -> (i32, i32) %off, %len = hal.buffer_view.compute_range %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], lengths=[%2#0, %2#1], element_size=4 return %off, %len : i32, i32 } @@ -124,11 +124,11 @@ func @buffer_view_compute_range(%arg0 : !ireex.ref) -> (i32, i32) { // ----- // CHECK-LABEL: @buffer_view_slice -func @buffer_view_slice(%arg0 : !ireex.ref) -> !ireex.ref { +func @buffer_view_slice(%arg0 : !iree.ref) -> !iree.ref { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) %2:2 = "test_hal.lengths"() : () -> (i32, i32) - // CHECK: %ref = vm.call.variadic @hal.buffer_view.slice(%arg0, [%0#0, %0#1], [%1#0, %1#1], [%2#0, %2#1], %c4) : (!ireex.ref, i32..., i32..., i32..., i32) -> !ireex.ref + // CHECK: %ref = vm.call.variadic @hal.buffer_view.slice(%arg0, [%0#0, %0#1], [%1#0, %1#1], [%2#0, %2#1], %c4) : (!iree.ref, i32..., i32..., i32..., i32) -> !iree.ref %slice = hal.buffer_view.slice %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], lengths=[%2#0, %2#1], element_size=4 - return %slice : !ireex.ref + return %slice : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/command_buffer_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/command_buffer_ops.mlir index 4142ac12f58a..e8cbbe764d09 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/command_buffer_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/command_buffer_ops.mlir @@ -1,19 +1,19 @@ // RUN: iree-opt -split-input-file -iree-convert-hal-to-vm %s | IreeFileCheck %s // CHECK-LABEL: @command_buffer_create -func @command_buffer_create(%arg0 : !ireex.ref) { - // CHECK: %ref = vm.call @hal.command_buffer.create(%arg0, %c1, %c3) : (!ireex.ref, i32, i32) -> !ireex.ref - %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !ireex.ref +func @command_buffer_create(%arg0 : !iree.ref) { + // CHECK: %ref = vm.call @hal.command_buffer.create(%arg0, %c1, %c3) : (!iree.ref, i32, i32) -> !iree.ref + %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !iree.ref return } // ----- // CHECK-LABEL: @command_buffer_begin_end -func @command_buffer_begin_end(%arg0 : !ireex.ref) { - // CHECK: vm.call @hal.command_buffer.begin(%arg0) : (!ireex.ref) -> () +func @command_buffer_begin_end(%arg0 : !iree.ref) { + // CHECK: vm.call @hal.command_buffer.begin(%arg0) : (!iree.ref) -> () hal.command_buffer.begin %arg0 - // CHECK: vm.call @hal.command_buffer.end(%arg0) : (!ireex.ref) -> () + // CHECK: vm.call @hal.command_buffer.end(%arg0) : (!iree.ref) -> () hal.command_buffer.end %arg0 return } @@ -21,14 +21,14 @@ func @command_buffer_begin_end(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_execution_barrier -func @command_buffer_execution_barrier(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_execution_barrier(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 %memory_barrier = hal.make_memory_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite" : tuple // TODO(benvanik): buffer barriers. - // %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %0, %1, %2 : tuple, i32, i32> - // CHECK: vm.call.variadic @hal.command_buffer.execution_barrier(%arg0, %c1, %c2, [%c192, %c768], []) : (!ireex.ref, i32, i32, i32..., i32...) + // %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %0, %1, %2 : tuple, i32, i32> + // CHECK: vm.call.variadic @hal.command_buffer.execution_barrier(%arg0, %c1, %c2, [%c192, %c768], []) : (!iree.ref, i32, i32, i32..., i32...) hal.command_buffer.execution_barrier %arg0, "CommandIssue", "CommandProcess", memory_barriers=[%memory_barrier, %memory_barrier] return @@ -37,12 +37,12 @@ func @command_buffer_execution_barrier(%arg0 : !ireex.ref) // ----- // CHECK-LABEL: @command_buffer_fill_buffer -func @command_buffer_fill_buffer(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_fill_buffer(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 %3 = "test_hal.pattern"() : () -> i32 - // CHECK: vm.call @hal.command_buffer.fill_buffer(%arg0, %0, %1, %2, %3) : (!ireex.ref, !ireex.ref, i32, i32, i32) -> () + // CHECK: vm.call @hal.command_buffer.fill_buffer(%arg0, %0, %1, %2, %3) : (!iree.ref, !iree.ref, i32, i32, i32) -> () hal.command_buffer.fill_buffer %arg0, %0, %1, %2, %3 return } @@ -50,12 +50,12 @@ func @command_buffer_fill_buffer(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_copy_buffer -func @command_buffer_copy_buffer(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_copy_buffer(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.source_offset"() : () -> i32 %2 = "test_hal.target_offset"() : () -> i32 %3 = "test_hal.length"() : () -> i32 - // CHECK: vm.call @hal.command_buffer.copy_buffer(%arg0, %0, %1, %0, %2, %3) : (!ireex.ref, !ireex.ref, i32, !ireex.ref, i32, i32) -> () + // CHECK: vm.call @hal.command_buffer.copy_buffer(%arg0, %0, %1, %0, %2, %3) : (!iree.ref, !iree.ref, i32, !iree.ref, i32, i32) -> () hal.command_buffer.copy_buffer %arg0, %0, %1, %0, %2, %3 return } @@ -63,13 +63,13 @@ func @command_buffer_copy_buffer(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_bind_descriptor_set -func @command_buffer_bind_descriptor_set(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref - %1 = "test_hal.descriptor_set"() : () -> !ireex.ref +func @command_buffer_bind_descriptor_set(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref + %1 = "test_hal.descriptor_set"() : () -> !iree.ref %2 = "test_hal.offset"() : () -> i32 - // CHECK: vm.call.variadic @hal.command_buffer.bind_descriptor_set(%arg0, %0, %zero, %1, []) : (!ireex.ref, !ireex.ref, i32, !ireex.ref, i32...) + // CHECK: vm.call.variadic @hal.command_buffer.bind_descriptor_set(%arg0, %0, %zero, %1, []) : (!iree.ref, !iree.ref, i32, !iree.ref, i32...) hal.command_buffer.bind_descriptor_set %arg0, %0, set=0, %1 - // CHECK: vm.call.variadic @hal.command_buffer.bind_descriptor_set(%arg0, %0, %zero_0, %1, [%2]) : (!ireex.ref, !ireex.ref, i32, !ireex.ref, i32...) + // CHECK: vm.call.variadic @hal.command_buffer.bind_descriptor_set(%arg0, %0, %zero_0, %1, [%2]) : (!iree.ref, !iree.ref, i32, !iree.ref, i32...) hal.command_buffer.bind_descriptor_set %arg0, %0, set=0, %1, offsets=[%2] return } @@ -77,12 +77,12 @@ func @command_buffer_bind_descriptor_set(%arg0 : !ireex.ref // ----- // CHECK-LABEL: @command_buffer_dispatch -func @command_buffer_dispatch(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref +func @command_buffer_dispatch(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref %1 = "test_hal.workgroup_x"() : () -> i32 %2 = "test_hal.workgroup_y"() : () -> i32 %3 = "test_hal.workgroup_z"() : () -> i32 - // CHECK: vm.call @hal.command_buffer.dispatch(%arg0, %0, %zero, %1, %2, %3) : (!ireex.ref, !ireex.ref, i32, i32, i32, i32) -> () + // CHECK: vm.call @hal.command_buffer.dispatch(%arg0, %0, %zero, %1, %2, %3) : (!iree.ref, !iree.ref, i32, i32, i32, i32) -> () hal.command_buffer.dispatch %arg0, %0, entry_point=0, workgroup_xyz=[%1, %2, %3] return } @@ -90,11 +90,11 @@ func @command_buffer_dispatch(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_dispatch_indirect -func @command_buffer_dispatch_indirect(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref - %1 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_dispatch_indirect(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref + %1 = "test_hal.buffer"() : () -> !iree.ref %2 = "test_hal.offset"() : () -> i32 - // CHECK: vm.call @hal.command_buffer.dispatch.indirect(%arg0, %0, %zero, %1, %2) : (!ireex.ref, !ireex.ref, i32, !ireex.ref, i32) -> () + // CHECK: vm.call @hal.command_buffer.dispatch.indirect(%arg0, %0, %zero, %1, %2) : (!iree.ref, !iree.ref, i32, !iree.ref, i32) -> () hal.command_buffer.dispatch.indirect %arg0, %0, entry_point=0, workgroups=%1[%2] return } diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/device_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/device_ops.mlir index b91655fc6917..4b2573407553 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/device_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/device_ops.mlir @@ -1,9 +1,9 @@ // RUN: iree-opt -split-input-file -iree-convert-hal-to-vm %s | IreeFileCheck %s // CHECK-LABEL: @device_allocator -func @device_allocator() -> !ireex.ref { - %0 = "test_hal.device"() : () -> !ireex.ref - // CHECK: %ref = vm.call @hal.device.allocator(%0) : (!ireex.ref) -> !ireex.ref - %allocator = hal.device.allocator %0 : !ireex.ref - return %allocator : !ireex.ref +func @device_allocator() -> !iree.ref { + %0 = "test_hal.device"() : () -> !iree.ref + // CHECK: %ref = vm.call @hal.device.allocator(%0) : (!iree.ref) -> !iree.ref + %allocator = hal.device.allocator %0 : !iree.ref + return %allocator : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/executable_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/executable_ops.mlir index b848f0fec6a8..91fd5810f22b 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/executable_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/executable_ops.mlir @@ -9,47 +9,47 @@ hal.executable @exe { // CHECK-DAG: vm.rodata @exe_data_1230128453 dense<[0, 1, 2, 3]> : vector<4xi8> // CHECK-DAG: vm.rodata @exe_data_1397773893 dense<[4, 5, 6, 7]> : vector<4xi8> -// CHECK-DAG: vm.global.ref @exe_cached mutable : !ireex.ref -// CHECK-DAG: vm.func @exe(%arg0: !ireex.ref) -> !ireex.ref { -// CHECK: %exe_cached = vm.global.load.ref @exe_cached : !ireex.ref -// CHECK-NEXT: %rnz = vm.cmp.nz.ref %exe_cached : !ireex.ref -// CHECK-NEXT: vm.cond_br %rnz, ^bb1(%exe_cached : !ireex.ref), ^bb2 -// CHECK-NEXT: ^bb1(%0: !ireex.ref): -// CHECK-NEXT: vm.return %0 : !ireex.ref +// CHECK-DAG: vm.global.ref @exe_cached mutable : !iree.ref +// CHECK-DAG: vm.func @exe(%arg0: !iree.ref) -> !iree.ref { +// CHECK: %exe_cached = vm.global.load.ref @exe_cached : !iree.ref +// CHECK-NEXT: %rnz = vm.cmp.nz.ref %exe_cached : !iree.ref +// CHECK-NEXT: vm.cond_br %rnz, ^bb1(%exe_cached : !iree.ref), ^bb2 +// CHECK-NEXT: ^bb1(%0: !iree.ref): +// CHECK-NEXT: vm.return %0 : !iree.ref // CHECK-NEXT: ^bb2: // CHECK-NEXT: %c1230128453 = vm.const.i32 1230128453 : i32 // CHECK-NEXT: %c1397773893 = vm.const.i32 1397773893 : i32 -// CHECK-NEXT: %1 = vm.call.variadic @hal.ex.match_supported_executable_format(%arg0, [%c1230128453, %c1397773893]) : (!ireex.ref, i32...) -> i32 +// CHECK-NEXT: %1 = vm.call.variadic @hal.ex.match_supported_executable_format(%arg0, [%c1230128453, %c1397773893]) : (!iree.ref, i32...) -> i32 // CHECK-NEXT: vm.br ^bb3(%1 : i32) // CHECK-NEXT: ^bb3(%2: i32): // CHECK-NEXT: %c1230128453_0 = vm.const.i32 1230128453 : i32 // CHECK-NEXT: %eq = vm.cmp.eq.i32 %2, %c1230128453_0 : i32 // CHECK-NEXT: vm.cond_br %eq, ^bb4(%2 : i32), ^bb5(%2 : i32) // CHECK-NEXT: ^bb4(%3: i32): -// CHECK-NEXT: %exe_data_1230128453 = vm.const.ref.rodata @exe_data_1230128453 : !ireex.byte_buffer_ref -// CHECK-NEXT: %ref = vm.call @hal.ex.cache_executable(%arg0, %3, %exe_data_1230128453) : (!ireex.ref, i32, !ireex.byte_buffer_ref) -> !ireex.ref -// CHECK-NEXT: vm.br ^bb7(%ref : !ireex.ref) +// CHECK-NEXT: %exe_data_1230128453 = vm.const.ref.rodata @exe_data_1230128453 : !iree.byte_buffer_ref +// CHECK-NEXT: %ref = vm.call @hal.ex.cache_executable(%arg0, %3, %exe_data_1230128453) : (!iree.ref, i32, !iree.byte_buffer_ref) -> !iree.ref +// CHECK-NEXT: vm.br ^bb7(%ref : !iree.ref) // CHECK-NEXT: ^bb5(%4: i32): // CHECK-NEXT: %c1397773893_1 = vm.const.i32 1397773893 : i32 // CHECK-NEXT: %eq_2 = vm.cmp.eq.i32 %4, %c1397773893_1 : i32 // CHECK-NEXT: vm.cond_br %eq_2, ^bb6(%4 : i32), ^bb8 // CHECK-NEXT: ^bb6(%5: i32): -// CHECK-NEXT: %exe_data_1397773893 = vm.const.ref.rodata @exe_data_1397773893 : !ireex.byte_buffer_ref -// CHECK-NEXT: %ref_3 = vm.call @hal.ex.cache_executable(%arg0, %5, %exe_data_1397773893) : (!ireex.ref, i32, !ireex.byte_buffer_ref) -> !ireex.ref -// CHECK-NEXT: vm.br ^bb7(%ref_3 : !ireex.ref) -// CHECK-NEXT: ^bb7(%6: !ireex.ref): -// CHECK-NEXT: vm.global.store.ref @exe_cached, %6 : !ireex.ref -// CHECK-NEXT: vm.return %6 : !ireex.ref +// CHECK-NEXT: %exe_data_1397773893 = vm.const.ref.rodata @exe_data_1397773893 : !iree.byte_buffer_ref +// CHECK-NEXT: %ref_3 = vm.call @hal.ex.cache_executable(%arg0, %5, %exe_data_1397773893) : (!iree.ref, i32, !iree.byte_buffer_ref) -> !iree.ref +// CHECK-NEXT: vm.br ^bb7(%ref_3 : !iree.ref) +// CHECK-NEXT: ^bb7(%6: !iree.ref): +// CHECK-NEXT: vm.global.store.ref @exe_cached, %6 : !iree.ref +// CHECK-NEXT: vm.return %6 : !iree.ref // CHECK-NEXT: ^bb8: -// CHECK-NEXT: %null = vm.const.ref.zero : !ireex.ref -// CHECK-NEXT: vm.return %null : !ireex.ref +// CHECK-NEXT: %null = vm.const.ref.zero : !iree.ref +// CHECK-NEXT: vm.return %null : !iree.ref // CHECK-NEXT: } // ----- // CHECK-LABEL: @exeLookup -func @exeLookup(%arg0 : !ireex.ref) -> !ireex.ref { - // CHECK: vm.call @exe(%arg0) : (!ireex.ref) -> !ireex.ref - %0 = hal.ex.cache_executable %arg0, @exe : !ireex.ref - return %0 : !ireex.ref +func @exeLookup(%arg0 : !iree.ref) -> !iree.ref { + // CHECK: vm.call @exe(%arg0) : (!iree.ref) -> !iree.ref + %0 = hal.ex.cache_executable %arg0, @exe : !iree.ref + return %0 : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/variable_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/variable_ops.mlir index e5413bc3fdc7..f674da2a1ede 100644 --- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/variable_ops.mlir +++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/variable_ops.mlir @@ -5,29 +5,29 @@ hal.variable @v_initialized_const 4 : i32 // ----- -// CHECK: vm.global.ref @v_initialized init(@initializer) : !ireex.ref -hal.variable @v_initialized init(@initializer) : !ireex.ref -func @initializer() -> !ireex.ref +// CHECK: vm.global.ref @v_initialized init(@initializer) : !iree.ref +hal.variable @v_initialized init(@initializer) : !iree.ref +func @initializer() -> !iree.ref // ----- -// CHECK: vm.global.ref @v_loaded : !ireex.ref -hal.variable @v_loaded : !ireex.ref +// CHECK: vm.global.ref @v_loaded : !iree.ref +hal.variable @v_loaded : !iree.ref // CHECK-LABEL: func @loaded func @loaded() { - // CHECK: %v_loaded = vm.global.load.ref @v_loaded : !ireex.ref - %0 = hal.variable.load @v_loaded : !ireex.ref + // CHECK: %v_loaded = vm.global.load.ref @v_loaded : !iree.ref + %0 = hal.variable.load @v_loaded : !iree.ref return } // ----- -// CHECK: vm.global.ref @v_stored mutable : !ireex.ref -hal.variable @v_stored mutable : !ireex.ref +// CHECK: vm.global.ref @v_stored mutable : !iree.ref +hal.variable @v_stored mutable : !iree.ref // CHECK-LABEL: func @stored func @stored() { - %0 = "test_hal.buffer"() : () -> !ireex.ref - // CHECK: vm.global.store.ref @v_stored, %0 : !ireex.ref - hal.variable.store %0, @v_stored : !ireex.ref + %0 = "test_hal.buffer"() : () -> !iree.ref + // CHECK: vm.global.store.ref @v_stored, %0 : !iree.ref + hal.variable.store %0, @v_stored : !iree.ref return } diff --git a/iree/compiler/Dialect/HAL/IR/test/allocator_folding.mlir b/iree/compiler/Dialect/HAL/IR/test/allocator_folding.mlir index 0d42e100c1dd..c0f93f518302 100644 --- a/iree/compiler/Dialect/HAL/IR/test/allocator_folding.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/allocator_folding.mlir @@ -3,16 +3,16 @@ // RUN: iree-opt -split-input-file -canonicalize %s | iree-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @simplify_allocate_shaped -func @simplify_allocate_shapedy() -> !ireex.ref { +func @simplify_allocate_shapedy() -> !iree.ref { // CHECK-DAG: [[AL:%.+]] = "test_hal.allocator" - %0 = "test_hal.allocator"() : () -> !ireex.ref + %0 = "test_hal.allocator"() : () -> !iree.ref // CHECK-DAG: [[SH:%.+]]:2 = "test_hal.shape" %1:2 = "test_hal.shape"() : () -> (i32, i32) // CHECK-NEXT: %buffer = hal.allocator.allocate.shaped [[AL]], "HostVisible|HostCoherent", "Transfer", shape=[ // CHECK-SAME: [[SH]]#0, [[SH]]#1 - // CHECK-SAME: ], element_size=4 : !ireex.ref + // CHECK-SAME: ], element_size=4 : !iree.ref %sz = hal.allocator.compute_size %0, "HostVisible|HostCoherent", "Transfer", shape=[%1#0, %1#1], element_size=4 - %buffer = hal.allocator.allocate %0, "HostVisible|HostCoherent", "Transfer", %sz : !ireex.ref + %buffer = hal.allocator.allocate %0, "HostVisible|HostCoherent", "Transfer", %sz : !iree.ref // CHECK-NEXT: return %buffer - return %buffer : !ireex.ref + return %buffer : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir index 4a5bbbdaedcb..b3cb555e9d6a 100644 --- a/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir @@ -4,7 +4,7 @@ // CHECK-LABEL: @allocator_compute_size func @allocator_compute_size() -> i32 { - %0 = "test_hal.allocator"() : () -> !ireex.ref + %0 = "test_hal.allocator"() : () -> !iree.ref %1:2 = "test_hal.shape"() : () -> (i32, i32) // CHECK: [[SZ:%.+]] = hal.allocator.compute_size %0, "HostVisible|HostCoherent", "Transfer", shape=[%1#0, %1#1], element_size=4 %sz = hal.allocator.compute_size %0, "HostVisible|HostCoherent", "Transfer", shape=[%1#0, %1#1], element_size=4 @@ -15,39 +15,39 @@ func @allocator_compute_size() -> i32 { // ----- // CHECK-LABEL: @allocator_allocate -func @allocator_allocate() -> !ireex.ref { +func @allocator_allocate() -> !iree.ref { // CHECK-DAG: [[C123:%.+]] = constant 123 %0 = constant 123 : i32 // CHECK-DAG: [[AL:%.+]] = "test_hal.allocator" - %1 = "test_hal.allocator"() : () -> !ireex.ref - // CHECK: [[CB:%.+]] = hal.allocator.allocate [[AL]], "HostVisible|HostCoherent", "Transfer", [[C123]] : !ireex.ref - %buffer = hal.allocator.allocate %1, "HostVisible|HostCoherent", "Transfer", %0 : !ireex.ref + %1 = "test_hal.allocator"() : () -> !iree.ref + // CHECK: [[CB:%.+]] = hal.allocator.allocate [[AL]], "HostVisible|HostCoherent", "Transfer", [[C123]] : !iree.ref + %buffer = hal.allocator.allocate %1, "HostVisible|HostCoherent", "Transfer", %0 : !iree.ref // CHECK-NEXT: return [[CB]] - return %buffer : !ireex.ref + return %buffer : !iree.ref } // ----- // CHECK-LABEL: @allocator_allocate_const -func @allocator_allocate_const() -> !ireex.ref { +func @allocator_allocate_const() -> !iree.ref { // CHECK-DAG: [[AL:%.+]] = "test_hal.allocator" - %allocator = "test_hal.allocator"() : () -> !ireex.ref - // CHECK: [[CB:%.+]] = hal.allocator.allocate.const [[AL]], "HostVisible|HostCoherent", "Transfer" : !ireex.ref = dense<123> : tensor<4x4xi32> - %buffer = hal.allocator.allocate.const %allocator, "HostVisible|HostCoherent", "Transfer" : !ireex.ref = dense<123> : tensor<4x4xi32> + %allocator = "test_hal.allocator"() : () -> !iree.ref + // CHECK: [[CB:%.+]] = hal.allocator.allocate.const [[AL]], "HostVisible|HostCoherent", "Transfer" : !iree.ref = dense<123> : tensor<4x4xi32> + %buffer = hal.allocator.allocate.const %allocator, "HostVisible|HostCoherent", "Transfer" : !iree.ref = dense<123> : tensor<4x4xi32> // CHECK-NEXT: return [[CB]] - return %buffer : !ireex.ref + return %buffer : !iree.ref } // ----- // CHECK-LABEL: @allocator_allocate_shaped -func @allocator_allocate_shaped() -> !ireex.ref { +func @allocator_allocate_shaped() -> !iree.ref { // CHECK-DAG: [[AL:%.+]] = "test_hal.allocator" - %0 = "test_hal.allocator"() : () -> !ireex.ref + %0 = "test_hal.allocator"() : () -> !iree.ref // CHECK-DAG: {{.+}} = "test_hal.shape" %1:2 = "test_hal.shape"() : () -> (i32, i32) - // CHECK: [[CB:%.+]] = hal.allocator.allocate.shaped [[AL]], "HostVisible|HostCoherent", "Transfer", shape=[{{.+}}#0, {{.+}}#1], element_size=4 : !ireex.ref - %buffer = hal.allocator.allocate.shaped %0, "HostVisible|HostCoherent", "Transfer", shape=[%1#0, %1#1], element_size=4 : !ireex.ref + // CHECK: [[CB:%.+]] = hal.allocator.allocate.shaped [[AL]], "HostVisible|HostCoherent", "Transfer", shape=[{{.+}}#0, {{.+}}#1], element_size=4 : !iree.ref + %buffer = hal.allocator.allocate.shaped %0, "HostVisible|HostCoherent", "Transfer", shape=[%1#0, %1#1], element_size=4 : !iree.ref // CHECK-NEXT: return [[CB]] - return %buffer : !ireex.ref + return %buffer : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/IR/test/buffer_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/buffer_ops.mlir index 99581b5a7501..ad09198ee8fe 100644 --- a/iree/compiler/Dialect/HAL/IR/test/buffer_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/buffer_ops.mlir @@ -3,19 +3,19 @@ // RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @buffer_subspan -func @buffer_subspan() -> !ireex.ref { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @buffer_subspan() -> !iree.ref { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 - // CHECK: %buffer = hal.buffer.subspan %0, %1, %2 : !ireex.ref - %buffer = hal.buffer.subspan %0, %1, %2 : !ireex.ref - return %buffer : !ireex.ref + // CHECK: %buffer = hal.buffer.subspan %0, %1, %2 : !iree.ref + %buffer = hal.buffer.subspan %0, %1, %2 : !iree.ref + return %buffer : !iree.ref } // ----- // CHECK-LABEL: @buffer_fill -func @buffer_fill(%arg0 : !ireex.ref) { +func @buffer_fill(%arg0 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.pattern"() : () -> i32 @@ -27,33 +27,33 @@ func @buffer_fill(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @buffer_read_data -func @buffer_read_data(%arg0 : !ireex.ref) { +func @buffer_read_data(%arg0 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 - %1 = "test_hal.mutable_data"() : () -> !ireex.mutable_byte_buffer_ref + %1 = "test_hal.mutable_data"() : () -> !iree.mutable_byte_buffer_ref %2 = "test_hal.device_size"() : () -> i32 %3 = "test_hal.device_size"() : () -> i32 - // CHECK: hal.buffer.read_data %arg0, %0, %1, %2, %3 : !ireex.mutable_byte_buffer_ref - hal.buffer.read_data %arg0, %0, %1, %2, %3 : !ireex.mutable_byte_buffer_ref + // CHECK: hal.buffer.read_data %arg0, %0, %1, %2, %3 : !iree.mutable_byte_buffer_ref + hal.buffer.read_data %arg0, %0, %1, %2, %3 : !iree.mutable_byte_buffer_ref return } // ----- // CHECK-LABEL: @buffer_write_data -func @buffer_write_data(%arg0 : !ireex.ref) { - %0 = "test_hal.mutable_data"() : () -> !ireex.mutable_byte_buffer_ref +func @buffer_write_data(%arg0 : !iree.ref) { + %0 = "test_hal.mutable_data"() : () -> !iree.mutable_byte_buffer_ref %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 %3 = "test_hal.device_size"() : () -> i32 - // CHECK: hal.buffer.write_data %0, %1, %arg0, %2, %3 : !ireex.mutable_byte_buffer_ref - hal.buffer.write_data %0, %1, %arg0, %2, %3 : !ireex.mutable_byte_buffer_ref + // CHECK: hal.buffer.write_data %0, %1, %arg0, %2, %3 : !iree.mutable_byte_buffer_ref + hal.buffer.write_data %0, %1, %arg0, %2, %3 : !iree.mutable_byte_buffer_ref return } // ----- // CHECK-LABEL: @buffer_copy_data -func @buffer_copy_data(%arg0 : !ireex.ref, %arg1 : !ireex.ref) { +func @buffer_copy_data(%arg0 : !iree.ref, %arg1 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 %1 = "test_hal.device_size"() : () -> i32 %2 = "test_hal.device_size"() : () -> i32 @@ -65,7 +65,7 @@ func @buffer_copy_data(%arg0 : !ireex.ref, %arg1 : !ireex.ref) -> i32 { +func @buffer_load(%arg0 : !iree.ref) -> i32 { %0 = "test_hal.device_size"() : () -> i32 // CHECK: [[VAL:%.+]] = hal.buffer.load %arg0[%0] : i32 %1 = hal.buffer.load %arg0[%0] : i32 @@ -76,7 +76,7 @@ func @buffer_load(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @buffer_store -func @buffer_store(%arg0 : i32, %arg1 : !ireex.ref) { +func @buffer_store(%arg0 : i32, %arg1 : !iree.ref) { %0 = "test_hal.device_size"() : () -> i32 // CHECK: hal.buffer.store %arg0, %arg1[%0] : i32 hal.buffer.store %arg0, %arg1[%0] : i32 @@ -86,7 +86,7 @@ func @buffer_store(%arg0 : i32, %arg1 : !ireex.ref) { // ----- // CHECK-LABEL: @buffer_view_compute_offset -func @buffer_view_compute_offset(%arg0 : !ireex.ref) -> i32 { +func @buffer_view_compute_offset(%arg0 : !iree.ref) -> i32 { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) // CHECK: %off = hal.buffer_view.compute_offset %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], element_size=4 @@ -97,7 +97,7 @@ func @buffer_view_compute_offset(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @buffer_view_compute_length -func @buffer_view_compute_length(%arg0 : !ireex.ref) -> i32 { +func @buffer_view_compute_length(%arg0 : !iree.ref) -> i32 { %0:2 = "test_hal.shape"() : () -> (i32, i32) // CHECK: %len = hal.buffer_view.compute_length %arg0, shape=[%0#0, %0#1], element_size=4 %len = hal.buffer_view.compute_length %arg0, shape=[%0#0, %0#1], element_size=4 @@ -107,7 +107,7 @@ func @buffer_view_compute_length(%arg0 : !ireex.ref) -> i32 { // ----- // CHECK-LABEL: @buffer_view_compute_range -func @buffer_view_compute_range(%arg0 : !ireex.ref) -> (i32, i32) { +func @buffer_view_compute_range(%arg0 : !iree.ref) -> (i32, i32) { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) %2:2 = "test_hal.lengths"() : () -> (i32, i32) @@ -119,11 +119,11 @@ func @buffer_view_compute_range(%arg0 : !ireex.ref) -> (i32, i32) { // ----- // CHECK-LABEL: @buffer_view_slice -func @buffer_view_slice(%arg0 : !ireex.ref) -> !ireex.ref { +func @buffer_view_slice(%arg0 : !iree.ref) -> !iree.ref { %0:2 = "test_hal.shape"() : () -> (i32, i32) %1:2 = "test_hal.indices"() : () -> (i32, i32) %2:2 = "test_hal.lengths"() : () -> (i32, i32) // CHECK: %slice = hal.buffer_view.slice %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], lengths=[%2#0, %2#1], element_size=4 %slice = hal.buffer_view.slice %arg0, shape=[%0#0, %0#1], indices=[%1#0, %1#1], lengths=[%2#0, %2#1], element_size=4 - return %slice : !ireex.ref + return %slice : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/IR/test/command_buffer_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/command_buffer_ops.mlir index c382bc4ab7bf..235fe53bb6c4 100644 --- a/iree/compiler/Dialect/HAL/IR/test/command_buffer_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/command_buffer_ops.mlir @@ -12,27 +12,27 @@ func @make_memory_barrier() -> tuple { // ----- // CHECK-LABEL: @make_buffer_barrier -func @make_buffer_barrier(%arg0 : !ireex.ref) -> tuple, i32, i32> { +func @make_buffer_barrier(%arg0 : !iree.ref) -> tuple, i32, i32> { %0 = "test_hal.offset"() : () -> i32 %1 = "test_hal.length"() : () -> i32 - // CHECK: %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %arg0, %0, %1 : tuple, i32, i32> - %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %arg0, %0, %1 : tuple, i32, i32> - return %buffer_barrier : tuple, i32, i32> + // CHECK: %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %arg0, %0, %1 : tuple, i32, i32> + %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %arg0, %0, %1 : tuple, i32, i32> + return %buffer_barrier : tuple, i32, i32> } // ----- // CHECK-LABEL: @command_buffer_create -func @command_buffer_create(%arg0 : !ireex.ref) { - // CHECK: %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !ireex.ref - %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !ireex.ref +func @command_buffer_create(%arg0 : !iree.ref) { + // CHECK: %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !iree.ref + %cmd = hal.command_buffer.create %arg0, "OneShot", "Transfer|Dispatch" : !iree.ref return } // ----- // CHECK-LABEL: @command_buffer_begin_end -func @command_buffer_begin_end(%arg0 : !ireex.ref) { +func @command_buffer_begin_end(%arg0 : !iree.ref) { // CHECK: hal.command_buffer.begin %arg0 hal.command_buffer.begin %arg0 // CHECK: hal.command_buffer.end %arg0 @@ -43,12 +43,12 @@ func @command_buffer_begin_end(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_execution_barrier -func @command_buffer_execution_barrier(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_execution_barrier(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 %memory_barrier = hal.make_memory_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite" : tuple - %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %0, %1, %2 : tuple, i32, i32> + %buffer_barrier = hal.make_buffer_barrier "HostRead|HostWrite", "MemoryRead|MemoryWrite", %0, %1, %2 : tuple, i32, i32> // CHECK: hal.command_buffer.execution_barrier %arg0, "CommandIssue", "CommandProcess" hal.command_buffer.execution_barrier %arg0, "CommandIssue", "CommandProcess" // CHECK-NEXT: hal.command_buffer.execution_barrier %arg0, "CommandIssue", "CommandProcess", memory_barriers=[%memory_barrier, %memory_barrier] @@ -67,8 +67,8 @@ func @command_buffer_execution_barrier(%arg0 : !ireex.ref) // ----- // CHECK-LABEL: @command_buffer_fill_buffer -func @command_buffer_fill_buffer(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_fill_buffer(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 %3 = "test_hal.pattern"() : () -> i32 @@ -80,8 +80,8 @@ func @command_buffer_fill_buffer(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_copy_buffer -func @command_buffer_copy_buffer(%arg0 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_copy_buffer(%arg0 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.source_offset"() : () -> i32 %2 = "test_hal.target_offset"() : () -> i32 %3 = "test_hal.length"() : () -> i32 @@ -93,9 +93,9 @@ func @command_buffer_copy_buffer(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_bind_descriptor_set -func @command_buffer_bind_descriptor_set(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref - %1 = "test_hal.descriptor_set"() : () -> !ireex.ref +func @command_buffer_bind_descriptor_set(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref + %1 = "test_hal.descriptor_set"() : () -> !iree.ref %2 = "test_hal.offset"() : () -> i32 // CHECK: hal.command_buffer.bind_descriptor_set %arg0, %0, set=0, %1 hal.command_buffer.bind_descriptor_set %arg0, %0, set=0, %1 @@ -107,8 +107,8 @@ func @command_buffer_bind_descriptor_set(%arg0 : !ireex.ref // ----- // CHECK-LABEL: @command_buffer_dispatch -func @command_buffer_dispatch(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref +func @command_buffer_dispatch(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref %1 = "test_hal.workgroup_x"() : () -> i32 %2 = "test_hal.workgroup_y"() : () -> i32 %3 = "test_hal.workgroup_z"() : () -> i32 @@ -120,9 +120,9 @@ func @command_buffer_dispatch(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @command_buffer_dispatch_indirect -func @command_buffer_dispatch_indirect(%arg0 : !ireex.ref) { - %0 = "test_hal.executable"() : () -> !ireex.ref - %1 = "test_hal.buffer"() : () -> !ireex.ref +func @command_buffer_dispatch_indirect(%arg0 : !iree.ref) { + %0 = "test_hal.executable"() : () -> !iree.ref + %1 = "test_hal.buffer"() : () -> !iree.ref %2 = "test_hal.offset"() : () -> i32 // CHECK: hal.command_buffer.dispatch.indirect %arg0, %0, entry_point=0, workgroups=%1[%2] hal.command_buffer.dispatch.indirect %arg0, %0, entry_point=0, workgroups=%1[%2] diff --git a/iree/compiler/Dialect/HAL/IR/test/descriptor_set_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/descriptor_set_ops.mlir index 7e7832823c30..236518e1084e 100644 --- a/iree/compiler/Dialect/HAL/IR/test/descriptor_set_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/descriptor_set_ops.mlir @@ -3,9 +3,9 @@ // RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @descriptor_set_allocate -func @descriptor_set_allocate(%arg0 : !ireex.ref, %arg1 : !ireex.ref) { - // CHECK: %descriptor_set = hal.descriptor_set.allocate %arg0, %arg1 : !ireex.ref - %0 = hal.descriptor_set.allocate %arg0, %arg1 : !ireex.ref +func @descriptor_set_allocate(%arg0 : !iree.ref, %arg1 : !iree.ref) { + // CHECK: %descriptor_set = hal.descriptor_set.allocate %arg0, %arg1 : !iree.ref + %0 = hal.descriptor_set.allocate %arg0, %arg1 : !iree.ref return } @@ -13,23 +13,23 @@ func @descriptor_set_allocate(%arg0 : !ireex.ref, %arg1 : !ireex.re // CHECK-LABEL: @descriptor_set_make_binding func @descriptor_set_make_binding() { - %0 = "test_hal.buffer"() : () -> !ireex.ref + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 - // CHECK: %binding = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> - %3 = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> + // CHECK: %binding = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> + %3 = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> return } // ----- // CHECK-LABEL: @descriptor_set_update -func @descriptor_set_update(%arg0 : !ireex.ref, %arg1 : !ireex.ref) { - %0 = "test_hal.buffer"() : () -> !ireex.ref +func @descriptor_set_update(%arg0 : !iree.ref, %arg1 : !iree.ref) { + %0 = "test_hal.buffer"() : () -> !iree.ref %1 = "test_hal.offset"() : () -> i32 %2 = "test_hal.length"() : () -> i32 // CHECK: [[B:%.+]] = hal.descriptor_set.make_binding - %3 = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> + %3 = hal.descriptor_set.make_binding binding=0, %0, %1, %2, "Read|Write" : tuple, i32, i32, i32> // CHECK-NEXT: hal.descriptor_set.update %arg0, %arg1, bindings={{\[}}[[B]]{{\]}} hal.descriptor_set.update %arg0, %arg1, bindings=[%3] return diff --git a/iree/compiler/Dialect/HAL/IR/test/device_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/device_ops.mlir index e0eaacb99bc7..c79bcff10b28 100644 --- a/iree/compiler/Dialect/HAL/IR/test/device_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/device_ops.mlir @@ -3,9 +3,9 @@ // RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @device_allocator -func @device_allocator() -> !ireex.ref { - %0 = "test_hal.device"() : () -> !ireex.ref - // CHECK: %allocator = hal.device.allocator %0 : !ireex.ref - %allocator = hal.device.allocator %0 : !ireex.ref - return %allocator : !ireex.ref +func @device_allocator() -> !iree.ref { + %0 = "test_hal.device"() : () -> !iree.ref + // CHECK: %allocator = hal.device.allocator %0 : !iree.ref + %allocator = hal.device.allocator %0 : !iree.ref + return %allocator : !iree.ref } diff --git a/iree/compiler/Dialect/HAL/IR/test/experimental_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/experimental_ops.mlir index c62f2c3a0057..88d018b51a82 100644 --- a/iree/compiler/Dialect/HAL/IR/test/experimental_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/experimental_ops.mlir @@ -3,29 +3,29 @@ // RUN: iree-opt -split-input-file %s | iree-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @shared_device -func @shared_device() -> !ireex.ref { - // CHECK: %dev = hal.ex.shared_device : !ireex.ref - %dev = hal.ex.shared_device : !ireex.ref - return %dev : !ireex.ref +func @shared_device() -> !iree.ref { + // CHECK: %dev = hal.ex.shared_device : !iree.ref + %dev = hal.ex.shared_device : !iree.ref + return %dev : !iree.ref } // ----- // CHECK-LABEL: @cache_executable hal.executable @foo {} -func @cache_executable() -> !ireex.ref { - %0 = "test_hal.device"() : () -> !ireex.ref - // CHECK: %exe = hal.ex.cache_executable %0, @foo : !ireex.ref - %exe = hal.ex.cache_executable %0, @foo : !ireex.ref - return %exe : !ireex.ref +func @cache_executable() -> !iree.ref { + %0 = "test_hal.device"() : () -> !iree.ref + // CHECK: %exe = hal.ex.cache_executable %0, @foo : !iree.ref + %exe = hal.ex.cache_executable %0, @foo : !iree.ref + return %exe : !iree.ref } // ----- // CHECK-LABEL: @submit_and_wait func @submit_and_wait() { - %0 = "test_hal.device"() : () -> !ireex.ref - %1 = "test_hal.command_buffer"() : () -> !ireex.ref + %0 = "test_hal.device"() : () -> !iree.ref + %1 = "test_hal.command_buffer"() : () -> !iree.ref // CHECK: hal.ex.submit_and_wait %0, %1 hal.ex.submit_and_wait %0, %1 return diff --git a/iree/compiler/Dialect/HAL/IR/test/variable_folding.mlir b/iree/compiler/Dialect/HAL/IR/test/variable_folding.mlir index ff64e45115bf..122e1bca8d36 100644 --- a/iree/compiler/Dialect/HAL/IR/test/variable_folding.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/variable_folding.mlir @@ -11,22 +11,22 @@ func @initializer() -> i32 { // ----- -hal.variable @v_unused : !ireex.ref +hal.variable @v_unused : !iree.ref // CHECK-LABEL: @unused_load func @unused_load() { // CHECK-NEXT: return - %0 = hal.variable.load @v_unused : !ireex.ref + %0 = hal.variable.load @v_unused : !iree.ref return } // ----- -hal.variable @v_nop mutable : !ireex.ref +hal.variable @v_nop mutable : !iree.ref // CHECK-LABEL: @nop_load_store func @nop_load_store() { // CHECK-NEXT: return - %0 = hal.variable.load @v_nop : !ireex.ref - hal.variable.store %0, @v_nop : !ireex.ref + %0 = hal.variable.load @v_nop : !iree.ref + hal.variable.store %0, @v_nop : !iree.ref return } diff --git a/iree/compiler/Dialect/HAL/IR/test/variable_ops.mlir b/iree/compiler/Dialect/HAL/IR/test/variable_ops.mlir index ea3a833c8e59..f5bbeea2d0e8 100644 --- a/iree/compiler/Dialect/HAL/IR/test/variable_ops.mlir +++ b/iree/compiler/Dialect/HAL/IR/test/variable_ops.mlir @@ -14,28 +14,28 @@ hal.variable @v_initialized_const 4 : i32 // ----- -// CHECK: hal.variable @v_initialized init(@initializer) : !ireex.ref -hal.variable @v_initialized init(@initializer) : !ireex.ref -func @initializer() -> !ireex.ref +// CHECK: hal.variable @v_initialized init(@initializer) : !iree.ref +hal.variable @v_initialized init(@initializer) : !iree.ref +func @initializer() -> !iree.ref // ----- -hal.variable @v_loaded : !ireex.ref +hal.variable @v_loaded : !iree.ref // CHECK-LABEL: @loaded func @loaded() { - // CHECK-NEXT: = hal.variable.load @v_loaded : !ireex.ref - %0 = hal.variable.load @v_loaded : !ireex.ref + // CHECK-NEXT: = hal.variable.load @v_loaded : !iree.ref + %0 = hal.variable.load @v_loaded : !iree.ref return } // ----- -hal.variable @v_stored mutable : !ireex.ref +hal.variable @v_stored mutable : !iree.ref // CHECK-LABEL: @stored func @stored() { // CHECK-NEXT: [[BUF:%.+]] = "test_hal.buffer" - %0 = "test_hal.buffer"() : () -> !ireex.ref - // CHECK-NEXT: hal.variable.store [[BUF]], @v_stored : !ireex.ref - hal.variable.store %0, @v_stored : !ireex.ref + %0 = "test_hal.buffer"() : () -> !iree.ref + // CHECK-NEXT: hal.variable.store [[BUF]], @v_stored : !iree.ref + hal.variable.store %0, @v_stored : !iree.ref return } diff --git a/iree/compiler/Dialect/HAL/Target/BUILD b/iree/compiler/Dialect/HAL/Target/BUILD index e6ce483c71c2..40b87ace0f98 100644 --- a/iree/compiler/Dialect/HAL/Target/BUILD +++ b/iree/compiler/Dialect/HAL/Target/BUILD @@ -30,7 +30,7 @@ cc_library( deps = [ "//iree/compiler/Dialect/Flow/IR", "//iree/compiler/Dialect/HAL/IR", - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Utils", "@llvm-project//llvm:support", "@llvm-project//mlir:IR", diff --git a/iree/compiler/Dialect/HAL/Target/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt index 5ad719625e19..36534707dbb1 100644 --- a/iree/compiler/Dialect/HAL/Target/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/CMakeLists.txt @@ -27,7 +27,7 @@ iree_cc_library( DEPS iree::compiler::Dialect::Flow::IR iree::compiler::Dialect::HAL::IR - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Utils LLVMSupport MLIRIR diff --git a/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/BUILD b/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/BUILD index 0f3aa08fae01..ae5cf8b49d12 100644 --- a/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/BUILD +++ b/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/BUILD @@ -30,7 +30,7 @@ cc_library( "//iree/compiler/Dialect/HAL/IR", "//iree/compiler/Dialect/HAL/Target:ExecutableTarget", "//iree/compiler/Dialect/HAL/Transforms", - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/Interpreter/IR", "//iree/compiler/Translation/Interpreter/Serialization", "//iree/compiler/Translation/Interpreter/Transforms", diff --git a/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/CMakeLists.txt index 89ddca26aca1..e92e8e4ef8d1 100644 --- a/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/LegacyInterpreter/CMakeLists.txt @@ -24,7 +24,7 @@ iree_cc_library( iree::compiler::Dialect::HAL::IR iree::compiler::Dialect::HAL::Target::ExecutableTarget iree::compiler::Dialect::HAL::Transforms - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::Interpreter::IR iree::compiler::Translation::Interpreter::Serialization iree::compiler::Translation::Interpreter::Transforms diff --git a/iree/compiler/Dialect/HAL/Target/LegacyUtil.cpp b/iree/compiler/Dialect/HAL/Target/LegacyUtil.cpp index 10f55fbb9675..fb09011eabc1 100644 --- a/iree/compiler/Dialect/HAL/Target/LegacyUtil.cpp +++ b/iree/compiler/Dialect/HAL/Target/LegacyUtil.cpp @@ -15,7 +15,7 @@ #include "iree/compiler/Dialect/HAL/Target/LegacyUtil.h" #include "iree/compiler/Dialect/Flow/IR/FlowOps.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Utils/TypeConversionUtils.h" #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/Attributes.h" diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD index 9fed6ba8be28..f4db69ed03b6 100644 --- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD +++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/BUILD @@ -28,7 +28,7 @@ cc_library( deps = [ "//iree/compiler/Dialect/Flow/IR", "//iree/compiler/Dialect/HAL/Target:ExecutableTarget", - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/SPIRV", "//iree/schemas:spirv_executable_def_cc_fbs", "@com_github_google_flatbuffers//:flatbuffers", diff --git a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt index 6ecc672f360d..a4b196ffeca1 100644 --- a/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt +++ b/iree/compiler/Dialect/HAL/Target/VulkanSPIRV/CMakeLists.txt @@ -22,7 +22,7 @@ iree_cc_library( DEPS iree::compiler::Dialect::Flow::IR iree::compiler::Dialect::HAL::Target::ExecutableTarget - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::SPIRV iree::schemas::spirv_executable_def_cc_fbs flatbuffers diff --git a/iree/compiler/Dialect/HAL/hal.imports.mlir b/iree/compiler/Dialect/HAL/hal.imports.mlir index 34e2b713c50a..078a2329a520 100644 --- a/iree/compiler/Dialect/HAL/hal.imports.mlir +++ b/iree/compiler/Dialect/HAL/hal.imports.mlir @@ -8,13 +8,13 @@ vm.module @hal { // Experimental/temporary ops //===----------------------------------------------------------------------===// -vm.import @ex.shared_device() -> !ireex.ref +vm.import @ex.shared_device() -> !iree.ref attributes {nosideeffects} // Returns one of the provided executable formats that can be used by the // device or 0 if none are supported. vm.import @ex.match_supported_executable_format( - %device : !ireex.ref, + %device : !iree.ref, %available_formats : i32 ... ) -> i32 attributes {nosideeffects} @@ -23,32 +23,32 @@ attributes {nosideeffects} // The executable may be shared with other contexts but as it is immutable // this does not matter. vm.import @ex.cache_executable( - %device : !ireex.ref, + %device : !iree.ref, %executable_format : i32, - %executable_data : !ireex.byte_buffer_ref -) -> !ireex.ref + %executable_data : !iree.byte_buffer_ref +) -> !iree.ref attributes {nosideeffects} vm.import @ex.push_binding( - %command_buffer : !ireex.ref, + %command_buffer : !iree.ref, %ordinal : i32, - %buffer : !ireex.ref, + %buffer : !iree.ref, %shape : i32 ..., %element_size : i32 ) vm.import @ex.executable_descriptor_set_layout( - %executable : !ireex.ref, + %executable : !iree.ref, %set : i32 -) -> !ireex.ref +) -> !iree.ref vm.import @ex.defer_release( - %operand : !ireex.opaque_ref + %operand : !iree.opaque_ref ) vm.import @ex.submit_and_wait( - %device : !ireex.ref, - %command_buffer : !ireex.ref + %device : !iree.ref, + %command_buffer : !iree.ref ) //===----------------------------------------------------------------------===// @@ -57,7 +57,7 @@ vm.import @ex.submit_and_wait( // Computes the byte size required for a buffer of the given shape and type. vm.import @allocator.compute_size( - %allocator : !ireex.ref, + %allocator : !iree.ref, %memory_types : i32, %buffer_usage : i32, %shape : i32 ..., @@ -67,30 +67,30 @@ attributes {nosideeffects} // Allocates a buffer from the allocator. vm.import @allocator.allocate( - %allocator : !ireex.ref, + %allocator : !iree.ref, %memory_types : i32, %buffer_usage : i32, %allocation_size : i32 -) -> !ireex.ref +) -> !iree.ref // Allocates a buffer from the allocator with the given constant contents. vm.import @allocator.allocate.const( - %allocator : !ireex.ref, + %allocator : !iree.ref, %memory_types : i32, %buffer_usage : i32, %shape : i32 ..., %element_size : i32, - %value : !ireex.byte_buffer_ref -) -> !ireex.ref + %value : !iree.byte_buffer_ref +) -> !iree.ref // Allocates a buffer from the allocator. vm.import @allocator.allocate.shaped( - %allocator : !ireex.ref, + %allocator : !iree.ref, %memory_types : i32, %buffer_usage : i32, %shape : i32 ..., %element_size : i32 -) -> !ireex.ref +) -> !iree.ref //===----------------------------------------------------------------------===// // iree::hal::Buffer @@ -98,14 +98,14 @@ vm.import @allocator.allocate.shaped( // Returns a reference to a subspan of the buffer. vm.import @buffer.subspan( - %source_buffer : !ireex.ref, + %source_buffer : !iree.ref, %source_offset : i32, %length : i32 -) -> !ireex.ref +) -> !iree.ref // Fills the target buffer with the given repeating value. vm.import @buffer.fill( - %target_buffer : !ireex.ref, + %target_buffer : !iree.ref, %target_offset : i32, %length : i32, %pattern : i32 @@ -113,34 +113,34 @@ vm.import @buffer.fill( // Reads a block of byte data from the resource at the given offset. vm.import @buffer.read_data( - %source_buffer : !ireex.ref, + %source_buffer : !iree.ref, %source_offset : i32, - %target_buffer : !ireex.mutable_byte_buffer_ref, + %target_buffer : !iree.mutable_byte_buffer_ref, %target_offset : i32, %length : i32 ) // Writes a block of byte data into the resource at the given offset. vm.import @buffer.write_data( - %target_buffer : !ireex.ref, + %target_buffer : !iree.ref, %target_offset : i32, - %source_buffer : !ireex.byte_buffer_ref, + %source_buffer : !iree.byte_buffer_ref, %source_offset : i32, %length : i32 ) // Copies data from the provided source_buffer into the buffer. vm.import @buffer.copy_data( - %source_buffer : !ireex.ref, + %source_buffer : !iree.ref, %source_offset : i32, - %target_buffer : !ireex.ref, + %target_buffer : !iree.ref, %target_offset : i32, %length : i32 ) // Loads a value from a buffer by mapping it. vm.import @buffer.load( - %source_buffer : !ireex.ref, + %source_buffer : !iree.ref, %source_offset : i32, %length : i32 ) -> i32 @@ -148,7 +148,7 @@ vm.import @buffer.load( // Stores a value into a buffer by mapping it. vm.import @buffer.store( %value : i32, - %target_buffer : !ireex.ref, + %target_buffer : !iree.ref, %target_offset : i32, %length : i32 ) @@ -159,7 +159,7 @@ vm.import @buffer.store( // Computes an element byte offset within a buffer. vm.import @buffer_view.compute_offset( - %buffer : !ireex.ref, + %buffer : !iree.ref, %shape : i32 ..., %indices : i32 ..., %element_size : i32 @@ -167,14 +167,14 @@ vm.import @buffer_view.compute_offset( // Computes a shaped buffer view length in bytes. vm.import @buffer_view.compute_length( - %buffer : !ireex.ref, + %buffer : !iree.ref, %shape : i32 ..., %element_size : i32 ) -> i32 // Computes a byte range within a buffer for one or more elements. vm.import @buffer_view.compute_range( - %buffer : !ireex.ref, + %buffer : !iree.ref, %shape : i32 ..., %indices : i32 ..., %lengths : i32 ..., @@ -184,12 +184,12 @@ vm.import @buffer_view.compute_range( // Returns a view into a buffer. The buffer is not copied and both the original // and sliced references must be synchronized. vm.import @buffer_view.slice( - %buffer : !ireex.ref, + %buffer : !iree.ref, %shape : i32 ..., %indices : i32 ..., %lengths : i32 ..., %element_size : i32 -) -> !ireex.ref +) -> !iree.ref //===----------------------------------------------------------------------===// // iree::hal::CommandBuffer @@ -197,26 +197,26 @@ vm.import @buffer_view.slice( // Returns a command buffer from the device pool ready to begin recording. vm.import @command_buffer.create( - %device : !ireex.ref, + %device : !iree.ref, %modes : i32, %command_categories : i32 -) -> !ireex.ref +) -> !iree.ref // Resets and begins recording into the command buffer, clearing all previously // recorded contents. vm.import @command_buffer.begin( - %command_buffer : !ireex.ref + %command_buffer : !iree.ref ) // Ends recording into the command buffer. vm.import @command_buffer.end( - %command_buffer : !ireex.ref + %command_buffer : !iree.ref ) // Defines a memory dependency between commands recorded before and after the // barrier. vm.import @command_buffer.execution_barrier( - %command_buffer : !ireex.ref, + %command_buffer : !iree.ref, %source_stage_mask : i32, %target_stage_mask : i32, // TODO(benvanik): tuple types. @@ -226,8 +226,8 @@ vm.import @command_buffer.execution_barrier( // Fills the target buffer with the given repeating value. vm.import @command_buffer.fill_buffer( - %command_buffer : !ireex.ref, - %target_buffer : !ireex.ref, + %command_buffer : !iree.ref, + %target_buffer : !iree.ref, %target_offset : i32, %length : i32, %pattern : i32 @@ -235,27 +235,27 @@ vm.import @command_buffer.fill_buffer( // Copies a range of one buffer to another. vm.import @command_buffer.copy_buffer( - %command_buffer : !ireex.ref, - %source_buffer : !ireex.ref, + %command_buffer : !iree.ref, + %source_buffer : !iree.ref, %source_offset : i32, - %target_buffer : !ireex.ref, + %target_buffer : !iree.ref, %target_offset : i32, %length : i32 ) // Binds a descriptor set to the given set number. vm.import @command_buffer.bind_descriptor_set( - %command_buffer : !ireex.ref, - %executable : !ireex.ref, + %command_buffer : !iree.ref, + %executable : !iree.ref, %set : i32, - %descriptor_set : !ireex.ref, + %descriptor_set : !iree.ref, %dynamic_offsets : i32 ... ) // Dispatches an execution request. vm.import @command_buffer.dispatch( - %command_buffer : !ireex.ref, - %executable : !ireex.ref, + %command_buffer : !iree.ref, + %executable : !iree.ref, %entry_point : i32, %workgroup_x : i32, %workgroup_y : i32, @@ -265,10 +265,10 @@ vm.import @command_buffer.dispatch( // Dispatches an execution request with the dispatch parameters loaded from the // given buffer. vm.import @command_buffer.dispatch.indirect( - %command_buffer : !ireex.ref, - %executable : !ireex.ref, + %command_buffer : !iree.ref, + %executable : !iree.ref, %entry_point : i32, - %workgroups_buffer : !ireex.ref, + %workgroups_buffer : !iree.ref, %workgroups_offset : i32 ) @@ -278,17 +278,17 @@ vm.import @command_buffer.dispatch.indirect( // Allocates a new descriptor set based on the given layout. vm.import @descriptor_set.allocate( - %device : !ireex.ref, - %set_layout : !ireex.ref -) -> !ireex.ref + %device : !iree.ref, + %set_layout : !iree.ref +) -> !iree.ref // Updates a single binding within a descriptor set. vm.import @descriptor_set.update( - %device : !ireex.ref, - %set : !ireex.ref, + %device : !iree.ref, + %set : !iree.ref, // TODO(benvanik): tuples so that we can batch these updates. %binding : i32, - %buffer : !ireex.ref, + %buffer : !iree.ref, %offset : i32, %length : i32, %access : i32 @@ -301,8 +301,8 @@ vm.import @descriptor_set.update( // Returns the allocator that can be used to allocate buffers compatible with // the device. vm.import @device.allocator( - %device : !ireex.ref -) -> !ireex.ref + %device : !iree.ref +) -> !iree.ref attributes {nosideeffects} } // module diff --git a/iree/compiler/Dialect/IREE/IR/IREEBase.td b/iree/compiler/Dialect/IREE/IR/IREEBase.td index 21aafb88657c..24ef59626d63 100644 --- a/iree/compiler/Dialect/IREE/IR/IREEBase.td +++ b/iree/compiler/Dialect/IREE/IR/IREEBase.td @@ -22,8 +22,8 @@ include "mlir/IR/OpBase.td" //===----------------------------------------------------------------------===// // TODO(b/143787186): rename when old dialects are removed. -def IREEX_Dialect : Dialect { - let name = "ireex"; +def IREE_Dialect : Dialect { + let name = "iree"; let cppNamespace = "IREE"; let summary = [{ @@ -31,6 +31,15 @@ def IREEX_Dialect : Dialect { }]; } +//===----------------------------------------------------------------------===// +// General types and helpers +//===----------------------------------------------------------------------===// + +def IREE_Bool : + AnyTypeOf<[I1, I8], "boolean-storing type (1 or 8 -bit integer)">; +def IREE_Element : AnyTypeOf<[AnyInteger, AnyFloat]>; +def IREE_MemRef : MemRefOf<[IREE_Element]>; + //===----------------------------------------------------------------------===// // Attribute constraints //===----------------------------------------------------------------------===// @@ -77,7 +86,7 @@ class NamedTupleOf elements, string descr> : //===----------------------------------------------------------------------===// def AnyRefObject : DialectType< - IREEX_Dialect, + IREE_Dialect, CPred<"$_self.isa()">, "ref_object"> { let typeDescription = [{ @@ -86,7 +95,7 @@ def AnyRefObject : DialectType< } def AnyRefPtr : DialectType< - IREEX_Dialect, + IREE_Dialect, CPred<"$_self.isa()">, "ref"> { let typeDescription = [{ @@ -102,7 +111,7 @@ class RefPtrOf : ]>, "ref<" # type.description # ">">; def ByteBufferType : DialectType< - IREEX_Dialect, + IREE_Dialect, CPred<"$_self.isa()">, "byte_buffer"> { let typeDescription = [{ @@ -113,7 +122,7 @@ def ByteBufferRef : RefPtrOf; def ByteBufferRefAttr : AliasedSymbolRefAttr; def MutableByteBufferType : DialectType< - IREEX_Dialect, + IREE_Dialect, CPred<"$_self.isa()">, "mutable_byte_buffer"> { let typeDescription = [{ diff --git a/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp b/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp index 3715308bd786..57b7c37a17c6 100644 --- a/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp +++ b/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp @@ -25,9 +25,9 @@ namespace mlir { namespace iree_compiler { -static DialectRegistration base_dialect; +static DialectRegistration base_dialect; -IREEXDialect::IREEXDialect(MLIRContext* context) +IREEDialect::IREEDialect(MLIRContext* context) : Dialect(getDialectNamespace(), context) { addTypes(); @@ -41,7 +41,7 @@ IREEXDialect::IREEXDialect(MLIRContext* context) // Type parsing and printing //===----------------------------------------------------------------------===// -Type IREEXDialect::parseType(DialectAsmParser& parser) const { +Type IREEDialect::parseType(DialectAsmParser& parser) const { Location loc = parser.getEncodedSourceLoc(parser.getNameLoc()); llvm::StringRef spec = parser.getFullSymbolSpec(); if (spec.consume_front("ref")) { @@ -78,7 +78,7 @@ Type IREEXDialect::parseType(DialectAsmParser& parser) const { return Type(); } -void IREEXDialect::printType(Type type, DialectAsmPrinter& os) const { +void IREEDialect::printType(Type type, DialectAsmPrinter& os) const { switch (type.getKind()) { case IREE::TypeKind::RefPtr: { auto objectType = type.cast().getObjectType(); diff --git a/iree/compiler/Dialect/IREE/IR/IREEDialect.h b/iree/compiler/Dialect/IREE/IR/IREEDialect.h index 59573e64216a..1c51fa20296f 100644 --- a/iree/compiler/Dialect/IREE/IR/IREEDialect.h +++ b/iree/compiler/Dialect/IREE/IR/IREEDialect.h @@ -22,11 +22,11 @@ namespace mlir { namespace iree_compiler { // TODO(b/143787186): rename to IREEDialect. -class IREEXDialect : public Dialect { +class IREEDialect : public Dialect { public: - explicit IREEXDialect(MLIRContext* context); + explicit IREEDialect(MLIRContext* context); // TODO(b/143787186): rename to iree. - static StringRef getDialectNamespace() { return "ireex"; } + static StringRef getDialectNamespace() { return "iree"; } /// Parses a type registered to this dialect. Type parseType(DialectAsmParser& parser) const override; diff --git a/iree/compiler/Dialect/IREE/IR/IREEOps.cpp b/iree/compiler/Dialect/IREE/IR/IREEOps.cpp index de324fd3cb50..1baa276b8741 100644 --- a/iree/compiler/Dialect/IREE/IR/IREEOps.cpp +++ b/iree/compiler/Dialect/IREE/IR/IREEOps.cpp @@ -30,6 +30,135 @@ namespace mlir { namespace iree_compiler { namespace IREE { +//===----------------------------------------------------------------------===// +// iree.return +//===----------------------------------------------------------------------===// + +static ParseResult parseReturnOp(OpAsmParser &parser, OperationState &state) { + SmallVector opInfo; + SmallVector types; + llvm::SMLoc loc = parser.getCurrentLocation(); + return failure(parser.parseOperandList(opInfo) || + (!opInfo.empty() && parser.parseColonTypeList(types)) || + parser.resolveOperands(opInfo, types, loc, state.operands)); +} + +static void printReturnOp(OpAsmPrinter &p, ReturnOp op) { + p << "iree.return"; + if (op.getNumOperands() > 0) { + p << ' '; + p.printOperands(op.operand_begin(), op.operand_end()); + p << " : "; + interleaveComma(op.getOperandTypes(), p); + } +} + +//===----------------------------------------------------------------------===// +// iree.load_input +//===----------------------------------------------------------------------===// + +ParseResult parseLoadInputOp(OpAsmParser &parser, OperationState &state) { + OpAsmParser::OperandType operand; + Type argType; + if (parser.parseLParen() || parser.parseOperand(operand) || + parser.parseColonType(argType) || parser.parseRParen() || + parser.resolveOperand(operand, argType, state.operands) || + parser.parseOptionalAttrDict(state.attributes)) { + return failure(); + } + Type outputType; + if (parser.parseColonType(outputType) || + parser.addTypeToList(outputType, state.types)) { + return failure(); + } + return success(); +} + +void printLoadInputOp(OpAsmPrinter &printer, Operation *op) { + auto inputValue = op->getOperand(0); + auto outputValue = op->getResult(0); + printer << op->getName() << '('; + printer.printOperand(inputValue); + printer << " : "; + printer.printType(inputValue->getType()); + printer << ") "; + printer.printOptionalAttrDict(op->getAttrs()); + printer << " : "; + printer.printType(outputValue->getType()); +} + +//===----------------------------------------------------------------------===// +// iree.store_output +//===----------------------------------------------------------------------===// + +ParseResult parseStoreOutputOp(OpAsmParser &parser, OperationState &state) { + OpAsmParser::OperandType op0, op1; + Type argType0, argType1; + if (parser.parseLParen() || parser.parseOperand(op0) || + parser.parseColonType(argType0) || parser.parseComma() || + parser.resolveOperand(op0, argType0, state.operands) || + parser.parseOperand(op1) || parser.parseColonType(argType1) || + parser.parseRParen() || + parser.resolveOperand(op1, argType1, state.operands) || + parser.parseOptionalAttrDict(state.attributes)) { + return failure(); + } + return success(); +} + +void printStoreOutputOp(OpAsmPrinter &printer, Operation *op) { + auto inputValue = op->getOperand(0); + auto outputValue = op->getOperand(1); + printer << op->getName() << '('; + printer.printOperand(inputValue); + printer << " : "; + printer.printType(inputValue->getType()); + printer << ", "; + printer.printOperand(outputValue); + printer << " : "; + printer.printType(outputValue->getType()); + printer << ") "; + printer.printOptionalAttrDict(op->getAttrs()); +} + +//===----------------------------------------------------------------------===// +// iree.store_reduce +//===----------------------------------------------------------------------===// + +ParseResult parseStoreReduceOp(OpAsmParser &parser, OperationState &state) { + OpAsmParser::OperandType src, dst; + Type srcType, dstType; + SymbolRefAttr reductionFn; + if (parser.parseLParen() || parser.parseOperand(src) || + parser.parseColonType(srcType) || + parser.resolveOperand(src, srcType, state.operands) || + parser.parseComma() || parser.parseOperand(dst) || + parser.parseColonType(dstType) || + parser.resolveOperand(dst, dstType, state.operands) || + parser.parseComma() || + parser.parseAttribute(reductionFn, "reduction_fn", state.attributes) || + parser.parseRParen() || parser.parseOptionalAttrDict(state.attributes)) { + return failure(); + } + return success(); +} + +void printStoreReduceOp(OpAsmPrinter &printer, Operation *op) { + auto storeReduceOp = cast(op); + printer << op->getName() << '('; + printer.printOperand(storeReduceOp.src()); + printer << " : "; + printer.printType(storeReduceOp.src()->getType()); + printer << ", "; + printer.printOperand(storeReduceOp.dst()); + printer << " : "; + printer.printType(storeReduceOp.dst()->getType()); + printer << ", "; + printer.printAttribute(storeReduceOp.reduction_fnAttr()); + printer << ") "; + printer.printOptionalAttrDict(op->getAttrs(), StringRef("reduction_fn")); +} + //===----------------------------------------------------------------------===// // iree.do_not_optimize //===----------------------------------------------------------------------===// @@ -53,7 +182,7 @@ ParseResult parseDoNotOptimizeOp(OpAsmParser &parser, OperationState &state) { } void printDoNotOptimizeOp(OpAsmPrinter &p, Operation *op) { - p << "ireex.do_not_optimize"; + p << "iree.do_not_optimize"; p << "("; p.printOperands(op->getOperands()); p << ")"; diff --git a/iree/compiler/Dialect/IREE/IR/IREEOps.td b/iree/compiler/Dialect/IREE/IR/IREEOps.td index 247fdf20caeb..f27dd7a0e200 100644 --- a/iree/compiler/Dialect/IREE/IR/IREEOps.td +++ b/iree/compiler/Dialect/IREE/IR/IREEOps.td @@ -17,13 +17,57 @@ include "iree/compiler/Dialect/IREE/IR/IREEBase.td" -class IREEX_Op traits = []> : - Op { +//===----------------------------------------------------------------------===// +// Op types +//===----------------------------------------------------------------------===// + +class IREE_Op traits = []> : + Op { let parser = [{ return parse$cppClass(parser, result); }]; let printer = [{ print$cppClass(p, *this); }]; } -def IREE_DoNotOptimizeOp : IREEX_Op<"do_not_optimize"> { +class IREE_PureOp traits = []> : + IREE_Op; + +//===----------------------------------------------------------------------===// +// Utilities +//===----------------------------------------------------------------------===// + +def IREE_ReturnOp : IREE_Op<"return", [Terminator]> { + let arguments = (ins Variadic:$operands); + + let builders = [OpBuilder< + "Builder *b, OperationState &result", [{ build(b, result, llvm::None); }] + >]; +} + +//===----------------------------------------------------------------------===// +// Executable ABI +//===----------------------------------------------------------------------===// + +def IREE_LoadInputOp : IREE_PureOp<"load_input"> { + let arguments = (ins IREE_MemRef:$src); + let results = (outs AnyType); +} + +def IREE_StoreOutputOp : IREE_Op<"store_output"> { + let arguments = (ins AnyType:$src, IREE_MemRef:$dst); +} + +def IREE_StoreReduceOp : IREE_Op<"store_reduce"> { + let arguments = (ins + AnyType:$src, + IREE_MemRef:$dst, + FlatSymbolRefAttr:$reduction_fn + ); +} + +//===----------------------------------------------------------------------===// +// Compiler hints +//===----------------------------------------------------------------------===// + +def IREE_DoNotOptimizeOp : IREE_Op<"do_not_optimize"> { let summary = "Prevents compiler optimizations of a value."; let description = [{ Wraps any operands in an unoptimizable identity. This operation is declared diff --git a/iree/compiler/IR/test/bindings.mlir b/iree/compiler/Dialect/IREE/IR/test/bindings.mlir similarity index 100% rename from iree/compiler/IR/test/bindings.mlir rename to iree/compiler/Dialect/IREE/IR/test/bindings.mlir diff --git a/iree/compiler/Dialect/IREE/IR/test/do_not_optimize.mlir b/iree/compiler/Dialect/IREE/IR/test/do_not_optimize.mlir index 5022edd217fc..6ab0a123b409 100644 --- a/iree/compiler/Dialect/IREE/IR/test/do_not_optimize.mlir +++ b/iree/compiler/Dialect/IREE/IR/test/do_not_optimize.mlir @@ -4,17 +4,17 @@ // CHECK-SAME: [[ARG0:%[a-zA-Z0-9]+]] // CHECK-SAME: [[ARG1:%[a-zA-Z0-9]+]] func @parse_print(%arg0 : tensor, %arg1 : tensor) { - // CHECK: ireex.do_not_optimize() - ireex.do_not_optimize() + // CHECK: iree.do_not_optimize() + iree.do_not_optimize() - // CHECK-NEXT: ireex.do_not_optimize([[ARG0]]) : tensor - %1 = ireex.do_not_optimize(%arg0) : tensor + // CHECK-NEXT: iree.do_not_optimize([[ARG0]]) : tensor + %1 = iree.do_not_optimize(%arg0) : tensor - // CHECK-NEXT: ireex.do_not_optimize([[ARG0]], [[ARG1]]) : tensor, tensor - %2:2 = ireex.do_not_optimize(%arg0, %arg1) : tensor, tensor + // CHECK-NEXT: iree.do_not_optimize([[ARG0]], [[ARG1]]) : tensor, tensor + %2:2 = iree.do_not_optimize(%arg0, %arg1) : tensor, tensor - // CHECK-NEXT: ireex.do_not_optimize([[ARG0]]) {some_unit} : tensor - %has_attr = ireex.do_not_optimize(%arg0) {some_unit} : tensor + // CHECK-NEXT: iree.do_not_optimize([[ARG0]]) {some_unit} : tensor + %has_attr = iree.do_not_optimize(%arg0) {some_unit} : tensor return } @@ -25,8 +25,8 @@ func @parse_print(%arg0 : tensor, %arg1 : tensor) { func @no_fold_constant() -> (i32) { // CHECK: constant 1 : i32 %0 = constant 1 : i32 - // CHECK: ireex.do_not_optimize - %1 = "ireex.do_not_optimize"(%0) : (i32) -> i32 + // CHECK: iree.do_not_optimize + %1 = "iree.do_not_optimize"(%0) : (i32) -> i32 return %1 : i32 } @@ -36,8 +36,8 @@ func @no_fold_constant() -> (i32) { func @no_fold_add() -> (i32) { // CHECK-NEXT: [[C1:%.+]] = vm.const.i32 1 : i32 %c1 = vm.const.i32 1 : i32 - // CHECK-NEXT: [[R1:%.+]] = ireex.do_not_optimize([[C1]]) - %0 = ireex.do_not_optimize(%c1) : i32 + // CHECK-NEXT: [[R1:%.+]] = iree.do_not_optimize([[C1]]) + %0 = iree.do_not_optimize(%c1) : i32 // CHECK-NEXT: [[R2:%.+]] = vm.add.i32 [[R1]], [[R1]] %1 = vm.add.i32 %0, %0 : i32 // CHECK-NEXT: return [[R2]] @@ -60,7 +60,7 @@ func @fold_add() -> (i32) { func @result_operand_count_mismatch(%arg0 : tensor, %arg1 : tensor) { // expected-error@+1 {{must have same number of operands and results}} - %1 = "ireex.do_not_optimize"(%arg0, %arg1) : (tensor, tensor) -> tensor + %1 = "iree.do_not_optimize"(%arg0, %arg1) : (tensor, tensor) -> tensor return } @@ -68,7 +68,7 @@ func @result_operand_count_mismatch(%arg0 : tensor, %arg1 : tensor) { func @result_operand_type_mismatch(%arg0 : tensor, %arg1 : tensor) { // expected-error@+1 {{must have same operand and result types, but they differ at index 1}} - %1:2 = "ireex.do_not_optimize"(%arg0, %arg1) : (tensor, tensor) -> (tensor, memref) + %1:2 = "iree.do_not_optimize"(%arg0, %arg1) : (tensor, tensor) -> (tensor, memref) return } diff --git a/iree/compiler/Dialect/IREE/Transforms/test/drop_compiler_hints.mlir b/iree/compiler/Dialect/IREE/Transforms/test/drop_compiler_hints.mlir index 569dbc205075..725cd762cfea 100644 --- a/iree/compiler/Dialect/IREE/Transforms/test/drop_compiler_hints.mlir +++ b/iree/compiler/Dialect/IREE/Transforms/test/drop_compiler_hints.mlir @@ -1,10 +1,10 @@ -// RUN: iree-opt -split-input-file -iree-drop-compiler-hints %s | IreeFileCheck --implicit-check-not="ireex.do_not_optimize" %s +// RUN: iree-opt -split-input-file -iree-drop-compiler-hints %s | IreeFileCheck --implicit-check-not="iree.do_not_optimize" %s // CHECK-LABEL: @constant func @constant() -> i32 { // CHECK-NEXT: [[C1:%.+]] = constant 1 %c1 = constant 1 : i32 - %0 = ireex.do_not_optimize(%c1) : i32 + %0 = iree.do_not_optimize(%c1) : i32 // CHECK-NEXT: return [[C1]] return %0 : i32 } @@ -15,12 +15,12 @@ func @constant() -> i32 { func @multiple() -> (i32, i32) { // CHECK-NEXT: [[C1:%.+]] = constant 1 %c1 = constant 1 : i32 - %0 = ireex.do_not_optimize(%c1) : i32 - %1 = ireex.do_not_optimize(%0) : i32 + %0 = iree.do_not_optimize(%c1) : i32 + %1 = iree.do_not_optimize(%0) : i32 // CHECK-NEXT: [[C2:%.+]] = constant 2 %c2 = constant 2 : i32 - %2 = ireex.do_not_optimize(%1) : i32 - %3 = ireex.do_not_optimize(%c2) : i32 + %2 = iree.do_not_optimize(%1) : i32 + %3 = iree.do_not_optimize(%c2) : i32 // CHECK-NEXT: return [[C1]], [[C2]] return %2, %3 : i32, i32 } @@ -33,7 +33,7 @@ func @multiple_operands() -> (i32, i32) { %c1 = constant 1 : i32 // CHECK-NEXT: [[C2:%.+]] = constant 2 %c2 = constant 2 : i32 - %0, %1 = ireex.do_not_optimize(%c1, %c2) : i32, i32 + %0, %1 = iree.do_not_optimize(%c1, %c2) : i32, i32 // CHECK-NEXT: return [[C1]], [[C2]] return %0, %1 : i32, i32 } @@ -42,7 +42,7 @@ func @multiple_operands() -> (i32, i32) { // CHECK-LABEL: @no_operands func @no_operands() { - ireex.do_not_optimize() + iree.do_not_optimize() // CHECK-NEXT: return return } @@ -53,7 +53,7 @@ func @no_operands() { func @no_fold_add() -> (i32) { // CHECK-NEXT: [[C1:%.+]] = vm.const.i32 1 : i32 %c1 = vm.const.i32 1 : i32 - %0 = ireex.do_not_optimize(%c1) : i32 + %0 = iree.do_not_optimize(%c1) : i32 // CHECK-NEXT: [[R:%.+]] = vm.add.i32 [[C1]], [[C1]] %1 = vm.add.i32 %0, %0 : i32 // CHECK-NEXT: return [[R]] @@ -70,7 +70,7 @@ module @deeply_nested { module @inner { // CHECK-LABEL: @no_operands func @no_operands() { - ireex.do_not_optimize() + iree.do_not_optimize() // CHECK-NEXT: return return } diff --git a/iree/compiler/Dialect/Interpreter/CMakeLists.txt b/iree/compiler/Dialect/Interpreter/CMakeLists.txt deleted file mode 100644 index d272b9cf9613..000000000000 --- a/iree/compiler/Dialect/Interpreter/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -add_subdirectory(IR) -add_subdirectory(Serialization) -add_subdirectory(Transforms) -add_subdirectory(Utils) diff --git a/iree/compiler/Dialect/VM/IR/test/assignment_folding.mlir b/iree/compiler/Dialect/VM/IR/test/assignment_folding.mlir index 14cffbe22a9c..34dd205b18bb 100644 --- a/iree/compiler/Dialect/VM/IR/test/assignment_folding.mlir +++ b/iree/compiler/Dialect/VM/IR/test/assignment_folding.mlir @@ -33,28 +33,28 @@ vm.module @select_i32_folds { // CHECK-LABEL: @select_ref_folds vm.module @select_ref_folds { // CHECK-LABEL: @select_ref_zero - vm.func @select_ref_zero(%arg0 : !ireex.opaque_ref, - %arg1 : !ireex.opaque_ref) -> !ireex.opaque_ref { - // CHECK: vm.return %arg1 : !ireex.opaque_ref + vm.func @select_ref_zero(%arg0 : !iree.opaque_ref, + %arg1 : !iree.opaque_ref) -> !iree.opaque_ref { + // CHECK: vm.return %arg1 : !iree.opaque_ref %zero = vm.const.i32.zero : i32 - %0 = vm.select.ref %zero, %arg0, %arg1 : !ireex.opaque_ref - vm.return %0 : !ireex.opaque_ref + %0 = vm.select.ref %zero, %arg0, %arg1 : !iree.opaque_ref + vm.return %0 : !iree.opaque_ref } // CHECK-LABEL: @select_ref_one - vm.func @select_ref_one(%arg0 : !ireex.opaque_ref, - %arg1 : !ireex.opaque_ref) -> !ireex.opaque_ref { - // CHECK: vm.return %arg0 : !ireex.opaque_ref + vm.func @select_ref_one(%arg0 : !iree.opaque_ref, + %arg1 : !iree.opaque_ref) -> !iree.opaque_ref { + // CHECK: vm.return %arg0 : !iree.opaque_ref %c123 = vm.const.i32 123 : i32 - %0 = vm.select.ref %c123, %arg0, %arg1 : !ireex.opaque_ref - vm.return %0 : !ireex.opaque_ref + %0 = vm.select.ref %c123, %arg0, %arg1 : !iree.opaque_ref + vm.return %0 : !iree.opaque_ref } // CHECK-LABEL: @select_ref_eq vm.func @select_ref_eq(%arg0 : i32, - %arg1 : !ireex.opaque_ref) -> !ireex.opaque_ref { - // CHECK: vm.return %arg1 : !ireex.opaque_ref - %0 = vm.select.ref %arg0, %arg1, %arg1 : !ireex.opaque_ref - vm.return %0 : !ireex.opaque_ref + %arg1 : !iree.opaque_ref) -> !iree.opaque_ref { + // CHECK: vm.return %arg1 : !iree.opaque_ref + %0 = vm.select.ref %arg0, %arg1, %arg1 : !iree.opaque_ref + vm.return %0 : !iree.opaque_ref } } diff --git a/iree/compiler/Dialect/VM/IR/test/assignment_ops.mlir b/iree/compiler/Dialect/VM/IR/test/assignment_ops.mlir index 077d6fb7ec6c..b66b9e444763 100644 --- a/iree/compiler/Dialect/VM/IR/test/assignment_ops.mlir +++ b/iree/compiler/Dialect/VM/IR/test/assignment_ops.mlir @@ -16,10 +16,10 @@ vm.module @my_module { // CHECK-LABEL: @select_ref vm.module @my_module { vm.func @select_ref(%arg0 : i32, - %arg1 : !ireex.opaque_ref, - %arg2 : !ireex.opaque_ref) -> !ireex.opaque_ref { - // CHECK: %ref = vm.select.ref %arg0, %arg1, %arg2 : !ireex.opaque_ref - %ref = vm.select.ref %arg0, %arg1, %arg2 : !ireex.opaque_ref - vm.return %ref : !ireex.opaque_ref + %arg1 : !iree.opaque_ref, + %arg2 : !iree.opaque_ref) -> !iree.opaque_ref { + // CHECK: %ref = vm.select.ref %arg0, %arg1, %arg2 : !iree.opaque_ref + %ref = vm.select.ref %arg0, %arg1, %arg2 : !iree.opaque_ref + vm.return %ref : !iree.opaque_ref } } diff --git a/iree/compiler/Dialect/VM/IR/test/comparison_folding.mlir b/iree/compiler/Dialect/VM/IR/test/comparison_folding.mlir index 9742f44af13c..b1a45e50d02a 100644 --- a/iree/compiler/Dialect/VM/IR/test/comparison_folding.mlir +++ b/iree/compiler/Dialect/VM/IR/test/comparison_folding.mlir @@ -344,10 +344,10 @@ vm.module @cmp_ugte_i32_folds { // CHECK-LABEL: @cmp_eq_ref_folds vm.module @cmp_eq_ref_folds { // CHECK-LABEL: @always_eq - vm.func @always_eq(%arg0 : !ireex.opaque_ref) -> i32 { + vm.func @always_eq(%arg0 : !iree.opaque_ref) -> i32 { // CHECK: %c1 = vm.const.i32 1 : i32 // CHECK-NEXT: vm.return %c1 : i32 - %eq = vm.cmp.eq.ref %arg0, %arg0 : !ireex.opaque_ref + %eq = vm.cmp.eq.ref %arg0, %arg0 : !iree.opaque_ref vm.return %eq : i32 } @@ -355,19 +355,19 @@ vm.module @cmp_eq_ref_folds { vm.func @const_eq() -> i32 { // CHECK: %c1 = vm.const.i32 1 : i32 // CHECK-NEXT: vm.return %c1 : i32 - %null = vm.const.ref.zero : !ireex.opaque_ref - %null0 = vm.const.ref.zero : !ireex.opaque_ref - %eq = vm.cmp.eq.ref %null, %null0 : !ireex.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + %null0 = vm.const.ref.zero : !iree.opaque_ref + %eq = vm.cmp.eq.ref %null, %null0 : !iree.opaque_ref vm.return %eq : i32 } // CHECK-LABEL: @cmp_null - vm.func @cmp_null(%arg0 : !ireex.opaque_ref) -> i32 { - // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !ireex.opaque_ref + vm.func @cmp_null(%arg0 : !iree.opaque_ref) -> i32 { + // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !iree.opaque_ref // CHECK-NEXT: %0 = vm.not.i32 %rnz : i32 // CHECK-NEXT: vm.return %0 : i32 - %null = vm.const.ref.zero : !ireex.opaque_ref - %eq = vm.cmp.eq.ref %arg0, %null : !ireex.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + %eq = vm.cmp.eq.ref %arg0, %null : !iree.opaque_ref vm.return %eq : i32 } } @@ -377,10 +377,10 @@ vm.module @cmp_eq_ref_folds { // CHECK-LABEL: @cmp_ne_ref_folds vm.module @cmp_ne_ref_folds { // CHECK-LABEL: @always_eq - vm.func @always_eq(%arg0 : !ireex.opaque_ref) -> i32 { + vm.func @always_eq(%arg0 : !iree.opaque_ref) -> i32 { // CHECK: %zero = vm.const.i32.zero : i32 // CHECK-NEXT: vm.return %zero : i32 - %ne = vm.cmp.ne.ref %arg0, %arg0 : !ireex.opaque_ref + %ne = vm.cmp.ne.ref %arg0, %arg0 : !iree.opaque_ref vm.return %ne : i32 } @@ -388,18 +388,18 @@ vm.module @cmp_ne_ref_folds { vm.func @const_eq() -> i32 { // CHECK: %zero = vm.const.i32.zero : i32 // CHECK-NEXT: vm.return %zero : i32 - %null = vm.const.ref.zero : !ireex.opaque_ref - %null0 = vm.const.ref.zero : !ireex.opaque_ref - %ne = vm.cmp.ne.ref %null, %null0 : !ireex.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + %null0 = vm.const.ref.zero : !iree.opaque_ref + %ne = vm.cmp.ne.ref %null, %null0 : !iree.opaque_ref vm.return %ne : i32 } // CHECK-LABEL: @cmp_null - vm.func @cmp_null(%arg0 : !ireex.opaque_ref) -> i32 { - // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !ireex.opaque_ref + vm.func @cmp_null(%arg0 : !iree.opaque_ref) -> i32 { + // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !iree.opaque_ref // CHECK-NEXT: vm.return %rnz : i32 - %null = vm.const.ref.zero : !ireex.opaque_ref - %ne = vm.cmp.ne.ref %arg0, %null : !ireex.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + %ne = vm.cmp.ne.ref %arg0, %null : !iree.opaque_ref vm.return %ne : i32 } } @@ -412,8 +412,8 @@ vm.module @cmp_nz_ref_folds { vm.func @const_null() -> i32 { // CHECK: %zero = vm.const.i32.zero : i32 // CHECK-NEXT: vm.return %zero : i32 - %null = vm.const.ref.zero : !ireex.opaque_ref - %ne = vm.cmp.nz.ref %null : !ireex.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + %ne = vm.cmp.nz.ref %null : !iree.opaque_ref vm.return %ne : i32 } } diff --git a/iree/compiler/Dialect/VM/IR/test/comparison_ops.mlir b/iree/compiler/Dialect/VM/IR/test/comparison_ops.mlir index b10f72e07aec..e9adc9e3b97e 100644 --- a/iree/compiler/Dialect/VM/IR/test/comparison_ops.mlir +++ b/iree/compiler/Dialect/VM/IR/test/comparison_ops.mlir @@ -114,10 +114,10 @@ vm.module @my_module { // CHECK-LABEL: @cmp_eq_ref vm.module @my_module { - vm.func @cmp_eq_ref(%arg0 : !ireex.opaque_ref, - %arg1 : !ireex.opaque_ref) -> i32 { - // CHECK: %req = vm.cmp.eq.ref %arg0, %arg1 : !ireex.opaque_ref - %req = vm.cmp.eq.ref %arg0, %arg1 : !ireex.opaque_ref + vm.func @cmp_eq_ref(%arg0 : !iree.opaque_ref, + %arg1 : !iree.opaque_ref) -> i32 { + // CHECK: %req = vm.cmp.eq.ref %arg0, %arg1 : !iree.opaque_ref + %req = vm.cmp.eq.ref %arg0, %arg1 : !iree.opaque_ref vm.return %req : i32 } } @@ -126,10 +126,10 @@ vm.module @my_module { // CHECK-LABEL: @cmp_ne_ref vm.module @my_module { - vm.func @cmp_ne_ref(%arg0 : !ireex.opaque_ref, - %arg1 : !ireex.opaque_ref) -> i32 { - // CHECK: %rne = vm.cmp.ne.ref %arg0, %arg1 : !ireex.opaque_ref - %rne = vm.cmp.ne.ref %arg0, %arg1 : !ireex.opaque_ref + vm.func @cmp_ne_ref(%arg0 : !iree.opaque_ref, + %arg1 : !iree.opaque_ref) -> i32 { + // CHECK: %rne = vm.cmp.ne.ref %arg0, %arg1 : !iree.opaque_ref + %rne = vm.cmp.ne.ref %arg0, %arg1 : !iree.opaque_ref vm.return %rne : i32 } } @@ -138,9 +138,9 @@ vm.module @my_module { // CHECK-LABEL: @cmp_nz_ref vm.module @my_module { - vm.func @cmp_nz_ref(%arg0 : !ireex.opaque_ref) -> i32 { - // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !ireex.opaque_ref - %rnz = vm.cmp.nz.ref %arg0 : !ireex.opaque_ref + vm.func @cmp_nz_ref(%arg0 : !iree.opaque_ref) -> i32 { + // CHECK: %rnz = vm.cmp.nz.ref %arg0 : !iree.opaque_ref + %rnz = vm.cmp.nz.ref %arg0 : !iree.opaque_ref vm.return %rnz : i32 } } diff --git a/iree/compiler/Dialect/VM/IR/test/const_folding.mlir b/iree/compiler/Dialect/VM/IR/test/const_folding.mlir index 7627e6c38144..0d6e932273cc 100644 --- a/iree/compiler/Dialect/VM/IR/test/const_folding.mlir +++ b/iree/compiler/Dialect/VM/IR/test/const_folding.mlir @@ -28,12 +28,12 @@ vm.module @const_i32_folds { // CHECK-LABEL: @const_ref_folds vm.module @const_ref_folds { // CHECK-LABEL: @cse_null - vm.func @cse_null() -> (!ireex.opaque_ref, !ireex.opaque_ref) { - // CHECK-NEXT: %null = vm.const.ref.zero : !ireex.opaque_ref - // CHECK-NEXT: vm.return %null, %null : !ireex.opaque_ref, !ireex.opaque_ref - %0 = vm.const.ref.zero : !ireex.opaque_ref - %1 = vm.const.ref.zero : !ireex.opaque_ref - vm.return %0, %1 : !ireex.opaque_ref, !ireex.opaque_ref + vm.func @cse_null() -> (!iree.opaque_ref, !iree.opaque_ref) { + // CHECK-NEXT: %null = vm.const.ref.zero : !iree.opaque_ref + // CHECK-NEXT: vm.return %null, %null : !iree.opaque_ref, !iree.opaque_ref + %0 = vm.const.ref.zero : !iree.opaque_ref + %1 = vm.const.ref.zero : !iree.opaque_ref + vm.return %0, %1 : !iree.opaque_ref, !iree.opaque_ref } } @@ -44,11 +44,11 @@ vm.module @const_rodata_folds { // CHECK-NEXT: vm.rodata @r2 vm.rodata @r2 dense<[9, 9, 9]> : vector<3xi32> // CHECK-NEXT: @cse_rodata_loads - vm.func @cse_rodata_loads() -> (!ireex.byte_buffer_ref, !ireex.byte_buffer_ref) { - // CHECK-NEXT: %r2 = vm.const.ref.rodata @r2 : !ireex.byte_buffer_ref - // CHECK-NEXT: vm.return %r2, %r2 : !ireex.byte_buffer_ref, !ireex.byte_buffer_ref - %0 = vm.const.ref.rodata @r2 : !ireex.byte_buffer_ref - %1 = vm.const.ref.rodata @r2 : !ireex.byte_buffer_ref - vm.return %0, %1 : !ireex.byte_buffer_ref, !ireex.byte_buffer_ref + vm.func @cse_rodata_loads() -> (!iree.byte_buffer_ref, !iree.byte_buffer_ref) { + // CHECK-NEXT: %r2 = vm.const.ref.rodata @r2 : !iree.byte_buffer_ref + // CHECK-NEXT: vm.return %r2, %r2 : !iree.byte_buffer_ref, !iree.byte_buffer_ref + %0 = vm.const.ref.rodata @r2 : !iree.byte_buffer_ref + %1 = vm.const.ref.rodata @r2 : !iree.byte_buffer_ref + vm.return %0, %1 : !iree.byte_buffer_ref, !iree.byte_buffer_ref } } diff --git a/iree/compiler/Dialect/VM/IR/test/const_ops.mlir b/iree/compiler/Dialect/VM/IR/test/const_ops.mlir index 963914cb33e3..7b8903d00cc8 100644 --- a/iree/compiler/Dialect/VM/IR/test/const_ops.mlir +++ b/iree/compiler/Dialect/VM/IR/test/const_ops.mlir @@ -26,10 +26,10 @@ vm.module @my_module { vm.module @my_module { // CHECK-LABEL: @const_ref_zero - vm.func @const_ref_zero() -> !ireex.opaque_ref { - // CHECK: %null = vm.const.ref.zero : !ireex.opaque_ref - %null = vm.const.ref.zero : !ireex.opaque_ref - vm.return %null : !ireex.opaque_ref + vm.func @const_ref_zero() -> !iree.opaque_ref { + // CHECK: %null = vm.const.ref.zero : !iree.opaque_ref + %null = vm.const.ref.zero : !iree.opaque_ref + vm.return %null : !iree.opaque_ref } } @@ -38,9 +38,9 @@ vm.module @my_module { vm.module @my_module { vm.rodata @buf0 dense<[0, 1, 2]> : tensor<3xi8> // CHECK-LABEL: @const_ref_rodata - vm.func @const_ref_rodata() -> !ireex.byte_buffer_ref { - // CHECK: %buf0 = vm.const.ref.rodata @buf0 : !ireex.byte_buffer_ref - %buf0 = vm.const.ref.rodata @buf0 : !ireex.byte_buffer_ref - vm.return %buf0 : !ireex.byte_buffer_ref + vm.func @const_ref_rodata() -> !iree.byte_buffer_ref { + // CHECK: %buf0 = vm.const.ref.rodata @buf0 : !iree.byte_buffer_ref + %buf0 = vm.const.ref.rodata @buf0 : !iree.byte_buffer_ref + vm.return %buf0 : !iree.byte_buffer_ref } } diff --git a/iree/compiler/Dialect/VM/IR/test/control_flow_ops.mlir b/iree/compiler/Dialect/VM/IR/test/control_flow_ops.mlir index d9eb3bbc8e64..f8c65eb488ed 100644 --- a/iree/compiler/Dialect/VM/IR/test/control_flow_ops.mlir +++ b/iree/compiler/Dialect/VM/IR/test/control_flow_ops.mlir @@ -80,10 +80,10 @@ vm.module @my_module { // CHECK-LABEL: @call_variadic_empty vm.module @my_module { - vm.import @import_fn(%arg0 : i32, %arg1 : !ireex.ref...) -> i32 + vm.import @import_fn(%arg0 : i32, %arg1 : !iree.ref...) -> i32 vm.func @call_variadic_empty(%arg0 : i32) -> i32 { - // CHECK: %0 = vm.call.variadic @import_fn(%arg0, []) : (i32, !ireex.ref...) -> i32 - %0 = vm.call.variadic @import_fn(%arg0, []) : (i32, !ireex.ref...) -> i32 + // CHECK: %0 = vm.call.variadic @import_fn(%arg0, []) : (i32, !iree.ref...) -> i32 + %0 = vm.call.variadic @import_fn(%arg0, []) : (i32, !iree.ref...) -> i32 vm.return %0 : i32 } } @@ -92,10 +92,10 @@ vm.module @my_module { // CHECK-LABEL: @call_variadic vm.module @my_module { - vm.import @import_fn(%arg0 : i32, %arg1 : !ireex.ref...) -> i32 - vm.func @call_variadic(%arg0 : i32, %arg1 : !ireex.ref) -> i32 { - // CHECK: %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1]) : (i32, !ireex.ref...) -> i32 - %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1]) : (i32, !ireex.ref...) -> i32 + vm.import @import_fn(%arg0 : i32, %arg1 : !iree.ref...) -> i32 + vm.func @call_variadic(%arg0 : i32, %arg1 : !iree.ref) -> i32 { + // CHECK: %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1]) : (i32, !iree.ref...) -> i32 + %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1]) : (i32, !iree.ref...) -> i32 vm.return %0 : i32 } } @@ -104,10 +104,10 @@ vm.module @my_module { // CHECK-LABEL: @call_variadic_multiple vm.module @my_module { - vm.import @import_fn(%arg0 : i32, %arg1 : !ireex.ref...) -> i32 - vm.func @call_variadic_multiple(%arg0 : i32, %arg1 : !ireex.ref) -> i32 { - // CHECK: %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !ireex.ref..., !ireex.ref...) -> i32 - %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !ireex.ref..., !ireex.ref...) -> i32 + vm.import @import_fn(%arg0 : i32, %arg1 : !iree.ref...) -> i32 + vm.func @call_variadic_multiple(%arg0 : i32, %arg1 : !iree.ref) -> i32 { + // CHECK: %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !iree.ref..., !iree.ref...) -> i32 + %0 = vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !iree.ref..., !iree.ref...) -> i32 vm.return %0 : i32 } } @@ -116,10 +116,10 @@ vm.module @my_module { // CHECK-LABEL: @call_variadic_no_results vm.module @my_module { - vm.import @import_fn(%arg0 : i32, %arg1 : !ireex.ref...) - vm.func @call_variadic_no_results(%arg0 : i32, %arg1 : !ireex.ref) { - // CHECK: vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !ireex.ref..., !ireex.ref...) - vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !ireex.ref..., !ireex.ref...) + vm.import @import_fn(%arg0 : i32, %arg1 : !iree.ref...) + vm.func @call_variadic_no_results(%arg0 : i32, %arg1 : !iree.ref) { + // CHECK: vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !iree.ref..., !iree.ref...) + vm.call.variadic @import_fn(%arg0, [%arg1, %arg1], [%arg1]) : (i32, !iree.ref..., !iree.ref...) vm.return } } diff --git a/iree/compiler/Dialect/VM/IR/test/global_folding.mlir b/iree/compiler/Dialect/VM/IR/test/global_folding.mlir index fa1bbefac94c..34c729db4802 100644 --- a/iree/compiler/Dialect/VM/IR/test/global_folding.mlir +++ b/iree/compiler/Dialect/VM/IR/test/global_folding.mlir @@ -28,11 +28,11 @@ vm.module @global_i32_folds { // CHECK-LABEL: @global_ref_folds_null vm.module @global_ref_folds_null { - // CHECK: vm.global.ref @g0 mutable : !ireex.opaque_ref - vm.global.ref @g0 mutable init(@g0init) : !ireex.opaque_ref - vm.func @g0init() -> !ireex.opaque_ref { - %null = vm.const.ref.zero : !ireex.opaque_ref - vm.return %null : !ireex.opaque_ref + // CHECK: vm.global.ref @g0 mutable : !iree.opaque_ref + vm.global.ref @g0 mutable init(@g0init) : !iree.opaque_ref + vm.func @g0init() -> !iree.opaque_ref { + %null = vm.const.ref.zero : !iree.opaque_ref + vm.return %null : !iree.opaque_ref } } @@ -64,22 +64,22 @@ vm.module @global_load_i32_folds { // CHECK-LABEL: @global_load_ref_folds vm.module @global_load_ref_folds { - vm.global.ref @g0 : !ireex.opaque_ref + vm.global.ref @g0 : !iree.opaque_ref // CHECK-LABEL: @inline_const_null - vm.func @inline_const_null() -> !ireex.opaque_ref { - // CHECK-NEXT: %null = vm.const.ref.zero : !ireex.opaque_ref - // CHECK-NEXT: vm.return %null : !ireex.opaque_ref - %g0 = vm.global.load.ref @g0 : !ireex.opaque_ref - vm.return %g0 : !ireex.opaque_ref + vm.func @inline_const_null() -> !iree.opaque_ref { + // CHECK-NEXT: %null = vm.const.ref.zero : !iree.opaque_ref + // CHECK-NEXT: vm.return %null : !iree.opaque_ref + %g0 = vm.global.load.ref @g0 : !iree.opaque_ref + vm.return %g0 : !iree.opaque_ref } - vm.global.ref @g1 mutable : !ireex.opaque_ref + vm.global.ref @g1 mutable : !iree.opaque_ref // CHECK-LABEL: @ignore_nonconst_value - vm.func @ignore_nonconst_value() -> !ireex.opaque_ref { + vm.func @ignore_nonconst_value() -> !iree.opaque_ref { // NOTE: ensure we don't inline non-constant values. - // CHECK-NEXT: %g1 = vm.global.load.ref @g1 : !ireex.opaque_ref - // CHECK-NEXT: vm.return %g1 : !ireex.opaque_ref - %g1 = vm.global.load.ref @g1 : !ireex.opaque_ref - vm.return %g1 : !ireex.opaque_ref + // CHECK-NEXT: %g1 = vm.global.load.ref @g1 : !iree.opaque_ref + // CHECK-NEXT: vm.return %g1 : !iree.opaque_ref + %g1 = vm.global.load.ref @g1 : !iree.opaque_ref + vm.return %g1 : !iree.opaque_ref } } diff --git a/iree/compiler/Dialect/VM/IR/test/global_ops.mlir b/iree/compiler/Dialect/VM/IR/test/global_ops.mlir index 8dc52a6e94dd..2788344809e0 100644 --- a/iree/compiler/Dialect/VM/IR/test/global_ops.mlir +++ b/iree/compiler/Dialect/VM/IR/test/global_ops.mlir @@ -28,11 +28,11 @@ vm.module @my_module { // CHECK-LABEL: @global_load_ref vm.module @my_module { - vm.global.ref @g0 : !ireex.opaque_ref - vm.func @global_load_ref() -> !ireex.opaque_ref { - // CHECK: %g0 = vm.global.load.ref @g0 : !ireex.opaque_ref - %g0 = vm.global.load.ref @g0 : !ireex.opaque_ref - vm.return %g0 : !ireex.opaque_ref + vm.global.ref @g0 : !iree.opaque_ref + vm.func @global_load_ref() -> !iree.opaque_ref { + // CHECK: %g0 = vm.global.load.ref @g0 : !iree.opaque_ref + %g0 = vm.global.load.ref @g0 : !iree.opaque_ref + vm.return %g0 : !iree.opaque_ref } } @@ -40,10 +40,10 @@ vm.module @my_module { // CHECK-LABEL: @global_store_ref vm.module @my_module { - vm.global.ref @g0 mutable : !ireex.opaque_ref - vm.func @global_store_ref(%arg0 : !ireex.opaque_ref) { - // CHECK: vm.global.store.ref @g0, %arg0 : !ireex.opaque_ref - vm.global.store.ref @g0, %arg0 : !ireex.opaque_ref + vm.global.ref @g0 mutable : !iree.opaque_ref + vm.func @global_store_ref(%arg0 : !iree.opaque_ref) { + // CHECK: vm.global.store.ref @g0, %arg0 : !iree.opaque_ref + vm.global.store.ref @g0, %arg0 : !iree.opaque_ref vm.return } } @@ -52,7 +52,7 @@ vm.module @my_module { // CHECK-LABEL: @global_reset_ref vm.module @my_module { - vm.global.ref @g0 mutable : !ireex.opaque_ref + vm.global.ref @g0 mutable : !iree.opaque_ref vm.func @global_reset_ref() { // CHECK: vm.global.reset.ref @g0 vm.global.reset.ref @g0 diff --git a/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir b/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir index 1be92decd091..ea0d9f13be77 100644 --- a/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir +++ b/iree/compiler/Dialect/VM/Transforms/test/global_initialization.mlir @@ -37,18 +37,18 @@ vm.module @initI32 { // CHECK-LABEL: @initRef vm.module @initRef { - // CHECK: vm.global.ref @g0 mutable : !ireex.opaque_ref - vm.global.ref @g0 mutable init(@g0init) : !ireex.opaque_ref - vm.func @g0init() -> !ireex.opaque_ref { - %null = vm.const.ref.zero : !ireex.opaque_ref - vm.return %null : !ireex.opaque_ref + // CHECK: vm.global.ref @g0 mutable : !iree.opaque_ref + vm.global.ref @g0 mutable init(@g0init) : !iree.opaque_ref + vm.func @g0init() -> !iree.opaque_ref { + %null = vm.const.ref.zero : !iree.opaque_ref + vm.return %null : !iree.opaque_ref } - // CHECK: vm.global.ref @g1 mutable : !ireex.opaque_ref - vm.global.ref @g1 mutable : !ireex.opaque_ref + // CHECK: vm.global.ref @g1 mutable : !iree.opaque_ref + vm.global.ref @g1 mutable : !iree.opaque_ref - // CHECK: vm.global.ref @g2 : !ireex.opaque_ref - vm.global.ref @g2 : !ireex.opaque_ref + // CHECK: vm.global.ref @g2 : !iree.opaque_ref + vm.global.ref @g2 : !iree.opaque_ref // CHECK: vm.func @__init() { // CHECK-NEXT: %ref = vm.call @g0init() diff --git a/iree/compiler/IR/BUILD b/iree/compiler/IR/BUILD deleted file mode 100644 index 86a3beb7cb99..000000000000 --- a/iree/compiler/IR/BUILD +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//build_tools/bazel:tblgen.bzl", "gentbl") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -exports_files(["OpBase.td"]) - -filegroup( - name = "td_files", - srcs = glob(["*.td"]), -) - -cc_library( - name = "IR", - srcs = [ - "Dialect.cpp", - "Ops.cpp", - "Ops.cpp.inc", - ], - hdrs = [ - "Dialect.h", - "Ops.h", - "Ops.h.inc", - ], - deps = [ - ":OpsGen", - "@llvm-project//llvm:support", - "@llvm-project//mlir:IR", - "@llvm-project//mlir:StandardOps", - "@llvm-project//mlir:Support", - ], - alwayslink = 1, -) - -gentbl( - name = "OpsGen", - tbl_outs = [ - ("-gen-op-decls", "Ops.h.inc"), - ("-gen-op-defs", "Ops.cpp.inc"), - ], - tblgen = "@llvm-project//mlir:mlir-tblgen", - td_file = "Ops.td", - td_srcs = [ - ":td_files", - "@llvm-project//mlir:OpBaseTdFiles", - ], -) diff --git a/iree/compiler/IR/CMakeLists.txt b/iree/compiler/IR/CMakeLists.txt deleted file mode 100644 index 83c125ff6d54..000000000000 --- a/iree/compiler/IR/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -iree_cc_library( - NAME - IR - HDRS - "Dialect.h" - "Ops.h" - SRCS - "Dialect.cpp" - "Ops.cpp" - "Ops.cpp.inc" - "Ops.h.inc" - DEPS - iree::compiler::IR::OpsGen - LLVMSupport - MLIRIR - MLIRStandardOps - ALWAYSLINK - PUBLIC -) - -iree_tablegen_library( - NAME - OpsGen - SRCS - Ops.td - OUTS - -gen-op-decls Ops.h.inc - -gen-op-defs Ops.cpp.inc -) diff --git a/iree/compiler/IR/Dialect.cpp b/iree/compiler/IR/Dialect.cpp deleted file mode 100644 index 0059d69c0c47..000000000000 --- a/iree/compiler/IR/Dialect.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "iree/compiler/IR/Dialect.h" - -#include "iree/compiler/IR/Ops.h" -#include "llvm/Support/SourceMgr.h" -#include "mlir/IR/DialectImplementation.h" - -namespace mlir { -namespace iree_compiler { - -static DialectRegistration iree_dialect; - -IREEDialect::IREEDialect(MLIRContext *context) - : Dialect(getDialectNamespace(), context) { -#define GET_OP_LIST - addOperations< -#include "iree/compiler/IR/Ops.cpp.inc" - >(); -} - -} // namespace iree_compiler -} // namespace mlir diff --git a/iree/compiler/IR/Dialect.h b/iree/compiler/IR/Dialect.h deleted file mode 100644 index f73bd0b4fd99..000000000000 --- a/iree/compiler/IR/Dialect.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef IREE_COMPILER_IR_DIALECT_H_ -#define IREE_COMPILER_IR_DIALECT_H_ - -#include "mlir/IR/Dialect.h" - -namespace mlir { -namespace iree_compiler { - -class IREEDialect : public Dialect { - public: - explicit IREEDialect(MLIRContext* context); - static StringRef getDialectNamespace() { return "iree"; } -}; - -} // namespace iree_compiler -} // namespace mlir - -#endif // IREE_COMPILER_IR_DIALECT_H_ diff --git a/iree/compiler/IR/OpBase.td b/iree/compiler/IR/OpBase.td deleted file mode 100644 index 6a0c468bb4fd..000000000000 --- a/iree/compiler/IR/OpBase.td +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Common IREE op definitions shared by the interpreter and sequencer dialects. - -#ifndef IREE_OP_BASE -#define IREE_OP_BASE - -include "mlir/IR/OpBase.td" - -//===----------------------------------------------------------------------===// -// Top-level IREE dialect -//===----------------------------------------------------------------------===// - -def IREE_Dialect : Dialect { - let name = "iree"; - let cppNamespace = "IREE"; -} - -//===----------------------------------------------------------------------===// -// General types and helpers -//===----------------------------------------------------------------------===// - -def IREE_Bool : - AnyTypeOf<[I1, I8], "boolean-storing type (1 or 8 -bit integer)">; -def IREE_Element : AnyTypeOf<[AnyInteger, AnyFloat]>; -def IREE_MemRef : MemRefOf<[IREE_Element]>; - -#endif // IREE_OP_BASE diff --git a/iree/compiler/IR/Ops.cpp b/iree/compiler/IR/Ops.cpp deleted file mode 100644 index 5616a29725a4..000000000000 --- a/iree/compiler/IR/Ops.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "iree/compiler/IR/Ops.h" - -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/SMLoc.h" -#include "mlir/IR/Attributes.h" -#include "mlir/IR/Builders.h" -#include "mlir/IR/Diagnostics.h" -#include "mlir/IR/OpImplementation.h" -#include "mlir/IR/TypeUtilities.h" -#include "mlir/IR/Value.h" -#include "mlir/Support/LogicalResult.h" -#include "mlir/Support/STLExtras.h" - -namespace mlir { -namespace iree_compiler { -namespace IREE { - -//===----------------------------------------------------------------------===// -// iree.return -//===----------------------------------------------------------------------===// - -static ParseResult parseReturnOp(OpAsmParser &parser, OperationState &state) { - SmallVector opInfo; - SmallVector types; - llvm::SMLoc loc = parser.getCurrentLocation(); - return failure(parser.parseOperandList(opInfo) || - (!opInfo.empty() && parser.parseColonTypeList(types)) || - parser.resolveOperands(opInfo, types, loc, state.operands)); -} - -static void printReturnOp(OpAsmPrinter &p, ReturnOp op) { - p << "iree.return"; - if (op.getNumOperands() > 0) { - p << ' '; - p.printOperands(op.operand_begin(), op.operand_end()); - p << " : "; - interleaveComma(op.getOperandTypes(), p); - } -} - -//===----------------------------------------------------------------------===// -// iree.load_input -//===----------------------------------------------------------------------===// - -ParseResult parseLoadInputOp(OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType operand; - Type argType; - if (parser.parseLParen() || parser.parseOperand(operand) || - parser.parseColonType(argType) || parser.parseRParen() || - parser.resolveOperand(operand, argType, state.operands) || - parser.parseOptionalAttrDict(state.attributes)) { - return failure(); - } - Type outputType; - if (parser.parseColonType(outputType) || - parser.addTypeToList(outputType, state.types)) { - return failure(); - } - return success(); -} - -void printLoadInputOp(OpAsmPrinter &printer, Operation *op) { - auto inputValue = op->getOperand(0); - auto outputValue = op->getResult(0); - printer << op->getName() << '('; - printer.printOperand(inputValue); - printer << " : "; - printer.printType(inputValue->getType()); - printer << ") "; - printer.printOptionalAttrDict(op->getAttrs()); - printer << " : "; - printer.printType(outputValue->getType()); -} - -//===----------------------------------------------------------------------===// -// iree.store_output -//===----------------------------------------------------------------------===// - -ParseResult parseStoreOutputOp(OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType op0, op1; - Type argType0, argType1; - if (parser.parseLParen() || parser.parseOperand(op0) || - parser.parseColonType(argType0) || parser.parseComma() || - parser.resolveOperand(op0, argType0, state.operands) || - parser.parseOperand(op1) || parser.parseColonType(argType1) || - parser.parseRParen() || - parser.resolveOperand(op1, argType1, state.operands) || - parser.parseOptionalAttrDict(state.attributes)) { - return failure(); - } - return success(); -} - -void printStoreOutputOp(OpAsmPrinter &printer, Operation *op) { - auto inputValue = op->getOperand(0); - auto outputValue = op->getOperand(1); - printer << op->getName() << '('; - printer.printOperand(inputValue); - printer << " : "; - printer.printType(inputValue->getType()); - printer << ", "; - printer.printOperand(outputValue); - printer << " : "; - printer.printType(outputValue->getType()); - printer << ") "; - printer.printOptionalAttrDict(op->getAttrs()); -} - -//===----------------------------------------------------------------------===// -// iree.store_reduce -//===----------------------------------------------------------------------===// - -ParseResult parseStoreReduceOp(OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType src, dst; - Type srcType, dstType; - SymbolRefAttr reductionFn; - if (parser.parseLParen() || parser.parseOperand(src) || - parser.parseColonType(srcType) || - parser.resolveOperand(src, srcType, state.operands) || - parser.parseComma() || parser.parseOperand(dst) || - parser.parseColonType(dstType) || - parser.resolveOperand(dst, dstType, state.operands) || - parser.parseComma() || - parser.parseAttribute(reductionFn, "reduction_fn", state.attributes) || - parser.parseRParen() || parser.parseOptionalAttrDict(state.attributes)) { - return failure(); - } - return success(); -} - -void printStoreReduceOp(OpAsmPrinter &printer, Operation *op) { - auto storeReduceOp = cast(op); - printer << op->getName() << '('; - printer.printOperand(storeReduceOp.src()); - printer << " : "; - printer.printType(storeReduceOp.src()->getType()); - printer << ", "; - printer.printOperand(storeReduceOp.dst()); - printer << " : "; - printer.printType(storeReduceOp.dst()->getType()); - printer << ", "; - printer.printAttribute(storeReduceOp.reduction_fnAttr()); - printer << ") "; - printer.printOptionalAttrDict(op->getAttrs(), StringRef("reduction_fn")); -} - -#define GET_OP_CLASSES -#include "iree/compiler/IR/Ops.cpp.inc" - -} // namespace IREE -} // namespace iree_compiler -} // namespace mlir diff --git a/iree/compiler/IR/Ops.h b/iree/compiler/IR/Ops.h deleted file mode 100644 index d9de52889809..000000000000 --- a/iree/compiler/IR/Ops.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef IREE_COMPILER_IR_OPS_H_ -#define IREE_COMPILER_IR_OPS_H_ - -#include "mlir/Dialect/StandardOps/Ops.h" -#include "mlir/IR/Attributes.h" -#include "mlir/IR/Dialect.h" -#include "mlir/IR/OpDefinition.h" -#include "mlir/IR/StandardTypes.h" - -namespace mlir { -namespace iree_compiler { -namespace IREE { - -#define GET_OP_CLASSES -#include "iree/compiler/IR/Ops.h.inc" - -} // namespace IREE -} // namespace iree_compiler -} // namespace mlir - -#endif // IREE_COMPILER_IR_OPS_H_ diff --git a/iree/compiler/IR/Ops.td b/iree/compiler/IR/Ops.td deleted file mode 100644 index b6fdead88ac1..000000000000 --- a/iree/compiler/IR/Ops.td +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// IREE ops for working with buffers and buffer views. -// These are used by common transforms between the sequencer and interpreter and -// allow us to share some of the common lowering passes from other dialects. - -#ifndef IREE_OPS -#define IREE_OPS - -include "iree/compiler/IR/OpBase.td" - -class IREE_Op traits = []> : - Op { - let parser = [{ return parse$cppClass(parser, result); }]; - let printer = [{ print$cppClass(p, *this); }]; -} - -class IREE_PureOp traits = []> : - IREE_Op; - -def IREE_ReturnOp : IREE_Op<"return", [Terminator]> { - let arguments = (ins Variadic:$operands); - - let builders = [OpBuilder< - "Builder *b, OperationState &result", [{ build(b, result, llvm::None); }] - >]; -} - -def IREE_LoadInputOp : IREE_PureOp<"load_input"> { - let arguments = (ins IREE_MemRef:$src); - let results = (outs AnyType); -} - -def IREE_StoreOutputOp : IREE_Op<"store_output"> { - let arguments = (ins AnyType:$src, IREE_MemRef:$dst); -} - -def IREE_StoreReduceOp : IREE_Op<"store_reduce"> { - let arguments = (ins - AnyType:$src, - IREE_MemRef:$dst, - FlatSymbolRefAttr:$reduction_fn - ); -} - -#endif // IREE_OPS diff --git a/iree/compiler/IR/test/BUILD b/iree/compiler/IR/test/BUILD deleted file mode 100644 index beab62e7cab3..000000000000 --- a/iree/compiler/IR/test/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//iree:build_defs.bzl", "iree_glob_lit_tests", "iree_setup_lit_package") - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 -) - -iree_setup_lit_package( - data = [ - "//iree/tools:iree-opt", - ], -) - -iree_glob_lit_tests() diff --git a/iree/compiler/Translation/Interpreter/IR/BUILD b/iree/compiler/Translation/Interpreter/IR/BUILD index 16db5ca95b1c..ba4df8a753b2 100644 --- a/iree/compiler/Translation/Interpreter/IR/BUILD +++ b/iree/compiler/Translation/Interpreter/IR/BUILD @@ -38,8 +38,7 @@ cc_library( ], deps = [ ":CommonOpsGen", - "//iree/compiler/IR", - "//iree/compiler/IR:OpsGen", + "//iree/compiler/Dialect/IREE/IR", "@llvm-project//llvm:support", "@llvm-project//mlir:IR", "@llvm-project//mlir:StandardOps", @@ -59,7 +58,7 @@ gentbl( td_srcs = [ ":td_files", "@llvm-project//mlir:OpBaseTdFiles", - "//iree/compiler/IR:OpBase.td", + "//iree/compiler/Dialect/IREE/IR:IREEBase.td", ], ) @@ -87,8 +86,7 @@ cc_library( ":Common", ":HLOpsGen", ":LLOpsGen", - "//iree/compiler/IR", - "//iree/compiler/IR:OpsGen", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/Interpreter/Serialization", "//iree/compiler/Translation/Interpreter/Utils", "//iree/compiler/Utils", @@ -112,7 +110,7 @@ gentbl( td_srcs = [ ":td_files", "@llvm-project//mlir:include/mlir/IR/OpBase.td", - "//iree/compiler/IR:OpBase.td", + "//iree/compiler/Dialect/IREE/IR:IREEBase.td", ], ) @@ -127,6 +125,6 @@ gentbl( td_srcs = [ ":td_files", "@llvm-project//mlir:include/mlir/IR/OpBase.td", - "//iree/compiler/IR:OpBase.td", + "//iree/compiler/Dialect/IREE/IR:IREEBase.td", ], ) diff --git a/iree/compiler/Translation/Interpreter/IR/CMakeLists.txt b/iree/compiler/Translation/Interpreter/IR/CMakeLists.txt index dc3698d43ba8..331aad31c6e8 100644 --- a/iree/compiler/Translation/Interpreter/IR/CMakeLists.txt +++ b/iree/compiler/Translation/Interpreter/IR/CMakeLists.txt @@ -32,7 +32,7 @@ iree_cc_library( "LLOps.cpp.inc" "OpWriters.cpp" DEPS - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::Interpreter::IR::HLOpsGen iree::compiler::Translation::Interpreter::IR::LLOpsGen iree::compiler::Translation::Interpreter::Serialization diff --git a/iree/compiler/Translation/Interpreter/IR/CommonBase.td b/iree/compiler/Translation/Interpreter/IR/CommonBase.td index 558622b72cb5..04c74f0aee05 100644 --- a/iree/compiler/Translation/Interpreter/IR/CommonBase.td +++ b/iree/compiler/Translation/Interpreter/IR/CommonBase.td @@ -17,7 +17,7 @@ #ifndef IREE_INTERPRETER_BASE #define IREE_INTERPRETER_BASE -include "iree/compiler/IR/OpBase.td" +include "iree/compiler/Dialect/IREE/IR/IREEBase.td" include "mlir/IR/OpBase.td" //===----------------------------------------------------------------------===// diff --git a/iree/compiler/Translation/Interpreter/IR/HLOps.cpp b/iree/compiler/Translation/Interpreter/IR/HLOps.cpp index b7a925064b1f..2c4e56305825 100644 --- a/iree/compiler/Translation/Interpreter/IR/HLOps.cpp +++ b/iree/compiler/Translation/Interpreter/IR/HLOps.cpp @@ -14,7 +14,7 @@ #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Function.h" diff --git a/iree/compiler/Translation/Interpreter/Serialization/BUILD b/iree/compiler/Translation/Interpreter/Serialization/BUILD index d29fd441b4c2..b530892d804f 100644 --- a/iree/compiler/Translation/Interpreter/Serialization/BUILD +++ b/iree/compiler/Translation/Interpreter/Serialization/BUILD @@ -36,7 +36,7 @@ cc_library( "VMModuleBuilder.h", ], deps = [ - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/Interpreter/Utils", "//iree/schemas:interpreter_module_def_cc_fbs", "//iree/schemas/bytecode:interpreter_bytecode_v0", diff --git a/iree/compiler/Translation/Interpreter/Serialization/CMakeLists.txt b/iree/compiler/Translation/Interpreter/Serialization/CMakeLists.txt index ba0c28ac331b..fca5260b30e6 100644 --- a/iree/compiler/Translation/Interpreter/Serialization/CMakeLists.txt +++ b/iree/compiler/Translation/Interpreter/Serialization/CMakeLists.txt @@ -28,7 +28,7 @@ iree_cc_library( "VMFunctionTableBuilder.cpp" "VMModuleBuilder.cpp" DEPS - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::Interpreter::IR iree::schemas::interpreter_module_def_cc_fbs iree::schemas::bytecode::interpreter_bytecode_v0 diff --git a/iree/compiler/Translation/Interpreter/Serialization/VMFunctionBuilder.cpp b/iree/compiler/Translation/Interpreter/Serialization/VMFunctionBuilder.cpp index 0ca3f5c4d719..fb7a28edd084 100644 --- a/iree/compiler/Translation/Interpreter/Serialization/VMFunctionBuilder.cpp +++ b/iree/compiler/Translation/Interpreter/Serialization/VMFunctionBuilder.cpp @@ -15,7 +15,7 @@ #include "iree/compiler/Translation/Interpreter/Serialization/VMFunctionBuilder.h" #include "flatbuffers/flatbuffers.h" -#include "iree/compiler/IR/Dialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" #include "iree/compiler/Translation/Interpreter/Serialization/BytecodeTables.h" #include "iree/compiler/Translation/Interpreter/Utils/Macros.h" #include "iree/schemas/bytecode/interpreter_bytecode_v0.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/BUILD b/iree/compiler/Translation/Interpreter/Transforms/BUILD index 2c8ae7db69fe..6762104d05fd 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/BUILD +++ b/iree/compiler/Translation/Interpreter/Transforms/BUILD @@ -43,7 +43,7 @@ cc_library( "Rewrites.h", ], deps = [ - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/Interpreter/IR", "//iree/compiler/Translation/Interpreter/IR:Common", "//iree/compiler/Translation/Interpreter/Serialization", diff --git a/iree/compiler/Translation/Interpreter/Transforms/CMakeLists.txt b/iree/compiler/Translation/Interpreter/Transforms/CMakeLists.txt index ca3df5769b34..1134911a9ea6 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/CMakeLists.txt +++ b/iree/compiler/Translation/Interpreter/Transforms/CMakeLists.txt @@ -35,7 +35,7 @@ iree_cc_library( "LowerXLAToIreeDialect.cpp" "MakeExecutableABI.cpp" DEPS - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::Interpreter::IR iree::compiler::Translation::Interpreter::Utils iree::compiler::Utils diff --git a/iree/compiler/Translation/Interpreter/Transforms/ConvertToMemRefCallingConvention.cpp b/iree/compiler/Translation/Interpreter/Transforms/ConvertToMemRefCallingConvention.cpp index 783615b77190..57c882302b00 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/ConvertToMemRefCallingConvention.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/ConvertToMemRefCallingConvention.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonOps.h" #include "iree/compiler/Translation/Interpreter/Utils/MemRefUtils.h" #include "iree/compiler/Utils/TypeConversionUtils.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/ExpandReductionsToOps.cpp b/iree/compiler/Translation/Interpreter/Transforms/ExpandReductionsToOps.cpp index 9f7a940086a2..f81fc73e10aa 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/ExpandReductionsToOps.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/ExpandReductionsToOps.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/HLDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" #include "iree/compiler/Translation/Interpreter/Transforms/ConversionUtils.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerInterpreterDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerInterpreterDialect.cpp index dc966d094d4f..06a13c7b68a1 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerInterpreterDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerInterpreterDialect.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonOps.h" #include "iree/compiler/Translation/Interpreter/IR/HLDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerStdToInterpreterDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerStdToInterpreterDialect.cpp index ebe1dcc8951d..85b727aaa81a 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerStdToInterpreterDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerStdToInterpreterDialect.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/HLDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" #include "iree/compiler/Translation/Interpreter/IR/LLDialect.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerStdToIreeDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerStdToIreeDialect.cpp index a873ad303c84..a5a70900ff8f 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerStdToIreeDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerStdToIreeDialect.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonOps.h" #include "iree/compiler/Translation/Interpreter/Utils/MemRefUtils.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerToInterpreterDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerToInterpreterDialect.cpp index 56288175c505..4cca3803ad37 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerToInterpreterDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerToInterpreterDialect.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" #include "iree/compiler/Translation/Interpreter/IR/CommonDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLDialect.h" #include "iree/compiler/Translation/Interpreter/IR/LLDialect.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToInterpreterDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToInterpreterDialect.cpp index e6dbd0a971a8..958a6ab78f4e 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToInterpreterDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToInterpreterDialect.cpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Dialect.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEDialect.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLDialect.h" #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToIreeDialect.cpp b/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToIreeDialect.cpp index a7104055ce63..32546248fdc3 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToIreeDialect.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/LowerXLAToIreeDialect.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonOps.h" #include "iree/compiler/Translation/Interpreter/Utils/MemRefUtils.h" #include "mlir/IR/PatternMatch.h" diff --git a/iree/compiler/Translation/Interpreter/Transforms/MakeExecutableABI.cpp b/iree/compiler/Translation/Interpreter/Transforms/MakeExecutableABI.cpp index 07d2e9d9f6a8..c0eb64bb46bf 100644 --- a/iree/compiler/Translation/Interpreter/Transforms/MakeExecutableABI.cpp +++ b/iree/compiler/Translation/Interpreter/Transforms/MakeExecutableABI.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/HLOps.h" #include "iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/iree/compiler/Translation/Interpreter/Utils/BUILD b/iree/compiler/Translation/Interpreter/Utils/BUILD index 4d675b615aa1..16b707e7400f 100644 --- a/iree/compiler/Translation/Interpreter/Utils/BUILD +++ b/iree/compiler/Translation/Interpreter/Utils/BUILD @@ -31,7 +31,7 @@ cc_library( "OpCreationUtils.h", ], deps = [ - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/Interpreter/IR:Common", "@llvm-project//llvm:support", "@llvm-project//mlir:IR", diff --git a/iree/compiler/Translation/Interpreter/Utils/CMakeLists.txt b/iree/compiler/Translation/Interpreter/Utils/CMakeLists.txt index 6f3525d0580c..e53fb6a620b4 100644 --- a/iree/compiler/Translation/Interpreter/Utils/CMakeLists.txt +++ b/iree/compiler/Translation/Interpreter/Utils/CMakeLists.txt @@ -23,7 +23,7 @@ iree_cc_library( "MemRefUtils.cpp" "OpCreationUtils.cpp" DEPS - iree::compiler::IR + iree::compiler::Dialect::IREE::IR tensorflow::mlir_xla LLVMSupport MLIRIR diff --git a/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.cpp b/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.cpp index fce756a567f7..3ebf6393f623 100644 --- a/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.cpp +++ b/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.cpp @@ -16,7 +16,7 @@ #include -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Location.h" diff --git a/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h b/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h index c35f9fc28563..b1e7d8bd406f 100644 --- a/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h +++ b/iree/compiler/Translation/Interpreter/Utils/OpCreationUtils.h @@ -21,7 +21,7 @@ #include -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/Interpreter/IR/CommonOps.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" diff --git a/iree/compiler/Translation/SPIRV/BUILD b/iree/compiler/Translation/SPIRV/BUILD index 7107bee1526c..ef4d5c1efdcc 100644 --- a/iree/compiler/Translation/SPIRV/BUILD +++ b/iree/compiler/Translation/SPIRV/BUILD @@ -48,7 +48,7 @@ cc_library( "XLAToSPIRV.h", ], deps = [ - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "//iree/compiler/Translation/SPIRV/Kernels", "//iree/compiler/Utils", "//iree/schemas:spirv_executable_def_cc_fbs", diff --git a/iree/compiler/Translation/SPIRV/CMakeLists.txt b/iree/compiler/Translation/SPIRV/CMakeLists.txt index afac8c30b698..349da12e269b 100644 --- a/iree/compiler/Translation/SPIRV/CMakeLists.txt +++ b/iree/compiler/Translation/SPIRV/CMakeLists.txt @@ -45,7 +45,7 @@ iree_cc_library( "XLAToSPIRV.cpp" DEPS flatbuffers - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::SPIRV::Kernels iree::compiler::Utils iree::schemas::spirv_executable_def_cc_fbs diff --git a/iree/compiler/Translation/SPIRV/IREECodegenUtils.h b/iree/compiler/Translation/SPIRV/IREECodegenUtils.h index 50aae55a9afa..60c31c92477c 100644 --- a/iree/compiler/Translation/SPIRV/IREECodegenUtils.h +++ b/iree/compiler/Translation/SPIRV/IREECodegenUtils.h @@ -20,7 +20,7 @@ #ifndef IREE_COMPILER_TRANSLATION_SPIRV_IREECODEGENUTILS_H #define IREE_COMPILER_TRANSLATION_SPIRV_IREECODEGENUTILS_H -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "mlir/IR/Function.h" #include "mlir/Support/LogicalResult.h" diff --git a/iree/compiler/Translation/SPIRV/IREEToSPIRV.h b/iree/compiler/Translation/SPIRV/IREEToSPIRV.h index 9529e9caae71..115836b70336 100644 --- a/iree/compiler/Translation/SPIRV/IREEToSPIRV.h +++ b/iree/compiler/Translation/SPIRV/IREEToSPIRV.h @@ -20,7 +20,7 @@ #ifndef IREE_COMPILER_TRANSLATION_SPIRV_IREETOSPIRV_H #define IREE_COMPILER_TRANSLATION_SPIRV_IREETOSPIRV_H -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Translation/SPIRV/SPIRVLowering.h" namespace mlir { diff --git a/iree/compiler/Translation/SPIRV/IndexComputation.h b/iree/compiler/Translation/SPIRV/IndexComputation.h index f613d775cbf9..5a125a64fe5e 100644 --- a/iree/compiler/Translation/SPIRV/IndexComputation.h +++ b/iree/compiler/Translation/SPIRV/IndexComputation.h @@ -29,6 +29,7 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" diff --git a/iree/compiler/Translation/SPIRV/IndexComputationAttribute.cpp b/iree/compiler/Translation/SPIRV/IndexComputationAttribute.cpp index fd958dd660a4..a59b9f72433b 100644 --- a/iree/compiler/Translation/SPIRV/IndexComputationAttribute.cpp +++ b/iree/compiler/Translation/SPIRV/IndexComputationAttribute.cpp @@ -20,7 +20,7 @@ //===----------------------------------------------------------------------===// #include "iree/compiler/Translation/SPIRV/IndexComputationAttribute.h" -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/Function.h" diff --git a/iree/compiler/Translation/SPIRV/PrepareReductionDispatch.cpp b/iree/compiler/Translation/SPIRV/PrepareReductionDispatch.cpp index c40fd2cac94a..cb70ef2f76cf 100644 --- a/iree/compiler/Translation/SPIRV/PrepareReductionDispatch.cpp +++ b/iree/compiler/Translation/SPIRV/PrepareReductionDispatch.cpp @@ -17,7 +17,7 @@ // Prepare dispatch regions that implement reductions before SPIR-V lowering. // //===----------------------------------------------------------------------===// -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "iree/compiler/Utils/DispatchUtils.h" #include "mlir/IR/Function.h" #include "mlir/IR/PatternMatch.h" diff --git a/iree/compiler/Translation/SPIRV/ReductionFnLowering.cpp b/iree/compiler/Translation/SPIRV/ReductionFnLowering.cpp index 77bfda03fa15..7b88c209546e 100644 --- a/iree/compiler/Translation/SPIRV/ReductionFnLowering.cpp +++ b/iree/compiler/Translation/SPIRV/ReductionFnLowering.cpp @@ -18,7 +18,7 @@ // //===----------------------------------------------------------------------===// -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/iree/compiler/Translation/SPIRV/SPIRVLowering.h b/iree/compiler/Translation/SPIRV/SPIRVLowering.h index 98cd734f2ee4..5933fea13b5d 100644 --- a/iree/compiler/Translation/SPIRV/SPIRVLowering.h +++ b/iree/compiler/Translation/SPIRV/SPIRVLowering.h @@ -25,6 +25,7 @@ #include "iree/compiler/Translation/SPIRV/TensorIndexToScalarValueMap.h" #include "mlir/Dialect/SPIRV/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/SPIRVOps.h" +#include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/Support/StringExtras.h" namespace mlir { diff --git a/iree/compiler/Utils/BUILD b/iree/compiler/Utils/BUILD index de867d1e6b94..c4567732737b 100644 --- a/iree/compiler/Utils/BUILD +++ b/iree/compiler/Utils/BUILD @@ -32,7 +32,7 @@ cc_library( "TypeConversionUtils.h", ], deps = [ - "//iree/compiler/IR", + "//iree/compiler/Dialect/IREE/IR", "@llvm-project//llvm:support", "@llvm-project//mlir:IR", "@llvm-project//mlir:Pass", diff --git a/iree/compiler/Utils/CMakeLists.txt b/iree/compiler/Utils/CMakeLists.txt index f1830a2e680a..eb97871a772a 100644 --- a/iree/compiler/Utils/CMakeLists.txt +++ b/iree/compiler/Utils/CMakeLists.txt @@ -24,7 +24,7 @@ iree_cc_library( "GraphUtils.cpp" "TypeConversionUtils.cpp" DEPS - iree::compiler::IR + iree::compiler::Dialect::IREE::IR tensorflow::mlir_xla LLVMSupport MLIRIR diff --git a/iree/compiler/Utils/DispatchUtils.cpp b/iree/compiler/Utils/DispatchUtils.cpp index 6304eb76c932..04318d1fe257 100644 --- a/iree/compiler/Utils/DispatchUtils.cpp +++ b/iree/compiler/Utils/DispatchUtils.cpp @@ -16,7 +16,7 @@ #include -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLExtras.h" diff --git a/iree/compiler/Utils/DispatchUtils.h b/iree/compiler/Utils/DispatchUtils.h index d1a2dd3e5733..a9ad28a12a54 100644 --- a/iree/compiler/Utils/DispatchUtils.h +++ b/iree/compiler/Utils/DispatchUtils.h @@ -17,7 +17,7 @@ #include -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "llvm/ADT/ArrayRef.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Function.h" diff --git a/iree/compiler/Utils/TypeConversionUtils.cpp b/iree/compiler/Utils/TypeConversionUtils.cpp index 51c3e54a52f5..7d1254520de2 100644 --- a/iree/compiler/Utils/TypeConversionUtils.cpp +++ b/iree/compiler/Utils/TypeConversionUtils.cpp @@ -16,7 +16,7 @@ #include -#include "iree/compiler/IR/Ops.h" +#include "iree/compiler/Dialect/IREE/IR/IREEOps.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/ErrorHandling.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/iree/hal/api.cc b/iree/hal/api.cc index d4edd888cf91..f8d030c141d0 100644 --- a/iree/hal/api.cc +++ b/iree/hal/api.cc @@ -371,7 +371,7 @@ IREE_API_EXPORT iree_status_t iree_hal_buffer_view_create( // Allocate and initialize the iree_hal_buffer_view struct. iree_hal_buffer_view* handle = nullptr; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(*handle), reinterpret_cast(&handle))); new (handle) iree_hal_buffer_view(); handle->allocator = allocator; @@ -671,7 +671,7 @@ iree_hal_driver_query_available_devices( *out_device_info_count = device_infos.size(); iree_hal_device_info_t* device_info_storage = nullptr; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, device_infos.size() * sizeof(*device_info_storage) + total_string_size, (void**)&device_info_storage)); @@ -762,7 +762,7 @@ iree_hal_driver_registry_query_available_drivers( *out_driver_count = available_drivers.size(); iree_string_view_t* driver_name_storage = nullptr; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, available_drivers.size() * sizeof(*driver_name_storage) + total_string_size, diff --git a/iree/modules/hal/hal_module.cc b/iree/modules/hal/hal_module.cc index 64b864e72dc5..bd75217cf7c6 100644 --- a/iree/modules/hal/hal_module.cc +++ b/iree/modules/hal/hal_module.cc @@ -60,7 +60,7 @@ static iree_vm_ref_type_descriptor_t iree_hal_executable_descriptor = {0}; descriptor.type_name = iree_make_cstring_view(name); \ descriptor.offsetof_counter = type::offsetof_counter(); \ descriptor.destroy = type::DirectDestroy; \ - IREE_API_RETURN_IF_API_ERROR(iree_vm_ref_register_type(&descriptor)); + IREE_RETURN_IF_ERROR(iree_vm_ref_register_type(&descriptor)); IREE_API_EXPORT iree_status_t IREE_API_CALL iree_hal_module_register_types() { static bool has_registered = false; diff --git a/iree/samples/custom_modules/custom_modules_test.cc b/iree/samples/custom_modules/custom_modules_test.cc index c0178e00b242..c157b9044416 100644 --- a/iree/samples/custom_modules/custom_modules_test.cc +++ b/iree/samples/custom_modules/custom_modules_test.cc @@ -29,29 +29,27 @@ namespace { class CustomModulesTest : public ::testing::Test { protected: virtual void SetUp() { - CHECK_EQ(IREE_STATUS_OK, - iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance_)); + IREE_CHECK_OK(iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance_)); - CHECK_EQ(IREE_STATUS_OK, iree_custom_native_module_register_types()); + IREE_CHECK_OK(iree_custom_native_module_register_types()); - CHECK_EQ(IREE_STATUS_OK, iree_custom_native_module_create( - IREE_ALLOCATOR_SYSTEM, &native_module_)) + IREE_CHECK_OK(iree_custom_native_module_create(IREE_ALLOCATOR_SYSTEM, + &native_module_)) << "Native module failed to init"; const auto* module_file_toc = iree::samples::custom_modules::custom_modules_test_module_create(); - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &bytecode_module_)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &bytecode_module_)) << "Bytecode module failed to load"; std::vector modules = {native_module_, bytecode_module_}; - CHECK_EQ(IREE_STATUS_OK, iree_vm_context_create_with_modules( - instance_, modules.data(), modules.size(), - IREE_ALLOCATOR_SYSTEM, &context_)); + IREE_CHECK_OK(iree_vm_context_create_with_modules( + instance_, modules.data(), modules.size(), IREE_ALLOCATOR_SYSTEM, + &context_)); } virtual void TearDown() { @@ -63,11 +61,10 @@ class CustomModulesTest : public ::testing::Test { iree_vm_function_t LookupFunction(absl::string_view function_name) { iree_vm_function_t function; - CHECK_EQ(IREE_STATUS_OK, - bytecode_module_->lookup_function( - bytecode_module_->self, IREE_VM_FUNCTION_LINKAGE_EXPORT, - iree_string_view_t{function_name.data(), function_name.size()}, - &function)) + IREE_CHECK_OK(bytecode_module_->lookup_function( + bytecode_module_->self, IREE_VM_FUNCTION_LINKAGE_EXPORT, + iree_string_view_t{function_name.data(), function_name.size()}, + &function)) << "Exported function '" << function_name << "' not found"; return function; } @@ -81,38 +78,34 @@ class CustomModulesTest : public ::testing::Test { TEST_F(CustomModulesTest, Run) { // Allocate one of our custom message types to pass in. iree_vm_ref_t input_message = {0}; - ASSERT_EQ(IREE_STATUS_OK, - iree_custom_message_wrap(iree_make_cstring_view("hello world!"), - IREE_ALLOCATOR_SYSTEM, &input_message)); + IREE_ASSERT_OK( + iree_custom_message_wrap(iree_make_cstring_view("hello world!"), + IREE_ALLOCATOR_SYSTEM, &input_message)); iree_vm_value_t count = IREE_VM_VALUE_MAKE_I32(5); // Pass in the message and number of times to print it. // TODO(benvanik): make a macro/magic. iree_vm_variant_list_t* inputs = nullptr; - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_alloc(2, IREE_ALLOCATOR_SYSTEM, &inputs)); - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_append_ref_move(inputs, &input_message)); - ASSERT_EQ(IREE_STATUS_OK, iree_vm_variant_list_append_value(inputs, count)); + IREE_ASSERT_OK(iree_vm_variant_list_alloc(2, IREE_ALLOCATOR_SYSTEM, &inputs)); + IREE_ASSERT_OK(iree_vm_variant_list_append_ref_move(inputs, &input_message)); + IREE_ASSERT_OK(iree_vm_variant_list_append_value(inputs, count)); // Prepare outputs list to accept the results from the invocation. iree_vm_variant_list_t* outputs = nullptr; - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_alloc(1, IREE_ALLOCATOR_SYSTEM, &outputs)); + IREE_ASSERT_OK( + iree_vm_variant_list_alloc(1, IREE_ALLOCATOR_SYSTEM, &outputs)); // Synchronously invoke the function. - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_invoke(context_, LookupFunction("reverseAndPrint"), - /*policy=*/nullptr, inputs, outputs, - IREE_ALLOCATOR_SYSTEM)); + IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("reverseAndPrint"), + /*policy=*/nullptr, inputs, outputs, + IREE_ALLOCATOR_SYSTEM)); iree_vm_variant_list_free(inputs); // Read back the message that we reversed inside of the module. iree_vm_ref_t* reversed_message = &iree_vm_variant_list_get(outputs, 0)->ref; char result_buffer[256]; - ASSERT_EQ(IREE_STATUS_OK, - iree_custom_message_read_value(reversed_message, result_buffer, - ABSL_ARRAYSIZE(result_buffer))); + IREE_ASSERT_OK(iree_custom_message_read_value(reversed_message, result_buffer, + ABSL_ARRAYSIZE(result_buffer))); EXPECT_STREQ("!dlrow olleh", result_buffer); iree_vm_variant_list_free(outputs); diff --git a/iree/samples/custom_modules/custom_modules_test.mlir b/iree/samples/custom_modules/custom_modules_test.mlir index 1c0946d4f79f..856fd9f156a8 100644 --- a/iree/samples/custom_modules/custom_modules_test.mlir +++ b/iree/samples/custom_modules/custom_modules_test.mlir @@ -17,18 +17,18 @@ // // See custom_modules/dialect/custom_ops.td for the op definitions and // custom_modules/dialect/custom.imports.mlir for the import definitions. -func @reverseAndPrint(%message : !ireex.ref, %count : i32) -> !ireex.ref +func @reverseAndPrint(%message : !iree.ref, %count : i32) -> !iree.ref attributes { iree.module.export } { %c1 = constant 1 : i32 - %0 = "custom.get_unique_message"() : () -> !ireex.ref - "custom.print"(%0, %c1) : (!ireex.ref, i32) -> () - %1 = call @reverse(%message) : (!ireex.ref) -> !ireex.ref - "custom.print"(%1, %count) : (!ireex.ref, i32) -> () - return %1 : !ireex.ref + %0 = "custom.get_unique_message"() : () -> !iree.ref + "custom.print"(%0, %c1) : (!iree.ref, i32) -> () + %1 = call @reverse(%message) : (!iree.ref) -> !iree.ref + "custom.print"(%1, %count) : (!iree.ref, i32) -> () + return %1 : !iree.ref } // Reverses a message. Just an example to show intra-module calls. -func @reverse(%message : !ireex.ref) -> !ireex.ref { - %0 = "custom.reverse"(%message) : (!ireex.ref) -> !ireex.ref - return %0 : !ireex.ref +func @reverse(%message : !iree.ref) -> !iree.ref { + %0 = "custom.reverse"(%message) : (!iree.ref) -> !iree.ref + return %0 : !iree.ref } diff --git a/iree/samples/custom_modules/dialect/custom.imports.mlir b/iree/samples/custom_modules/dialect/custom.imports.mlir index 5c43f55e152e..3755775a3629 100644 --- a/iree/samples/custom_modules/dialect/custom.imports.mlir +++ b/iree/samples/custom_modules/dialect/custom.imports.mlir @@ -25,20 +25,20 @@ vm.module @custom { // Prints the %message provided %count times. // Maps to the IREE::Custom::PrintOp. vm.import @print( - %message : !ireex.ref, + %message : !iree.ref, %count : i32 ) // Returns the message with its characters reversed. // Maps to the IREE::Custom::ReverseOp. vm.import @reverse( - %message : !ireex.ref -) -> !ireex.ref + %message : !iree.ref +) -> !iree.ref attributes {nosideeffects} // Returns a per-context unique message. // Maps to the IREE::Custom::GetUniqueMessageOp. -vm.import @get_unique_message() -> !ireex.ref +vm.import @get_unique_message() -> !iree.ref attributes {nosideeffects} } // vm.module diff --git a/iree/samples/custom_modules/dialect/test/conversion.mlir b/iree/samples/custom_modules/dialect/test/conversion.mlir index 309825c1a74a..fe7021956cd2 100644 --- a/iree/samples/custom_modules/dialect/test/conversion.mlir +++ b/iree/samples/custom_modules/dialect/test/conversion.mlir @@ -19,10 +19,10 @@ // RUN: custom-opt %s -iree-vm-conversion -split-input-file | IreeFileCheck %s // CHECK-LABEL: @printOp -func @printOp(%arg0 : !ireex.ref) { +func @printOp(%arg0 : !iree.ref) { %c1_i32 = constant 1 : i32 - // CHECK: vm.call @custom.print(%arg0, %c1) : (!ireex.ref, i32) -> () - "custom.print"(%arg0, %c1_i32) : (!ireex.ref, i32) -> () + // CHECK: vm.call @custom.print(%arg0, %c1) : (!iree.ref, i32) -> () + "custom.print"(%arg0, %c1_i32) : (!iree.ref, i32) -> () return } @@ -31,10 +31,10 @@ func @printOp(%arg0 : !ireex.ref) { // ----- // CHECK-LABEL: @reverseOp -func @reverseOp(%arg0 : !ireex.ref) -> !ireex.ref { - // CHECK: %ref = vm.call @custom.reverse(%arg0) : (!ireex.ref) -> !ireex.ref - %0 = "custom.reverse"(%arg0) : (!ireex.ref) -> !ireex.ref - return %0 : !ireex.ref +func @reverseOp(%arg0 : !iree.ref) -> !iree.ref { + // CHECK: %ref = vm.call @custom.reverse(%arg0) : (!iree.ref) -> !iree.ref + %0 = "custom.reverse"(%arg0) : (!iree.ref) -> !iree.ref + return %0 : !iree.ref } // CHECK: vm.import @custom.reverse @@ -42,10 +42,10 @@ func @reverseOp(%arg0 : !ireex.ref) -> !ireex.ref !ireex.ref { - // CHECK: %ref = vm.call @custom.get_unique_message() : () -> !ireex.ref - %0 = "custom.get_unique_message"() : () -> !ireex.ref - return %0 : !ireex.ref +func @getUniqueMessageOp() -> !iree.ref { + // CHECK: %ref = vm.call @custom.get_unique_message() : () -> !iree.ref + %0 = "custom.get_unique_message"() : () -> !iree.ref + return %0 : !iree.ref } // CHECK: vm.import @custom.get_unique_message diff --git a/iree/samples/custom_modules/dialect/test/custom_ops.mlir b/iree/samples/custom_modules/dialect/test/custom_ops.mlir index 9dc33f6ec0cc..78799b1cbcbf 100644 --- a/iree/samples/custom_modules/dialect/test/custom_ops.mlir +++ b/iree/samples/custom_modules/dialect/test/custom_ops.mlir @@ -19,27 +19,27 @@ // RUN: custom-opt -split-input-file %s | custom-opt -split-input-file | IreeFileCheck %s // CHECK-LABEL: @printOp -func @printOp(%arg0 : !ireex.ref) { +func @printOp(%arg0 : !iree.ref) { %c1_i32 = constant 1 : i32 - // CHECK: "custom.print"(%arg0, %c1_i32) : (!ireex.ref, i32) -> () - "custom.print"(%arg0, %c1_i32) : (!ireex.ref, i32) -> () + // CHECK: "custom.print"(%arg0, %c1_i32) : (!iree.ref, i32) -> () + "custom.print"(%arg0, %c1_i32) : (!iree.ref, i32) -> () return } // ----- // CHECK-LABEL: @reverseOp -func @reverseOp(%arg0 : !ireex.ref) -> !ireex.ref { - // CHECK: %0 = "custom.reverse"(%arg0) : (!ireex.ref) -> !ireex.ref - %0 = "custom.reverse"(%arg0) : (!ireex.ref) -> !ireex.ref - return %0 : !ireex.ref +func @reverseOp(%arg0 : !iree.ref) -> !iree.ref { + // CHECK: %0 = "custom.reverse"(%arg0) : (!iree.ref) -> !iree.ref + %0 = "custom.reverse"(%arg0) : (!iree.ref) -> !iree.ref + return %0 : !iree.ref } // ----- // CHECK-LABEL: @getUniqueMessageOp -func @getUniqueMessageOp() -> !ireex.ref { - // CHECK: %0 = "custom.get_unique_message"() : () -> !ireex.ref - %0 = "custom.get_unique_message"() : () -> !ireex.ref - return %0 : !ireex.ref +func @getUniqueMessageOp() -> !iree.ref { + // CHECK: %0 = "custom.get_unique_message"() : () -> !iree.ref + %0 = "custom.get_unique_message"() : () -> !iree.ref + return %0 : !iree.ref } diff --git a/iree/samples/custom_modules/native_module.c b/iree/samples/custom_modules/native_module.c index 869026632649..d243b88ccec8 100644 --- a/iree/samples/custom_modules/native_module.c +++ b/iree/samples/custom_modules/native_module.c @@ -97,7 +97,7 @@ iree_status_t iree_custom_message_create(iree_string_view_t value, iree_vm_ref_t* out_message_ref) { // Note that we allocate the message and the string value together. iree_custom_message_t* message = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_custom_message_t) + value.size, (void**)&message)); message->ref_object.counter = 1; message->allocator = allocator; @@ -112,7 +112,7 @@ iree_status_t iree_custom_message_wrap(iree_string_view_t value, iree_allocator_t allocator, iree_vm_ref_t* out_message_ref) { iree_custom_message_t* message = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_custom_message_t), (void**)&message)); message->ref_object.counter = 1; message->allocator = allocator; @@ -183,7 +183,7 @@ static iree_status_t iree_custom_native_reverse_thunk( IREE_VM_DEREF_OR_RETURN(iree_custom_message_t, src_message, &frame->registers.ref[0], IREE_CUSTOM_MESSAGE_TYPE_ID); - IREE_API_RETURN_IF_API_ERROR(iree_custom_message_create( + IREE_RETURN_IF_ERROR(iree_custom_message_create( src_message->value, src_message->allocator, &frame->registers.ref[0])); IREE_VM_DEREF_OR_RETURN(iree_custom_message_t, dst_message, &frame->registers.ref[0], @@ -334,7 +334,7 @@ static iree_status_t iree_custom_native_module_alloc_state( iree_custom_native_module_t* module = (iree_custom_native_module_t*)self; iree_custom_native_module_state_t* state = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_custom_native_module_state_t), (void**)&state)); state->allocator = allocator; @@ -342,7 +342,7 @@ static iree_status_t iree_custom_native_module_alloc_state( int unique_id = atomic_fetch_add(&module->next_unique_id, 1); char buffer[16]; snprintf(buffer, 16, "ctx_%d", unique_id); - IREE_API_RETURN_IF_API_ERROR(iree_custom_message_create( + IREE_RETURN_IF_ERROR(iree_custom_message_create( iree_make_cstring_view(buffer), allocator, &state->unique_message)); *out_module_state = (iree_vm_module_state_t*)state; @@ -403,7 +403,7 @@ iree_status_t iree_custom_native_module_create(iree_allocator_t allocator, *out_module = NULL; iree_custom_native_module_t* module = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_custom_native_module_t), (void**)&module)); module->allocator = allocator; module->next_unique_id = 0; diff --git a/iree/samples/simple_embedding/simple_embedding_test.cc b/iree/samples/simple_embedding/simple_embedding_test.cc index c54e519e4a58..11938a56393f 100644 --- a/iree/samples/simple_embedding/simple_embedding_test.cc +++ b/iree/samples/simple_embedding/simple_embedding_test.cc @@ -31,7 +31,7 @@ namespace iree { namespace samples { namespace { -#define ASSERT_API_OK(expr) ASSERT_EQ(IREE_STATUS_OK, (expr)) +#define ASSERT_API_OK(expr) IREE_ASSERT_OK((expr)) struct TestParams { // HAL driver to use for the test. @@ -47,9 +47,8 @@ std::vector GetAvailableDriverTestParams() { std::vector all_test_params; iree_string_view_t* driver_names = nullptr; iree_host_size_t driver_count = 0; - CHECK_EQ(IREE_STATUS_OK, - iree_hal_driver_registry_query_available_drivers( - IREE_ALLOCATOR_SYSTEM, &driver_names, &driver_count)); + IREE_CHECK_OK(iree_hal_driver_registry_query_available_drivers( + IREE_ALLOCATOR_SYSTEM, &driver_names, &driver_count)); for (int i = 0; i < driver_count; ++i) { TestParams test_params; test_params.driver_name = @@ -67,11 +66,10 @@ class SimpleEmbeddingTest : public ::testing::Test, TEST_P(SimpleEmbeddingTest, RunOnce) { // TODO(benvanik): move to instance-based registration. - ASSERT_EQ(IREE_STATUS_OK, iree_hal_module_register_types()); + IREE_ASSERT_OK(iree_hal_module_register_types()); iree_vm_instance_t* instance = nullptr; - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance)); + IREE_ASSERT_OK(iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance)); // Create the driver/device as defined by the test and setup the HAL module. const auto& driver_name = GetParam().driver_name; @@ -101,9 +99,9 @@ TEST_P(SimpleEmbeddingTest, RunOnce) { // Allocate a context that will hold the module state across invocations. iree_vm_context_t* context = nullptr; std::vector modules = {hal_module, bytecode_module}; - ASSERT_EQ(IREE_STATUS_OK, iree_vm_context_create_with_modules( - instance, modules.data(), modules.size(), - IREE_ALLOCATOR_SYSTEM, &context)); + IREE_ASSERT_OK(iree_vm_context_create_with_modules( + instance, modules.data(), modules.size(), IREE_ALLOCATOR_SYSTEM, + &context)); LOG(INFO) << "Module loaded and context is ready for use"; iree_vm_module_release(hal_module); iree_vm_module_release(bytecode_module); @@ -145,25 +143,24 @@ TEST_P(SimpleEmbeddingTest, RunOnce) { // Setup call inputs with our buffers. // TODO(benvanik): make a macro/magic. iree_vm_variant_list_t* inputs = nullptr; - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_alloc(2, IREE_ALLOCATOR_SYSTEM, &inputs)); + IREE_ASSERT_OK(iree_vm_variant_list_alloc(2, IREE_ALLOCATOR_SYSTEM, &inputs)); auto arg0_buffer_ref = iree_hal_buffer_move_ref(arg0_buffer); auto arg1_buffer_ref = iree_hal_buffer_move_ref(arg1_buffer); - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_append_ref_move(inputs, &arg0_buffer_ref)); - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_append_ref_move(inputs, &arg1_buffer_ref)); + IREE_ASSERT_OK( + iree_vm_variant_list_append_ref_move(inputs, &arg0_buffer_ref)); + IREE_ASSERT_OK( + iree_vm_variant_list_append_ref_move(inputs, &arg1_buffer_ref)); // Prepare outputs list to accept the results from the invocation. iree_vm_variant_list_t* outputs = nullptr; - ASSERT_EQ(IREE_STATUS_OK, - iree_vm_variant_list_alloc(1, IREE_ALLOCATOR_SYSTEM, &outputs)); + IREE_ASSERT_OK( + iree_vm_variant_list_alloc(1, IREE_ALLOCATOR_SYSTEM, &outputs)); // Synchronously invoke the function. LOG(INFO) << "Calling " << kMainFunctionName << "..."; - ASSERT_EQ(IREE_STATUS_OK, iree_vm_invoke(context, main_function, - /*policy=*/nullptr, inputs, outputs, - IREE_ALLOCATOR_SYSTEM)); + IREE_ASSERT_OK(iree_vm_invoke(context, main_function, + /*policy=*/nullptr, inputs, outputs, + IREE_ALLOCATOR_SYSTEM)); iree_vm_variant_list_free(inputs); // Get the result buffers from the invocation. diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt index 2dfc878b8209..60bf1113e2d1 100644 --- a/iree/tools/CMakeLists.txt +++ b/iree/tools/CMakeLists.txt @@ -33,7 +33,7 @@ if(${IREE_BUILD_COMPILER}) MLIRTranslation MLIRSupport MLIRVectorOps - iree::compiler::IR + iree::compiler::Dialect::IREE::IR iree::compiler::Translation::Interpreter::IR tensorflow::mlir_xla ) diff --git a/iree/vm/bytecode_dispatch.c b/iree/vm/bytecode_dispatch.c index 2bedc2930560..a5cce32dc1a9 100644 --- a/iree/vm/bytecode_dispatch.c +++ b/iree/vm/bytecode_dispatch.c @@ -637,7 +637,7 @@ iree_status_t iree_vm_bytecode_dispatch( iree_vm_stack_frame_t* callee_frame = NULL; iree_status_t enter_status = iree_vm_stack_function_enter(stack, target_function, &callee_frame); - if (enter_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(enter_status)) { // TODO(benvanik): set execution result to stack overflow. return enter_status; } @@ -648,7 +648,7 @@ iree_status_t iree_vm_bytecode_dispatch( // Call external function. iree_status_t call_status = target_function.module->execute( target_function.module, stack, callee_frame, out_result); - if (call_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(call_status)) { // TODO(benvanik): set execution result to failure/capture stack. return call_status; } @@ -726,7 +726,7 @@ iree_status_t iree_vm_bytecode_dispatch( iree_vm_stack_frame_t* callee_frame = NULL; iree_status_t enter_status = iree_vm_stack_function_enter(stack, target_function, &callee_frame); - if (enter_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(enter_status)) { // TODO(benvanik): set execution result to stack overflow. return enter_status; } @@ -739,7 +739,7 @@ iree_status_t iree_vm_bytecode_dispatch( // Call external function. iree_status_t call_status = target_function.module->execute( target_function.module, stack, callee_frame, out_result); - if (call_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(call_status)) { // TODO(benvanik): set execution result to failure/capture stack. return call_status; } diff --git a/iree/vm/bytecode_dispatch_test.cc b/iree/vm/bytecode_dispatch_test.cc index 45d73ab7d3dc..16896fc797b1 100644 --- a/iree/vm/bytecode_dispatch_test.cc +++ b/iree/vm/bytecode_dispatch_test.cc @@ -44,20 +44,19 @@ std::vector GetModuleTestParams() { const auto* module_file_toc = iree::vm::bytecode_dispatch_test_module_create(); iree_vm_module_t* module = nullptr; - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) << "Bytecode module failed to load"; iree_vm_module_signature_t signature = module->signature(module->self); function_names.reserve(signature.export_function_count); for (int i = 0; i < signature.export_function_count; ++i) { iree_string_view_t name; - CHECK_EQ(IREE_STATUS_OK, - module->get_function(module->self, IREE_VM_FUNCTION_LINKAGE_EXPORT, - i, nullptr, &name, nullptr)); + IREE_CHECK_OK(module->get_function(module->self, + IREE_VM_FUNCTION_LINKAGE_EXPORT, i, + nullptr, &name, nullptr)); function_names.push_back({std::string(name.data, name.size)}); } iree_vm_module_release(module); @@ -70,23 +69,21 @@ class VMBytecodeDispatchTest public ::testing::WithParamInterface { protected: virtual void SetUp() { - CHECK_EQ(IREE_STATUS_OK, - iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance_)); + IREE_CHECK_OK(iree_vm_instance_create(IREE_ALLOCATOR_SYSTEM, &instance_)); const auto* module_file_toc = iree::vm::bytecode_dispatch_test_module_create(); - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &bytecode_module_)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &bytecode_module_)) << "Bytecode module failed to load"; std::vector modules = {bytecode_module_}; - CHECK_EQ(IREE_STATUS_OK, iree_vm_context_create_with_modules( - instance_, modules.data(), modules.size(), - IREE_ALLOCATOR_SYSTEM, &context_)); + IREE_CHECK_OK(iree_vm_context_create_with_modules( + instance_, modules.data(), modules.size(), IREE_ALLOCATOR_SYSTEM, + &context_)); } virtual void TearDown() { @@ -97,11 +94,10 @@ class VMBytecodeDispatchTest iree_status_t RunFunction(absl::string_view function_name) { iree_vm_function_t function; - CHECK_EQ(IREE_STATUS_OK, - bytecode_module_->lookup_function( - bytecode_module_->self, IREE_VM_FUNCTION_LINKAGE_EXPORT, - iree_string_view_t{function_name.data(), function_name.size()}, - &function)) + IREE_CHECK_OK(bytecode_module_->lookup_function( + bytecode_module_->self, IREE_VM_FUNCTION_LINKAGE_EXPORT, + iree_string_view_t{function_name.data(), function_name.size()}, + &function)) << "Exported function '" << function_name << "' not found"; return iree_vm_invoke(context_, function, @@ -119,7 +115,7 @@ TEST_P(VMBytecodeDispatchTest, Check) { bool expect_failure = absl::StartsWith(test_params.function_name, "fail_"); iree_status_t result = RunFunction(test_params.function_name); - if (result == IREE_STATUS_OK) { + if (iree_status_is_ok(result)) { if (expect_failure) { GTEST_FAIL() << "Function expected failure but succeeded"; } else { diff --git a/iree/vm/bytecode_module.cc b/iree/vm/bytecode_module.cc index c9f8ef568b9b..85c05ee1772b 100644 --- a/iree/vm/bytecode_module.cc +++ b/iree/vm/bytecode_module.cc @@ -438,8 +438,8 @@ static iree_status_t iree_vm_bytecode_module_alloc_state( total_state_struct_size += import_function_count * sizeof(iree_vm_function_t); iree_vm_bytecode_module_state_t* state = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( - allocator, total_state_struct_size, (void**)&state)); + IREE_RETURN_IF_ERROR(iree_allocator_malloc(allocator, total_state_struct_size, + (void**)&state)); state->allocator = allocator; uint8_t* p = ((uint8_t*)state) + sizeof(iree_vm_bytecode_module_state_t); @@ -510,7 +510,7 @@ static iree_status_t iree_vm_bytecode_module_execute( if (frame->function.module != self) { return IREE_STATUS_INVALID_ARGUMENT; } else if (frame->function.linkage != IREE_VM_FUNCTION_LINKAGE_INTERNAL) { - IREE_API_RETURN_IF_API_ERROR(iree_vm_bytecode_module_get_function( + IREE_RETURN_IF_ERROR(iree_vm_bytecode_module_get_function( self, frame->function.linkage, frame->function.ordinal, &frame->function, NULL, NULL)); } @@ -553,14 +553,13 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_bytecode_module_create( if (!module_def) { return IREE_STATUS_INVALID_ARGUMENT; } - IREE_API_RETURN_IF_API_ERROR( - iree_vm_bytecode_module_flatbuffer_verify(module_def)); + IREE_RETURN_IF_ERROR(iree_vm_bytecode_module_flatbuffer_verify(module_def)); size_t type_table_size = module_def->types()->size() * sizeof(iree_vm_type_def_t); iree_vm_bytecode_module_t* module = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_vm_bytecode_module_t) + type_table_size, (void**)&module)); module->allocator = allocator; diff --git a/iree/vm/bytecode_module_benchmark.cc b/iree/vm/bytecode_module_benchmark.cc index 4f558b6b2135..a42746bac7d9 100644 --- a/iree/vm/bytecode_module_benchmark.cc +++ b/iree/vm/bytecode_module_benchmark.cc @@ -49,12 +49,11 @@ static iree_status_t RunFunction(benchmark::State& state, const auto* module_file_toc = iree::vm::bytecode_module_benchmark_module_create(); iree_vm_module_t* module = nullptr; - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) << "Bytecode module failed to load"; iree_vm_module_state_t* module_state; @@ -81,11 +80,10 @@ static iree_status_t RunFunction(benchmark::State& state, iree_vm_stack_init(state_resolver, stack.get()); iree_vm_function_t function; - CHECK_EQ(IREE_STATUS_OK, - module->lookup_function( - module, IREE_VM_FUNCTION_LINKAGE_EXPORT, - iree_string_view_t{function_name.data(), function_name.size()}, - &function)) + IREE_CHECK_OK(module->lookup_function( + module, IREE_VM_FUNCTION_LINKAGE_EXPORT, + iree_string_view_t{function_name.data(), function_name.size()}, + &function)) << "Exported function '" << function_name << "' not found"; while (state.KeepRunningBatch(batch_size)) { @@ -98,8 +96,8 @@ static iree_status_t RunFunction(benchmark::State& state, } iree_vm_execution_result_t result; - CHECK_EQ(IREE_STATUS_OK, - module->execute(module->self, stack.get(), entry_frame, &result)); + IREE_CHECK_OK( + module->execute(module->self, stack.get(), entry_frame, &result)); iree_vm_stack_function_leave(stack.get()); } @@ -117,12 +115,11 @@ static void BM_ModuleCreate(benchmark::State& state) { const auto* module_file_toc = iree::vm::bytecode_module_benchmark_module_create(); iree_vm_module_t* module = nullptr; - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) << "Bytecode module failed to load"; // Just testing creation and verification here! @@ -137,12 +134,11 @@ static void BM_ModuleCreateState(benchmark::State& state) { const auto* module_file_toc = iree::vm::bytecode_module_benchmark_module_create(); iree_vm_module_t* module = nullptr; - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) << "Bytecode module failed to load"; while (state.KeepRunning()) { @@ -165,12 +161,11 @@ static void BM_FullModuleInit(benchmark::State& state) { const auto* module_file_toc = iree::vm::bytecode_module_benchmark_module_create(); iree_vm_module_t* module = nullptr; - CHECK_EQ(IREE_STATUS_OK, - iree_vm_bytecode_module_create( - iree_const_byte_span_t{ - reinterpret_cast(module_file_toc->data), - module_file_toc->size}, - IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) + IREE_CHECK_OK(iree_vm_bytecode_module_create( + iree_const_byte_span_t{ + reinterpret_cast(module_file_toc->data), + module_file_toc->size}, + IREE_ALLOCATOR_NULL, IREE_ALLOCATOR_SYSTEM, &module)) << "Bytecode module failed to load"; iree_vm_module_state_t* module_state; @@ -199,7 +194,7 @@ static void BM_EmptyFuncReference(benchmark::State& state) { BENCHMARK(BM_EmptyFuncReference); static void BM_EmptyFuncBytecode(benchmark::State& state) { - CHECK_EQ(IREE_STATUS_OK, RunFunction(state, "empty_func", {})); + IREE_CHECK_OK(RunFunction(state, "empty_func", {})); } BENCHMARK(BM_EmptyFuncBytecode); @@ -236,8 +231,8 @@ static void BM_CallInternalFuncReference(benchmark::State& state) { BENCHMARK(BM_CallInternalFuncReference); static void BM_CallInternalFuncBytecode(benchmark::State& state) { - CHECK_EQ(IREE_STATUS_OK, RunFunction(state, "call_internal_func", {100}, - /*batch_size=*/10)); + IREE_CHECK_OK(RunFunction(state, "call_internal_func", {100}, + /*batch_size=*/10)); } BENCHMARK(BM_CallInternalFuncBytecode); @@ -265,8 +260,8 @@ static void BM_CallImportedFuncReference(benchmark::State& state) { BENCHMARK(BM_CallImportedFuncReference); static void BM_CallImportedFuncBytecode(benchmark::State& state) { - CHECK_EQ(IREE_STATUS_OK, RunFunction(state, "call_imported_func", {100}, - /*batch_size=*/10)); + IREE_CHECK_OK(RunFunction(state, "call_imported_func", {100}, + /*batch_size=*/10)); } BENCHMARK(BM_CallImportedFuncBytecode); @@ -287,9 +282,9 @@ static void BM_LoopSumReference(benchmark::State& state) { BENCHMARK(BM_LoopSumReference)->Arg(100000); static void BM_LoopSumBytecode(benchmark::State& state) { - CHECK_EQ(IREE_STATUS_OK, RunFunction(state, "loop_sum", - {static_cast(state.range(0))}, - /*batch_size=*/state.range(0))); + IREE_CHECK_OK(RunFunction(state, "loop_sum", + {static_cast(state.range(0))}, + /*batch_size=*/state.range(0))); } BENCHMARK(BM_LoopSumBytecode)->Arg(100000); diff --git a/iree/vm/context.c b/iree/vm/context.c index 73e5a26bc060..729f5fa41e4c 100644 --- a/iree/vm/context.c +++ b/iree/vm/context.c @@ -60,15 +60,15 @@ static iree_status_t iree_vm_context_resolve_module_imports( iree_vm_module_signature_t module_signature = module->signature(module->self); for (int i = 0; i < module_signature.import_function_count; ++i) { iree_string_view_t full_name; - IREE_API_RETURN_IF_API_ERROR( + IREE_RETURN_IF_ERROR( module->get_function(module->self, IREE_VM_FUNCTION_LINKAGE_IMPORT, i, /*out_function=*/NULL, /*out_name=*/&full_name, /*out_signature=*/NULL)); iree_vm_function_t import_function; - IREE_API_RETURN_IF_API_ERROR( + IREE_RETURN_IF_ERROR( iree_vm_context_resolve_function(context, full_name, &import_function)); - IREE_API_RETURN_IF_API_ERROR( + IREE_RETURN_IF_ERROR( module->resolve_import(module->self, module_state, i, import_function)); } return IREE_STATUS_OK; @@ -79,7 +79,7 @@ static iree_status_t iree_vm_invoke_empty_function( iree_vm_stack_frame_t* callee_frame = NULL; iree_status_t status = iree_vm_stack_function_enter(stack, function, &callee_frame); - if (status != IREE_STATUS_OK) { + if (!iree_status_is_ok(status)) { return status; } @@ -103,10 +103,9 @@ static void iree_vm_context_release_modules(iree_vm_context_t* context, continue; } iree_vm_function_t deinit_function; - if (iree_vm_module_lookup_function_by_name( + if (iree_status_is_ok(iree_vm_module_lookup_function_by_name( module, IREE_VM_FUNCTION_LINKAGE_EXPORT, - iree_make_cstring_view("__deinit"), - &deinit_function) == IREE_STATUS_OK) { + iree_make_cstring_view("__deinit"), &deinit_function))) { iree_vm_invoke_empty_function(stack, deinit_function); } } @@ -163,7 +162,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_create_with_modules( sizeof(iree_vm_module_state_t*) * module_count; iree_vm_context_t* context = NULL; - IREE_API_RETURN_IF_API_ERROR( + IREE_RETURN_IF_ERROR( iree_allocator_malloc(allocator, context_size, (void**)&context)); atomic_store(&context->ref_count, 1); context->instance = instance; @@ -184,7 +183,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_create_with_modules( iree_status_t register_status = iree_vm_context_register_modules(context, modules, module_count); - if (register_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(register_status)) { iree_vm_context_destroy(context); return register_status; } @@ -203,11 +202,11 @@ static iree_status_t iree_vm_context_destroy(iree_vm_context_t* context) { // If we shrunk the stack (or made it so that it could dynamically grow) // then we could stack-allocate it here and not need the allocator at all. iree_vm_stack_t* stack = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( context->allocator, sizeof(iree_vm_stack_t), (void**)&stack)); iree_status_t status = iree_vm_stack_init(iree_vm_context_state_resolver(context), stack); - if (status != IREE_STATUS_OK) { + if (!iree_status_is_ok(status)) { iree_allocator_free(context->allocator, stack); return status; } @@ -318,11 +317,11 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_register_modules( // If we shrunk the stack (or made it so that it could dynamically grow) // then we could stack-allocate it here and not need the allocator at all. iree_vm_stack_t* stack = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( context->allocator, sizeof(iree_vm_stack_t), (void**)&stack)); iree_status_t status = iree_vm_stack_init(iree_vm_context_state_resolver(context), stack); - if (status != IREE_STATUS_OK) { + if (!iree_status_is_ok(status)) { iree_allocator_free(context->allocator, stack); return status; } @@ -341,7 +340,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_register_modules( iree_vm_module_state_t* module_state = NULL; iree_status_t alloc_status = module->alloc_state(module->self, context->allocator, &module_state); - if (alloc_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(alloc_status)) { // NOTE: we need to clean up initialized modules. iree_vm_context_release_modules(context, stack, orig_count, orig_count + i); @@ -356,7 +355,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_register_modules( // TODO(benvanik): re-resolve imports for previous modules? iree_status_t resolve_status = iree_vm_context_resolve_module_imports(context, module, module_state); - if (resolve_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(resolve_status)) { // NOTE: we need to clean up initialized modules. iree_vm_context_release_modules(context, stack, orig_count, orig_count + i); @@ -372,13 +371,12 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_context_register_modules( // As initialization functions may reference imports we need to perform all // of these after we have resolved the imports above. iree_vm_function_t init_function; - if (iree_vm_module_lookup_function_by_name( + if (iree_status_is_ok(iree_vm_module_lookup_function_by_name( module, IREE_VM_FUNCTION_LINKAGE_EXPORT, - iree_make_cstring_view("__init"), - &init_function) == IREE_STATUS_OK) { + iree_make_cstring_view("__init"), &init_function))) { iree_status_t init_status = iree_vm_invoke_empty_function(stack, init_function); - if (init_status != IREE_STATUS_OK) { + if (!iree_status_is_ok(init_status)) { // NOTE: we need to clean up initialized modules. iree_vm_context_release_modules(context, stack, orig_count, orig_count + i); diff --git a/iree/vm/instance.c b/iree/vm/instance.c index b2bfe396f5f9..df51422f0cbd 100644 --- a/iree/vm/instance.c +++ b/iree/vm/instance.c @@ -30,10 +30,10 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_instance_create( } *out_instance = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_vm_register_builtin_types()); + IREE_RETURN_IF_ERROR(iree_vm_register_builtin_types()); iree_vm_instance_t* instance = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( + IREE_RETURN_IF_ERROR(iree_allocator_malloc( allocator, sizeof(iree_vm_instance_t), (void**)&instance)); instance->allocator = allocator; atomic_store(&instance->ref_count, 1); diff --git a/iree/vm/invocation.c b/iree/vm/invocation.c index 175c5cc5cfb8..fac8ad6d3148 100644 --- a/iree/vm/invocation.c +++ b/iree/vm/invocation.c @@ -49,14 +49,13 @@ static iree_status_t iree_vm_marshal_outputs( uint8_t reg = return_registers->registers[i]; if (reg & IREE_REF_REGISTER_TYPE_BIT) { // Always move (as the stack frame will be destroyed soon). - IREE_API_RETURN_IF_API_ERROR(iree_vm_variant_list_append_ref_move( + IREE_RETURN_IF_ERROR(iree_vm_variant_list_append_ref_move( outputs, ®isters->ref[reg & IREE_REF_REGISTER_MASK])); } else { iree_vm_value_t value; value.type = IREE_VM_VALUE_TYPE_I32; value.i32 = registers->i32[reg & IREE_I32_REGISTER_MASK]; - IREE_API_RETURN_IF_API_ERROR( - iree_vm_variant_list_append_value(outputs, value)); + IREE_RETURN_IF_ERROR(iree_vm_variant_list_append_value(outputs, value)); } } return IREE_STATUS_OK; @@ -70,18 +69,17 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_invoke( // NOTE: it is ok to have no inputs or outputs. If we do have them, though, // they must be valid. // TODO(benvanik): validate outputs capacity. - IREE_API_RETURN_IF_API_ERROR( - iree_vm_validate_function_inputs(function, inputs)); + IREE_RETURN_IF_ERROR(iree_vm_validate_function_inputs(function, inputs)); // Allocate a stack on the heap and initialize it. // If we shrunk the stack (or made it so that it could dynamically grow) // then we could stack-allocate it here and not need the allocator at all. iree_vm_stack_t* stack = NULL; - IREE_API_RETURN_IF_API_ERROR(iree_allocator_malloc( - allocator, sizeof(iree_vm_stack_t), (void**)&stack)); + IREE_RETURN_IF_ERROR(iree_allocator_malloc(allocator, sizeof(iree_vm_stack_t), + (void**)&stack)); iree_status_t status = iree_vm_stack_init(iree_vm_context_state_resolver(context), stack); - if (status != IREE_STATUS_OK) { + if (!iree_status_is_ok(status)) { iree_allocator_free(allocator, stack); return status; } @@ -90,20 +88,20 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_invoke( status = iree_vm_stack_function_enter(stack, function, &callee_frame); // Marhsal inputs. - if (status == IREE_STATUS_OK && inputs) { + if (iree_status_is_ok(status) && inputs) { status = iree_vm_marshal_inputs(inputs, callee_frame); } // Perform execution. Note that for synchronous execution we expect this to // complete without yielding. - if (status == IREE_STATUS_OK) { + if (iree_status_is_ok(status)) { iree_vm_execution_result_t result; status = function.module->execute(function.module->self, stack, callee_frame, &result); } // Marshal outputs. - if (status == IREE_STATUS_OK && outputs) { + if (iree_status_is_ok(status) && outputs) { status = iree_vm_marshal_outputs(callee_frame, outputs); } diff --git a/iree/vm/module.c b/iree/vm/module.c index 2d1626eadc9d..695c0cc5068e 100644 --- a/iree/vm/module.c +++ b/iree/vm/module.c @@ -81,11 +81,11 @@ iree_vm_module_lookup_function_by_ordinal(const iree_vm_module_t* module, IREE_API_EXPORT iree_string_view_t IREE_API_CALL iree_vm_function_name(const iree_vm_function_t* function) { iree_string_view_t name; - if (function->module->get_function( + if (!iree_status_is_ok(function->module->get_function( function->module->self, function->linkage, function->ordinal, /*out_function=*/NULL, /*out_name=*/&name, - /*out_signature=*/NULL) != IREE_STATUS_OK) { + /*out_signature=*/NULL))) { return iree_make_cstring_view(""); } return name; @@ -104,7 +104,7 @@ iree_vm_function_reflection_attr(const iree_vm_function_t* function, iree_status_t status = module->get_function_reflection_attr( module->self, function->linkage, function->ordinal, index, &index_key, &index_value); - if (status != IREE_STATUS_OK) break; + if (!iree_status_is_ok(status)) break; if (iree_string_view_compare(key, index_key) == 0) { return index_value; } diff --git a/iree/vm/ref.c b/iree/vm/ref.c index 505731b66254..5cc108d7d55e 100644 --- a/iree/vm/ref.c +++ b/iree/vm/ref.c @@ -98,7 +98,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_ref_wrap_assign( IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_ref_wrap_retain( void* ptr, iree_vm_ref_type_t type, iree_vm_ref_t* out_ref) { - IREE_API_RETURN_IF_API_ERROR(iree_vm_ref_wrap_assign(ptr, type, out_ref)); + IREE_RETURN_IF_ERROR(iree_vm_ref_wrap_assign(ptr, type, out_ref)); if (out_ref->ptr) { volatile atomic_intptr_t* counter = IREE_GET_REF_COUNTER_PTR(out_ref); atomic_fetch_add(counter, 1); diff --git a/iree/vm/ref.h b/iree/vm/ref.h index 19c9e30e4abd..7a8bcaeba14b 100644 --- a/iree/vm/ref.h +++ b/iree/vm/ref.h @@ -157,7 +157,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_ref_check(iree_vm_ref_t* ref, iree_vm_ref_type_t type); #define IREE_VM_DEREF_OR_RETURN(value_type, value, ref, type) \ - IREE_API_RETURN_IF_API_ERROR(iree_vm_ref_check(ref, type)); \ + IREE_RETURN_IF_ERROR(iree_vm_ref_check(ref, type)); \ value_type* value = (value_type*)(ref)->ptr; // Retains the reference-counted pointer |ref|. diff --git a/iree/vm/ref_test.cc b/iree/vm/ref_test.cc index 44ccaff65331..ee1a96968804 100644 --- a/iree/vm/ref_test.cc +++ b/iree/vm/ref_test.cc @@ -59,12 +59,12 @@ static iree_vm_ref_t MakeRef() { descriptor.type_name = iree_make_cstring_view(typeid(T).name()); descriptor.offsetof_counter = T::offsetof_counter(); descriptor.destroy = T::DirectDestroy; - CHECK_EQ(IREE_STATUS_OK, iree_vm_ref_register_type(&descriptor)); + IREE_CHECK_OK(iree_vm_ref_register_type(&descriptor)); T::kTypeID = descriptor.type; } iree_vm_ref_t ref = {0}; - CHECK_EQ(IREE_STATUS_OK, iree_vm_ref_wrap_assign(new T(), T::kTypeID, &ref)); + IREE_CHECK_OK(iree_vm_ref_wrap_assign(new T(), T::kTypeID, &ref)); return ref; } @@ -81,7 +81,7 @@ static void RegisterTypeC() { descriptor.offsetof_counter = offsetof(ref_object_c_t, ref_object.counter); descriptor.destroy = +[](void* ptr) { delete reinterpret_cast(ptr); }; - CHECK_EQ(IREE_STATUS_OK, iree_vm_ref_register_type(&descriptor)); + IREE_CHECK_OK(iree_vm_ref_register_type(&descriptor)); kCTypeID = descriptor.type; } } @@ -99,8 +99,7 @@ TEST(VMRefTest, TypeRegistration) { TEST(VMRefTest, WrappingCStruct) { RegisterTypeC(); iree_vm_ref_t ref = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_wrap_assign(new ref_object_c_t(), kCTypeID, &ref)); + IREE_EXPECT_OK(iree_vm_ref_wrap_assign(new ref_object_c_t(), kCTypeID, &ref)); EXPECT_EQ(1, ReadCounter(&ref)); iree_vm_ref_release(&ref); } @@ -122,13 +121,13 @@ TEST(VMRefTest, WrappingSubclassedRefObject) { descriptor.type_name = iree_make_cstring_view(typeid(BaseType).name()); descriptor.offsetof_counter = BaseType::offsetof_counter(); descriptor.destroy = BaseType::DirectDestroy; - ASSERT_EQ(IREE_STATUS_OK, iree_vm_ref_register_type(&descriptor)); + IREE_ASSERT_OK(iree_vm_ref_register_type(&descriptor)); allocated_derived_types = 0; iree_vm_ref_t ref = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_wrap_assign(new DerivedType(), descriptor.type, &ref)); + IREE_EXPECT_OK( + iree_vm_ref_wrap_assign(new DerivedType(), descriptor.type, &ref)); EXPECT_EQ(1, ReadCounter(&ref)); EXPECT_EQ(1, allocated_derived_types); @@ -159,8 +158,7 @@ TEST(VMRefTest, WrappingReleasesExisting) { // Checking null refs is fine. TEST(VMRefTest, CheckNull) { iree_vm_ref_t null_ref = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_check(&null_ref, IREE_VM_REF_TYPE_NULL)); + IREE_EXPECT_OK(iree_vm_ref_check(&null_ref, IREE_VM_REF_TYPE_NULL)); EXPECT_EQ( IREE_STATUS_INVALID_ARGUMENT, iree_vm_ref_check(&null_ref, static_cast(1234))); @@ -169,7 +167,7 @@ TEST(VMRefTest, CheckNull) { // Tests type checks. TEST(VMRefTest, Check) { iree_vm_ref_t a_ref = MakeRef(); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_check(&a_ref, A::kTypeID)); + IREE_EXPECT_OK(iree_vm_ref_check(&a_ref, A::kTypeID)); EXPECT_EQ(IREE_STATUS_INVALID_ARGUMENT, iree_vm_ref_check(&a_ref, B::kTypeID)); iree_vm_ref_release(&a_ref); @@ -210,16 +208,15 @@ TEST(VMRefTest, RetainReleasesExisting) { TEST(VMRefTest, RetainCheckedNull) { iree_vm_ref_t null_ref_0 = {0}; iree_vm_ref_t null_ref_1 = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_retain_checked(&null_ref_0, A::kTypeID, &null_ref_1)); + IREE_EXPECT_OK( + iree_vm_ref_retain_checked(&null_ref_0, A::kTypeID, &null_ref_1)); } // Tests that types are verified and retains fail if types don't match. TEST(VMRefTest, RetainChecked) { iree_vm_ref_t a_ref_0 = MakeRef(); iree_vm_ref_t a_ref_1 = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_retain_checked(&a_ref_0, A::kTypeID, &a_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_checked(&a_ref_0, A::kTypeID, &a_ref_1)); iree_vm_ref_release(&a_ref_0); iree_vm_ref_release(&a_ref_1); } @@ -248,7 +245,7 @@ TEST(VMRefTest, RetainOrMoveMoving) { iree_vm_ref_t a_ref_0 = MakeRef(); iree_vm_ref_t a_ref_1 = {0}; iree_vm_ref_retain_or_move(/*is_move=*/1, &a_ref_0, &a_ref_1); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_check(&a_ref_0, IREE_VM_REF_TYPE_NULL)); + IREE_EXPECT_OK(iree_vm_ref_check(&a_ref_0, IREE_VM_REF_TYPE_NULL)); iree_vm_ref_release(&a_ref_1); } @@ -269,7 +266,7 @@ TEST(VMRefTest, RetainOrMoveRetainingIntoSelf) { TEST(VMRefTest, RetainOrMoveMovingIntoSelf) { iree_vm_ref_t a_ref = MakeRef(); iree_vm_ref_retain_or_move(/*is_move=*/1, &a_ref, &a_ref); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_check(&a_ref, A::kTypeID)); + IREE_EXPECT_OK(iree_vm_ref_check(&a_ref, A::kTypeID)); iree_vm_ref_release(&a_ref); } @@ -298,12 +295,10 @@ TEST(VMRefTest, RetainOrMoveMovingReleasesExisting) { TEST(VMRefTest, RetainOrMoveCheckedNull) { iree_vm_ref_t null_ref_0 = {0}; iree_vm_ref_t null_ref_1 = {0}; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_retain_or_move_checked( - /*is_move=*/0, &null_ref_0, A::kTypeID, &null_ref_1)); - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_retain_or_move_checked( - /*is_move=*/1, &null_ref_0, A::kTypeID, &null_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/0, &null_ref_0, A::kTypeID, &null_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/1, &null_ref_0, A::kTypeID, &null_ref_1)); } // Tests that retains/moves work when types match. @@ -311,8 +306,8 @@ TEST(VMRefTest, RetainOrMoveCheckedMatch) { // Retain. iree_vm_ref_t a_ref_0 = MakeRef(); iree_vm_ref_t a_ref_1 = {0}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_retain_or_move_checked( - /*is_move=*/0, &a_ref_0, A::kTypeID, &a_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/0, &a_ref_0, A::kTypeID, &a_ref_1)); EXPECT_EQ(1, iree_vm_ref_equal(&a_ref_0, &a_ref_1)); EXPECT_EQ(2, ReadCounter(&a_ref_0)); iree_vm_ref_release(&a_ref_0); @@ -321,8 +316,8 @@ TEST(VMRefTest, RetainOrMoveCheckedMatch) { // Move. iree_vm_ref_t b_ref_0 = MakeRef(); iree_vm_ref_t b_ref_1 = {0}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_retain_or_move_checked( - /*is_move=*/1, &b_ref_0, B::kTypeID, &b_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/1, &b_ref_0, B::kTypeID, &b_ref_1)); EXPECT_EQ(0, iree_vm_ref_equal(&b_ref_0, &b_ref_1)); EXPECT_EQ(1, ReadCounter(&b_ref_1)); iree_vm_ref_release(&b_ref_1); @@ -354,16 +349,16 @@ TEST(VMRefTest, RetainOrMoveCheckedMismatch) { TEST(VMRefTest, RetainOrMoveCheckedReleasesExistingNull) { iree_vm_ref_t null_ref = {0}; iree_vm_ref_t a_ref = MakeRef(); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_retain_or_move_checked( - /*is_move=*/0, &null_ref, A::kTypeID, &a_ref)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/0, &null_ref, A::kTypeID, &a_ref)); } // Tests that existing references are released when being overwritten. TEST(VMRefTest, RetainOrMoveCheckedReleasesExisting) { iree_vm_ref_t a_ref_0 = MakeRef(); iree_vm_ref_t a_ref_1 = MakeRef(); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_retain_or_move_checked( - /*is_move=*/1, &a_ref_0, A::kTypeID, &a_ref_1)); + IREE_EXPECT_OK(iree_vm_ref_retain_or_move_checked( + /*is_move=*/1, &a_ref_0, A::kTypeID, &a_ref_1)); iree_vm_ref_release(&a_ref_1); } @@ -415,7 +410,7 @@ TEST(VMRefTest, MovingResetsSource) { iree_vm_ref_t a_ref_0 = MakeRef(); iree_vm_ref_t a_ref_1 = {0}; iree_vm_ref_move(&a_ref_0, &a_ref_1); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_check(&a_ref_0, IREE_VM_REF_TYPE_NULL)); + IREE_EXPECT_OK(iree_vm_ref_check(&a_ref_0, IREE_VM_REF_TYPE_NULL)); iree_vm_ref_release(&a_ref_1); } @@ -423,7 +418,7 @@ TEST(VMRefTest, MovingResetsSource) { TEST(VMRefTest, MovingIntoSelf) { iree_vm_ref_t a_ref = MakeRef(); iree_vm_ref_move(&a_ref, &a_ref); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_ref_check(&a_ref, A::kTypeID)); + IREE_EXPECT_OK(iree_vm_ref_check(&a_ref, A::kTypeID)); iree_vm_ref_release(&a_ref); } diff --git a/iree/vm/stack.c b/iree/vm/stack.c index 2610d6fda6b9..906b80af0ed4 100644 --- a/iree/vm/stack.c +++ b/iree/vm/stack.c @@ -28,7 +28,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_stack_init( IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_stack_deinit(iree_vm_stack_t* stack) { while (stack->depth) { - IREE_API_RETURN_IF_API_ERROR(iree_vm_stack_function_leave(stack)); + IREE_RETURN_IF_ERROR(iree_vm_stack_function_leave(stack)); } return IREE_STATUS_OK; } @@ -61,7 +61,7 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_stack_function_enter( } } if (!callee_frame->module_state) { - IREE_API_RETURN_IF_API_ERROR(stack->state_resolver.query_module_state( + IREE_RETURN_IF_ERROR(stack->state_resolver.query_module_state( stack->state_resolver.self, function.module, &callee_frame->module_state)); } diff --git a/iree/vm/stack_test.cc b/iree/vm/stack_test.cc index 8f14532f8402..e96ee95be701 100644 --- a/iree/vm/stack_test.cc +++ b/iree/vm/stack_test.cc @@ -49,7 +49,7 @@ static iree_status_t SentinelStateResolver( TEST(VMStackTest, Usage) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); @@ -57,8 +57,8 @@ TEST(VMStackTest, Usage) { iree_vm_function_t function_a = {MODULE_A_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0}; iree_vm_stack_frame_t* frame_a = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); EXPECT_EQ(0, frame_a->function.ordinal); EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); @@ -66,39 +66,39 @@ TEST(VMStackTest, Usage) { iree_vm_function_t function_b = {MODULE_B_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 1}; iree_vm_stack_frame_t* frame_b = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); EXPECT_EQ(1, frame_b->function.ordinal); EXPECT_EQ(frame_b, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(frame_a, iree_vm_stack_parent_frame(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } // Tests stack cleanup with unpopped frames (like during failure teardown). TEST(VMStackTest, DeinitWithRemainingFrames) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); iree_vm_function_t function_a = {MODULE_A_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0}; iree_vm_stack_frame_t* frame_a = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); EXPECT_EQ(0, frame_a->function.ordinal); EXPECT_EQ(frame_a, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); // Don't pop the last frame before deinit; it should handle it. - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get())); } @@ -106,7 +106,7 @@ TEST(VMStackTest, DeinitWithRemainingFrames) { TEST(VMStackTest, StackOverflow) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); @@ -116,8 +116,8 @@ TEST(VMStackTest, StackOverflow) { IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0}; for (int i = 0; i < IREE_MAX_STACK_DEPTH; ++i) { iree_vm_stack_frame_t* frame_a = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); } // Try to push on one more frame. @@ -130,26 +130,26 @@ TEST(VMStackTest, StackOverflow) { // Should still be frame A. EXPECT_EQ(0, iree_vm_stack_current_frame(stack.get())->function.ordinal); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } // Tests unbalanced stack popping. TEST(VMStackTest, UnbalancedPop) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); EXPECT_EQ(IREE_STATUS_FAILED_PRECONDITION, iree_vm_stack_function_leave(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } // Tests module state reuse and querying. TEST(VMStackTest, ModuleStateQueries) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_current_frame(stack.get())); EXPECT_EQ(nullptr, iree_vm_stack_parent_frame(stack.get())); @@ -161,8 +161,8 @@ TEST(VMStackTest, ModuleStateQueries) { iree_vm_function_t function_a = {MODULE_A_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0}; iree_vm_stack_frame_t* frame_a = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); EXPECT_EQ(MODULE_A_STATE_SENTINEL, frame_a->module_state); EXPECT_EQ(1, module_a_state_resolve_count); @@ -170,22 +170,22 @@ TEST(VMStackTest, ModuleStateQueries) { iree_vm_function_t function_b = {MODULE_B_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 1}; iree_vm_stack_frame_t* frame_b = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); EXPECT_EQ(MODULE_B_STATE_SENTINEL, frame_b->module_state); EXPECT_EQ(1, module_b_state_resolve_count); // [A, B, B (reuse)] - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_b, &frame_b)); EXPECT_EQ(MODULE_B_STATE_SENTINEL, frame_b->module_state); EXPECT_EQ(1, module_b_state_resolve_count); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } // Tests that module state query failures propagate to callers correctly. @@ -198,7 +198,7 @@ TEST(VMStackTest, ModuleStateQueryFailure) { // NOTE: always failing. return IREE_STATUS_INTERNAL; }}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); // Push should fail if we can't query state, status should propagate. iree_vm_function_t function_a = {MODULE_A_SENTINEL, @@ -207,7 +207,7 @@ TEST(VMStackTest, ModuleStateQueryFailure) { EXPECT_EQ(IREE_STATUS_INTERNAL, iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } static int dummy_object_count = 0; @@ -234,7 +234,7 @@ iree_vm_ref_type_t DummyObject::kTypeID = IREE_VM_REF_TYPE_NULL; TEST(VMStackTest, RefRegisterCleanup) { auto stack = std::make_unique(); iree_vm_state_resolver_t state_resolver = {nullptr, SentinelStateResolver}; - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_init(state_resolver, stack.get())); + IREE_EXPECT_OK(iree_vm_stack_init(state_resolver, stack.get())); dummy_object_count = 0; DummyObject::RegisterType(); @@ -242,20 +242,19 @@ TEST(VMStackTest, RefRegisterCleanup) { iree_vm_function_t function_a = {MODULE_A_SENTINEL, IREE_VM_FUNCTION_LINKAGE_INTERNAL, 0}; iree_vm_stack_frame_t* frame_a = nullptr; - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); + IREE_EXPECT_OK( + iree_vm_stack_function_enter(stack.get(), function_a, &frame_a)); frame_a->registers.ref_register_count = 1; memset(&frame_a->registers.ref[0], 0, sizeof(iree_vm_ref_t)); - EXPECT_EQ(IREE_STATUS_OK, - iree_vm_ref_wrap_assign(new DummyObject(), DummyObject::kTypeID, - &frame_a->registers.ref[0])); + IREE_EXPECT_OK(iree_vm_ref_wrap_assign( + new DummyObject(), DummyObject::kTypeID, &frame_a->registers.ref[0])); EXPECT_EQ(1, dummy_object_count); // This should release the ref for us. Heap checker will yell if it doesn't. - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_function_leave(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_function_leave(stack.get())); EXPECT_EQ(0, dummy_object_count); - EXPECT_EQ(IREE_STATUS_OK, iree_vm_stack_deinit(stack.get())); + IREE_EXPECT_OK(iree_vm_stack_deinit(stack.get())); } } // namespace diff --git a/iree/vm/types.c b/iree/vm/types.c index b7e0562a7a31..0aafc2c7aa56 100644 --- a/iree/vm/types.c +++ b/iree/vm/types.c @@ -39,8 +39,8 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_register_builtin_types() { iree_vm_ro_byte_buffer_descriptor.offsetof_counter = offsetof(iree_vm_ro_byte_buffer_t, ref_object.counter); iree_vm_ro_byte_buffer_descriptor.type_name = - iree_make_cstring_view("ireex.byte_buffer"); - IREE_API_RETURN_IF_API_ERROR( + iree_make_cstring_view("iree.byte_buffer"); + IREE_RETURN_IF_ERROR( iree_vm_ref_register_type(&iree_vm_ro_byte_buffer_descriptor)); return IREE_STATUS_OK; diff --git a/iree/vm/types.h b/iree/vm/types.h index 981203a4a264..306afc016bbf 100644 --- a/iree/vm/types.h +++ b/iree/vm/types.h @@ -37,26 +37,26 @@ extern "C" { } // TODO(benvanik): make these macros standard/document them. -#define IREE_VM_DEFINE_TYPE_ADAPTERS(name, T) \ - IREE_API_EXPORT iree_vm_ref_t IREE_API_CALL name##_retain_ref(T* value) { \ - iree_vm_ref_t ref = {0}; \ - iree_vm_ref_wrap_retain(value, name##_descriptor.type, &ref); \ - return ref; \ - } \ - IREE_API_EXPORT iree_vm_ref_t IREE_API_CALL name##_move_ref(T* value) { \ - iree_vm_ref_t ref = {0}; \ - iree_vm_ref_wrap_assign(value, name##_descriptor.type, &ref); \ - return ref; \ - } \ - IREE_API_EXPORT T* IREE_API_CALL name##_deref(iree_vm_ref_t* ref) { \ - if (iree_vm_ref_check(ref, name##_descriptor.type) != IREE_STATUS_OK) { \ - return NULL; \ - } \ - return (T*)ref->ptr; \ - } \ - IREE_API_EXPORT const iree_vm_ref_type_descriptor_t* \ - name##_get_descriptor() { \ - return &name##_descriptor; \ +#define IREE_VM_DEFINE_TYPE_ADAPTERS(name, T) \ + IREE_API_EXPORT iree_vm_ref_t IREE_API_CALL name##_retain_ref(T* value) { \ + iree_vm_ref_t ref = {0}; \ + iree_vm_ref_wrap_retain(value, name##_descriptor.type, &ref); \ + return ref; \ + } \ + IREE_API_EXPORT iree_vm_ref_t IREE_API_CALL name##_move_ref(T* value) { \ + iree_vm_ref_t ref = {0}; \ + iree_vm_ref_wrap_assign(value, name##_descriptor.type, &ref); \ + return ref; \ + } \ + IREE_API_EXPORT T* IREE_API_CALL name##_deref(iree_vm_ref_t* ref) { \ + if (!iree_status_is_ok(iree_vm_ref_check(ref, name##_descriptor.type))) { \ + return NULL; \ + } \ + return (T*)ref->ptr; \ + } \ + IREE_API_EXPORT const iree_vm_ref_type_descriptor_t* \ + name##_get_descriptor() { \ + return &name##_descriptor; \ } // The built-in constant buffer type. diff --git a/iree/vm/variant_list.c b/iree/vm/variant_list.c index bc59992fc26e..e0635519ff6b 100644 --- a/iree/vm/variant_list.c +++ b/iree/vm/variant_list.c @@ -31,9 +31,9 @@ IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_variant_list_alloc( iree_host_size_t alloc_size = iree_vm_variant_list_alloc_size(capacity); iree_vm_variant_list_t* list = NULL; - IREE_API_RETURN_IF_API_ERROR( + IREE_RETURN_IF_ERROR( iree_allocator_malloc(allocator, alloc_size, (void**)&list)); - IREE_API_RETURN_IF_API_ERROR(iree_vm_variant_list_init(list, capacity)); + IREE_RETURN_IF_ERROR(iree_vm_variant_list_init(list, capacity)); list->allocator = allocator; *out_list = list; return IREE_STATUS_OK;