Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/42357 )
Change subject: base: Make the functions in intmath.hh constexpr.
..
base: Make the functions in intmath.hh constexpr.
These simple functions can potentially be evaluated at compile time, and
marking them constexpr makes them available in more contexts.
Change-Id: I9cf39c517e7c53c276883f311739c1b153ccfd44
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42357
Maintainer: Gabe Black
Tested-by: kokoro
Reviewed-by: Daniel Carvalho
---
M src/base/intmath.hh
1 file changed, 7 insertions(+), 7 deletions(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/intmath.hh b/src/base/intmath.hh
index 473f0e3..acf7681 100644
--- a/src/base/intmath.hh
+++ b/src/base/intmath.hh
@@ -39,7 +39,7 @@
/**
* @ingroup api_base_utils
*/
-inline uint64_t
+static constexpr uint64_t
power(uint32_t n, uint32_t e)
{
uint64_t result = 1;
@@ -59,7 +59,7 @@
* @ingroup api_base_utils
*/
template
-inline typename std::enable_if_t::value, int>
+static constexpr std::enable_if_t::value, int>
floorLog2(T x)
{
assert(x > 0);
@@ -84,7 +84,7 @@
* @ingroup api_base_utils
*/
template
-inline int
+static constexpr int
ceilLog2(const T& n)
{
assert(n > 0);
@@ -98,7 +98,7 @@
* @ingroup api_base_utils
*/
template
-inline bool
+static constexpr bool
isPowerOf2(const T& n)
{
// If n is non-zero, and subtracting one borrows all the way to the MSB
@@ -110,7 +110,7 @@
* @ingroup api_base_utils
*/
template
-inline T
+static constexpr T
divCeil(const T& a, const U& b)
{
return (a + b - 1) / b;
@@ -127,7 +127,7 @@
* @ingroup api_base_utils
*/
template
-inline T
+static constexpr T
roundUp(const T& val, const U& align)
{
assert(isPowerOf2(align));
@@ -146,7 +146,7 @@
* @ingroup api_base_utils
*/
template
-inline T
+static constexpr T
roundDown(const T& val, const U& align)
{
assert(isPowerOf2(align));
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42357
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9cf39c517e7c53c276883f311739c1b153ccfd44
Gerrit-Change-Number: 42357
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black
Gerrit-Reviewer: Bobby R. Bruce
Gerrit-Reviewer: Daniel Carvalho
Gerrit-Reviewer: Gabe Black
Gerrit-Reviewer: kokoro
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s