Renaming iree_vm_variant2_t to iree_vm_variant_t.
diff --git a/bindings/python/pyiree/rt/function_abi.cc b/bindings/python/pyiree/rt/function_abi.cc
index 9bce1b6..58a0295 100644
--- a/bindings/python/pyiree/rt/function_abi.cc
+++ b/bindings/python/pyiree/rt/function_abi.cc
@@ -189,7 +189,7 @@
}
py::object UnpackScalar(const RawSignatureParser::Description& desc,
- iree_vm_variant_t& f_result) {
+ const iree_vm_variant_t& f_result) {
switch (desc.scalar.type) {
case AbiConstants::ScalarType::kUint8:
case AbiConstants::ScalarType::kUint16:
@@ -296,7 +296,7 @@
}
for (size_t i = 0, e = descs.size(); i < e; ++i) {
const Description& desc = descs[i];
- iree_vm_variant2_t f_result = {0};
+ iree_vm_variant_t f_result = iree_vm_variant_empty();
if (!iree_status_is_ok(
iree_vm_list_get_variant(f_results.raw_ptr(), i, &f_result))) {
throw RaiseValueError("Could not get result from list");
@@ -304,7 +304,7 @@
switch (desc.type) {
case RawSignatureParser::Type::kBuffer: {
iree_hal_buffer_view_t* buffer_view =
- iree_hal_buffer_view_deref(&f_result->ref);
+ iree_hal_buffer_view_deref(&f_result.ref);
if (!buffer_view) {
throw RaiseValueError(
"Could not deref result buffer view (wrong type?)");
@@ -343,7 +343,7 @@
"Ref objects not yet supported");
break;
case RawSignatureParser::Type::kScalar:
- py_results[i] = UnpackScalar(desc, *f_result);
+ py_results[i] = UnpackScalar(desc, f_result);
break;
default:
throw RaisePyError(PyExc_NotImplementedError,
diff --git a/bindings/python/pyiree/rt/vm.cc b/bindings/python/pyiree/rt/vm.cc
index 86817ce..171c403 100644
--- a/bindings/python/pyiree/rt/vm.cc
+++ b/bindings/python/pyiree/rt/vm.cc
@@ -197,7 +197,7 @@
absl::StrAppend(&s, "<VmVariantList(", size(), "): [");
for (iree_host_size_t i = 0, e = size(); i < e; ++i) {
- iree_vm_variant2_t variant = {0};
+ iree_vm_variant_t variant = iree_vm_variant_empty();
if (iree_status_is_ok(
iree_vm_list_get_variant(mutable_this->raw_ptr(), i, &variant))) {
absl::StrAppend(&s, "Error");
@@ -205,17 +205,17 @@
}
if (i > 0) absl::StrAppend(&s, ", ");
- if (IREE_VM_VARIANT_IS_VALUE(variant)) {
- absl::StrAppend(&s, variant->i32);
- } else if (IREE_VM_VARIANT_IS_REF(variant)) {
+ if (iree_vm_variant_is_value(variant)) {
+ absl::StrAppend(&s, variant.i32);
+ } else if (iree_vm_variant_is_ref(variant)) {
// Pretty print a subset of ABI impacting known types.
- if (iree_hal_buffer_isa(&variant->ref)) {
- auto* hal_buffer = iree_hal_buffer_deref(&variant->ref);
+ if (iree_hal_buffer_isa(&variant.ref)) {
+ auto* hal_buffer = iree_hal_buffer_deref(&variant.ref);
assert(hal_buffer);
absl::StrAppend(&s, "HalBuffer(",
iree_hal_buffer_byte_length(hal_buffer), ")");
- } else if (iree_hal_buffer_view_isa(&variant->ref)) {
- auto hal_bv = iree_hal_buffer_view_deref(&variant->ref);
+ } else if (iree_hal_buffer_view_isa(&variant.ref)) {
+ auto hal_bv = iree_hal_buffer_view_deref(&variant.ref);
absl::StrAppend(&s, "HalBufferView(");
absl::InlinedVector<int32_t, 5> shape(
iree_hal_buffer_view_shape_rank(hal_bv));
@@ -225,7 +225,7 @@
iree_hal_buffer_view_element_type(hal_bv))),
")");
} else {
- absl::StrAppend(&s, "Unknown(", variant->ref_type, ")");
+ absl::StrAppend(&s, "Unknown(", variant.type.ref_type, ")");
}
} else {
absl::StrAppend(&s, "None");
diff --git a/iree/modules/strings/strings_module.cc b/iree/modules/strings/strings_module.cc
index a52bac0..abd07ee 100644
--- a/iree/modules/strings/strings_module.cc
+++ b/iree/modules/strings/strings_module.cc
@@ -28,10 +28,7 @@
#include "iree/modules/strings/api.h"
#include "iree/modules/strings/api_detail.h"
#include "iree/vm/bytecode_module.h"
-#include "iree/vm/module.h"
#include "iree/vm/module_abi_cc.h"
-#include "iree/vm/ref.h"
-#include "iree/vm/stack.h"
static iree_vm_ref_type_descriptor_t strings_string_descriptor = {0};
static iree_vm_ref_type_descriptor_t strings_string_tensor_descriptor = {0};
diff --git a/iree/tools/run_mlir_main.cc b/iree/tools/run_mlir_main.cc
index 78d16dd..8a4b2c2 100644
--- a/iree/tools/run_mlir_main.cc
+++ b/iree/tools/run_mlir_main.cc
@@ -66,7 +66,6 @@
#include "iree/tools/vm_util.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
-#include "iree/vm/value.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
diff --git a/iree/tools/vm_util.cc b/iree/tools/vm_util.cc
index d1bfa58..24da00d 100644
--- a/iree/tools/vm_util.cc
+++ b/iree/tools/vm_util.cc
@@ -27,7 +27,6 @@
#include "iree/base/status.h"
#include "iree/hal/api.h"
#include "iree/modules/hal/hal_module.h"
-#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
namespace iree {
@@ -170,7 +169,7 @@
Status PrintVariantList(absl::Span<const RawSignatureParser::Description> descs,
iree_vm_list_t* variant_list, std::ostream* os) {
for (int i = 0; i < iree_vm_list_size(variant_list); ++i) {
- iree_vm_variant2_t variant = {nullptr};
+ iree_vm_variant_t variant = iree_vm_variant_empty();
RETURN_IF_ERROR(FromApiStatus(
iree_vm_list_get_variant(variant_list, i, &variant), IREE_LOC))
<< "variant " << i << "not present";
diff --git a/iree/vm/invocation.c b/iree/vm/invocation.c
index 5d1265f..f8cf3f9 100644
--- a/iree/vm/invocation.c
+++ b/iree/vm/invocation.c
@@ -31,7 +31,7 @@
uint16_t ref_reg = 0;
out_dst_reg_list->size = (uint16_t)count;
for (iree_host_size_t i = 0; i < count; ++i) {
- iree_vm_variant2_t variant = {0};
+ iree_vm_variant_t variant = iree_vm_variant_empty();
IREE_RETURN_IF_ERROR(iree_vm_list_get_variant(inputs, i, &variant));
if (iree_vm_type_def_is_ref(&variant.type)) {
out_dst_reg_list->registers[i] =
diff --git a/iree/vm/list.c b/iree/vm/list.c
index 961d3a3..ac1785e 100644
--- a/iree/vm/list.c
+++ b/iree/vm/list.c
@@ -81,7 +81,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant_storage = (iree_vm_variant2_t*)list->storage;
+ iree_vm_variant_t* variant_storage = (iree_vm_variant_t*)list->storage;
for (iree_host_size_t i = offset; i < length; ++i) {
if (iree_vm_type_def_is_ref(&variant_storage[i].type)) {
iree_vm_ref_release(&variant_storage[i].ref);
@@ -94,14 +94,14 @@
IREE_API_EXPORT iree_host_size_t iree_vm_list_storage_size(
const iree_vm_type_def_t* element_type, iree_host_size_t capacity) {
- iree_host_size_t element_size = sizeof(iree_vm_variant2_t);
+ iree_host_size_t element_size = sizeof(iree_vm_variant_t);
if (element_type) {
if (iree_vm_type_def_is_value(element_type)) {
element_size = kValueTypeSizes[element_type->value_type];
} else if (iree_vm_type_def_is_ref(element_type)) {
element_size = sizeof(iree_vm_ref_t);
} else {
- element_size = sizeof(iree_vm_variant2_t);
+ element_size = sizeof(iree_vm_variant_t);
}
}
return iree_align(sizeof(iree_vm_list_t), 8) +
@@ -112,7 +112,7 @@
iree_byte_span_t storage, const iree_vm_type_def_t* element_type,
iree_host_size_t capacity, iree_vm_list_t** out_list) {
iree_vm_list_storage_mode_t storage_mode = IREE_VM_LIST_STORAGE_MODE_VARIANT;
- iree_host_size_t element_size = sizeof(iree_vm_variant2_t);
+ iree_host_size_t element_size = sizeof(iree_vm_variant_t);
if (element_type) {
if (iree_vm_type_def_is_value(element_type)) {
storage_mode = IREE_VM_LIST_STORAGE_MODE_VALUE;
@@ -122,7 +122,7 @@
element_size = sizeof(iree_vm_ref_t);
} else {
storage_mode = IREE_VM_LIST_STORAGE_MODE_VARIANT;
- element_size = sizeof(iree_vm_variant2_t);
+ element_size = sizeof(iree_vm_variant_t);
}
}
@@ -175,7 +175,7 @@
list->element_size = sizeof(iree_vm_ref_t);
} else {
list->storage_mode = IREE_VM_LIST_STORAGE_MODE_VARIANT;
- list->element_size = sizeof(iree_vm_variant2_t);
+ list->element_size = sizeof(iree_vm_variant_t);
}
iree_status_t status = iree_vm_list_reserve(list, initial_capacity);
@@ -348,7 +348,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (!iree_vm_type_def_is_value(&variant->type)) {
return IREE_STATUS_FAILED_PRECONDITION;
}
@@ -391,7 +391,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (!iree_vm_type_def_is_value(&variant->type)) {
return IREE_STATUS_FAILED_PRECONDITION;
}
@@ -446,7 +446,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (variant->type.ref_type) {
iree_vm_ref_release(&variant->ref);
}
@@ -493,7 +493,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (!iree_vm_type_def_is_ref(&variant->type)) {
return IREE_STATUS_FAILED_PRECONDITION;
}
@@ -527,7 +527,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (variant->type.value_type) {
memset(&variant->ref, 0, sizeof(variant->ref));
}
@@ -569,7 +569,7 @@
IREE_API_EXPORT iree_status_t IREE_API_CALL
iree_vm_list_get_variant(const iree_vm_list_t* list, iree_host_size_t i,
- iree_vm_variant2_t* out_value) {
+ iree_vm_variant_t* out_value) {
if (i >= list->count) return IREE_STATUS_OUT_OF_RANGE;
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
switch (list->storage_mode) {
@@ -586,7 +586,7 @@
break;
}
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
- iree_vm_variant2_t* variant = (iree_vm_variant2_t*)element_ptr;
+ iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
out_value->type = variant->type;
if (iree_vm_type_def_is_ref(&variant->type)) {
iree_vm_ref_assign(&variant->ref, &out_value->ref);
@@ -603,12 +603,12 @@
}
IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_list_set_variant(
- iree_vm_list_t* list, iree_host_size_t i, const iree_vm_variant2_t* value) {
+ iree_vm_list_t* list, iree_host_size_t i, const iree_vm_variant_t* value) {
return IREE_STATUS_UNIMPLEMENTED;
}
IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_list_push_variant(
- iree_vm_list_t* list, const iree_vm_variant2_t* value) {
+ iree_vm_list_t* list, const iree_vm_variant_t* value) {
iree_host_size_t i = iree_vm_list_size(list);
IREE_RETURN_IF_ERROR(iree_vm_list_resize(list, i + 1));
return iree_vm_list_set_variant(list, i, value);
diff --git a/iree/vm/list.h b/iree/vm/list.h
index 745724c..00fd046 100644
--- a/iree/vm/list.h
+++ b/iree/vm/list.h
@@ -175,21 +175,21 @@
// lifetime.
IREE_API_EXPORT iree_status_t IREE_API_CALL
iree_vm_list_get_variant(const iree_vm_list_t* list, iree_host_size_t i,
- iree_vm_variant2_t* out_value);
+ iree_vm_variant_t* out_value);
// Sets the value of the element at the given index. If the specified |value|
// type differs from the list storage type the value will be converted using the
// value type semantics (such as sign/zero extend, etc). If the variant is a ref
// then it will be retained.
IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_list_set_variant(
- iree_vm_list_t* list, iree_host_size_t i, const iree_vm_variant2_t* value);
+ iree_vm_list_t* list, iree_host_size_t i, const iree_vm_variant_t* value);
// Pushes the value of the element to the end of the list. If the specified
// |value| type differs from the list storage type the value will be converted
// using the value type semantics (such as sign/zero extend, etc). If the
// variant is a ref then it will be retained.
-IREE_API_EXPORT iree_status_t IREE_API_CALL iree_vm_list_push_variant(
- iree_vm_list_t* list, const iree_vm_variant2_t* value);
+IREE_API_EXPORT iree_status_t IREE_API_CALL
+iree_vm_list_push_variant(iree_vm_list_t* list, const iree_vm_variant_t* value);
#endif // IREE_API_NO_PROTOTYPES
diff --git a/iree/vm/type_def.h b/iree/vm/type_def.h
index d93e594..2055fa2 100644
--- a/iree/vm/type_def.h
+++ b/iree/vm/type_def.h
@@ -88,7 +88,12 @@
uint8_t value_storage[IREE_VM_VALUE_STORAGE_SIZE]; // max size of all value
// types
};
-} iree_vm_variant2_t;
+} iree_vm_variant_t;
+
+#define iree_vm_variant_empty() \
+ { {IREE_VM_VALUE_TYPE_NONE, IREE_VM_REF_TYPE_NULL}, {0}, }
+#define iree_vm_variant_is_value(v) iree_vm_type_def_is_value(&v.type)
+#define iree_vm_variant_is_ref(v) iree_vm_type_def_is_ref(&v.type)
#ifdef __cplusplus
} // extern "C"