Simplify ukernel headers now that out-of-line asm is out of the picture (#15563)
Now that the primary delivery vehicle for ukernels is LLVMCPU, where
ukernels have to be built as bitcode, which precludes using any
out-of-line asm, we can simplify exported_bits.h.
diff --git a/runtime/src/iree/builtins/ukernel/BUILD.bazel b/runtime/src/iree/builtins/ukernel/BUILD.bazel
index 74a2446..0cbdf64 100644
--- a/runtime/src/iree/builtins/ukernel/BUILD.bazel
+++ b/runtime/src/iree/builtins/ukernel/BUILD.bazel
@@ -15,14 +15,8 @@
)
iree_runtime_cc_library(
- name = "static_assert",
- hdrs = ["static_assert.h"],
-)
-
-iree_runtime_cc_library(
name = "exported_bits",
hdrs = ["exported_bits.h"],
- deps = [":static_assert"],
)
internal_headers = [
@@ -34,7 +28,6 @@
"pack_internal.h",
"query_tile_sizes.h",
"query_tile_sizes_internal.h",
- "static_assert.h",
"unpack.h",
"unpack_internal.h",
]
@@ -70,7 +63,6 @@
visibility = ["//visibility:private"],
deps = [
":exported_bits",
- ":static_assert",
"//runtime/src/iree/base:core_headers",
"//runtime/src/iree/builtins/ukernel/arch:ukernel_arch",
],
diff --git a/runtime/src/iree/builtins/ukernel/CMakeLists.txt b/runtime/src/iree/builtins/ukernel/CMakeLists.txt
index 6224e34..1be3537 100644
--- a/runtime/src/iree/builtins/ukernel/CMakeLists.txt
+++ b/runtime/src/iree/builtins/ukernel/CMakeLists.txt
@@ -12,21 +12,11 @@
iree_cc_library(
NAME
- static_assert
- HDRS
- "static_assert.h"
- DEPS
-
- PUBLIC
-)
-
-iree_cc_library(
- NAME
exported_bits
HDRS
"exported_bits.h"
DEPS
- ::static_assert
+
PUBLIC
)
@@ -41,7 +31,6 @@
"pack_internal.h"
"query_tile_sizes.h"
"query_tile_sizes_internal.h"
- "static_assert.h"
"unpack.h"
"unpack_internal.h"
)
@@ -62,7 +51,6 @@
"pack_internal.h"
"query_tile_sizes.h"
"query_tile_sizes_internal.h"
- "static_assert.h"
"unpack.h"
"unpack_internal.h"
DEPS
@@ -89,14 +77,12 @@
"query_tile_sizes.c"
"query_tile_sizes.h"
"query_tile_sizes_internal.h"
- "static_assert.h"
"unpack.c"
"unpack.h"
"unpack_internal.h"
"unpack_tile.c"
DEPS
::exported_bits
- ::static_assert
iree::base::core_headers
iree::builtins::ukernel::arch::ukernel_arch
PUBLIC
diff --git a/runtime/src/iree/builtins/ukernel/common.h b/runtime/src/iree/builtins/ukernel/common.h
index 378cad7..8046a5b 100644
--- a/runtime/src/iree/builtins/ukernel/common.h
+++ b/runtime/src/iree/builtins/ukernel/common.h
@@ -29,9 +29,6 @@
// Include common flag values, shared with the compiler.
#include "iree/builtins/ukernel/exported_bits.h"
-// Include IREE_UK_STATIC_ASSERT.
-#include "iree/builtins/ukernel/static_assert.h"
-
// Clang on Windows has __builtin_clzll; otherwise we need to use the
// windows intrinsic functions.
#if defined(_MSC_VER)
@@ -218,6 +215,16 @@
#endif
//===----------------------------------------------------------------------===//
+// IREE_UK_STATIC_ASSERT, a static assert macro usable in C and C++.
+//===----------------------------------------------------------------------===//
+
+#if defined(__cplusplus)
+#define IREE_UK_STATIC_ASSERT(COND) static_assert(COND, #COND)
+#else
+#define IREE_UK_STATIC_ASSERT(COND) _Static_assert(COND, #COND)
+#endif
+
+//===----------------------------------------------------------------------===//
// Local replacements for stdint.h types and constants
// Refer to the comment at the top of this file for why we can't include
// stdint.h.
diff --git a/runtime/src/iree/builtins/ukernel/exported_bits.h b/runtime/src/iree/builtins/ukernel/exported_bits.h
index c027c5b..788bb0f 100644
--- a/runtime/src/iree/builtins/ukernel/exported_bits.h
+++ b/runtime/src/iree/builtins/ukernel/exported_bits.h
@@ -7,34 +7,19 @@
#ifndef IREE_BUILTINS_UKERNEL_EXPORTED_BITS_H_
#define IREE_BUILTINS_UKERNEL_EXPORTED_BITS_H_
-#include "iree/builtins/ukernel/static_assert.h"
-
// This header is shared across:
//
// * C++ code under compiler/
// * C code under runtime/.../ukernel/
-// * asm code under runtime/.../ukernel/
//
// Being shared with compiler/ means that we should treat these flags as set
// in stone. Don't count on being able to remove or change the numerical value
// of an existing flag.
//
-// Being shared with asm code means that the only thing that we can do here is
-// #define literal integers. The C/C++ code only cares about the flags values
-// but asm code also cares about the bit-position values (i.e. the log2's).
-// Consistency between the two is guarded by static_assert's but only when
-// the language is C/C++ (not assembly).
-//
// Ukernel flags are typically of type uint32. For now, we treat all flags as
// specific to one op, sometimes duplicating identical flags for multiple ops.
// In the future we might let multiple ops share common flags, but it is too
-// early to tell which yet.
-
-// Static assertions ensuring consistency of flag values, for those flags for
-// which we define _BIT_POS (typically, flags that are used in asm code, where
-// having _BIT_POS allows using bit-test instructions.)
-#define IREE_UK_ENSURE_CONSISTENT_FLAG(F) \
- IREE_UK_STATIC_ASSERT((F) == (1u << (F##_BIT_POS)))
+// early to tell which yet. We also might widen flags to uint64 as needed.
//===----------------------------------------------------------------------===//
// mmt4d
@@ -55,8 +40,6 @@
// bit flags
#define IREE_UK_FLAG_MMT4D_ACCUMULATE 0x100
-#define IREE_UK_FLAG_MMT4D_ACCUMULATE_BIT_POS 8
-IREE_UK_ENSURE_CONSISTENT_FLAG(IREE_UK_FLAG_MMT4D_ACCUMULATE);
#define IREE_UK_FLAG_MMT4D_SKIP_INTERMEDIATE_ROUNDINGS 0x400
//===----------------------------------------------------------------------===//
diff --git a/runtime/src/iree/builtins/ukernel/static_assert.h b/runtime/src/iree/builtins/ukernel/static_assert.h
deleted file mode 100644
index e6f00ab..0000000
--- a/runtime/src/iree/builtins/ukernel/static_assert.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2022 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_BUILTINS_UKERNEL_STATIC_ASSERT_H_
-#define IREE_BUILTINS_UKERNEL_STATIC_ASSERT_H_
-
-// IREE_UK_STATIC_ASSERT, a static assert macro usable in C, C++ and
-// assembly (though it may evaluate to nothing in assembly).
-
-#if defined(__ASSEMBLER__)
-// Note that __STDC__ may also be defined here (when the assembler driver is the
-// C compiler driver). So it's easiest to handle __ASSEMBLER__ before __STDC__.
-//
-// Evaluate to nothing (TODO: If we care for static asserts in assembly, perhaps
-// implement them as an assembler .macro?)
-#define IREE_UK_STATIC_ASSERT(COND)
-#elif defined(__cplusplus)
-// Note that depending on the C++ compiler, __STDC__ may or may not be defined
-// here! It is defined by G++ but not by Clang++! So, let's also handle
-// __cplusplus before __STDC__.
-#define IREE_UK_STATIC_ASSERT(COND) static_assert(COND, #COND)
-#elif defined(__STDC__) || defined(_MSC_VER)
-// Really C, as neither __ASSEMBLER__ nor __cplusplus are defined.
-#define IREE_UK_STATIC_ASSERT(COND) _Static_assert(COND, #COND)
-#else
-#error Expected either __cplusplus or __STDC__ or __ASSEMBLER__ to be defined.
-#endif
-
-#endif // IREE_BUILTINS_UKERNEL_STATIC_ASSERT_H_