Improve code generation for ARM64 VisitArrayGet/Set.
We prefer the code sequence
add temp, obj, #offset
ldr out, [temp, index LSL #shift_amount]
to
add temp, obj, index LSL #shift_amount
ldr out, [temp, #offset]
Change-Id: I98f51a1b5a5ecd84c677d6dbd4c4bfc0f157f5e2
diff --git a/compiler/optimizing/common_arm64.h b/compiler/optimizing/common_arm64.h
index 246fff9..f545475 100644
--- a/compiler/optimizing/common_arm64.h
+++ b/compiler/optimizing/common_arm64.h
@@ -151,6 +151,15 @@
return vixl::MemOperand(base.X(), offset);
}
+static inline vixl::MemOperand HeapOperand(const vixl::Register& base,
+ const vixl::Register& regoffset,
+ vixl::Shift shift = vixl::LSL,
+ unsigned shift_amount = 0) {
+ // A heap reference must be 32bit, so fit in a W register.
+ DCHECK(base.IsW());
+ return vixl::MemOperand(base.X(), regoffset, shift, shift_amount);
+}
+
static inline vixl::MemOperand HeapOperand(const vixl::Register& base, Offset offset) {
return HeapOperand(base, offset.SizeValue());
}