blob: d3f431e3271f2a9a1575d03e1c5c5e468fee20cf [file] [log] [blame]
Andreas Gampe878d58c2015-01-15 23:24:00 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_
18#define ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_
19
Alexandre Rames8626b742015-11-25 16:28:08 +000020#include "code_generator.h"
Anton Kirilov74234da2017-01-13 14:42:47 +000021#include "instruction_simplifier_shared.h"
Andreas Gampe878d58c2015-01-15 23:24:00 -080022#include "locations.h"
23#include "nodes.h"
24#include "utils/arm64/assembler_arm64.h"
Scott Wakeling97c72b72016-06-24 16:19:36 +010025
Artem Serovaf4e42a2016-08-08 15:11:24 +010026// TODO(VIXL): Make VIXL compile with -Wshadow.
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wshadow"
29#include "aarch64/disasm-aarch64.h"
30#include "aarch64/macro-assembler-aarch64.h"
31#include "aarch64/simulator-aarch64.h"
32#pragma GCC diagnostic pop
Andreas Gampe878d58c2015-01-15 23:24:00 -080033
34namespace art {
Anton Kirilov74234da2017-01-13 14:42:47 +000035
36using helpers::CanFitInShifterOperand;
37using helpers::HasShifterOperand;
38
Andreas Gampe878d58c2015-01-15 23:24:00 -080039namespace arm64 {
40namespace helpers {
41
Andreas Gampe878d58c2015-01-15 23:24:00 -080042// Convenience helpers to ease conversion to and from VIXL operands.
43static_assert((SP == 31) && (WSP == 31) && (XZR == 32) && (WZR == 32),
44 "Unexpected values for register codes.");
45
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010046inline int VIXLRegCodeFromART(int code) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080047 if (code == SP) {
Scott Wakeling97c72b72016-06-24 16:19:36 +010048 return vixl::aarch64::kSPRegInternalCode;
Andreas Gampe878d58c2015-01-15 23:24:00 -080049 }
50 if (code == XZR) {
Scott Wakeling97c72b72016-06-24 16:19:36 +010051 return vixl::aarch64::kZeroRegCode;
Andreas Gampe878d58c2015-01-15 23:24:00 -080052 }
53 return code;
54}
55
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010056inline int ARTRegCodeFromVIXL(int code) {
Scott Wakeling97c72b72016-06-24 16:19:36 +010057 if (code == vixl::aarch64::kSPRegInternalCode) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080058 return SP;
59 }
Scott Wakeling97c72b72016-06-24 16:19:36 +010060 if (code == vixl::aarch64::kZeroRegCode) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080061 return XZR;
62 }
63 return code;
64}
65
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010066inline vixl::aarch64::Register XRegisterFrom(Location location) {
Roland Levillain3a448e42016-04-01 18:37:46 +010067 DCHECK(location.IsRegister()) << location;
Scott Wakeling97c72b72016-06-24 16:19:36 +010068 return vixl::aarch64::Register::GetXRegFromCode(VIXLRegCodeFromART(location.reg()));
Andreas Gampe878d58c2015-01-15 23:24:00 -080069}
70
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010071inline vixl::aarch64::Register WRegisterFrom(Location location) {
Roland Levillain3a448e42016-04-01 18:37:46 +010072 DCHECK(location.IsRegister()) << location;
Scott Wakeling97c72b72016-06-24 16:19:36 +010073 return vixl::aarch64::Register::GetWRegFromCode(VIXLRegCodeFromART(location.reg()));
Andreas Gampe878d58c2015-01-15 23:24:00 -080074}
75
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010076inline vixl::aarch64::Register RegisterFrom(Location location, Primitive::Type type) {
Roland Levillain3a448e42016-04-01 18:37:46 +010077 DCHECK(type != Primitive::kPrimVoid && !Primitive::IsFloatingPointType(type)) << type;
Andreas Gampe878d58c2015-01-15 23:24:00 -080078 return type == Primitive::kPrimLong ? XRegisterFrom(location) : WRegisterFrom(location);
79}
80
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010081inline vixl::aarch64::Register OutputRegister(HInstruction* instr) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080082 return RegisterFrom(instr->GetLocations()->Out(), instr->GetType());
83}
84
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010085inline vixl::aarch64::Register InputRegisterAt(HInstruction* instr, int input_index) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080086 return RegisterFrom(instr->GetLocations()->InAt(input_index),
87 instr->InputAt(input_index)->GetType());
88}
89
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010090inline vixl::aarch64::FPRegister DRegisterFrom(Location location) {
Roland Levillain3a448e42016-04-01 18:37:46 +010091 DCHECK(location.IsFpuRegister()) << location;
Scott Wakeling97c72b72016-06-24 16:19:36 +010092 return vixl::aarch64::FPRegister::GetDRegFromCode(location.reg());
Andreas Gampe878d58c2015-01-15 23:24:00 -080093}
94
Alexandre Ramesbadf2b22016-08-24 17:08:49 +010095inline vixl::aarch64::FPRegister SRegisterFrom(Location location) {
Roland Levillain3a448e42016-04-01 18:37:46 +010096 DCHECK(location.IsFpuRegister()) << location;
Scott Wakeling97c72b72016-06-24 16:19:36 +010097 return vixl::aarch64::FPRegister::GetSRegFromCode(location.reg());
Andreas Gampe878d58c2015-01-15 23:24:00 -080098}
99
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100100inline vixl::aarch64::FPRegister FPRegisterFrom(Location location, Primitive::Type type) {
Roland Levillain3a448e42016-04-01 18:37:46 +0100101 DCHECK(Primitive::IsFloatingPointType(type)) << type;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800102 return type == Primitive::kPrimDouble ? DRegisterFrom(location) : SRegisterFrom(location);
103}
104
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100105inline vixl::aarch64::FPRegister OutputFPRegister(HInstruction* instr) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800106 return FPRegisterFrom(instr->GetLocations()->Out(), instr->GetType());
107}
108
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100109inline vixl::aarch64::FPRegister InputFPRegisterAt(HInstruction* instr, int input_index) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800110 return FPRegisterFrom(instr->GetLocations()->InAt(input_index),
111 instr->InputAt(input_index)->GetType());
112}
113
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100114inline vixl::aarch64::CPURegister CPURegisterFrom(Location location, Primitive::Type type) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100115 return Primitive::IsFloatingPointType(type)
116 ? vixl::aarch64::CPURegister(FPRegisterFrom(location, type))
117 : vixl::aarch64::CPURegister(RegisterFrom(location, type));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800118}
119
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100120inline vixl::aarch64::CPURegister OutputCPURegister(HInstruction* instr) {
Alexandre Rames542361f2015-01-29 16:57:31 +0000121 return Primitive::IsFloatingPointType(instr->GetType())
Scott Wakeling97c72b72016-06-24 16:19:36 +0100122 ? static_cast<vixl::aarch64::CPURegister>(OutputFPRegister(instr))
123 : static_cast<vixl::aarch64::CPURegister>(OutputRegister(instr));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800124}
125
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100126inline vixl::aarch64::CPURegister InputCPURegisterAt(HInstruction* instr, int index) {
Alexandre Rames542361f2015-01-29 16:57:31 +0000127 return Primitive::IsFloatingPointType(instr->InputAt(index)->GetType())
Scott Wakeling97c72b72016-06-24 16:19:36 +0100128 ? static_cast<vixl::aarch64::CPURegister>(InputFPRegisterAt(instr, index))
129 : static_cast<vixl::aarch64::CPURegister>(InputRegisterAt(instr, index));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800130}
131
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100132inline vixl::aarch64::CPURegister InputCPURegisterOrZeroRegAt(HInstruction* instr,
Alexandre Ramesbe919d92016-08-23 18:33:36 +0100133 int index) {
134 HInstruction* input = instr->InputAt(index);
135 Primitive::Type input_type = input->GetType();
136 if (input->IsConstant() && input->AsConstant()->IsZeroBitPattern()) {
137 return (Primitive::ComponentSize(input_type) >= vixl::aarch64::kXRegSizeInBytes)
Scott Wakeling79db9972017-01-19 14:08:42 +0000138 ? vixl::aarch64::Register(vixl::aarch64::xzr)
139 : vixl::aarch64::Register(vixl::aarch64::wzr);
Alexandre Ramesbe919d92016-08-23 18:33:36 +0100140 }
141 return InputCPURegisterAt(instr, index);
142}
143
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100144inline int64_t Int64ConstantFrom(Location location) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800145 HConstant* instr = location.GetConstant();
Nicolas Geoffrayde0eb6f2015-03-04 10:28:04 +0000146 if (instr->IsIntConstant()) {
147 return instr->AsIntConstant()->GetValue();
148 } else if (instr->IsNullConstant()) {
149 return 0;
150 } else {
Roland Levillain3a448e42016-04-01 18:37:46 +0100151 DCHECK(instr->IsLongConstant()) << instr->DebugName();
Nicolas Geoffrayde0eb6f2015-03-04 10:28:04 +0000152 return instr->AsLongConstant()->GetValue();
153 }
Andreas Gampe878d58c2015-01-15 23:24:00 -0800154}
155
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100156inline vixl::aarch64::Operand OperandFrom(Location location, Primitive::Type type) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800157 if (location.IsRegister()) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100158 return vixl::aarch64::Operand(RegisterFrom(location, type));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800159 } else {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100160 return vixl::aarch64::Operand(Int64ConstantFrom(location));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800161 }
162}
163
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100164inline vixl::aarch64::Operand InputOperandAt(HInstruction* instr, int input_index) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800165 return OperandFrom(instr->GetLocations()->InAt(input_index),
166 instr->InputAt(input_index)->GetType());
167}
168
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100169inline vixl::aarch64::MemOperand StackOperandFrom(Location location) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100170 return vixl::aarch64::MemOperand(vixl::aarch64::sp, location.GetStackIndex());
Andreas Gampe878d58c2015-01-15 23:24:00 -0800171}
172
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100173inline vixl::aarch64::MemOperand HeapOperand(const vixl::aarch64::Register& base,
Scott Wakeling97c72b72016-06-24 16:19:36 +0100174 size_t offset = 0) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800175 // A heap reference must be 32bit, so fit in a W register.
176 DCHECK(base.IsW());
Scott Wakeling97c72b72016-06-24 16:19:36 +0100177 return vixl::aarch64::MemOperand(base.X(), offset);
Andreas Gampe878d58c2015-01-15 23:24:00 -0800178}
179
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100180inline vixl::aarch64::MemOperand HeapOperand(const vixl::aarch64::Register& base,
Scott Wakeling97c72b72016-06-24 16:19:36 +0100181 const vixl::aarch64::Register& regoffset,
182 vixl::aarch64::Shift shift = vixl::aarch64::LSL,
183 unsigned shift_amount = 0) {
Alexandre Rames82000b02015-07-07 11:34:16 +0100184 // A heap reference must be 32bit, so fit in a W register.
185 DCHECK(base.IsW());
Scott Wakeling97c72b72016-06-24 16:19:36 +0100186 return vixl::aarch64::MemOperand(base.X(), regoffset, shift, shift_amount);
Alexandre Rames82000b02015-07-07 11:34:16 +0100187}
188
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100189inline vixl::aarch64::MemOperand HeapOperand(const vixl::aarch64::Register& base,
Scott Wakeling97c72b72016-06-24 16:19:36 +0100190 Offset offset) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800191 return HeapOperand(base, offset.SizeValue());
192}
193
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100194inline vixl::aarch64::MemOperand HeapOperandFrom(Location location, Offset offset) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800195 return HeapOperand(RegisterFrom(location, Primitive::kPrimNot), offset);
196}
197
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100198inline Location LocationFrom(const vixl::aarch64::Register& reg) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100199 return Location::RegisterLocation(ARTRegCodeFromVIXL(reg.GetCode()));
Andreas Gampe878d58c2015-01-15 23:24:00 -0800200}
201
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100202inline Location LocationFrom(const vixl::aarch64::FPRegister& fpreg) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100203 return Location::FpuRegisterLocation(fpreg.GetCode());
Andreas Gampe878d58c2015-01-15 23:24:00 -0800204}
205
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100206inline vixl::aarch64::Operand OperandFromMemOperand(
Scott Wakeling97c72b72016-06-24 16:19:36 +0100207 const vixl::aarch64::MemOperand& mem_op) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800208 if (mem_op.IsImmediateOffset()) {
Scott Wakeling97c72b72016-06-24 16:19:36 +0100209 return vixl::aarch64::Operand(mem_op.GetOffset());
Andreas Gampe878d58c2015-01-15 23:24:00 -0800210 } else {
211 DCHECK(mem_op.IsRegisterOffset());
Scott Wakeling97c72b72016-06-24 16:19:36 +0100212 if (mem_op.GetExtend() != vixl::aarch64::NO_EXTEND) {
213 return vixl::aarch64::Operand(mem_op.GetRegisterOffset(),
214 mem_op.GetExtend(),
215 mem_op.GetShiftAmount());
216 } else if (mem_op.GetShift() != vixl::aarch64::NO_SHIFT) {
217 return vixl::aarch64::Operand(mem_op.GetRegisterOffset(),
218 mem_op.GetShift(),
219 mem_op.GetShiftAmount());
Andreas Gampe878d58c2015-01-15 23:24:00 -0800220 } else {
221 LOG(FATAL) << "Should not reach here";
222 UNREACHABLE();
223 }
224 }
225}
226
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100227inline bool CanEncodeConstantAsImmediate(HConstant* constant, HInstruction* instr) {
Roland Levillain22c49222016-03-18 14:04:28 +0000228 DCHECK(constant->IsIntConstant() || constant->IsLongConstant() || constant->IsNullConstant())
229 << constant->DebugName();
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000230
231 // For single uses we let VIXL handle the constant generation since it will
232 // use registers that are not managed by the register allocator (wip0, wip1).
Vladimir Marko46817b82016-03-29 12:21:58 +0100233 if (constant->GetUses().HasExactlyOneElement()) {
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000234 return true;
235 }
236
Scott Wakeling40a04bf2015-12-11 09:50:36 +0000237 // Our code generator ensures shift distances are within an encodable range.
238 if (instr->IsRor()) {
239 return true;
240 }
241
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000242 int64_t value = CodeGenerator::GetInt64ValueOf(constant);
243
Alexandre Ramese6dbf482015-10-19 10:10:41 +0100244 if (instr->IsAnd() || instr->IsOr() || instr->IsXor()) {
245 // Uses logical operations.
Scott Wakeling97c72b72016-06-24 16:19:36 +0100246 return vixl::aarch64::Assembler::IsImmLogical(value, vixl::aarch64::kXRegSize);
Alexandre Ramese6dbf482015-10-19 10:10:41 +0100247 } else if (instr->IsNeg()) {
248 // Uses mov -immediate.
Scott Wakeling97c72b72016-06-24 16:19:36 +0100249 return vixl::aarch64::Assembler::IsImmMovn(value, vixl::aarch64::kXRegSize);
Alexandre Ramese6dbf482015-10-19 10:10:41 +0100250 } else {
251 DCHECK(instr->IsAdd() ||
Artem Serov328429f2016-07-06 16:23:04 +0100252 instr->IsIntermediateAddress() ||
Alexandre Ramese6dbf482015-10-19 10:10:41 +0100253 instr->IsBoundsCheck() ||
254 instr->IsCompare() ||
255 instr->IsCondition() ||
Roland Levillain22c49222016-03-18 14:04:28 +0000256 instr->IsSub())
257 << instr->DebugName();
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000258 // Uses aliases of ADD/SUB instructions.
Alexandre Ramesb69fbfb2015-10-16 09:08:46 +0100259 // If `value` does not fit but `-value` does, VIXL will automatically use
260 // the 'opposite' instruction.
Scott Wakeling97c72b72016-06-24 16:19:36 +0100261 return vixl::aarch64::Assembler::IsImmAddSub(value)
262 || vixl::aarch64::Assembler::IsImmAddSub(-value);
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000263 }
264}
265
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100266inline Location ARM64EncodableConstantOrRegister(HInstruction* constant,
Serban Constantinescu2d35d9d2015-02-22 22:08:01 +0000267 HInstruction* instr) {
268 if (constant->IsConstant()
269 && CanEncodeConstantAsImmediate(constant->AsConstant(), instr)) {
270 return Location::ConstantLocation(constant->AsConstant());
271 }
272
273 return Location::RequiresRegister();
274}
275
Zheng Xuda403092015-04-24 17:35:39 +0800276// Check if registers in art register set have the same register code in vixl. If the register
277// codes are same, we can initialize vixl register list simply by the register masks. Currently,
278// only SP/WSP and ZXR/WZR codes are different between art and vixl.
279// Note: This function is only used for debug checks.
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100280inline bool ArtVixlRegCodeCoherentForRegSet(uint32_t art_core_registers,
Vladimir Marko804b03f2016-09-14 16:26:36 +0100281 size_t num_core,
282 uint32_t art_fpu_registers,
283 size_t num_fpu) {
Zheng Xuda403092015-04-24 17:35:39 +0800284 // The register masks won't work if the number of register is larger than 32.
285 DCHECK_GE(sizeof(art_core_registers) * 8, num_core);
286 DCHECK_GE(sizeof(art_fpu_registers) * 8, num_fpu);
287 for (size_t art_reg_code = 0; art_reg_code < num_core; ++art_reg_code) {
288 if (RegisterSet::Contains(art_core_registers, art_reg_code)) {
289 if (art_reg_code != static_cast<size_t>(VIXLRegCodeFromART(art_reg_code))) {
290 return false;
291 }
292 }
293 }
294 // There is no register code translation for float registers.
295 return true;
296}
297
Anton Kirilov74234da2017-01-13 14:42:47 +0000298inline vixl::aarch64::Shift ShiftFromOpKind(HDataProcWithShifterOp::OpKind op_kind) {
Alexandre Rames8626b742015-11-25 16:28:08 +0000299 switch (op_kind) {
Anton Kirilov74234da2017-01-13 14:42:47 +0000300 case HDataProcWithShifterOp::kASR: return vixl::aarch64::ASR;
301 case HDataProcWithShifterOp::kLSL: return vixl::aarch64::LSL;
302 case HDataProcWithShifterOp::kLSR: return vixl::aarch64::LSR;
Alexandre Rames8626b742015-11-25 16:28:08 +0000303 default:
304 LOG(FATAL) << "Unexpected op kind " << op_kind;
305 UNREACHABLE();
Scott Wakeling97c72b72016-06-24 16:19:36 +0100306 return vixl::aarch64::NO_SHIFT;
Alexandre Rames8626b742015-11-25 16:28:08 +0000307 }
308}
309
Anton Kirilov74234da2017-01-13 14:42:47 +0000310inline vixl::aarch64::Extend ExtendFromOpKind(HDataProcWithShifterOp::OpKind op_kind) {
Alexandre Rames8626b742015-11-25 16:28:08 +0000311 switch (op_kind) {
Anton Kirilov74234da2017-01-13 14:42:47 +0000312 case HDataProcWithShifterOp::kUXTB: return vixl::aarch64::UXTB;
313 case HDataProcWithShifterOp::kUXTH: return vixl::aarch64::UXTH;
314 case HDataProcWithShifterOp::kUXTW: return vixl::aarch64::UXTW;
315 case HDataProcWithShifterOp::kSXTB: return vixl::aarch64::SXTB;
316 case HDataProcWithShifterOp::kSXTH: return vixl::aarch64::SXTH;
317 case HDataProcWithShifterOp::kSXTW: return vixl::aarch64::SXTW;
Alexandre Rames8626b742015-11-25 16:28:08 +0000318 default:
319 LOG(FATAL) << "Unexpected op kind " << op_kind;
320 UNREACHABLE();
Scott Wakeling97c72b72016-06-24 16:19:36 +0100321 return vixl::aarch64::NO_EXTEND;
Alexandre Rames8626b742015-11-25 16:28:08 +0000322 }
323}
324
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100325inline bool ShifterOperandSupportsExtension(HInstruction* instruction) {
Anton Kirilov74234da2017-01-13 14:42:47 +0000326 DCHECK(HasShifterOperand(instruction, kArm64));
Alexandre Rames8626b742015-11-25 16:28:08 +0000327 // Although the `neg` instruction is an alias of the `sub` instruction, `HNeg`
328 // does *not* support extension. This is because the `extended register` form
329 // of the `sub` instruction interprets the left register with code 31 as the
330 // stack pointer and not the zero register. (So does the `immediate` form.) In
331 // the other form `shifted register, the register with code 31 is interpreted
332 // as the zero register.
333 return instruction->IsAdd() || instruction->IsSub();
334}
335
Alexandre Ramesbadf2b22016-08-24 17:08:49 +0100336inline bool IsConstantZeroBitPattern(const HInstruction* instruction) {
Alexandre Ramesbe919d92016-08-23 18:33:36 +0100337 return instruction->IsConstant() && instruction->AsConstant()->IsZeroBitPattern();
338}
339
Andreas Gampe878d58c2015-01-15 23:24:00 -0800340} // namespace helpers
341} // namespace arm64
342} // namespace art
343
344#endif // ART_COMPILER_OPTIMIZING_COMMON_ARM64_H_