[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
Wed Mar 11 15:20:08 PDT 2020


nicolasvasilache created this revision.
nicolasvasilache added a reviewer: aartbik.
Herald added subscribers: llvm-commits, danielkiss, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini, kristof.beyls.
Herald added a project: LLVM.
nicolasvasilache updated this revision to Diff 249772.
nicolasvasilache added a comment.
nicolasvasilache added reviewers: flaub, stella.stamenova.

Update commit message.


The C runner utils API was still not vanilla enough for certain use
cases on embedded ARM SDKs, this enables such cases.

Adding people more widely for historical Windows related build issues.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76031

Files:
  mlir/include/mlir/ExecutionEngine/CRunnerUtils.h


Index: mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -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.249772.patch
Type: text/x-patch
Size: 1866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200311/3440f657/attachment-0001.bin>


More information about the llvm-commits mailing list