Go to the documentation of this file.
140 #ifndef __ARCH_GENERIC_VEC_REG_HH__
141 #define __ARCH_GENERIC_VEC_REG_HH__
147 #include <type_traits>
169 template <
typename VecElem,
size_t NumElems,
bool Const>
173 static constexpr
inline size_t
176 return sizeof(
VecElem) * NumElems;
180 using Container =
typename std::conditional<Const,
194 template<
bool Condition = !Const>
198 template<
bool Condition = !Const>
209 return container.template raw_ptr<VecElem>()[idx];
213 template<
bool Condition = !Const>
217 return container.template raw_ptr<VecElem>()[idx];
223 template<
typename VE2,
size_t NE2,
bool C2>
232 template<
typename VE2,
size_t NE2,
bool C2>
244 os <<
"[" << std::hex << (uint32_t)vr[0];
245 for (uint32_t
e = 1;
e < vr.
size();
e++)
246 os <<
" " << std::hex << (uint32_t)vr[
e];
261 template <
typename VecElem,
bool Const>
271 template <
size_t SIZE>
274 static_assert(
SIZE > 0,
275 "Cannot create Vector Register Container of zero size");
277 "Vector Register size limit exceeded");
279 static constexpr
inline size_t size() {
return SIZE; };
292 assert(that.size() >=
SIZE);
322 assert(that.size() >=
SIZE);
368 template <
typename Ret>
371 template <
typename Ret>
389 "VecElem does not evenly divide the register size");
391 "Viewing VecReg as something bigger than it is");
399 "VecElem does not evenly divide the register size");
401 "Viewing VecReg as something bigger than it is");
405 template <
typename VecElem,
int LaneIdx>
407 template <
typename VecElem,
int LaneIdx>
409 template <
typename VecElem>
411 template <
typename VecElem>
420 for (
auto&
b:
v.container) {
457 template <LaneSize LS>
477 template <
typename T>
explicit
481 template <
typename T>
483 operator=(
const T& that)
489 typename std::enable_if<
sizeof(T) ==
ByteSz,
int>::
type I = 0>
491 return *
static_cast<const T*
>(&
_val);
496 template <LaneSize LS>
500 return os << static_cast<typename LaneData<LS>::UnderlyingType>(
d);
511 template <
typename VecElem,
bool Const>
535 using Cont =
typename std::conditional<Const,
538 static_assert(!std::is_const<VecElem>::value || Const,
539 "Asked for non-const lane of const type!");
540 static_assert(std::is_integral<VecElem>::value,
541 "VecElem type is not integral!");
554 template <
bool Assignable = !Const>
565 template <
bool Assignable = !Const,
typename T>
568 static_assert(
sizeof(T) >=
sizeof(
VecElem),
569 "Attempt to perform widening bitwise copy.");
570 static_assert(
sizeof(T) <=
sizeof(
VecElem),
571 "Attempt to perform narrowing bitwise copy.");
588 template<
typename T,
bool Const>
594 template <
typename VecElem,
int LaneIdx>
603 template <
typename VecElem,
int LaneIdx>
612 template <
typename VecElem>
621 template <
typename VecElem>
647 "Vector register value overflow at unserialize");
649 for (
int i = 0; i < VecRegContainer<Sz>::size();
i++) {
651 if (2 *
i < value.size())
652 b = stoul(value.substr(
i * 2, 2),
nullptr, 16);
653 v.template raw_ptr<uint8_t>()[
i] =
b;
constexpr size_t DummyVecRegSizeBytes
static constexpr size_t size()
Size of the register in bytes.
VecLaneT(Cont &cont)
Constructor.
LaneSize
We define an auxiliary abstraction for LaneData.
bool operator!=(const VecRegT< VE2, NE2, C2 > &that) const
Inequality operator.
MyClass & operator=(const std::vector< uint8_t > &that)
From vector<uint8_t>.
const Ret * raw_ptr() const
Get pointer to bytes.
MyClass & operator=(const Container &that)
From appropriately sized uint8_t[].
VecRegT< VecElem, NumElems, false > as()
constexpr unsigned MaxVecRegLenInBytes
std::enable_if< Assignable, MyClass & >::type operator=(const VecElem &that)
Assignment operators.
typename std::conditional< Const, const VecElem, VecElem >::type Cont
typename std::conditional< Const, const VecRegContainer< size()>, VecRegContainer< size()> >::type Container
Container type alias.
VecLaneT< VecElem, false > laneView()
View as the Nth lane of type VecElem.
VecRegT< VecElem, NumElems, true > as() const
View interposers.
void copyTo(Container &dst) const
Copy the contents into the input buffer.
bool operator!=(const VecRegContainer< S2 > &that) const
Inequality operator.
bool operator==(const VecRegT< VE2, NE2, C2 > &that) const
Equality operator.
std::enable_if< Condition, void >::type zero()
Zero the container.
static constexpr auto ByteSz
VecRegContainer(const std::vector< uint8_t > &that)
DummyVecReg::Container DummyVecRegContainer
Vector Lane abstraction Another view of a container.
std::enable_if< Condition, MyClass & >::type operator=(const MyClass &that)
MyClass & operator=(const MyClass &that)
Assignment operators.
const VecElem & operator[](size_t idx) const
Index operator.
void zero()
Zero the container.
const std::string print() const
bool to_number(const std::string &value, VecRegContainer< Sz > &v)
Calls required for serialization/deserialization.
uint32_t DummyVecElem
Dummy type aliases and constants for architectures that do not implement vector registers.
VecRegT(Container &cnt)
Constructor.
static constexpr size_t size()
void copyTo(std::vector< uint8_t > &dst) const
To vector<uint8_t> This is required for serialisation.
std::enable_if< Assignable, MyClass & >::type operator=(const T &that)
Generic.
LaneData(typename std::enable_if< sizeof(T)==ByteSz, const T & >::type t)
bool operator==(const VecRegContainer< S2 > &that) const
Equality operator.
std::enable_if< Condition, VecElem & >::type operator[](size_t idx)
Index operator.
Overload hash function for BasicBlockRange type.
constexpr unsigned DummyNumVecElemPerVecReg
friend std::ostream & operator<<(std::ostream &os, const MyClass &v)
Output operator.
std::ostream & operator<<(std::ostream &os, const LaneData< LS > &d)
Output operator overload for LaneData<Size>.
Cont & container
Reference to data.
typename std::conditional< LS==LaneSize::EightByte, uint64_t, typename std::conditional< LS==LaneSize::FourByte, uint32_t, typename std::conditional< LS==LaneSize::TwoByte, uint16_t, typename std::conditional< LS==LaneSize::Byte, uint8_t, void >::type >::type >::type >::type UnderlyingType
Alias to the native type of the appropriate size.
Container & container
Reference to container.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
std::array< uint8_t, SIZE > Container
std::string csprintf(const char *format, const Args &...args)
LaneSize is an abstraction of a LS byte value for the execution and thread contexts to handle values ...
friend std::ostream & operator<<(std::ostream &os, const MyClass &vr)
Output stream operator.
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
Vector Register Abstraction This generic class is a view in a particularization of MVC,...
const std::string print() const
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17