[PATCH] D76031: [mlir][CRunnerUtils] Enable compilation with C++11 toolchain on microcontroller platforms.
Nicolas Vasilache via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 07:36:05 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8093e31e4e21: [mlir][CRunnerUtils] Enable compilation with C++11 toolchain on microcontroller… (authored by nicolasvasilache).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76031/new/
https://reviews.llvm.org/D76031
Files:
mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
mlir/lib/ExecutionEngine/CMakeLists.txt
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===================================================================
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -36,7 +36,9 @@
${outlibs})
add_llvm_library(mlir_c_runner_utils SHARED CRunnerUtils.cpp)
+set_property(TARGET mlir_c_runner_utils PROPERTY CXX_STANDARD 11)
add_llvm_library(mlir_c_runner_utils_static CRunnerUtils.cpp)
+set_property(TARGET mlir_c_runner_utils_static PROPERTY CXX_STANDARD 11)
target_compile_definitions(mlir_c_runner_utils PRIVATE mlir_c_runner_utils_EXPORTS)
add_llvm_library(mlir_runner_utils SHARED RunnerUtils.cpp)
Index: mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
//
// This file declares basic classes and functions to manipulate structured MLIR
-// types at runtime. Entities in this file are must be retargetable, including
-// on targets without a C++ runtime.
+// types at runtime. Entities in this file must be compliant with C++11 and be
+// retargetable, including on targets without a C++ runtime.
//
//===----------------------------------------------------------------------===//
@@ -45,9 +45,7 @@
constexpr bool isPowerOf2(int N) { return (!(N & (N - 1))); }
constexpr unsigned nextPowerOf2(int N) {
- if (N <= 1)
- return 1;
- return isPowerOf2(N) ? N : 2 * nextPowerOf2((N + 1) / 2);
+ return (N <= 1) ? 1 : (isPowerOf2(N) ? N : (2 * nextPowerOf2((N + 1) / 2)));
}
template <typename T, int Dim, bool IsPowerOf2>
@@ -59,8 +57,8 @@
static_assert(detail::nextPowerOf2(sizeof(T[Dim])) == sizeof(T[Dim]),
"size error");
}
- constexpr T &operator[](unsigned i) { return vector[i]; }
- constexpr const T &operator[](unsigned i) const { return vector[i]; }
+ inline T &operator[](unsigned i) { return vector[i]; }
+ inline const T &operator[](unsigned i) const { return vector[i]; }
private:
T vector[Dim];
@@ -76,8 +74,8 @@
static_assert(detail::nextPowerOf2(sizeof(T[Dim])) < 2 * sizeof(T[Dim]),
"size error");
}
- constexpr T &operator[](unsigned i) { return vector[i]; }
- constexpr const T &operator[](unsigned i) const { return vector[i]; }
+ inline T &operator[](unsigned i) { return vector[i]; }
+ inline const T &operator[](unsigned i) const { return vector[i]; }
private:
T vector[Dim];
@@ -88,8 +86,8 @@
// N-D vectors recurse down to 1-D.
template <typename T, int Dim, int... Dims>
struct Vector {
- constexpr Vector<T, Dims...> &operator[](unsigned i) { return vector[i]; }
- constexpr const Vector<T, Dims...> &operator[](unsigned i) const {
+ inline Vector<T, Dims...> &operator[](unsigned i) { return vector[i]; }
+ inline const Vector<T, Dims...> &operator[](unsigned i) const {
return vector[i];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76031.249927.patch
Type: text/x-patch
Size: 3051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200312/9720381d/attachment.bin>
More information about the llvm-commits
mailing list