libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
bitsVector.cpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
9#include <triton/cpuSize.hpp>
10#include <triton/exceptions.hpp>
11
12
13
14namespace triton {
15 namespace arch {
16
18 this->high = 0;
19 this->low = 0;
20 }
21
22
23 BitsVector::BitsVector(triton::uint32 high /* bits */, triton::uint32 low /* bits */) {
24 this->setBits(high, low);
25 }
26
27
29 this->high = other.high;
30 this->low = other.low;
31 }
32
33
35 return this->high;
36 }
37
38
40 return this->low;
41 }
42
43
45 return (this->high - this->low) + 1;
46 }
47
48
50 triton::uint512 max = -1;
51 max = max >> (512 - this->getVectorSize());
52 return max;
53 }
54
55
57 this->high = v;
58
60 throw triton::exceptions::BitsVector("BitsVector::setHigh(): The highest bit cannot be greater than triton::bitsize::max_supported.");
61 }
62
63
65 this->low = v;
66
67 if (this->low > this->high)
68 throw triton::exceptions::BitsVector("BitsVector::setLow(): The lower bit cannot be greater than highest.");
69 }
70
71
73 this->high = high;
74 this->low = low;
75
76 if (this->high >= triton::bitsize::max_supported)
77 throw triton::exceptions::BitsVector("BitsVector::setBits(): The highest bit cannot be greater than triton::bitsize::max_supported.");
78
79 if (this->low > this->high)
80 throw triton::exceptions::BitsVector("BitsVector::setBits(): The lower bit cannot be greater than highest.");
81 }
82
83
85 this->high = other.high;
86 this->low = other.low;
87 return *this;
88 }
89
90
91 std::ostream& operator<<(std::ostream& stream, const BitsVector& bv) {
92 stream << "bv[" << bv.getHigh() << ".." << bv.getLow() << "]";
93 return stream;
94 }
95
96
97 std::ostream& operator<<(std::ostream& stream, const BitsVector* bv) {
98 stream << *bv;
99 return stream;
100 }
101
102 }; /* arch namespace */
103}; /* triton namespace */
This class is used to deal with registers and memory as bits vector.
TRITON_EXPORT triton::uint512 getMaxValue(void) const
Returns the max possible value of the bitvector.
triton::uint32 low
The lower bit of the bitvector.
TRITON_EXPORT triton::uint32 getHigh(void) const
Returns the highest bit.
TRITON_EXPORT triton::uint32 getVectorSize(void) const
Returns the size in bits of the vector.
TRITON_EXPORT triton::uint32 getLow(void) const
Returns the lower bit.
TRITON_EXPORT void setHigh(triton::uint32 v)
Sets the highest bit position.
TRITON_EXPORT void setBits(triton::uint32 high, triton::uint32 low)
Sets the bits (high, low) position.
TRITON_EXPORT BitsVector()
Constructor.
TRITON_EXPORT void setLow(triton::uint32 v)
Sets the lower bit position.
triton::uint32 high
The highest bit of the bitvector.
TRITON_EXPORT BitsVector & operator=(const BitsVector &other)
Copy a BitsVector.
The exception class used by bitvectors.
std::ostream & operator<<(std::ostream &stream, BasicBlock &block)
Displays an BasicBlock.
constexpr triton::uint32 max_supported
max size supported in bit
Definition cpuSize.hpp:76
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.