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" |
| 21 | #include "dex/compiler_internals.h" |
| 22 | |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 23 | #include <map> |
| 24 | |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 25 | namespace art { |
| 26 | |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 27 | class Arm64Mir2Lir : public Mir2Lir { |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 28 | protected: |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 29 | // 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 | |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 34 | // TODO: consolidate 64-bit target support. |
| 35 | class InToRegStorageMapper { |
| 36 | public: |
Zheng Xu | 949cd97 | 2014-06-23 18:33:08 +0800 | [diff] [blame^] | 37 | virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref) = 0; |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 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() {} |
Zheng Xu | 949cd97 | 2014-06-23 18:33:08 +0800 | [diff] [blame^] | 45 | virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref); |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 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 Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 67 | 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, |
Matteo Franchin | c61b3c9 | 2014-06-18 11:52:47 +0100 | [diff] [blame] | 72 | RegLocation rl_dest, int lit) OVERRIDE; |
| 73 | bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div, |
| 74 | RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 75 | bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE; |
| 76 | LIR* CheckSuspendUsingLoad() OVERRIDE; |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 77 | RegStorage LoadHelper(ThreadOffset<4> offset) OVERRIDE; |
| 78 | RegStorage LoadHelper(ThreadOffset<8> offset) OVERRIDE; |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 79 | LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest, |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 80 | OpSize size, VolatileKind is_volatile) OVERRIDE; |
| 81 | LIR* LoadRefDisp(RegStorage r_base, int displacement, RegStorage r_dest, |
| 82 | VolatileKind is_volatile) |
| 83 | OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 84 | LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale, |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 85 | OpSize size) OVERRIDE; |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 86 | LIR* LoadRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 87 | LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement, |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 88 | RegStorage r_dest, OpSize size) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 89 | LIR* LoadConstantNoClobber(RegStorage r_dest, int value); |
| 90 | LIR* LoadConstantWide(RegStorage r_dest, int64_t value); |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 91 | LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src, |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 92 | OpSize size, VolatileKind is_volatile) OVERRIDE; |
| 93 | LIR* StoreRefDisp(RegStorage r_base, int displacement, RegStorage r_src, |
| 94 | VolatileKind is_volatile) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 95 | LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale, |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 96 | OpSize size) OVERRIDE; |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 97 | LIR* StoreRefIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 98 | LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement, |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 99 | RegStorage r_src, OpSize size) OVERRIDE; |
Zheng Xu | 7c1c263 | 2014-06-17 18:17:31 +0800 | [diff] [blame] | 100 | void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE; |
| 101 | LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg, |
| 102 | int offset, int check_value, LIR* target) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 103 | |
| 104 | // Required for target - register utilities. |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 105 | RegStorage TargetReg(SpecialTargetRegister reg); |
| 106 | RegStorage GetArgMappingToPhysicalReg(int arg_num); |
| 107 | RegLocation GetReturnAlt(); |
| 108 | RegLocation GetReturnWideAlt(); |
| 109 | RegLocation LocCReturn(); |
buzbee | a0cd2d7 | 2014-06-01 09:33:49 -0700 | [diff] [blame] | 110 | RegLocation LocCReturnRef(); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 111 | RegLocation LocCReturnDouble(); |
| 112 | RegLocation LocCReturnFloat(); |
| 113 | RegLocation LocCReturnWide(); |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 114 | ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 115 | void AdjustSpillMask(); |
| 116 | void ClobberCallerSave(); |
| 117 | void FreeCallTemps(); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 118 | void LockCallTemps(); |
| 119 | void MarkPreservedSingle(int v_reg, RegStorage reg); |
| 120 | void MarkPreservedDouble(int v_reg, RegStorage reg); |
| 121 | void CompilerInitializeRegAlloc(); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 122 | |
| 123 | // Required for target - miscellaneous. |
| 124 | void AssembleLIR(); |
| 125 | uint32_t LinkFixupInsns(LIR* head_lir, LIR* tail_lir, CodeOffset offset); |
| 126 | int AssignInsnOffsets(); |
| 127 | void AssignOffsets(); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 128 | uint8_t* EncodeLIRs(uint8_t* write_pos, LIR* lir); |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 129 | void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE; |
| 130 | void SetupTargetResourceMasks(LIR* lir, uint64_t flags, |
| 131 | ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 132 | const char* GetTargetInstFmt(int opcode); |
| 133 | const char* GetTargetInstName(int opcode); |
| 134 | std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr); |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 135 | ResourceMask GetPCUseDefEncoding() const OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 136 | uint64_t GetTargetInstFlags(int opcode); |
Ian Rogers | 5aa6e04 | 2014-06-13 16:38:24 -0700 | [diff] [blame] | 137 | size_t GetInsnSize(LIR* lir) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 138 | bool IsUnconditionalBranch(LIR* lir); |
| 139 | |
Vladimir Marko | 674744e | 2014-04-24 15:18:26 +0100 | [diff] [blame] | 140 | // Check support for volatile load/store of a given size. |
| 141 | bool SupportsVolatileLoadStore(OpSize size) OVERRIDE; |
| 142 | // Get the register class for load/store of a field. |
| 143 | RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; |
| 144 | |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 145 | // Required for target - Dalvik-level generators. |
Serban Constantinescu | ed65c5e | 2014-05-22 15:10:18 +0100 | [diff] [blame] | 146 | void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 147 | RegLocation lr_shift); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 148 | void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, |
| 149 | RegLocation rl_src1, RegLocation rl_src2); |
| 150 | void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, |
| 151 | RegLocation rl_index, RegLocation rl_dest, int scale); |
| 152 | void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index, |
| 153 | RegLocation rl_src, int scale, bool card_mark); |
| 154 | void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest, |
| 155 | RegLocation rl_src1, RegLocation rl_shift); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 156 | void GenLongOp(OpKind op, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 157 | void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 158 | RegLocation rl_src2); |
| 159 | void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 160 | RegLocation rl_src2); |
| 161 | void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 162 | RegLocation rl_src2); |
| 163 | void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 164 | RegLocation rl_src2); |
| 165 | void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 166 | RegLocation rl_src2); |
| 167 | void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 168 | RegLocation rl_src2); |
| 169 | void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src); |
| 170 | bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object); |
| 171 | bool GenInlinedMinMaxInt(CallInfo* info, bool is_min); |
| 172 | bool GenInlinedSqrt(CallInfo* info); |
| 173 | bool GenInlinedPeek(CallInfo* info, OpSize size); |
| 174 | bool GenInlinedPoke(CallInfo* info, OpSize size); |
Serban Constantinescu | 169489b | 2014-06-11 16:43:35 +0100 | [diff] [blame] | 175 | bool GenInlinedAbsLong(CallInfo* info); |
Serban Constantinescu | ed65c5e | 2014-05-22 15:10:18 +0100 | [diff] [blame] | 176 | void GenIntToLong(RegLocation rl_dest, RegLocation rl_src); |
| 177 | void GenNotLong(RegLocation rl_dest, RegLocation rl_src); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 178 | void GenNegLong(RegLocation rl_dest, RegLocation rl_src); |
| 179 | void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 180 | RegLocation rl_src2); |
| 181 | void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 182 | RegLocation rl_src2); |
| 183 | void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 184 | RegLocation rl_src2); |
Serban Constantinescu | ed65c5e | 2014-05-22 15:10:18 +0100 | [diff] [blame] | 185 | void GenDivRemLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
| 186 | RegLocation rl_src2, bool is_div); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 187 | RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div); |
| 188 | RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div); |
| 189 | void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2); |
| 190 | void GenDivZeroCheckWide(RegStorage reg); |
| 191 | void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method); |
| 192 | void GenExitSequence(); |
| 193 | void GenSpecialExitSequence(); |
| 194 | void GenFillArrayData(DexOffset table_offset, RegLocation rl_src); |
| 195 | void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double); |
| 196 | void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir); |
| 197 | void GenSelect(BasicBlock* bb, MIR* mir); |
Andreas Gampe | b14329f | 2014-05-15 11:16:06 -0700 | [diff] [blame] | 198 | bool GenMemBarrier(MemBarrierKind barrier_kind); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 199 | void GenMonitorEnter(int opt_flags, RegLocation rl_src); |
| 200 | void GenMonitorExit(int opt_flags, RegLocation rl_src); |
| 201 | void GenMoveException(RegLocation rl_dest); |
| 202 | void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit, |
| 203 | int first_bit, int second_bit); |
| 204 | void GenNegDouble(RegLocation rl_dest, RegLocation rl_src); |
| 205 | void GenNegFloat(RegLocation rl_dest, RegLocation rl_src); |
| 206 | void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src); |
| 207 | void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 208 | |
| 209 | uint32_t GenPairWise(uint32_t reg_mask, int* reg1, int* reg2); |
| 210 | void UnSpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask); |
| 211 | void SpillCoreRegs(RegStorage base, int offset, uint32_t reg_mask); |
Matteo Franchin | bc6d197 | 2014-05-13 12:33:28 +0100 | [diff] [blame] | 212 | void UnSpillFPRegs(RegStorage base, int offset, uint32_t reg_mask); |
| 213 | void SpillFPRegs(RegStorage base, int offset, uint32_t reg_mask); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 214 | |
| 215 | // Required for target - single operation generators. |
| 216 | LIR* OpUnconditionalBranch(LIR* target); |
| 217 | LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target); |
| 218 | LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target); |
| 219 | LIR* OpCondBranch(ConditionCode cc, LIR* target); |
| 220 | LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target); |
| 221 | LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src); |
| 222 | LIR* OpIT(ConditionCode cond, const char* guide); |
| 223 | void OpEndIT(LIR* it); |
| 224 | LIR* OpMem(OpKind op, RegStorage r_base, int disp); |
| 225 | LIR* OpPcRelLoad(RegStorage reg, LIR* target); |
| 226 | LIR* OpReg(OpKind op, RegStorage r_dest_src); |
| 227 | void OpRegCopy(RegStorage r_dest, RegStorage r_src); |
| 228 | LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src); |
Serban Constantinescu | ed65c5e | 2014-05-22 15:10:18 +0100 | [diff] [blame] | 229 | LIR* OpRegImm64(OpKind op, RegStorage r_dest_src1, int64_t value); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 230 | LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value); |
| 231 | LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset); |
| 232 | LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2); |
| 233 | LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type); |
| 234 | LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type); |
| 235 | LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src); |
Zheng Xu | e2eb29e | 2014-06-12 10:22:33 +0800 | [diff] [blame] | 236 | LIR* OpRegRegImm64(OpKind op, RegStorage r_dest, RegStorage r_src1, int64_t value); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 237 | LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value); |
| 238 | LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2); |
| 239 | LIR* OpTestSuspend(LIR* target); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 240 | LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset) OVERRIDE; |
| 241 | LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 242 | LIR* OpVldm(RegStorage r_base, int count); |
| 243 | LIR* OpVstm(RegStorage r_base, int count); |
| 244 | void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset); |
| 245 | void OpRegCopyWide(RegStorage dest, RegStorage src); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 246 | void OpTlsCmp(ThreadOffset<4> offset, int val) OVERRIDE; |
| 247 | void OpTlsCmp(ThreadOffset<8> offset, int val) OVERRIDE; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 248 | |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 249 | LIR* LoadBaseDispBody(RegStorage r_base, int displacement, RegStorage r_dest, OpSize size); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 250 | LIR* StoreBaseDispBody(RegStorage r_base, int displacement, RegStorage r_src, OpSize size); |
Serban Constantinescu | ed65c5e | 2014-05-22 15:10:18 +0100 | [diff] [blame] | 251 | LIR* OpRegRegRegShift(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2, |
| 252 | int shift); |
Andreas Gampe | 47b31aa | 2014-06-19 01:10:07 -0700 | [diff] [blame] | 253 | LIR* OpRegRegRegExtend(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2, |
| 254 | A64RegExtEncodings ext, uint8_t amount); |
Matteo Franchin | bc6d197 | 2014-05-13 12:33:28 +0100 | [diff] [blame] | 255 | LIR* OpRegRegShift(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift); |
Stuart Monteith | f8ec48e | 2014-06-06 17:05:08 +0100 | [diff] [blame] | 256 | LIR* OpRegRegExtend(OpKind op, RegStorage r_dest_src1, RegStorage r_src2, int shift); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 257 | static const ArmEncodingMap EncodingMap[kA64Last]; |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 258 | int EncodeShift(int code, int amount); |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 259 | int EncodeExtend(int extend_type, int amount); |
| 260 | bool IsExtendEncoding(int encoded_value); |
| 261 | int EncodeLogicalImmediate(bool is_wide, uint64_t value); |
| 262 | uint64_t DecodeLogicalImmediate(bool is_wide, int value); |
| 263 | |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 264 | ArmConditionCode ArmConditionEncoding(ConditionCode code); |
| 265 | bool InexpensiveConstantInt(int32_t value); |
| 266 | bool InexpensiveConstantFloat(int32_t value); |
| 267 | bool InexpensiveConstantLong(int64_t value); |
| 268 | bool InexpensiveConstantDouble(int64_t value); |
| 269 | |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 270 | void FlushIns(RegLocation* ArgLocs, RegLocation rl_method); |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 271 | |
| 272 | int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel, |
| 273 | NextCallInsn next_call_insn, |
| 274 | const MethodReference& target_method, |
| 275 | uint32_t vtable_idx, |
| 276 | uintptr_t direct_code, uintptr_t direct_method, InvokeType type, |
| 277 | bool skip_this); |
| 278 | |
| 279 | int GenDalvikArgsRange(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 | InToRegStorageMapping in_to_reg_storage_mapping_; |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 286 | |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 287 | private: |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 288 | /** |
| 289 | * @brief Given register xNN (dNN), returns register wNN (sNN). |
| 290 | * @param reg #RegStorage containing a Solo64 input register (e.g. @c x1 or @c d2). |
| 291 | * @return A Solo32 with the same register number as the @p reg (e.g. @c w1 or @c s2). |
| 292 | * @see As64BitReg |
| 293 | */ |
| 294 | RegStorage As32BitReg(RegStorage reg) { |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 295 | DCHECK(!reg.IsPair()); |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 296 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) { |
| 297 | if (kFailOnSizeError) { |
| 298 | LOG(FATAL) << "Expected 64b register"; |
| 299 | } else { |
| 300 | LOG(WARNING) << "Expected 64b register"; |
| 301 | return reg; |
| 302 | } |
| 303 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 304 | RegStorage ret_val = RegStorage(RegStorage::k32BitSolo, |
| 305 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 306 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask) |
| 307 | ->GetReg().GetReg(), |
| 308 | ret_val.GetReg()); |
| 309 | return ret_val; |
| 310 | } |
| 311 | |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 312 | RegStorage Check32BitReg(RegStorage reg) { |
| 313 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) { |
| 314 | if (kFailOnSizeError) { |
| 315 | LOG(FATAL) << "Checked for 32b register"; |
| 316 | } else { |
| 317 | LOG(WARNING) << "Checked for 32b register"; |
| 318 | return As32BitReg(reg); |
| 319 | } |
| 320 | } |
| 321 | return reg; |
| 322 | } |
| 323 | |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 324 | /** |
| 325 | * @brief Given register wNN (sNN), returns register xNN (dNN). |
| 326 | * @param reg #RegStorage containing a Solo32 input register (e.g. @c w1 or @c s2). |
| 327 | * @return A Solo64 with the same register number as the @p reg (e.g. @c x1 or @c d2). |
| 328 | * @see As32BitReg |
| 329 | */ |
| 330 | RegStorage As64BitReg(RegStorage reg) { |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 331 | DCHECK(!reg.IsPair()); |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 332 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) { |
| 333 | if (kFailOnSizeError) { |
| 334 | LOG(FATAL) << "Expected 32b register"; |
| 335 | } else { |
| 336 | LOG(WARNING) << "Expected 32b register"; |
| 337 | return reg; |
| 338 | } |
| 339 | } |
Matteo Franchin | 5acc8b0 | 2014-06-05 15:10:35 +0100 | [diff] [blame] | 340 | RegStorage ret_val = RegStorage(RegStorage::k64BitSolo, |
| 341 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 342 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask) |
| 343 | ->GetReg().GetReg(), |
| 344 | ret_val.GetReg()); |
| 345 | return ret_val; |
| 346 | } |
| 347 | |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 348 | RegStorage Check64BitReg(RegStorage reg) { |
| 349 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) { |
| 350 | if (kFailOnSizeError) { |
| 351 | LOG(FATAL) << "Checked for 64b register"; |
| 352 | } else { |
| 353 | LOG(WARNING) << "Checked for 64b register"; |
| 354 | return As64BitReg(reg); |
| 355 | } |
| 356 | } |
| 357 | return reg; |
| 358 | } |
| 359 | |
Matteo Franchin | c41e6dc | 2014-06-13 19:16:28 +0100 | [diff] [blame] | 360 | LIR* LoadFPConstantValue(RegStorage r_dest, int32_t value); |
| 361 | LIR* LoadFPConstantValueWide(RegStorage r_dest, int64_t value); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 362 | void ReplaceFixup(LIR* prev_lir, LIR* orig_lir, LIR* new_lir); |
| 363 | void InsertFixupBefore(LIR* prev_lir, LIR* orig_lir, LIR* new_lir); |
| 364 | void AssignDataOffsets(); |
| 365 | RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
| 366 | bool is_div, bool check_zero); |
| 367 | RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src1, int lit, bool is_div); |
Matteo Franchin | 43ec873 | 2014-03-31 15:00:14 +0100 | [diff] [blame] | 368 | }; |
| 369 | |
| 370 | } // namespace art |
| 371 | |
| 372 | #endif // ART_COMPILER_DEX_QUICK_ARM64_CODEGEN_ARM64_H_ |