Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/34816 )

Change subject: base: Add M5_LIKELY and M5_UNLIKELY macros to compiler.hh.
......................................................................

base: Add M5_LIKELY and M5_UNLIKELY macros to compiler.hh.

The clang/gcc implementation uses the nonstandard __builtin_expect(). In
C++20, new standard attributes can be used instead. We can't use those
yet though.

Change-Id: Idd2541a7eca0d97ac6c643abbf2910cbc343d7e5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34816
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/base/compiler.hh
1 file changed, 2 insertions(+), 0 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/compiler.hh b/src/base/compiler.hh
index 38736ca..1eaebc8 100644
--- a/src/base/compiler.hh
+++ b/src/base/compiler.hh
@@ -56,6 +56,8 @@
 #  define M5_UNREACHABLE __builtin_unreachable()
 #  define M5_PUBLIC __attribute__ ((visibility ("default")))
 #  define M5_LOCAL __attribute__ ((visibility ("hidden")))
+#  define M5_LIKELY(cond) __builtin_expect(!!(cond), 1)
+#  define M5_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
 #endif

 #if defined(__clang__)

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34816
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: Idd2541a7eca0d97ac6c643abbf2910cbc343d7e5
Gerrit-Change-Number: 34816
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Anthony Gutierrez <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to