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