Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/41515 )
Change subject: base: Add some operators to the BitUnion types.
......................................................................
base: Add some operators to the BitUnion types.
The operators it seems to need are ones which modify the BitUnion being
operated on, vs ones which just use it to produce a new value. The later
kind can be handled by converting the BitUnion into its underlying type
and then applying the built in operators.
Change-Id: I8aa08bf74d8ad88f4dfbb0031610c52ad412d03b
---
M src/base/bitunion.hh
1 file changed, 102 insertions(+), 11 deletions(-)
diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh
index aef6f6e..feb94b0 100644
--- a/src/base/bitunion.hh
+++ b/src/base/bitunion.hh
@@ -260,35 +260,126 @@
BitUnionOperators() {}
+ //Conversion operators.
operator const typename Base::__StorageType () const
{
return Base::__storage;
}
- typename Base::__StorageType
+ //Basic assignment operators.
+ BitUnionOperators &
operator=(typename Base::__StorageType const &val)
{
Base::__storage = val;
- return val;
+ return *this;
}
- typename Base::__StorageType
+ BitUnionOperators &
operator=(BitUnionOperators const &other)
{
- Base::__storage = other;
- return Base::__storage;
+ return operator=(other.__storage);
}
- bool
- operator<(Base const &base) const
+ //Increment and decrement operators.
+ BitUnionOperators &
+ operator++()
{
- return Base::__storage < base.__storage;
+ Base::__storage++;
+ return *this;
}
- bool
- operator==(Base const &base) const
+ BitUnionOperators
+ operator++(int)
{
- return Base::__storage == base.__storage;
+ BitUnionOperators ret = *this;
+ operator++();
+ return ret;
+ }
+
+ BitUnionOperators &
+ operator--()
+ {
+ Base::__storage--;
+ return *this;
+ }
+
+ BitUnionOperators
+ operator--(int)
+ {
+ BitUnionOperators ret = *this;
+ operator--;
+ return ret;
+ }
+
+ //Operation and assignment operators
+ BitUnionOperators &
+ operator+=(typename Base::__StorageType const &val)
+ {
+ Base::__storage += val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator-=(typename Base::__StorageType const &val)
+ {
+ Base::__storage -= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator*=(typename Base::__StorageType const &val)
+ {
+ Base::__storage *= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator/=(typename Base::__StorageType const &val)
+ {
+ Base::__storage /= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator%=(typename Base::__StorageType const &val)
+ {
+ Base::__storage %= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator&=(typename Base::__StorageType const &val)
+ {
+ Base::__storage &= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator|=(typename Base::__StorageType const &val)
+ {
+ Base::__storage |= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator^=(typename Base::__StorageType const &val)
+ {
+ Base::__storage ^= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator<<=(typename Base::__StorageType const &val)
+ {
+ Base::__storage <<= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator>>=(typename Base::__StorageType const &val)
+ {
+ Base::__storage >>= val;
+ return *this;
}
};
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41515
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: I8aa08bf74d8ad88f4dfbb0031610c52ad412d03b
Gerrit-Change-Number: 41515
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
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