aboutsummaryrefslogtreecommitdiff
path: root/gold/aarch64-reloc-property.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gold/aarch64-reloc-property.cc')
-rw-r--r--gold/aarch64-reloc-property.cc46
1 files changed, 40 insertions, 6 deletions
diff --git a/gold/aarch64-reloc-property.cc b/gold/aarch64-reloc-property.cc
index bf521d7..d0dee40 100644
--- a/gold/aarch64-reloc-property.cc
+++ b/gold/aarch64-reloc-property.cc
@@ -59,18 +59,52 @@ template<>
bool
rvalue_checkup<0, 0>(int64_t) { return true; }
+namespace
+{
+
+template<int L, int U>
+class Rvalue_bit_select_impl
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return (x & ((1ULL << (U+1)) - 1)) >> L;
+ }
+};
+
+template<int L>
+class Rvalue_bit_select_impl<L, 63>
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return x >> L;
+ }
+};
+
+// By our convention, L=U=0 means that the whole value should be retrieved.
+template<>
+class Rvalue_bit_select_impl<0, 0>
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return x;
+ }
+};
+
+} // End anonymous namespace.
+
template<int L, int U>
uint64_t
rvalue_bit_select(uint64_t x)
{
- if (U == 63) return x >> L;
- return (x & (((uint64_t)1 << (U+1)) - 1)) >> L;
+ return Rvalue_bit_select_impl<L, U>::calc(x);
}
-template<>
-uint64_t
-rvalue_bit_select<0, 0>(uint64_t x) { return x; }
-
AArch64_reloc_property::AArch64_reloc_property(
unsigned int code,
const char* name,