Skip to content

Commit

Permalink
Replacing some VM macros with static inline functions.
Browse files Browse the repository at this point in the history
# Conflicts:
#	iree/vm/value.h
  • Loading branch information
benvanik committed Aug 17, 2020
1 parent 033adac commit b7c1c12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
10 changes: 3 additions & 7 deletions iree/vm/bytecode_module_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
#include <stdint.h>
#include <string.h>

#ifdef IREE_PLATFORM_ANDROID
// VC++ does not have C11's stdalign.h.
#if !defined(_MSC_VER)
#include <stdalign.h>
#else
// TODO(benvanik): figure out how to make MSVC happy with C11 stdalign.h.
#ifdef __cplusplus
#include <cstdalign>
#endif // __cplusplus
#endif
#endif // _MSC_VER

#include "iree/base/api.h"
#include "iree/vm/builtin_types.h"
Expand Down
17 changes: 5 additions & 12 deletions iree/vm/type_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,28 @@ typedef struct {
iree_vm_ref_type_t ref_type : 24;
} iree_vm_type_def_t;

#ifdef __cplusplus
inline iree_vm_type_def_t iree_vm_type_def_make_variant_type() {
static inline iree_vm_type_def_t iree_vm_type_def_make_variant_type() {
iree_vm_type_def_t result;
result.value_type = IREE_VM_VALUE_TYPE_NONE;
result.ref_type = IREE_VM_REF_TYPE_NULL;
return result;
}
inline iree_vm_type_def_t iree_vm_type_def_make_value_type(

static inline iree_vm_type_def_t iree_vm_type_def_make_value_type(
iree_vm_value_type_t value_type) {
iree_vm_type_def_t result;
result.value_type = value_type;
result.ref_type = IREE_VM_REF_TYPE_NULL;
return result;
}
inline iree_vm_type_def_t iree_vm_type_def_make_ref_type(

static inline iree_vm_type_def_t iree_vm_type_def_make_ref_type(
iree_vm_ref_type_t ref_type) {
iree_vm_type_def_t result;
result.value_type = IREE_VM_VALUE_TYPE_NONE;
result.ref_type = ref_type;
return result;
}
#else
#define iree_vm_type_def_make_variant_type() \
{ .value_type = IREE_VM_VALUE_TYPE_NONE, .ref_type = IREE_VM_REF_TYPE_NULL, }
#define iree_vm_type_def_make_value_type(value_type) \
{ .value_type = (value_type), .ref_type = IREE_VM_REF_TYPE_NULL, }
#define iree_vm_type_def_make_ref_type(ref_type) \
{ .value_type = IREE_VM_VALUE_TYPE_NONE, .ref_type = (ref_type), }
#endif // __cplusplus

#define iree_vm_type_def_is_value(v) \
((v)->value_type != IREE_VM_VALUE_TYPE_NONE)
Expand Down

0 comments on commit b7c1c12

Please sign in to comment.