ROSE 0.11.145.147
Alignment.h
1#ifndef ROSE_BinaryAnalysis_Alignment_H
2#define ROSE_BinaryAnalysis_Alignment_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <RoseFirst.h>
6#include <Sawyer/Optional.h>
7
8#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
9#include <boost/serialization/access.hpp>
10#endif
11
12namespace Rose {
13namespace BinaryAnalysis {
14
16class Alignment {
17private:
18 uint64_t value_ = 1;
19 size_t nBits_ = 64;
20
21#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
22private:
23 friend class boost::serialization::access;
24
25 template<class S>
26 void serialize(S &s, const unsigned /*version*/) {
27 s & BOOST_SERIALIZATION_NVP(value_);
28 s & BOOST_SERIALIZATION_NVP(nBits_);
29 }
30#endif
31
32public:
37
43 Alignment(uint64_t alignment, size_t nBits);
44
48 Alignment& operator=(const Alignment&) = default;
49 Alignment& operator=(const uint64_t);
55 uint64_t get() const;
56 uint64_t operator*() const;
57 void set(uint64_t);
65 size_t nBits() const;
66 void nBits(size_t);
72 uint64_t alignDown(uint64_t) const;
73
82
86 bool isAligned(uint64_t) const;
87};
88
89} // namespace
90} // namespace
91#endif
92#endif
Information about alignments.
Definition Alignment.h:16
bool isAligned(uint64_t) const
Test whether a value is aligned.
uint64_t operator*() const
Property: Alignment.
void nBits(size_t)
Property: Number of bits in the values being aligned.
Alignment & operator=(const uint64_t)
Assignment.
size_t nBits() const
Property: Number of bits in the values being aligned.
Alignment(uint64_t alignment, size_t nBits)
Constructor with specific alignment.
uint64_t get() const
Property: Alignment.
Alignment()
Default constructor.
uint64_t alignDown(uint64_t) const
Round value down to closest multiple of the alignment.
void set(uint64_t)
Property: Alignment.
Sawyer::Optional< uint64_t > alignUp(uint64_t) const
Round value up to the closest multiple of the alignment.
Alignment & operator=(const Alignment &)=default
Assignment.
Holds a value or nothing.
Definition Optional.h:56
The ROSE library.