Aarch64: Introduce MemOperand::IsValid() and MemOperand::Equals().

Change-Id: I716ce507b398b4a86048d9346a1233b67baef99e
This commit is contained in:
Alexandre Rames 2016-07-05 11:14:01 +01:00
parent 61e54cf693
commit 8edbcac915
2 changed files with 26 additions and 2 deletions

View File

@ -365,7 +365,12 @@ Operand Operand::ToExtendedRegister() const {
// MemOperand
MemOperand::MemOperand(Register base, int64_t offset, AddrMode addrmode)
: base_(base), regoffset_(NoReg), offset_(offset), addrmode_(addrmode) {
: base_(base),
regoffset_(NoReg),
offset_(offset),
addrmode_(addrmode),
shift_(NO_SHIFT),
extend_(NO_EXTEND) {
VIXL_ASSERT(base.Is64Bits() && !base.IsZero());
}
@ -408,7 +413,11 @@ MemOperand::MemOperand(Register base,
MemOperand::MemOperand(Register base, const Operand& offset, AddrMode addrmode)
: base_(base), regoffset_(NoReg), addrmode_(addrmode) {
: base_(base),
regoffset_(NoReg),
addrmode_(addrmode),
shift_(NO_SHIFT),
extend_(NO_EXTEND) {
VIXL_ASSERT(base.Is64Bits() && !base.IsZero());
if (offset.IsImmediate()) {

View File

@ -827,6 +827,21 @@ class MemOperand {
void AddOffset(int64_t offset);
bool IsValid() const {
return base_.IsValid() &&
((addrmode_ == Offset) || (addrmode_ == PreIndex) ||
(addrmode_ == PostIndex)) &&
((shift_ == NO_SHIFT) || (extend_ == NO_EXTEND)) &&
((offset_ == 0) || !regoffset_.IsValid());
}
bool Equals(const MemOperand& other) const {
return base_.Is(other.base_) && regoffset_.Is(other.regoffset_) &&
(offset_ == other.offset_) && (addrmode_ == other.addrmode_) &&
(shift_ == other.shift_) && (extend_ == other.extend_) &&
(shift_amount_ == other.shift_amount_);
}
private:
Register base_;
Register regoffset_;