blob: 68fa6f40cba1e9662a7775a8f6e7b27c797a5dbb [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
Matteo Franchine45fb9e2014-05-06 10:10:30 +010027class Arm64Mir2Lir : public Mir2Lir {
buzbee33ae5582014-06-12 14:56:32 -070028 protected:
Andreas Gampe3c12c512014-06-24 18:46:29 +000029 // If we detect a size error, FATAL out.
30 static constexpr bool kFailOnSizeError = false && kIsDebugBuild;
31 // If we detect a size error, report to LOG.
32 static constexpr bool kReportSizeError = false && kIsDebugBuild;
33
buzbee33ae5582014-06-12 14:56:32 -070034 // TODO: consolidate 64-bit target support.
35 class InToRegStorageMapper {
36 public:
37 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide) = 0;
38 virtual ~InToRegStorageMapper() {}
39 };
40
41 class InToRegStorageArm64Mapper : public InToRegStorageMapper {
42 public:
43 InToRegStorageArm64Mapper() : cur_core_reg_(0), cur_fp_reg_(0) {}
44 virtual ~InToRegStorageArm64Mapper() {}
45 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide);
46 private:
47 int cur_core_reg_;
48 int cur_fp_reg_;
49 };
50
51 class InToRegStorageMapping {
52 public:
53 InToRegStorageMapping() : max_mapped_in_(0), is_there_stack_mapped_(false),
54 initialized_(false) {}
55 void Initialize(RegLocation* arg_locs, int count, InToRegStorageMapper* mapper);
56 int GetMaxMappedIn() { return max_mapped_in_; }
57 bool IsThereStackMapped() { return is_there_stack_mapped_; }
58 RegStorage Get(int in_position);
59 bool IsInitialized() { return initialized_; }
60 private:
61 std::map<int, RegStorage> mapping_;
62 int max_mapped_in_;
63 bool is_there_stack_mapped_;
64 bool initialized_;
65 };
66
Matteo Franchin43ec8732014-03-31 15:00:14 +010067 public:
68 Arm64Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
69
70 // Required for target - codegen helpers.
71 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
72 RegLocation rl_dest, int lit);
73 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
74 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe2f244e92014-05-08 03:35:25 -070075 RegStorage LoadHelper(ThreadOffset<4> offset) OVERRIDE;
76 RegStorage LoadHelper(ThreadOffset<8> offset) 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;
Andreas Gampe3c12c512014-06-24 18:46:29 +000084 LIR* LoadRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010085 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010086 RegStorage r_dest, OpSize size) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010087 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
88 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Vladimir Marko3bf7c602014-05-07 14:55:43 +010089 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +000090 OpSize size, VolatileKind is_volatile) OVERRIDE;
91 LIR* StoreRefDisp(RegStorage r_base, int displacement, RegStorage r_src,
92 VolatileKind is_volatile) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010093 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010094 OpSize size) OVERRIDE;
Andreas Gampe3c12c512014-06-24 18:46:29 +000095 LIR* StoreRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010096 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010097 RegStorage r_src, OpSize size) OVERRIDE;
Zheng Xu7c1c2632014-06-17 18:17:31 +080098 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE;
99 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
100 int offset, int check_value, LIR* target) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100101
102 // Required for target - register utilities.
Matteo Franchin43ec8732014-03-31 15:00:14 +0100103 RegStorage TargetReg(SpecialTargetRegister reg);
104 RegStorage GetArgMappingToPhysicalReg(int arg_num);
105 RegLocation GetReturnAlt();
106 RegLocation GetReturnWideAlt();
107 RegLocation LocCReturn();
buzbeea0cd2d72014-06-01 09:33:49 -0700108 RegLocation LocCReturnRef();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100109 RegLocation LocCReturnDouble();
110 RegLocation LocCReturnFloat();
111 RegLocation LocCReturnWide();
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100112 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100113 void AdjustSpillMask();
114 void ClobberCallerSave();
115 void FreeCallTemps();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100116 void LockCallTemps();
117 void MarkPreservedSingle(int v_reg, RegStorage reg);
118 void MarkPreservedDouble(int v_reg, RegStorage reg);
119 void CompilerInitializeRegAlloc();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100120
121 // Required for target - miscellaneous.
122 void AssembleLIR();
123 uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset);
124 int AssignInsnOffsets();
125 void AssignOffsets();
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100126 uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100127 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
128 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
129 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100130 const char* GetTargetInstFmt(int opcode);
131 const char* GetTargetInstName(int opcode);
132 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100133 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100134 uint64_t GetTargetInstFlags(int opcode);
Ian Rogers5aa6e042014-06-13 16:38:24 -0700135 size_t GetInsnSize(LIR* lir) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100136 bool IsUnconditionalBranch(LIR* lir);
137
Vladimir Marko674744e2014-04-24 15:18:26 +0100138 // Check support for volatile load/store of a given size.
139 bool SupportsVolatileLoadStore(OpSize size) OVERRIDE;
140 // Get the register class for load/store of a field.
141 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
142
Matteo Franchin43ec8732014-03-31 15:00:14 +0100143 // Required for target - Dalvik-level generators.
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100144 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
145 RegLocation lr_shift);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100146 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
147 RegLocation rl_src1, RegLocation rl_src2);
148 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array,
149 RegLocation rl_index, RegLocation rl_dest, int scale);
150 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
151 RegLocation rl_src, int scale, bool card_mark);
152 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
153 RegLocation rl_src1, RegLocation rl_shift);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100154 void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100155 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
156 RegLocation rl_src2);
157 void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
158 RegLocation rl_src2);
159 void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
160 RegLocation rl_src2);
161 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
162 RegLocation rl_src2);
163 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
164 RegLocation rl_src2);
165 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
166 RegLocation rl_src2);
167 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src);
168 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object);
169 bool GenInlinedMinMaxInt(CallInfo* info, bool is_min);
170 bool GenInlinedSqrt(CallInfo* info);
171 bool GenInlinedPeek(CallInfo* info, OpSize size);
172 bool GenInlinedPoke(CallInfo* info, OpSize size);
Serban Constantinescu169489b2014-06-11 16:43:35 +0100173 bool GenInlinedAbsLong(CallInfo* info);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100174 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src);
175 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100176 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
177 void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
178 RegLocation rl_src2);
179 void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
180 RegLocation rl_src2);
181 void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
182 RegLocation rl_src2);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100183 void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
184 RegLocation rl_src2, bool is_div);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100185 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div);
186 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div);
187 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
188 void GenDivZeroCheckWide(RegStorage reg);
189 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method);
190 void GenExitSequence();
191 void GenSpecialExitSequence();
192 void GenFillArrayData(DexOffset table_offset, RegLocation rl_src);
193 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double);
194 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir);
195 void GenSelect(BasicBlock* bb, MIR* mir);
Andreas Gampeb14329f2014-05-15 11:16:06 -0700196 bool GenMemBarrier(MemBarrierKind barrier_kind);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100197 void GenMonitorEnter(int opt_flags, RegLocation rl_src);
198 void GenMonitorExit(int opt_flags, RegLocation rl_src);
199 void GenMoveException(RegLocation rl_dest);
200 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
201 int first_bit, int second_bit);
202 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src);
203 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src);
204 void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
205 void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100206 bool GenSpecialCase(BasicBlock* bb, MIR* mir, const InlineMethod& special);
207
208 uint32_t GenPairWise(uint32_t reg_mask, int* reg1, int* reg2);
209 void UnSpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask);
210 void SpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask);
Matteo Franchinbc6d1972014-05-13 12:33:28 +0100211 void UnSpillFPRegs(RegStorage base, int offset, uint32_t reg_mask);
212 void SpillFPRegs(RegStorage base, int offset, uint32_t reg_mask);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100213
214 // Required for target - single operation generators.
215 LIR* OpUnconditionalBranch(LIR* target);
216 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target);
217 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target);
218 LIR* OpCondBranch(ConditionCode cc, LIR* target);
219 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target);
220 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src);
221 LIR* OpIT(ConditionCode cond, const char* guide);
222 void OpEndIT(LIR* it);
223 LIR* OpMem(OpKind op, RegStorage r_base, int disp);
224 LIR* OpPcRelLoad(RegStorage reg, LIR* target);
225 LIR* OpReg(OpKind op, RegStorage r_dest_src);
226 void OpRegCopy(RegStorage r_dest, RegStorage r_src);
227 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100228 LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100229 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value);
230 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
231 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2);
232 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type);
233 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type);
234 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src);
Zheng Xue2eb29e2014-06-12 10:22:33 +0800235 LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100236 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value);
237 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2);
238 LIR* OpTestSuspend(LIR* target);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700239 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset) OVERRIDE;
240 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100241 LIR* OpVldm(RegStorage r_base, int count);
242 LIR* OpVstm(RegStorage r_base, int count);
243 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
244 void OpRegCopyWide(RegStorage dest, RegStorage src);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700245 void OpTlsCmp(ThreadOffset<4> offset, int val) OVERRIDE;
246 void OpTlsCmp(ThreadOffset<8> offset, int val) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100247
Vladimir Marko3bf7c602014-05-07 14:55:43 +0100248 LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100249 LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100250 LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
251 int shift);
Andreas Gampe47b31aa2014-06-19 01:10:07 -0700252 LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
253 A64RegExtEncodings ext, uint8_t amount);
Matteo Franchinbc6d1972014-05-13 12:33:28 +0100254 LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
Stuart Monteithf8ec48e2014-06-06 17:05:08 +0100255 LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100256 static const ArmEncodingMap EncodingMap[kA64Last];
Matteo Franchin43ec8732014-03-31 15:00:14 +0100257 int EncodeShift(int code, int amount);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100258 int EncodeExtend(int extend_type, int amount);
259 bool IsExtendEncoding(int encoded_value);
260 int EncodeLogicalImmediate(bool is_wide, uint64_t value);
261 uint64_t DecodeLogicalImmediate(bool is_wide, int value);
262
Matteo Franchin43ec8732014-03-31 15:00:14 +0100263 ArmConditionCode ArmConditionEncoding(ConditionCode code);
264 bool InexpensiveConstantInt(int32_t value);
265 bool InexpensiveConstantFloat(int32_t value);
266 bool InexpensiveConstantLong(int64_t value);
267 bool InexpensiveConstantDouble(int64_t value);
268
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100269 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method);
buzbee33ae5582014-06-12 14:56:32 -0700270
271 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
272 NextCallInsn next_call_insn,
273 const MethodReference& target_method,
274 uint32_t vtable_idx,
275 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
276 bool skip_this);
277
278 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
279 NextCallInsn next_call_insn,
280 const MethodReference& target_method,
281 uint32_t vtable_idx,
282 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
283 bool skip_this);
284 InToRegStorageMapping in_to_reg_storage_mapping_;
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100285
Matteo Franchin43ec8732014-03-31 15:00:14 +0100286 private:
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100287 /**
288 * @brief Given register xNN (dNN), returns register wNN (sNN).
289 * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2).
290 * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2).
291 * @see As64BitReg
292 */
293 RegStorage As32BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100294 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000295 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
296 if (kFailOnSizeError) {
297 LOG(FATAL) << "Expected 64b register";
298 } else {
299 LOG(WARNING) << "Expected 64b register";
300 return reg;
301 }
302 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100303 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
304 reg.GetRawBits() & RegStorage::kRegTypeMask);
305 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
306 ->GetReg().GetReg(),
307 ret_val.GetReg());
308 return ret_val;
309 }
310
Andreas Gampe3c12c512014-06-24 18:46:29 +0000311 RegStorage Check32BitReg(RegStorage reg) {
312 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
313 if (kFailOnSizeError) {
314 LOG(FATAL) << "Checked for 32b register";
315 } else {
316 LOG(WARNING) << "Checked for 32b register";
317 return As32BitReg(reg);
318 }
319 }
320 return reg;
321 }
322
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100323 /**
324 * @brief Given register wNN (sNN), returns register xNN (dNN).
325 * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2).
326 * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2).
327 * @see As32BitReg
328 */
329 RegStorage As64BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100330 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000331 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
332 if (kFailOnSizeError) {
333 LOG(FATAL) << "Expected 32b register";
334 } else {
335 LOG(WARNING) << "Expected 32b register";
336 return reg;
337 }
338 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100339 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
340 reg.GetRawBits() & RegStorage::kRegTypeMask);
341 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
342 ->GetReg().GetReg(),
343 ret_val.GetReg());
344 return ret_val;
345 }
346
Andreas Gampe3c12c512014-06-24 18:46:29 +0000347 RegStorage Check64BitReg(RegStorage reg) {
348 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
349 if (kFailOnSizeError) {
350 LOG(FATAL) << "Checked for 64b register";
351 } else {
352 LOG(WARNING) << "Checked for 64b register";
353 return As64BitReg(reg);
354 }
355 }
356 return reg;
357 }
358
Matteo Franchinc41e6dc2014-06-13 19:16:28 +0100359 LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value);
360 LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100361 void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
362 void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
363 void AssignDataOffsets();
364 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
365 bool is_div, bool check_zero);
366 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100367};
368
369} // namespace art
370
371#endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_