blob: 1c402928c3185a53d7196746b7bbb4eacaa03257 [file] [log] [blame]
Matteo Franchin43ec8732014-03-31 15:00:14 +01001/*
2 * Copyright (C) 2011 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_DEX_QUICK_ARM64_CODEGEN_ARM64_H_
18#define ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_
19
20#include "arm64_lir.h"
21#include "dex/compiler_internals.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070022#include "dex/quick/mir_to_lir.h"
Matteo Franchin43ec8732014-03-31 15:00:14 +010023
buzbee33ae5582014-06-12 14:56:32 -070024#include <map>
25
Matteo Franchin43ec8732014-03-31 15:00:14 +010026namespace art {
27
Andreas Gampe4b537a82014-06-30 22:24:53 -070028class Arm64Mir2Lir FINAL : public Mir2Lir {
buzbee33ae5582014-06-12 14:56:32 -070029 protected:
30 // TODO: consolidate 64-bit target support.
31 class InToRegStorageMapper {
32 public:
Zheng Xu949cd972014-06-23 18:33:08 +080033 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref) = 0;
buzbee33ae5582014-06-12 14:56:32 -070034 virtual ~InToRegStorageMapper() {}
35 };
36
37 class InToRegStorageArm64Mapper : public InToRegStorageMapper {
38 public:
39 InToRegStorageArm64Mapper() : cur_core_reg_(0), cur_fp_reg_(0) {}
40 virtual ~InToRegStorageArm64Mapper() {}
Zheng Xu949cd972014-06-23 18:33:08 +080041 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref);
buzbee33ae5582014-06-12 14:56:32 -070042 private:
43 int cur_core_reg_;
44 int cur_fp_reg_;
45 };
46
47 class InToRegStorageMapping {
48 public:
49 InToRegStorageMapping() : max_mapped_in_(0), is_there_stack_mapped_(false),
50 initialized_(false) {}
51 void Initialize(RegLocation* arg_locs, int count, InToRegStorageMapper* mapper);
52 int GetMaxMappedIn() { return max_mapped_in_; }
53 bool IsThereStackMapped() { return is_there_stack_mapped_; }
54 RegStorage Get(int in_position);
55 bool IsInitialized() { return initialized_; }
56 private:
57 std::map<int, RegStorage> mapping_;
58 int max_mapped_in_;
59 bool is_there_stack_mapped_;
60 bool initialized_;
61 };
62
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +010063 public:
64 Arm64Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
Matteo Franchin43ec8732014-03-31 15:00:14 +010065
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +010066 // Required for target - codegen helpers.
67 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
68 RegLocation rl_dest, int lit) OVERRIDE;
69 bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div,
70 RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
71 bool HandleEasyDivRem64(Instruction::Code dalvik_opcode, bool is_div,
72 RegLocation rl_src, RegLocation rl_dest, int64_t lit);
73 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
74 LIR* CheckSuspendUsingLoad() OVERRIDE;
75 RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE;
76 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
77 OpSize size, VolatileKind is_volatile) OVERRIDE;
78 LIR* LoadRefDisp(RegStorage r_base, int displacement, RegStorage r_dest,
79 VolatileKind is_volatile) OVERRIDE;
80 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
81 OpSize size) OVERRIDE;
82 LIR* LoadRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale)
83 OVERRIDE;
84 LIR* LoadConstantNoClobber(RegStorage r_dest, int value) OVERRIDE;
85 LIR* LoadConstantWide(RegStorage r_dest, int64_t value) OVERRIDE;
86 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src, OpSize size,
87 VolatileKind is_volatile) OVERRIDE;
88 LIR* StoreRefDisp(RegStorage r_base, int displacement, RegStorage r_src, VolatileKind is_volatile)
89 OVERRIDE;
90 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
91 OpSize size) OVERRIDE;
92 LIR* StoreRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale) OVERRIDE;
93 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE;
94 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
95 int offset, int check_value, LIR* target, LIR** compare) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010096
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +010097 // Required for target - register utilities.
98 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
99 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
100 if (wide_kind == kWide || wide_kind == kRef) {
Matteo Franchined7a0f22014-06-10 19:23:45 +0100101 return As64BitReg(TargetReg(symbolic_reg));
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100102 } else {
103 return Check32BitReg(TargetReg(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700104 }
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100105 }
106 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
107 return As64BitReg(TargetReg(symbolic_reg));
108 }
109 RegStorage GetArgMappingToPhysicalReg(int arg_num) OVERRIDE;
110 RegLocation GetReturnAlt() OVERRIDE;
111 RegLocation GetReturnWideAlt() OVERRIDE;
112 RegLocation LocCReturn() OVERRIDE;
113 RegLocation LocCReturnRef() OVERRIDE;
114 RegLocation LocCReturnDouble() OVERRIDE;
115 RegLocation LocCReturnFloat() OVERRIDE;
116 RegLocation LocCReturnWide() OVERRIDE;
117 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
118 void AdjustSpillMask() OVERRIDE;
119 void ClobberCallerSave() OVERRIDE;
120 void FreeCallTemps() OVERRIDE;
121 void LockCallTemps() OVERRIDE;
122 void CompilerInitializeRegAlloc() OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100123
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100124 // Required for target - miscellaneous.
125 void AssembleLIR() OVERRIDE;
126 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
127 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
128 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
129 const char* GetTargetInstFmt(int opcode) OVERRIDE;
130 const char* GetTargetInstName(int opcode) OVERRIDE;
131 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
132 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
133 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
134 size_t GetInsnSize(LIR* lir) OVERRIDE;
135 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100136
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100137 // Get the register class for load/store of a field.
138 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100139
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100140 // Required for target - Dalvik-level generators.
141 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
142 RegLocation lr_shift) OVERRIDE;
143 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
144 RegLocation rl_src2) OVERRIDE;
145 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
146 RegLocation rl_dest, int scale) OVERRIDE;
147 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
148 RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
149 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
150 RegLocation rl_shift) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100151 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
152 RegLocation rl_src2) OVERRIDE;
153 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
154 RegLocation rl_src2) OVERRIDE;
155 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
156 RegLocation rl_src2) OVERRIDE;
157 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
158 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
159 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
160 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
161 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
162 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
163 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
164 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
165 bool GenInlinedCeil(CallInfo* info) OVERRIDE;
166 bool GenInlinedFloor(CallInfo* info) OVERRIDE;
167 bool GenInlinedRint(CallInfo* info) OVERRIDE;
168 bool GenInlinedRound(CallInfo* info, bool is_double) OVERRIDE;
169 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
170 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Martyn Capewell9a8a5062014-08-07 11:31:48 +0100171 bool GenInlinedAbsInt(CallInfo* info) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100172 bool GenInlinedAbsLong(CallInfo* info) OVERRIDE;
Zheng Xu947717a2014-08-07 14:05:23 +0800173 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100174 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Andreas Gampec76c6142014-08-04 16:30:03 -0700175 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
176 RegLocation rl_src2) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100177 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
178 OVERRIDE;
179 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div)
180 OVERRIDE;
181 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
182 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
183 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
184 void GenExitSequence() OVERRIDE;
185 void GenSpecialExitSequence() OVERRIDE;
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700186 void GenFillArrayData(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100187 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
188 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
189 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
190 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
191 int32_t true_val, int32_t false_val, RegStorage rs_dest,
192 int dest_reg_class) OVERRIDE;
Andreas Gampe90969af2014-07-15 23:02:11 -0700193
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100194 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
195 void GenMonitorEnter(int opt_flags, RegLocation rl_src) OVERRIDE;
196 void GenMonitorExit(int opt_flags, RegLocation rl_src) OVERRIDE;
197 void GenMoveException(RegLocation rl_dest) OVERRIDE;
198 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
199 int first_bit, int second_bit) OVERRIDE;
200 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
201 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Andreas Gampe48971b32014-08-06 10:09:01 -0700202 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
203 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100204
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100205 // Required for target - single operation generators.
206 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
207 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
208 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
209 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
210 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
211 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
212 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
213 void OpEndIT(LIR* it) OVERRIDE;
214 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
215 LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
216 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
217 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
218 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
219 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
220 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
221 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
222 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
223 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
224 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
225 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
226 LIR* OpTestSuspend(LIR* target) OVERRIDE;
227 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
228 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
229 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
Andreas Gampef29ecd62014-07-29 00:35:00 -0700230
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100231 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
Matteo Franchinc763e352014-07-04 12:53:27 +0100232 bool InexpensiveConstantInt(int32_t value, Instruction::Code opcode) OVERRIDE;
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100233 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
234 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
235 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100236
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100237 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100238
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100239 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
buzbee33ae5582014-06-12 14:56:32 -0700240 NextCallInsn next_call_insn,
241 const MethodReference& target_method,
242 uint32_t vtable_idx,
243 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100244 bool skip_this) OVERRIDE;
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100245
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100246 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
247 NextCallInsn next_call_insn,
248 const MethodReference& target_method,
249 uint32_t vtable_idx,
250 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
251 bool skip_this) OVERRIDE;
Serguei Katkov59a42af2014-07-05 00:55:46 +0700252
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100253 bool WideGPRsAreAliases() OVERRIDE {
254 return true; // 64b architecture.
255 }
256 bool WideFPRsAreAliases() OVERRIDE {
257 return true; // 64b architecture.
258 }
Andreas Gampe98430592014-07-27 19:44:50 -0700259
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100260 size_t GetInstructionOffset(LIR* lir) OVERRIDE;
261
262 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
263
264 private:
265 /**
266 * @brief Given register xNN (dNN), returns register wNN (sNN).
267 * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2).
268 * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2).
269 * @see As64BitReg
270 */
271 RegStorage As32BitReg(RegStorage reg) {
272 DCHECK(!reg.IsPair());
273 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
274 if (kFailOnSizeError) {
275 LOG(FATAL) << "Expected 64b register";
276 } else {
277 LOG(WARNING) << "Expected 64b register";
278 return reg;
Andreas Gampe3c12c512014-06-24 18:46:29 +0000279 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100280 }
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100281 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
282 reg.GetRawBits() & RegStorage::kRegTypeMask);
283 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
284 ->GetReg().GetReg(),
285 ret_val.GetReg());
286 return ret_val;
287 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100288
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100289 RegStorage Check32BitReg(RegStorage reg) {
290 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
291 if (kFailOnSizeError) {
292 LOG(FATAL) << "Checked for 32b register";
293 } else {
294 LOG(WARNING) << "Checked for 32b register";
295 return As32BitReg(reg);
Andreas Gampe3c12c512014-06-24 18:46:29 +0000296 }
Andreas Gampe3c12c512014-06-24 18:46:29 +0000297 }
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100298 return reg;
299 }
Andreas Gampe3c12c512014-06-24 18:46:29 +0000300
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100301 /**
302 * @brief Given register wNN (sNN), returns register xNN (dNN).
303 * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2).
304 * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2).
305 * @see As32BitReg
306 */
307 RegStorage As64BitReg(RegStorage reg) {
308 DCHECK(!reg.IsPair());
309 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
310 if (kFailOnSizeError) {
311 LOG(FATAL) << "Expected 32b register";
312 } else {
313 LOG(WARNING) << "Expected 32b register";
314 return reg;
Andreas Gampe3c12c512014-06-24 18:46:29 +0000315 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100316 }
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100317 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
318 reg.GetRawBits() & RegStorage::kRegTypeMask);
319 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
320 ->GetReg().GetReg(),
321 ret_val.GetReg());
322 return ret_val;
323 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100324
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100325 RegStorage Check64BitReg(RegStorage reg) {
326 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
327 if (kFailOnSizeError) {
328 LOG(FATAL) << "Checked for 64b register";
329 } else {
330 LOG(WARNING) << "Checked for 64b register";
331 return As64BitReg(reg);
Andreas Gampe3c12c512014-06-24 18:46:29 +0000332 }
Andreas Gampe3c12c512014-06-24 18:46:29 +0000333 }
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100334 return reg;
335 }
Andreas Gampe3c12c512014-06-24 18:46:29 +0000336
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100337 int32_t EncodeImmSingle(uint32_t bits);
338 int32_t EncodeImmDouble(uint64_t bits);
339 LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value);
340 LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value);
341 void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
342 void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
343 void AssignDataOffsets();
344 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
345 bool is_div, bool check_zero);
346 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div);
347 size_t GetLoadStoreSize(LIR* lir);
348
349 bool SmallLiteralDivRem64(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
350 RegLocation rl_dest, int64_t lit);
351
352 uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset);
353 int AssignInsnOffsets();
354 void AssignOffsets();
355 uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir);
356
357 // Spill core and FP registers. Returns the SP difference: either spill size, or whole
358 // frame size.
359 int SpillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size);
360
361 // Unspill core and FP registers.
362 void UnspillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size);
363
364 void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
365
366 LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value);
367 LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value);
368
369 LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
370 LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
371 int shift);
372 int EncodeShift(int code, int amount);
373
374 LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2,
375 A64RegExtEncodings ext, uint8_t amount);
376 LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
377 A64RegExtEncodings ext, uint8_t amount);
378 int EncodeExtend(int extend_type, int amount);
379 bool IsExtendEncoding(int encoded_value);
380
381 LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size);
382 LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size);
383
384 int EncodeLogicalImmediate(bool is_wide, uint64_t value);
385 uint64_t DecodeLogicalImmediate(bool is_wide, int value);
386 ArmConditionCode ArmConditionEncoding(ConditionCode code);
387
388 // Helper used in the two GenSelect variants.
389 void GenSelect(int32_t left, int32_t right, ConditionCode code, RegStorage rs_dest,
390 int result_reg_class);
391
Andreas Gampec76c6142014-08-04 16:30:03 -0700392 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
393 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
394 void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
395 RegLocation rl_src2, bool is_div);
396
Serban Constantinescu2eba1fa2014-07-31 19:07:17 +0100397 InToRegStorageMapping in_to_reg_storage_mapping_;
398 static const ArmEncodingMap EncodingMap[kA64Last];
Matteo Franchin43ec8732014-03-31 15:00:14 +0100399};
400
401} // namespace art
402
403#endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_