diff options
author | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2019-05-26 23:31:22 +0100 |
---|---|---|
committer | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2019-06-10 17:36:55 +0000 |
commit | 542fd370b285b0bd0e13ffa186e46e128e84273f (patch) | |
tree | fc2c0c6c570eeb186d8eb7462d9b91fdaefb28bd /src/base | |
parent | ec50225a654ddaedfcc6608409af496bab1d41c1 (diff) | |
download | gem5-542fd370b285b0bd0e13ffa186e46e128e84273f.tar.xz |
base: Add function to count trailing zeros in a 64-bit integer
Change-Id: Iaad0679b403bc5015ffeacbf7284313e41a36cd0
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19128
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/bitfield.hh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh index ec1ffce50..59b239a88 100644 --- a/src/base/bitfield.hh +++ b/src/base/bitfield.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited + * Copyright (c) 2017, 2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -293,4 +293,15 @@ inline int ctz32(uint32_t value) return value ? __builtin_ctz(value) : 32; } +/** + * Count trailing zeros in a 64-bit value. + * + * @param An input value + * @return The number of trailing zeros or 64 if the value is zero. + */ +inline int ctz64(uint64_t value) +{ + return value ? __builtin_ctzll(value) : 64; +} + #endif // __BASE_BITFIELD_HH__ |