Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 1 | /* |
| 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" |
Andreas Gampe | 0b9203e | 2015-01-22 20:39:27 -0800 | [diff] [blame] | 21 | #include "base/logging.h" |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 22 | #include "dex/quick/mir_to_lir.h" |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 23 | |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 24 | #include <map> |
| 25 | |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 26 | namespace art { |
| 27 | |
Andreas Gampe | 4b537a8 | 2014-06-30 22:24:53 -0700 | [diff] [blame] | 28 | class Arm64Mir2Lir FINAL : public Mir2Lir { |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 29 | protected: |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 30 | class InToRegStorageArm64Mapper : public InToRegStorageMapper { |
| 31 | public: |
| 32 | InToRegStorageArm64Mapper() : cur_core_reg_(0), cur_fp_reg_(0) {} |
| 33 | virtual ~InToRegStorageArm64Mapper() {} |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 34 | virtual RegStorage GetNextReg(ShortyArg arg); |
| 35 | virtual void Reset() OVERRIDE { |
| 36 | cur_core_reg_ = 0; |
| 37 | cur_fp_reg_ = 0; |
| 38 | } |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 39 | private: |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 40 | size_t cur_core_reg_; |
| 41 | size_t cur_fp_reg_; |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 44 | InToRegStorageArm64Mapper in_to_reg_storage_arm64_mapper_; |
| 45 | InToRegStorageMapper* GetResetedInToRegStorageMapper() OVERRIDE { |
| 46 | in_to_reg_storage_arm64_mapper_.Reset(); |
| 47 | return &in_to_reg_storage_arm64_mapper_; |
| 48 | } |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 49 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 50 | public: |
| 51 | Arm64Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 52 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 53 | // Required for target - codegen helpers. |
| 54 | bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src, |
| 55 | RegLocation rl_dest, int lit) OVERRIDE; |
| 56 | bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div, |
| 57 | RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE; |
| 58 | bool HandleEasyDivRem64(Instruction::Code dalvik_opcode, bool is_div, |
| 59 | RegLocation rl_src, RegLocation rl_dest, int64_t lit); |
| 60 | bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE; |
Ningsheng Jian | 675e09b | 2014-10-23 13:48:36 +0800 | [diff] [blame] | 61 | void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1, |
| 62 | int32_t constant) OVERRIDE; |
| 63 | void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1, |
| 64 | int64_t constant) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 65 | LIR* CheckSuspendUsingLoad() OVERRIDE; |
| 66 | RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE; |
| 67 | LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest, |
| 68 | OpSize size, VolatileKind is_volatile) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 69 | LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale, |
| 70 | OpSize size) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 71 | LIR* LoadConstantNoClobber(RegStorage r_dest, int value) OVERRIDE; |
| 72 | LIR* LoadConstantWide(RegStorage r_dest, int64_t value) OVERRIDE; |
| 73 | LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src, OpSize size, |
| 74 | VolatileKind is_volatile) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 75 | LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale, |
| 76 | OpSize size) OVERRIDE; |
Vladimir Marko | bf535be | 2014-11-19 18:52:35 +0000 | [diff] [blame] | 77 | |
| 78 | /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage) |
| 79 | void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE; |
| 80 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 81 | LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg, |
| 82 | int offset, int check_value, LIR* target, LIR** compare) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 83 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 84 | // Required for target - register utilities. |
| 85 | RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE; |
| 86 | RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE { |
| 87 | if (wide_kind == kWide || wide_kind == kRef) { |
Matteo Franchin | ed7a0f2 | 2014-06-10 19:23:45 +0100 | [diff] [blame] | 88 | return As64BitReg(TargetReg(symbolic_reg)); |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 89 | } else { |
| 90 | return Check32BitReg(TargetReg(symbolic_reg)); |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 91 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 92 | } |
| 93 | RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE { |
| 94 | return As64BitReg(TargetReg(symbolic_reg)); |
| 95 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 96 | RegLocation GetReturnAlt() OVERRIDE; |
| 97 | RegLocation GetReturnWideAlt() OVERRIDE; |
| 98 | RegLocation LocCReturn() OVERRIDE; |
| 99 | RegLocation LocCReturnRef() OVERRIDE; |
| 100 | RegLocation LocCReturnDouble() OVERRIDE; |
| 101 | RegLocation LocCReturnFloat() OVERRIDE; |
| 102 | RegLocation LocCReturnWide() OVERRIDE; |
| 103 | ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE; |
| 104 | void AdjustSpillMask() OVERRIDE; |
| 105 | void ClobberCallerSave() OVERRIDE; |
| 106 | void FreeCallTemps() OVERRIDE; |
| 107 | void LockCallTemps() OVERRIDE; |
| 108 | void CompilerInitializeRegAlloc() OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 109 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 110 | // Required for target - miscellaneous. |
| 111 | void AssembleLIR() OVERRIDE; |
| 112 | void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE; |
| 113 | void SetupTargetResourceMasks(LIR* lir, uint64_t flags, |
| 114 | ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE; |
| 115 | const char* GetTargetInstFmt(int opcode) OVERRIDE; |
| 116 | const char* GetTargetInstName(int opcode) OVERRIDE; |
| 117 | std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE; |
| 118 | ResourceMask GetPCUseDefEncoding() const OVERRIDE; |
| 119 | uint64_t GetTargetInstFlags(int opcode) OVERRIDE; |
| 120 | size_t GetInsnSize(LIR* lir) OVERRIDE; |
| 121 | bool IsUnconditionalBranch(LIR* lir) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 122 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 123 | // Get the register class for load/store of a field. |
| 124 | RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; |
Vladimir Marko | 674744e | 2014-04-24 15:18:26 +0100 | [diff] [blame] | 125 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 126 | // Required for target - Dalvik-level generators. |
| 127 | void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 128 | RegLocation lr_shift) OVERRIDE; |
| 129 | void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 130 | RegLocation rl_src2, int flags) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 131 | void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index, |
| 132 | RegLocation rl_dest, int scale) OVERRIDE; |
| 133 | void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index, |
| 134 | RegLocation rl_src, int scale, bool card_mark) OVERRIDE; |
| 135 | void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 136 | RegLocation rl_shift, int flags) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 137 | void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 138 | RegLocation rl_src2) OVERRIDE; |
| 139 | void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 140 | RegLocation rl_src2) OVERRIDE; |
| 141 | void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 142 | RegLocation rl_src2) OVERRIDE; |
| 143 | void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
| 144 | bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE; |
| 145 | bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE; |
| 146 | bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE; |
| 147 | bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE; |
| 148 | bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE; |
| 149 | bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE; |
| 150 | bool GenInlinedSqrt(CallInfo* info) OVERRIDE; |
| 151 | bool GenInlinedCeil(CallInfo* info) OVERRIDE; |
| 152 | bool GenInlinedFloor(CallInfo* info) OVERRIDE; |
| 153 | bool GenInlinedRint(CallInfo* info) OVERRIDE; |
| 154 | bool GenInlinedRound(CallInfo* info, bool is_double) OVERRIDE; |
| 155 | bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE; |
| 156 | bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE; |
Martyn Capewell | 9a8a506 | 2014-08-07 11:31:48 +0100 | [diff] [blame] | 157 | bool GenInlinedAbsInt(CallInfo* info) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 158 | bool GenInlinedAbsLong(CallInfo* info) OVERRIDE; |
Zheng Xu | 947717a | 2014-08-07 14:05:23 +0800 | [diff] [blame] | 159 | bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 160 | void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 161 | void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 162 | RegLocation rl_src2, int flags) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 163 | RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div) |
| 164 | OVERRIDE; |
| 165 | RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) |
| 166 | OVERRIDE; |
| 167 | void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE; |
| 168 | void GenDivZeroCheckWide(RegStorage reg) OVERRIDE; |
| 169 | void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE; |
| 170 | void GenExitSequence() OVERRIDE; |
| 171 | void GenSpecialExitSequence() OVERRIDE; |
Vladimir Marko | 6ce3eba | 2015-02-16 13:05:59 +0000 | [diff] [blame] | 172 | void GenSpecialEntryForSuspend() OVERRIDE; |
| 173 | void GenSpecialExitForSuspend() OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 174 | void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE; |
| 175 | void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE; |
| 176 | void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE; |
| 177 | void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code, |
| 178 | int32_t true_val, int32_t false_val, RegStorage rs_dest, |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 179 | RegisterClass dest_reg_class) OVERRIDE; |
Andreas Gampe | 90969af | 2014-07-15 23:02:11 -0700 | [diff] [blame] | 180 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 181 | bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE; |
| 182 | void GenMonitorEnter(int opt_flags, RegLocation rl_src) OVERRIDE; |
| 183 | void GenMonitorExit(int opt_flags, RegLocation rl_src) OVERRIDE; |
| 184 | void GenMoveException(RegLocation rl_dest) OVERRIDE; |
| 185 | void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit, |
| 186 | int first_bit, int second_bit) OVERRIDE; |
| 187 | void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
| 188 | void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
Andreas Gampe | 48971b3 | 2014-08-06 10:09:01 -0700 | [diff] [blame] | 189 | void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE; |
| 190 | void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE; |
Ningsheng Jian | a262f77 | 2014-11-25 16:48:07 +0800 | [diff] [blame] | 191 | void GenMaddMsubInt(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
| 192 | RegLocation rl_src3, bool is_sub); |
| 193 | void GenMaddMsubLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
| 194 | RegLocation rl_src3, bool is_sub); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 195 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 196 | // Required for target - single operation generators. |
| 197 | LIR* OpUnconditionalBranch(LIR* target) OVERRIDE; |
| 198 | LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE; |
| 199 | LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE; |
| 200 | LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE; |
| 201 | LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE; |
| 202 | LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 203 | LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE; |
| 204 | void OpEndIT(LIR* it) OVERRIDE; |
| 205 | LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE; |
| 206 | LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE; |
| 207 | LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE; |
| 208 | void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 209 | LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 210 | LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE; |
| 211 | LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE; |
| 212 | LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE; |
| 213 | LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE; |
| 214 | LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 215 | LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE; |
| 216 | LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE; |
| 217 | LIR* OpTestSuspend(LIR* target) OVERRIDE; |
| 218 | LIR* OpVldm(RegStorage r_base, int count) OVERRIDE; |
| 219 | LIR* OpVstm(RegStorage r_base, int count) OVERRIDE; |
| 220 | void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE; |
Andreas Gampe | f29ecd6 | 2014-07-29 00:35:00 -0700 | [diff] [blame] | 221 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 222 | bool InexpensiveConstantInt(int32_t value) OVERRIDE; |
Matteo Franchin | c763e35 | 2014-07-04 12:53:27 +0100 | [diff] [blame] | 223 | bool InexpensiveConstantInt(int32_t value, Instruction::Code opcode) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 224 | bool InexpensiveConstantFloat(int32_t value) OVERRIDE; |
| 225 | bool InexpensiveConstantLong(int64_t value) OVERRIDE; |
| 226 | bool InexpensiveConstantDouble(int64_t value) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 227 | |
Ningsheng Jian | a262f77 | 2014-11-25 16:48:07 +0800 | [diff] [blame] | 228 | void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir) OVERRIDE; |
| 229 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 230 | bool WideGPRsAreAliases() const OVERRIDE { |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 231 | return true; // 64b architecture. |
| 232 | } |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 233 | bool WideFPRsAreAliases() const OVERRIDE { |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 234 | return true; // 64b architecture. |
| 235 | } |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 236 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 237 | size_t GetInstructionOffset(LIR* lir) OVERRIDE; |
| 238 | |
Vladimir Marko | 7c2ad5a | 2014-09-24 12:42:55 +0100 | [diff] [blame] | 239 | NextCallInsn GetNextSDCallInsn() OVERRIDE; |
| 240 | |
| 241 | /* |
| 242 | * @brief Generate a relative call to the method that will be patched at link time. |
| 243 | * @param target_method The MethodReference of the method to be invoked. |
| 244 | * @param type How the method will be invoked. |
| 245 | * @returns Call instruction |
| 246 | */ |
| 247 | LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type); |
| 248 | |
| 249 | /* |
| 250 | * @brief Generate the actual call insn based on the method info. |
| 251 | * @param method_info the lowering info for the method call. |
| 252 | * @returns Call instruction |
| 253 | */ |
| 254 | virtual LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE; |
| 255 | |
| 256 | /* |
| 257 | * @brief Handle ARM specific literals. |
| 258 | */ |
| 259 | void InstallLiteralPools() OVERRIDE; |
| 260 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 261 | LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE; |
| 262 | |
| 263 | private: |
| 264 | /** |
| 265 | * @brief Given register xNN (dNN), returns register wNN (sNN). |
| 266 | * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2). |
| 267 | * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2). |
| 268 | * @see As64BitReg |
| 269 | */ |
| 270 | RegStorage As32BitReg(RegStorage reg) { |
| 271 | DCHECK(!reg.IsPair()); |
| 272 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) { |
| 273 | if (kFailOnSizeError) { |
| 274 | LOG(FATAL) << "Expected 64b register"; |
| 275 | } else { |
| 276 | LOG(WARNING) << "Expected 64b register"; |
| 277 | return reg; |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 278 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 279 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 280 | RegStorage ret_val = RegStorage(RegStorage::k32BitSolo, |
| 281 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 282 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask) |
| 283 | ->GetReg().GetReg(), |
| 284 | ret_val.GetReg()); |
| 285 | return ret_val; |
| 286 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 287 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 288 | RegStorage Check32BitReg(RegStorage reg) { |
| 289 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) { |
| 290 | if (kFailOnSizeError) { |
| 291 | LOG(FATAL) << "Checked for 32b register"; |
| 292 | } else { |
| 293 | LOG(WARNING) << "Checked for 32b register"; |
| 294 | return As32BitReg(reg); |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 295 | } |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 296 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 297 | return reg; |
| 298 | } |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 299 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 300 | /** |
| 301 | * @brief Given register wNN (sNN), returns register xNN (dNN). |
| 302 | * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2). |
| 303 | * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2). |
| 304 | * @see As32BitReg |
| 305 | */ |
| 306 | RegStorage As64BitReg(RegStorage reg) { |
| 307 | DCHECK(!reg.IsPair()); |
| 308 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) { |
| 309 | if (kFailOnSizeError) { |
| 310 | LOG(FATAL) << "Expected 32b register"; |
| 311 | } else { |
| 312 | LOG(WARNING) << "Expected 32b register"; |
| 313 | return reg; |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 314 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 315 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 316 | RegStorage ret_val = RegStorage(RegStorage::k64BitSolo, |
| 317 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 318 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask) |
| 319 | ->GetReg().GetReg(), |
| 320 | ret_val.GetReg()); |
| 321 | return ret_val; |
| 322 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 323 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 324 | RegStorage Check64BitReg(RegStorage reg) { |
| 325 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) { |
| 326 | if (kFailOnSizeError) { |
| 327 | LOG(FATAL) << "Checked for 64b register"; |
| 328 | } else { |
| 329 | LOG(WARNING) << "Checked for 64b register"; |
| 330 | return As64BitReg(reg); |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 331 | } |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 332 | } |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 333 | return reg; |
| 334 | } |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 335 | |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 336 | int32_t EncodeImmSingle(uint32_t bits); |
| 337 | int32_t EncodeImmDouble(uint64_t bits); |
| 338 | LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value); |
| 339 | LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value); |
| 340 | void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir); |
| 341 | void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir); |
| 342 | void AssignDataOffsets(); |
| 343 | RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 344 | bool is_div, int flags) OVERRIDE; |
| 345 | RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div) OVERRIDE; |
Serban Constantinescu | 2eba1fa | 2014-07-31 19:07:17 +0100 | [diff] [blame] | 346 | size_t GetLoadStoreSize(LIR* lir); |
| 347 | |
| 348 | bool SmallLiteralDivRem64(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src, |
| 349 | RegLocation rl_dest, int64_t lit); |
| 350 | |
| 351 | uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset); |
| 352 | int AssignInsnOffsets(); |
| 353 | void AssignOffsets(); |
| 354 | uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir); |
| 355 | |
| 356 | // Spill core and FP registers. Returns the SP difference: either spill size, or whole |
| 357 | // frame size. |
| 358 | int SpillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size); |
| 359 | |
| 360 | // Unspill core and FP registers. |
| 361 | void UnspillRegs(RegStorage base, uint32_t core_reg_mask, uint32_t fp_reg_mask, int frame_size); |
| 362 | |
| 363 | void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2); |
| 364 | |
| 365 | LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value); |
| 366 | LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value); |
| 367 | |
| 368 | LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift); |
| 369 | LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2, |
| 370 | int shift); |
| 371 | int EncodeShift(int code, int amount); |
| 372 | |
| 373 | LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, |
| 374 | A64RegExtEncodings ext, uint8_t amount); |
| 375 | LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2, |
| 376 | A64RegExtEncodings ext, uint8_t amount); |
| 377 | int EncodeExtend(int extend_type, int amount); |
| 378 | bool IsExtendEncoding(int encoded_value); |
| 379 | |
| 380 | LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size); |
| 381 | LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size); |
| 382 | |
| 383 | int EncodeLogicalImmediate(bool is_wide, uint64_t value); |
| 384 | uint64_t DecodeLogicalImmediate(bool is_wide, int value); |
| 385 | ArmConditionCode ArmConditionEncoding(ConditionCode code); |
| 386 | |
| 387 | // Helper used in the two GenSelect variants. |
| 388 | void GenSelect(int32_t left, int32_t right, ConditionCode code, RegStorage rs_dest, |
| 389 | int result_reg_class); |
| 390 | |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 391 | void GenNotLong(RegLocation rl_dest, RegLocation rl_src); |
| 392 | void GenNegLong(RegLocation rl_dest, RegLocation rl_src); |
| 393 | void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 394 | RegLocation rl_src2, bool is_div, int flags); |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 395 | |
Matteo Franchin | 4163c53 | 2014-07-15 15:20:27 +0100 | [diff] [blame] | 396 | static const A64EncodingMap EncodingMap[kA64Last]; |
Vladimir Marko | 7c2ad5a | 2014-09-24 12:42:55 +0100 | [diff] [blame] | 397 | |
| 398 | ArenaVector<LIR*> call_method_insns_; |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 399 | |
| 400 | int GenDalvikArgsBulkCopy(CallInfo* info, int first, int count) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | } // namespace art |
| 404 | |
| 405 | #endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_ |