[Mlir-commits] [mlir] c224b4d - [mlir] NFC - Move Vector structure from RunnerUtils.h to CRunnerUtils.h
Nicolas Vasilache
llvmlistbot at llvm.org
Mon Mar 2 06:47:07 PST 2020
Author: Nicolas Vasilache
Date: 2020-03-02T09:43:47-05:00
New Revision: c224b4dcf4249b851e6b4cf2f5da9ded943f0fd3
URL: https://github.com/llvm/llvm-project/commit/c224b4dcf4249b851e6b4cf2f5da9ded943f0fd3
DIFF: https://github.com/llvm/llvm-project/commit/c224b4dcf4249b851e6b4cf2f5da9ded943f0fd3.diff
LOG: [mlir] NFC - Move Vector structure from RunnerUtils.h to CRunnerUtils.h
Summary: The Vector struct does not require a C++ runtime.
Differential Revision: https://reviews.llvm.org/D75409
Added:
Modified:
mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
mlir/include/mlir/ExecutionEngine/RunnerUtils.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
index 9f0dbf8eba12..d82963b1aa03 100644
--- a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -36,6 +36,31 @@ template <int N> void dropFront(int64_t arr[N], int64_t *res) {
*(res + i - 1) = arr[i];
}
+//===----------------------------------------------------------------------===//
+// Codegen-compatible structures for Vector type.
+//===----------------------------------------------------------------------===//
+template <typename T, int Dim, int... Dims>
+struct Vector {
+ Vector<T, Dims...> vector[Dim];
+};
+
+template <typename T, int Dim>
+struct Vector<T, Dim> {
+ T vector[Dim];
+};
+
+template <int D1, typename T>
+using Vector1D = Vector<T, D1>;
+template <int D1, int D2, typename T>
+using Vector2D = Vector<T, D1, D2>;
+template <int D1, int D2, int D3, typename T>
+using Vector3D = Vector<T, D1, D2, D3>;
+template <int D1, int D2, int D3, int D4, typename T>
+using Vector4D = Vector<T, D1, D2, D3, D4>;
+
+//===----------------------------------------------------------------------===//
+// Codegen-compatible structures for StridedMemRef type.
+//===----------------------------------------------------------------------===//
/// StridedMemRef descriptor type with static rank.
template <typename T, int N> struct StridedMemRefType {
T *basePtr;
@@ -72,13 +97,18 @@ template <typename T> struct StridedMemRefType<T, 0> {
int64_t offset;
};
+//===----------------------------------------------------------------------===//
+// Codegen-compatible structure for UnrankedMemRef type.
+//===----------------------------------------------------------------------===//
// Unranked MemRef
template <typename T> struct UnrankedMemRefType {
int64_t rank;
void *descriptor;
};
-// Small runtime support "lib" for vector.print lowering.
+//===----------------------------------------------------------------------===//
+// Small runtime support "lib" for vector.print lowering during codegen.
+//===----------------------------------------------------------------------===//
extern "C" MLIR_CRUNNERUTILS_EXPORT void print_f32(float f);
extern "C" MLIR_CRUNNERUTILS_EXPORT void print_f64(double d);
extern "C" MLIR_CRUNNERUTILS_EXPORT void print_open();
diff --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
index feb38ec829b5..2676e648930c 100644
--- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
@@ -60,18 +60,6 @@ void printUnrankedMemRefMetaData(StreamType &os, UnrankedMemRefType<T> &V) {
<< "descriptor@ = " << reinterpret_cast<void *>(V.descriptor) << "\n";
}
-template <typename T, int Dim, int... Dims> struct Vector {
- Vector<T, Dims...> vector[Dim];
-};
-template <typename T, int Dim> struct Vector<T, Dim> { T vector[Dim]; };
-
-template <int D1, typename T> using Vector1D = Vector<T, D1>;
-template <int D1, int D2, typename T> using Vector2D = Vector<T, D1, D2>;
-template <int D1, int D2, int D3, typename T>
-using Vector3D = Vector<T, D1, D2, D3>;
-template <int D1, int D2, int D3, int D4, typename T>
-using Vector4D = Vector<T, D1, D2, D3, D4>;
-
////////////////////////////////////////////////////////////////////////////////
// Templated instantiation follows.
////////////////////////////////////////////////////////////////////////////////
More information about the Mlir-commits
mailing list