blob: 18f2a291c5065950531ef4b229f29542dbefa11c [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"
22
buzbee33ae5582014-06-12 14:56:32 -070023#include <map>
24
Matteo Franchin43ec8732014-03-31 15:00:14 +010025namespace art {
26
Andreas Gampe4b537a82014-06-30 22:24:53 -070027class Arm64Mir2Lir FINAL : public Mir2Lir {
buzbee33ae5582014-06-12 14:56:32 -070028 protected:
29 // TODO: consolidate 64-bit target support.
30 class InToRegStorageMapper {
31 public:
Zheng Xu949cd972014-06-23 18:33:08 +080032 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref) = 0;
buzbee33ae5582014-06-12 14:56:32 -070033 virtual ~InToRegStorageMapper() {}
34 };
35
36 class InToRegStorageArm64Mapper : public InToRegStorageMapper {
37 public:
38 InToRegStorageArm64Mapper() : cur_core_reg_(0), cur_fp_reg_(0) {}
39 virtual ~InToRegStorageArm64Mapper() {}
Zheng Xu949cd972014-06-23 18:33:08 +080040 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref);
buzbee33ae5582014-06-12 14:56:32 -070041 private:
42 int cur_core_reg_;
43 int cur_fp_reg_;
44 };
45
46 class InToRegStorageMapping {
47 public:
48 InToRegStorageMapping() : max_mapped_in_(0), is_there_stack_mapped_(false),
49 initialized_(false) {}
50 void Initialize(RegLocation* arg_locs, int count, InToRegStorageMapper* mapper);
51 int GetMaxMappedIn() { return max_mapped_in_; }
52 bool IsThereStackMapped() { return is_there_stack_mapped_; }
53 RegStorage Get(int in_position);
54 bool IsInitialized() { return initialized_; }
55 private:
56 std::map<int, RegStorage> mapping_;
57 int max_mapped_in_;
58 bool is_there_stack_mapped_;
59 bool initialized_;
60 };
61
Matteo Franchin43ec8732014-03-31 15:00:14 +010062 public:
63 Arm64Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
64
65 // Required for target - codegen helpers.
66 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
Matteo Franchinc61b3c92014-06-18 11:52:47 +010067 RegLocation rl_dest, int lit) OVERRIDE;
Matteo Franchin7c6c2ac2014-07-01 18:03:08 +010068 bool SmallLiteralDivRem64(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
69 RegLocation rl_dest, int64_t lit);
Matteo Franchinc61b3c92014-06-18 11:52:47 +010070 bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div,
71 RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Matteo Franchin7c6c2ac2014-07-01 18:03:08 +010072 bool HandleEasyDivRem64(Instruction::Code dalvik_opcode, bool is_div,
73 RegLocation rl_src, RegLocation rl_dest, int64_t lit);
Matteo Franchin43ec8732014-03-31 15:00:14 +010074 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
75 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -070076 RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010077 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
Andreas Gampe3c12c512014-06-24 18:46:29 +000078 OpSize size, VolatileKind is_volatile) OVERRIDE;
79 LIR* LoadRefDisp(RegStorage r_base, int displacement, RegStorage r_dest,
80 VolatileKind is_volatile)
81 OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010082 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010083 OpSize size) OVERRIDE;
Matteo Franchin255e0142014-07-04 13:50:41 +010084 LIR* LoadRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale)
85 OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010086 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
87 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Vladimir Marko3bf7c602014-05-07 14:55:43 +010088 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +000089 OpSize size, VolatileKind is_volatile) OVERRIDE;
90 LIR* StoreRefDisp(RegStorage r_base, int displacement, RegStorage r_src,
91 VolatileKind is_volatile) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010092 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010093 OpSize size) OVERRIDE;
Matteo Franchin255e0142014-07-04 13:50:41 +010094 LIR* StoreRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale)
95 OVERRIDE;
Zheng Xu7c1c2632014-06-17 18:17:31 +080096 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE;
97 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +000098 int offset, int check_value, LIR* target, LIR** compare) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010099
100 // Required for target - register utilities.
Andreas Gampe4b537a82014-06-30 22:24:53 -0700101 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700102 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700103 if (wide_kind == kWide || wide_kind == kRef) {
Matteo Franchined7a0f22014-06-10 19:23:45 +0100104 return As64BitReg(TargetReg(symbolic_reg));
Andreas Gampe4b537a82014-06-30 22:24:53 -0700105 } else {
Matteo Franchined7a0f22014-06-10 19:23:45 +0100106 return Check32BitReg(TargetReg(symbolic_reg));
Andreas Gampe4b537a82014-06-30 22:24:53 -0700107 }
108 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700109 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Matteo Franchined7a0f22014-06-10 19:23:45 +0100110 return As64BitReg(TargetReg(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700111 }
Matteo Franchin43ec8732014-03-31 15:00:14 +0100112 RegStorage GetArgMappingToPhysicalReg(int arg_num);
113 RegLocation GetReturnAlt();
114 RegLocation GetReturnWideAlt();
115 RegLocation LocCReturn();
buzbeea0cd2d72014-06-01 09:33:49 -0700116 RegLocation LocCReturnRef();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100117 RegLocation LocCReturnDouble();
118 RegLocation LocCReturnFloat();
119 RegLocation LocCReturnWide();
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100120 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100121 void AdjustSpillMask();
122 void ClobberCallerSave();
123 void FreeCallTemps();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100124 void LockCallTemps();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100125 void CompilerInitializeRegAlloc();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100126
127 // Required for target - miscellaneous.
128 void AssembleLIR();
129 uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset);
130 int AssignInsnOffsets();
131 void AssignOffsets();
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100132 uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100133 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
134 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
135 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100136 const char* GetTargetInstFmt(int opcode);
137 const char* GetTargetInstName(int opcode);
138 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100139 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100140 uint64_t GetTargetInstFlags(int opcode);
Ian Rogers5aa6e042014-06-13 16:38:24 -0700141 size_t GetInsnSize(LIR* lir) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100142 bool IsUnconditionalBranch(LIR* lir);
143
Vladimir Marko674744e2014-04-24 15:18:26 +0100144 // Get the register class for load/store of a field.
145 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
146
Matteo Franchin43ec8732014-03-31 15:00:14 +0100147 // Required for target - Dalvik-level generators.
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100148 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
149 RegLocation lr_shift);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100150 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
151 RegLocation rl_src1, RegLocation rl_src2);
152 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array,
153 RegLocation rl_index, RegLocation rl_dest, int scale);
154 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
155 RegLocation rl_src, int scale, bool card_mark);
156 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
157 RegLocation rl_src1, RegLocation rl_shift);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100158 void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100159 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
160 RegLocation rl_src2);
161 void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
162 RegLocation rl_src2);
163 void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
164 RegLocation rl_src2);
165 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
166 RegLocation rl_src2);
167 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
168 RegLocation rl_src2);
169 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
170 RegLocation rl_src2);
171 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src);
Serban Constantinescu23abec92014-07-02 16:13:38 +0100172 bool GenInlinedReverseBits(CallInfo* info, OpSize size);
Vladimir Marko5030d3e2014-07-17 10:43:08 +0100173 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
Serban Constantinescu63fe93d2014-06-30 17:10:28 +0100174 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100175 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object);
Serban Constantinescu23abec92014-07-02 16:13:38 +0100176 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long);
177 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100178 bool GenInlinedSqrt(CallInfo* info);
179 bool GenInlinedPeek(CallInfo* info, OpSize size);
180 bool GenInlinedPoke(CallInfo* info, OpSize size);
Serban Constantinescu169489b2014-06-11 16:43:35 +0100181 bool GenInlinedAbsLong(CallInfo* info);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100182 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src);
183 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100184 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
185 void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
186 RegLocation rl_src2);
187 void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
188 RegLocation rl_src2);
189 void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
190 RegLocation rl_src2);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100191 void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
192 RegLocation rl_src2, bool is_div);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100193 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div);
194 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div);
195 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
196 void GenDivZeroCheckWide(RegStorage reg);
197 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method);
198 void GenExitSequence();
199 void GenSpecialExitSequence();
200 void GenFillArrayData(DexOffset table_offset, RegLocation rl_src);
201 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double);
202 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir);
Andreas Gampe90969af2014-07-15 23:02:11 -0700203 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
204 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
205 int32_t true_val, int32_t false_val, RegStorage rs_dest,
206 int dest_reg_class) OVERRIDE;
207 // Helper used in the above two.
208 void GenSelect(int32_t left, int32_t right, ConditionCode code, RegStorage rs_dest,
209 int result_reg_class);
210
Andreas Gampeb14329f2014-05-15 11:16:06 -0700211 bool GenMemBarrier(MemBarrierKind barrier_kind);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100212 void GenMonitorEnter(int opt_flags, RegLocation rl_src);
213 void GenMonitorExit(int opt_flags, RegLocation rl_src);
214 void GenMoveException(RegLocation rl_dest);
215 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
216 int first_bit, int second_bit);
217 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src);
218 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src);
219 void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
220 void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100221
Andreas Gampef29ecd62014-07-29 00:35:00 -0700222 // Spill core and FP registers. Returns the SP difference: either spill size, or whole
223 // frame size.
224 int SpillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size);
225
226 // Unspill core and FP registers.
227 void UnspillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100228
229 // Required for target - single operation generators.
230 LIR* OpUnconditionalBranch(LIR* target);
231 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target);
232 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target);
233 LIR* OpCondBranch(ConditionCode cc, LIR* target);
234 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target);
235 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src);
236 LIR* OpIT(ConditionCode cond, const char* guide);
237 void OpEndIT(LIR* it);
238 LIR* OpMem(OpKind op, RegStorage r_base, int disp);
239 LIR* OpPcRelLoad(RegStorage reg, LIR* target);
240 LIR* OpReg(OpKind op, RegStorage r_dest_src);
241 void OpRegCopy(RegStorage r_dest, RegStorage r_src);
242 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100243 LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100244 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100245 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2);
246 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type);
247 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type);
248 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src);
Zheng Xue2eb29e2014-06-12 10:22:33 +0800249 LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100250 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value);
251 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2);
252 LIR* OpTestSuspend(LIR* target);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100253 LIR* OpVldm(RegStorage r_base, int count);
254 LIR* OpVstm(RegStorage r_base, int count);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100255 void OpRegCopyWide(RegStorage dest, RegStorage src);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100256
Vladimir Marko3bf7c602014-05-07 14:55:43 +0100257 LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100258 LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100259 LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
260 int shift);
Andreas Gampe47b31aa2014-06-19 01:10:07 -0700261 LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
262 A64RegExtEncodings ext, uint8_t amount);
Matteo Franchinbc6d1972014-05-13 12:33:28 +0100263 LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
Zheng Xucedee472014-07-01 09:53:22 +0800264 LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2,
265 A64RegExtEncodings ext, uint8_t amount);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100266 static const ArmEncodingMap EncodingMap[kA64Last];
Matteo Franchin43ec8732014-03-31 15:00:14 +0100267 int EncodeShift(int code, int amount);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100268 int EncodeExtend(int extend_type, int amount);
269 bool IsExtendEncoding(int encoded_value);
270 int EncodeLogicalImmediate(bool is_wide, uint64_t value);
271 uint64_t DecodeLogicalImmediate(bool is_wide, int value);
272
Matteo Franchin43ec8732014-03-31 15:00:14 +0100273 ArmConditionCode ArmConditionEncoding(ConditionCode code);
274 bool InexpensiveConstantInt(int32_t value);
275 bool InexpensiveConstantFloat(int32_t value);
276 bool InexpensiveConstantLong(int64_t value);
277 bool InexpensiveConstantDouble(int64_t value);
278
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100279 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method);
buzbee33ae5582014-06-12 14:56:32 -0700280
281 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
282 NextCallInsn next_call_insn,
283 const MethodReference& target_method,
284 uint32_t vtable_idx,
285 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
286 bool skip_this);
287
288 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
289 NextCallInsn next_call_insn,
290 const MethodReference& target_method,
291 uint32_t vtable_idx,
292 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
293 bool skip_this);
294 InToRegStorageMapping in_to_reg_storage_mapping_;
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100295
Serguei Katkov59a42af2014-07-05 00:55:46 +0700296 bool WideGPRsAreAliases() OVERRIDE {
297 return true; // 64b architecture.
298 }
299 bool WideFPRsAreAliases() OVERRIDE {
300 return true; // 64b architecture.
301 }
Serban Constantinescu63999682014-07-15 17:44:21 +0100302 size_t GetInstructionOffset(LIR* lir);
Serguei Katkov59a42af2014-07-05 00:55:46 +0700303
Andreas Gampe98430592014-07-27 19:44:50 -0700304 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
305
Matteo Franchin43ec8732014-03-31 15:00:14 +0100306 private:
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100307 /**
308 * @brief Given register xNN (dNN), returns register wNN (sNN).
309 * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2).
310 * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2).
311 * @see As64BitReg
312 */
313 RegStorage As32BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100314 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000315 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
316 if (kFailOnSizeError) {
317 LOG(FATAL) << "Expected 64b register";
318 } else {
319 LOG(WARNING) << "Expected 64b register";
320 return reg;
321 }
322 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100323 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
324 reg.GetRawBits() & RegStorage::kRegTypeMask);
325 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
326 ->GetReg().GetReg(),
327 ret_val.GetReg());
328 return ret_val;
329 }
330
Andreas Gampe3c12c512014-06-24 18:46:29 +0000331 RegStorage Check32BitReg(RegStorage reg) {
332 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
333 if (kFailOnSizeError) {
334 LOG(FATAL) << "Checked for 32b register";
335 } else {
336 LOG(WARNING) << "Checked for 32b register";
337 return As32BitReg(reg);
338 }
339 }
340 return reg;
341 }
342
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100343 /**
344 * @brief Given register wNN (sNN), returns register xNN (dNN).
345 * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2).
346 * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2).
347 * @see As32BitReg
348 */
349 RegStorage As64BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100350 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000351 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
352 if (kFailOnSizeError) {
353 LOG(FATAL) << "Expected 32b register";
354 } else {
355 LOG(WARNING) << "Expected 32b register";
356 return reg;
357 }
358 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100359 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
360 reg.GetRawBits() & RegStorage::kRegTypeMask);
361 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
362 ->GetReg().GetReg(),
363 ret_val.GetReg());
364 return ret_val;
365 }
366
Andreas Gampe3c12c512014-06-24 18:46:29 +0000367 RegStorage Check64BitReg(RegStorage reg) {
368 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
369 if (kFailOnSizeError) {
370 LOG(FATAL) << "Checked for 64b register";
371 } else {
372 LOG(WARNING) << "Checked for 64b register";
373 return As64BitReg(reg);
374 }
375 }
376 return reg;
377 }
378
Matteo Franchinc41e6dc2014-06-13 19:16:28 +0100379 LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value);
380 LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100381 void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
382 void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
383 void AssignDataOffsets();
384 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
385 bool is_div, bool check_zero);
386 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div);
Serban Constantinescu63999682014-07-15 17:44:21 +0100387 size_t GetLoadStoreSize(LIR* lir);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100388};
389
390} // namespace art
391
392#endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_