blob: f71713fc960aa66dfc4aa61e9e39bb527ed03ff2 [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;
68 bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div,
69 RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010070 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
71 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe2f244e92014-05-08 03:35:25 -070072 RegStorage LoadHelper(ThreadOffset<4> offset) OVERRIDE;
73 RegStorage LoadHelper(ThreadOffset<8> offset) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010074 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
Andreas Gampe3c12c512014-06-24 18:46:29 +000075 OpSize size, VolatileKind is_volatile) OVERRIDE;
76 LIR* LoadRefDisp(RegStorage r_base, int displacement, RegStorage r_dest,
77 VolatileKind is_volatile)
78 OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010079 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010080 OpSize size) OVERRIDE;
Andreas Gampe3c12c512014-06-24 18:46:29 +000081 LIR* LoadRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010082 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010083 RegStorage r_dest, OpSize size) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010084 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
85 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Vladimir Marko3bf7c602014-05-07 14:55:43 +010086 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +000087 OpSize size, VolatileKind is_volatile) OVERRIDE;
88 LIR* StoreRefDisp(RegStorage r_base, int displacement, RegStorage r_src,
89 VolatileKind is_volatile) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010090 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010091 OpSize size) OVERRIDE;
Andreas Gampe3c12c512014-06-24 18:46:29 +000092 LIR* StoreRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010093 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010094 RegStorage r_src, OpSize size) OVERRIDE;
Zheng Xu7c1c2632014-06-17 18:17:31 +080095 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE;
96 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
97 int offset, int check_value, LIR* target) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +010098
99 // Required for target - register utilities.
Andreas Gampe4b537a82014-06-30 22:24:53 -0700100 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
101 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, bool is_wide) OVERRIDE {
102 RegStorage reg = TargetReg(symbolic_reg);
103 if (is_wide) {
104 return (reg.Is64Bit()) ? reg : As64BitReg(reg);
105 } else {
106 return (reg.Is32Bit()) ? reg : As32BitReg(reg);
107 }
108 }
109 RegStorage TargetRefReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
110 RegStorage reg = TargetReg(symbolic_reg);
111 return (reg.Is64Bit() ? reg : As64BitReg(reg));
112 }
Matteo Franchin43ec8732014-03-31 15:00:14 +0100113 RegStorage GetArgMappingToPhysicalReg(int arg_num);
114 RegLocation GetReturnAlt();
115 RegLocation GetReturnWideAlt();
116 RegLocation LocCReturn();
buzbeea0cd2d72014-06-01 09:33:49 -0700117 RegLocation LocCReturnRef();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100118 RegLocation LocCReturnDouble();
119 RegLocation LocCReturnFloat();
120 RegLocation LocCReturnWide();
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100121 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100122 void AdjustSpillMask();
123 void ClobberCallerSave();
124 void FreeCallTemps();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100125 void LockCallTemps();
126 void MarkPreservedSingle(int v_reg, RegStorage reg);
127 void MarkPreservedDouble(int v_reg, RegStorage reg);
128 void CompilerInitializeRegAlloc();
Matteo Franchin43ec8732014-03-31 15:00:14 +0100129
130 // Required for target - miscellaneous.
131 void AssembleLIR();
132 uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset);
133 int AssignInsnOffsets();
134 void AssignOffsets();
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100135 uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100136 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
137 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
138 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100139 const char* GetTargetInstFmt(int opcode);
140 const char* GetTargetInstName(int opcode);
141 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr);
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100142 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100143 uint64_t GetTargetInstFlags(int opcode);
Ian Rogers5aa6e042014-06-13 16:38:24 -0700144 size_t GetInsnSize(LIR* lir) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100145 bool IsUnconditionalBranch(LIR* lir);
146
Vladimir Marko674744e2014-04-24 15:18:26 +0100147 // Check support for volatile load/store of a given size.
148 bool SupportsVolatileLoadStore(OpSize size) OVERRIDE;
149 // Get the register class for load/store of a field.
150 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
151
Matteo Franchin43ec8732014-03-31 15:00:14 +0100152 // Required for target - Dalvik-level generators.
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100153 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
154 RegLocation lr_shift);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100155 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
156 RegLocation rl_src1, RegLocation rl_src2);
157 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array,
158 RegLocation rl_index, RegLocation rl_dest, int scale);
159 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
160 RegLocation rl_src, int scale, bool card_mark);
161 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
162 RegLocation rl_src1, RegLocation rl_shift);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100163 void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100164 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
165 RegLocation rl_src2);
166 void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
167 RegLocation rl_src2);
168 void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
169 RegLocation rl_src2);
170 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
171 RegLocation rl_src2);
172 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
173 RegLocation rl_src2);
174 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
175 RegLocation rl_src2);
176 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src);
177 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object);
178 bool GenInlinedMinMaxInt(CallInfo* info, bool is_min);
179 bool GenInlinedSqrt(CallInfo* info);
180 bool GenInlinedPeek(CallInfo* info, OpSize size);
181 bool GenInlinedPoke(CallInfo* info, OpSize size);
Serban Constantinescu169489b2014-06-11 16:43:35 +0100182 bool GenInlinedAbsLong(CallInfo* info);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100183 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src);
184 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100185 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
186 void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
187 RegLocation rl_src2);
188 void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
189 RegLocation rl_src2);
190 void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
191 RegLocation rl_src2);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100192 void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
193 RegLocation rl_src2, bool is_div);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100194 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div);
195 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div);
196 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
197 void GenDivZeroCheckWide(RegStorage reg);
198 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method);
199 void GenExitSequence();
200 void GenSpecialExitSequence();
201 void GenFillArrayData(DexOffset table_offset, RegLocation rl_src);
202 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double);
203 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir);
204 void GenSelect(BasicBlock* bb, MIR* mir);
Andreas Gampeb14329f2014-05-15 11:16:06 -0700205 bool GenMemBarrier(MemBarrierKind barrier_kind);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100206 void GenMonitorEnter(int opt_flags, RegLocation rl_src);
207 void GenMonitorExit(int opt_flags, RegLocation rl_src);
208 void GenMoveException(RegLocation rl_dest);
209 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
210 int first_bit, int second_bit);
211 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src);
212 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src);
213 void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
214 void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100215
216 uint32_t GenPairWise(uint32_t reg_mask, int* reg1, int* reg2);
217 void UnSpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask);
218 void SpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask);
Matteo Franchinbc6d1972014-05-13 12:33:28 +0100219 void UnSpillFPRegs(RegStorage base, int offset, uint32_t reg_mask);
220 void SpillFPRegs(RegStorage base, int offset, uint32_t reg_mask);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100221
222 // Required for target - single operation generators.
223 LIR* OpUnconditionalBranch(LIR* target);
224 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target);
225 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target);
226 LIR* OpCondBranch(ConditionCode cc, LIR* target);
227 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target);
228 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src);
229 LIR* OpIT(ConditionCode cond, const char* guide);
230 void OpEndIT(LIR* it);
231 LIR* OpMem(OpKind op, RegStorage r_base, int disp);
232 LIR* OpPcRelLoad(RegStorage reg, LIR* target);
233 LIR* OpReg(OpKind op, RegStorage r_dest_src);
234 void OpRegCopy(RegStorage r_dest, RegStorage r_src);
235 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100236 LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100237 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value);
238 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
239 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2);
240 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type);
241 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type);
242 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src);
Zheng Xue2eb29e2014-06-12 10:22:33 +0800243 LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100244 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value);
245 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2);
246 LIR* OpTestSuspend(LIR* target);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700247 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset) OVERRIDE;
248 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100249 LIR* OpVldm(RegStorage r_base, int count);
250 LIR* OpVstm(RegStorage r_base, int count);
251 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
252 void OpRegCopyWide(RegStorage dest, RegStorage src);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700253 void OpTlsCmp(ThreadOffset<4> offset, int val) OVERRIDE;
254 void OpTlsCmp(ThreadOffset<8> offset, int val) OVERRIDE;
Matteo Franchin43ec8732014-03-31 15:00:14 +0100255
Vladimir Marko3bf7c602014-05-07 14:55:43 +0100256 LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100257 LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100258 LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
259 int shift);
Andreas Gampe47b31aa2014-06-19 01:10:07 -0700260 LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2,
261 A64RegExtEncodings ext, uint8_t amount);
Matteo Franchinbc6d1972014-05-13 12:33:28 +0100262 LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
Stuart Monteithf8ec48e2014-06-06 17:05:08 +0100263 LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100264 static const ArmEncodingMap EncodingMap[kA64Last];
Matteo Franchin43ec8732014-03-31 15:00:14 +0100265 int EncodeShift(int code, int amount);
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100266 int EncodeExtend(int extend_type, int amount);
267 bool IsExtendEncoding(int encoded_value);
268 int EncodeLogicalImmediate(bool is_wide, uint64_t value);
269 uint64_t DecodeLogicalImmediate(bool is_wide, int value);
270
Matteo Franchin43ec8732014-03-31 15:00:14 +0100271 ArmConditionCode ArmConditionEncoding(ConditionCode code);
272 bool InexpensiveConstantInt(int32_t value);
273 bool InexpensiveConstantFloat(int32_t value);
274 bool InexpensiveConstantLong(int64_t value);
275 bool InexpensiveConstantDouble(int64_t value);
276
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100277 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method);
buzbee33ae5582014-06-12 14:56:32 -0700278
279 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
280 NextCallInsn next_call_insn,
281 const MethodReference& target_method,
282 uint32_t vtable_idx,
283 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
284 bool skip_this);
285
286 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
287 NextCallInsn next_call_insn,
288 const MethodReference& target_method,
289 uint32_t vtable_idx,
290 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
291 bool skip_this);
292 InToRegStorageMapping in_to_reg_storage_mapping_;
Matteo Franchine45fb9e2014-05-06 10:10:30 +0100293
Matteo Franchin43ec8732014-03-31 15:00:14 +0100294 private:
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100295 /**
296 * @brief Given register xNN (dNN), returns register wNN (sNN).
297 * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2).
298 * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2).
299 * @see As64BitReg
300 */
301 RegStorage As32BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100302 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000303 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
304 if (kFailOnSizeError) {
305 LOG(FATAL) << "Expected 64b register";
306 } else {
307 LOG(WARNING) << "Expected 64b register";
308 return reg;
309 }
310 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100311 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
312 reg.GetRawBits() & RegStorage::kRegTypeMask);
313 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
314 ->GetReg().GetReg(),
315 ret_val.GetReg());
316 return ret_val;
317 }
318
Andreas Gampe3c12c512014-06-24 18:46:29 +0000319 RegStorage Check32BitReg(RegStorage reg) {
320 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
321 if (kFailOnSizeError) {
322 LOG(FATAL) << "Checked for 32b register";
323 } else {
324 LOG(WARNING) << "Checked for 32b register";
325 return As32BitReg(reg);
326 }
327 }
328 return reg;
329 }
330
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100331 /**
332 * @brief Given register wNN (sNN), returns register xNN (dNN).
333 * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2).
334 * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2).
335 * @see As32BitReg
336 */
337 RegStorage As64BitReg(RegStorage reg) {
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100338 DCHECK(!reg.IsPair());
Andreas Gampe3c12c512014-06-24 18:46:29 +0000339 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
340 if (kFailOnSizeError) {
341 LOG(FATAL) << "Expected 32b register";
342 } else {
343 LOG(WARNING) << "Expected 32b register";
344 return reg;
345 }
346 }
Matteo Franchin5acc8b02014-06-05 15:10:35 +0100347 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
348 reg.GetRawBits() & RegStorage::kRegTypeMask);
349 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
350 ->GetReg().GetReg(),
351 ret_val.GetReg());
352 return ret_val;
353 }
354
Andreas Gampe3c12c512014-06-24 18:46:29 +0000355 RegStorage Check64BitReg(RegStorage reg) {
356 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
357 if (kFailOnSizeError) {
358 LOG(FATAL) << "Checked for 64b register";
359 } else {
360 LOG(WARNING) << "Checked for 64b register";
361 return As64BitReg(reg);
362 }
363 }
364 return reg;
365 }
366
Matteo Franchinc41e6dc2014-06-13 19:16:28 +0100367 LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value);
368 LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100369 void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
370 void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir);
371 void AssignDataOffsets();
372 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
373 bool is_div, bool check_zero);
374 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div);
Matteo Franchin43ec8732014-03-31 15:00:14 +0100375};
376
377} // namespace art
378
379#endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_