Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ |
| 18 | #define ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 19 | |
| 20 | #include "dex/compiler_internals.h" |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 21 | #include "dex/quick/mir_to_lir.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 22 | #include "x86_lir.h" |
| 23 | |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 24 | #include <map> |
Maxim Kazantsev | 6dccdc2 | 2014-08-18 18:43:55 +0700 | [diff] [blame] | 25 | #include <vector> |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 26 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 27 | namespace art { |
| 28 | |
Mark Mendell | e87f9b5 | 2014-04-30 14:13:18 -0400 | [diff] [blame] | 29 | class X86Mir2Lir : public Mir2Lir { |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 30 | protected: |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 31 | class InToRegStorageX86_64Mapper : public InToRegStorageMapper { |
| 32 | public: |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 33 | explicit InToRegStorageX86_64Mapper(Mir2Lir* m2l) |
| 34 | : m2l_(m2l), cur_core_reg_(0), cur_fp_reg_(0) {} |
| 35 | virtual RegStorage GetNextReg(ShortyArg arg); |
| 36 | virtual void Reset() OVERRIDE { |
| 37 | cur_core_reg_ = 0; |
| 38 | cur_fp_reg_ = 0; |
| 39 | } |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 40 | protected: |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 41 | Mir2Lir* m2l_; |
Vladimir Marko | 0f9b03c | 2015-01-12 18:21:07 +0000 | [diff] [blame] | 42 | private: |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 43 | size_t cur_core_reg_; |
| 44 | size_t cur_fp_reg_; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 45 | }; |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 46 | |
Vladimir Marko | 0f9b03c | 2015-01-12 18:21:07 +0000 | [diff] [blame] | 47 | class InToRegStorageX86Mapper : public InToRegStorageMapper { |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 48 | public: |
Vladimir Marko | 0f9b03c | 2015-01-12 18:21:07 +0000 | [diff] [blame] | 49 | explicit InToRegStorageX86Mapper(Mir2Lir* m2l) : m2l_(m2l), cur_core_reg_(0) {} |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 50 | virtual RegStorage GetNextReg(ShortyArg arg); |
Vladimir Marko | 0f9b03c | 2015-01-12 18:21:07 +0000 | [diff] [blame] | 51 | virtual void Reset() OVERRIDE { |
| 52 | cur_core_reg_ = 0; |
| 53 | } |
| 54 | protected: |
| 55 | Mir2Lir* m2l_; |
| 56 | private: |
| 57 | size_t cur_core_reg_; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 58 | }; |
Dmitry Petrochenko | 58994cd | 2014-05-17 01:02:18 +0700 | [diff] [blame] | 59 | |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 60 | InToRegStorageX86_64Mapper in_to_reg_storage_x86_64_mapper_; |
| 61 | InToRegStorageX86Mapper in_to_reg_storage_x86_mapper_; |
| 62 | InToRegStorageMapper* GetResetedInToRegStorageMapper() OVERRIDE { |
| 63 | InToRegStorageMapper* res; |
| 64 | if (cu_->target64) { |
| 65 | res = &in_to_reg_storage_x86_64_mapper_; |
| 66 | } else { |
| 67 | res = &in_to_reg_storage_x86_mapper_; |
| 68 | } |
| 69 | res->Reset(); |
| 70 | return res; |
| 71 | } |
| 72 | |
Maxim Kazantsev | 6dccdc2 | 2014-08-18 18:43:55 +0700 | [diff] [blame] | 73 | class ExplicitTempRegisterLock { |
| 74 | public: |
| 75 | ExplicitTempRegisterLock(X86Mir2Lir* mir_to_lir, int n_regs, ...); |
| 76 | ~ExplicitTempRegisterLock(); |
| 77 | protected: |
| 78 | std::vector<RegStorage> temp_regs_; |
| 79 | X86Mir2Lir* const mir_to_lir_; |
| 80 | }; |
| 81 | |
Serguei Katkov | 717a3e4 | 2014-11-13 17:19:42 +0600 | [diff] [blame] | 82 | virtual int GenDalvikArgsBulkCopy(CallInfo* info, int first, int count) OVERRIDE; |
| 83 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 84 | public: |
Elena Sayapina | dd64450 | 2014-07-01 18:39:52 +0700 | [diff] [blame] | 85 | X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 86 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 87 | // Required for target - codegen helpers. |
| 88 | bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 89 | RegLocation rl_dest, int lit) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 90 | bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE; |
Ningsheng Jian | 675e09b | 2014-10-23 13:48:36 +0800 | [diff] [blame] | 91 | void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1, |
| 92 | int32_t constant) OVERRIDE; |
| 93 | void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1, |
| 94 | int64_t constant) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 95 | LIR* CheckSuspendUsingLoad() OVERRIDE; |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 96 | RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 97 | LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest, |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 98 | OpSize size, VolatileKind is_volatile) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 99 | 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] | 100 | OpSize size) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 101 | LIR* LoadConstantNoClobber(RegStorage r_dest, int value); |
| 102 | LIR* LoadConstantWide(RegStorage r_dest, int64_t value); |
Yevgeny Rouban | 6af8206 | 2014-11-26 18:11:54 +0600 | [diff] [blame] | 103 | void GenLongToInt(RegLocation rl_dest, RegLocation rl_src); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 104 | LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src, |
Andreas Gampe | 3c12c51 | 2014-06-24 18:46:29 +0000 | [diff] [blame] | 105 | OpSize size, VolatileKind is_volatile) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 106 | LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale, |
| 107 | OpSize size) OVERRIDE; |
Vladimir Marko | bf535be | 2014-11-19 18:52:35 +0000 | [diff] [blame] | 108 | |
| 109 | /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage) |
| 110 | void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE; |
| 111 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 112 | void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 113 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 114 | // Required for target - register utilities. |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 115 | RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE; |
Andreas Gampe | ccc6026 | 2014-07-04 18:02:38 -0700 | [diff] [blame] | 116 | RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE { |
| 117 | if (wide_kind == kWide) { |
| 118 | if (cu_->target64) { |
| 119 | return As64BitReg(TargetReg32(symbolic_reg)); |
| 120 | } else { |
| 121 | // x86: construct a pair. |
| 122 | DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) || |
Vladimir Marko | 0f9b03c | 2015-01-12 18:21:07 +0000 | [diff] [blame] | 123 | (kFArg0 <= symbolic_reg && symbolic_reg < kFArg3) || |
Andreas Gampe | ccc6026 | 2014-07-04 18:02:38 -0700 | [diff] [blame] | 124 | (kRet0 == symbolic_reg)); |
| 125 | return RegStorage::MakeRegPair(TargetReg32(symbolic_reg), |
| 126 | TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1))); |
| 127 | } |
| 128 | } else if (wide_kind == kRef && cu_->target64) { |
| 129 | return As64BitReg(TargetReg32(symbolic_reg)); |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 130 | } else { |
Andreas Gampe | ccc6026 | 2014-07-04 18:02:38 -0700 | [diff] [blame] | 131 | return TargetReg32(symbolic_reg); |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 132 | } |
| 133 | } |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 134 | RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE { |
Andreas Gampe | ccc6026 | 2014-07-04 18:02:38 -0700 | [diff] [blame] | 135 | return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide); |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 136 | } |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 137 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 138 | RegLocation GetReturnAlt() OVERRIDE; |
| 139 | RegLocation GetReturnWideAlt() OVERRIDE; |
| 140 | RegLocation LocCReturn() OVERRIDE; |
| 141 | RegLocation LocCReturnRef() OVERRIDE; |
| 142 | RegLocation LocCReturnDouble() OVERRIDE; |
| 143 | RegLocation LocCReturnFloat() OVERRIDE; |
| 144 | RegLocation LocCReturnWide() OVERRIDE; |
| 145 | |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 146 | ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 147 | void AdjustSpillMask() OVERRIDE; |
| 148 | void ClobberCallerSave() OVERRIDE; |
| 149 | void FreeCallTemps() OVERRIDE; |
| 150 | void LockCallTemps() OVERRIDE; |
| 151 | |
| 152 | void CompilerInitializeRegAlloc() OVERRIDE; |
| 153 | int VectorRegisterSize() OVERRIDE; |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 154 | int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 155 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 156 | // Required for target - miscellaneous. |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 157 | void AssembleLIR() OVERRIDE; |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 158 | void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE; |
| 159 | void SetupTargetResourceMasks(LIR* lir, uint64_t flags, |
| 160 | ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 161 | const char* GetTargetInstFmt(int opcode) OVERRIDE; |
| 162 | const char* GetTargetInstName(int opcode) OVERRIDE; |
| 163 | std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE; |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 164 | ResourceMask GetPCUseDefEncoding() const OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 165 | uint64_t GetTargetInstFlags(int opcode) OVERRIDE; |
Ian Rogers | 5aa6e04 | 2014-06-13 16:38:24 -0700 | [diff] [blame] | 166 | size_t GetInsnSize(LIR* lir) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 167 | bool IsUnconditionalBranch(LIR* lir) OVERRIDE; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 168 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 169 | // Get the register class for load/store of a field. |
| 170 | RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE; |
Vladimir Marko | 674744e | 2014-04-24 15:18:26 +0100 | [diff] [blame] | 171 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 172 | // Required for target - Dalvik-level generators. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 173 | void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 174 | RegLocation rl_dest, int scale) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 175 | void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 176 | RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE; |
| 177 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 178 | void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 179 | RegLocation rl_src2) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 180 | void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 181 | RegLocation rl_src2) OVERRIDE; |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 182 | void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 183 | RegLocation rl_src2) OVERRIDE; |
| 184 | void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
| 185 | |
| 186 | bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE; |
| 187 | bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE; |
| 188 | bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE; |
Yixin Shou | 8c914c0 | 2014-07-28 14:17:09 -0400 | [diff] [blame] | 189 | bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 190 | bool GenInlinedSqrt(CallInfo* info) OVERRIDE; |
Yixin Shou | 7071c8d | 2014-03-05 06:07:48 -0500 | [diff] [blame] | 191 | bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE; |
| 192 | bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 193 | bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE; |
| 194 | bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE; |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 195 | bool GenInlinedCharAt(CallInfo* info) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 196 | |
| 197 | // Long instructions. |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 198 | void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 199 | RegLocation rl_src2, int flags) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 200 | void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 201 | RegLocation rl_src2, int flags) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 202 | void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 203 | RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 204 | void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE; |
| 205 | void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
| 206 | void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, |
| 207 | RegLocation rl_src1, RegLocation rl_shift) OVERRIDE; |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame] | 208 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 209 | /* |
| 210 | * @brief Generate a two address long operation with a constant value |
| 211 | * @param rl_dest location of result |
| 212 | * @param rl_src constant source operand |
| 213 | * @param op Opcode to be generated |
| 214 | * @return success or not |
| 215 | */ |
| 216 | bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op); |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 217 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 218 | /* |
| 219 | * @brief Generate a three address long operation with a constant value |
| 220 | * @param rl_dest location of result |
| 221 | * @param rl_src1 source operand |
| 222 | * @param rl_src2 constant source operand |
| 223 | * @param op Opcode to be generated |
| 224 | * @return success or not |
| 225 | */ |
| 226 | bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
| 227 | Instruction::Code op); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 228 | /** |
| 229 | * @brief Generate a long arithmetic operation. |
| 230 | * @param rl_dest The destination. |
| 231 | * @param rl_src1 First operand. |
| 232 | * @param rl_src2 Second operand. |
| 233 | * @param op The DEX opcode for the operation. |
| 234 | * @param is_commutative The sources can be swapped if needed. |
| 235 | */ |
| 236 | virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
| 237 | Instruction::Code op, bool is_commutative); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 238 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 239 | /** |
| 240 | * @brief Generate a two operand long arithmetic operation. |
| 241 | * @param rl_dest The destination. |
| 242 | * @param rl_src Second operand. |
| 243 | * @param op The DEX opcode for the operation. |
| 244 | */ |
| 245 | void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 246 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 247 | /** |
| 248 | * @brief Generate a long operation. |
| 249 | * @param rl_dest The destination. Must be in a register |
| 250 | * @param rl_src The other operand. May be in a register or in memory. |
| 251 | * @param op The DEX opcode for the operation. |
| 252 | */ |
| 253 | virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 254 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 255 | |
| 256 | // TODO: collapse reg_lo, reg_hi |
| 257 | RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div) |
| 258 | OVERRIDE; |
| 259 | RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE; |
| 260 | void GenDivZeroCheckWide(RegStorage reg) OVERRIDE; |
| 261 | void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE; |
| 262 | void GenExitSequence() OVERRIDE; |
| 263 | void GenSpecialExitSequence() OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 264 | void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE; |
| 265 | void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE; |
| 266 | void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE; |
| 267 | void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code, |
| 268 | int32_t true_val, int32_t false_val, RegStorage rs_dest, |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 269 | RegisterClass dest_reg_class) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 270 | bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE; |
| 271 | void GenMoveException(RegLocation rl_dest) OVERRIDE; |
| 272 | void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit, |
| 273 | int first_bit, int second_bit) OVERRIDE; |
| 274 | void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
| 275 | void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE; |
Chao-ying Fu | da96aed | 2014-10-27 14:42:00 -0700 | [diff] [blame] | 276 | const uint16_t* ConvertPackedSwitchTable(MIR* mir, const uint16_t* table); |
Andreas Gampe | 48971b3 | 2014-08-06 10:09:01 -0700 | [diff] [blame] | 277 | void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE; |
| 278 | void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE; |
Chao-ying Fu | da96aed | 2014-10-27 14:42:00 -0700 | [diff] [blame] | 279 | LIR* InsertCaseLabel(DexOffset vaddr, int keyVal) OVERRIDE; |
| 280 | void MarkPackedCaseLabels(Mir2Lir::SwitchTable* tab_rec) OVERRIDE; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 281 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 282 | /** |
| 283 | * @brief Implement instanceof a final class with x86 specific code. |
| 284 | * @param use_declaring_class 'true' if we can use the class itself. |
| 285 | * @param type_idx Type index to use if use_declaring_class is 'false'. |
| 286 | * @param rl_dest Result to be set to 0 or 1. |
| 287 | * @param rl_src Object to be tested. |
| 288 | */ |
| 289 | void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 290 | RegLocation rl_src) OVERRIDE; |
Chao-ying Fu | a014776 | 2014-06-06 18:38:49 -0700 | [diff] [blame] | 291 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 292 | // Single operation generators. |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 293 | LIR* OpUnconditionalBranch(LIR* target) OVERRIDE; |
| 294 | LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE; |
| 295 | LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE; |
| 296 | LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE; |
| 297 | LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE; |
| 298 | LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 299 | LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE; |
| 300 | void OpEndIT(LIR* it) OVERRIDE; |
| 301 | LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE; |
| 302 | LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE; |
| 303 | LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE; |
| 304 | void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 305 | LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 306 | LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE; |
| 307 | LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE; |
| 308 | LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE; |
| 309 | LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE; |
| 310 | LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE; |
| 311 | LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE; |
| 312 | LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE; |
| 313 | LIR* OpTestSuspend(LIR* target) OVERRIDE; |
| 314 | LIR* OpVldm(RegStorage r_base, int count) OVERRIDE; |
| 315 | LIR* OpVstm(RegStorage r_base, int count) OVERRIDE; |
| 316 | void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE; |
| 317 | bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 318 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 319 | bool InexpensiveConstantInt(int32_t value) OVERRIDE; |
| 320 | bool InexpensiveConstantFloat(int32_t value) OVERRIDE; |
| 321 | bool InexpensiveConstantLong(int64_t value) OVERRIDE; |
| 322 | bool InexpensiveConstantDouble(int64_t value) OVERRIDE; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 323 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 324 | /* |
| 325 | * @brief Should try to optimize for two address instructions? |
| 326 | * @return true if we try to avoid generating three operand instructions. |
| 327 | */ |
| 328 | virtual bool GenerateTwoOperandInstructions() const { return true; } |
Mark Mendell | e87f9b5 | 2014-04-30 14:13:18 -0400 | [diff] [blame] | 329 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 330 | /* |
| 331 | * @brief x86 specific codegen for int operations. |
| 332 | * @param opcode Operation to perform. |
| 333 | * @param rl_dest Destination for the result. |
| 334 | * @param rl_lhs Left hand operand. |
| 335 | * @param rl_rhs Right hand operand. |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 336 | * @param flags The instruction optimization flags. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 337 | */ |
| 338 | void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 339 | RegLocation rl_rhs, int flags) OVERRIDE; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 340 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 341 | /* |
| 342 | * @brief Load the Method* of a dex method into the register. |
| 343 | * @param target_method The MethodReference of the method to be invoked. |
| 344 | * @param type How the method will be invoked. |
| 345 | * @param register that will contain the code address. |
| 346 | * @note register will be passed to TargetReg to get physical register. |
| 347 | */ |
| 348 | void LoadMethodAddress(const MethodReference& target_method, InvokeType type, |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 349 | SpecialTargetRegister symbolic_reg) OVERRIDE; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 350 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 351 | /* |
| 352 | * @brief Load the Class* of a Dex Class type into the register. |
Fred Shih | e7f82e2 | 2014-08-06 10:46:37 -0700 | [diff] [blame] | 353 | * @param dex DexFile that contains the class type. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 354 | * @param type How the method will be invoked. |
| 355 | * @param register that will contain the code address. |
| 356 | * @note register will be passed to TargetReg to get physical register. |
| 357 | */ |
Fred Shih | e7f82e2 | 2014-08-06 10:46:37 -0700 | [diff] [blame] | 358 | void LoadClassType(const DexFile& dex_file, uint32_t type_idx, |
| 359 | SpecialTargetRegister symbolic_reg) OVERRIDE; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 360 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 361 | NextCallInsn GetNextSDCallInsn() OVERRIDE; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 362 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 363 | /* |
| 364 | * @brief Generate a relative call to the method that will be patched at link time. |
| 365 | * @param target_method The MethodReference of the method to be invoked. |
| 366 | * @param type How the method will be invoked. |
| 367 | * @returns Call instruction |
| 368 | */ |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 369 | LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type); |
| 370 | |
| 371 | /* |
| 372 | * @brief Generate the actual call insn based on the method info. |
| 373 | * @param method_info the lowering info for the method call. |
| 374 | * @returns Call instruction |
| 375 | */ |
| 376 | LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 377 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 378 | /* |
| 379 | * @brief Handle x86 specific literals |
| 380 | */ |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 381 | void InstallLiteralPools() OVERRIDE; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 382 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 383 | /* |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 384 | * @brief Generate the debug_frame FDE information. |
| 385 | * @returns pointer to vector containing CFE information |
| 386 | */ |
Tong Shen | 547cdfd | 2014-08-05 01:54:19 -0700 | [diff] [blame] | 387 | std::vector<uint8_t>* ReturnFrameDescriptionEntry() OVERRIDE; |
Razvan A Lupusoru | bd288c2 | 2013-12-20 17:27:23 -0800 | [diff] [blame] | 388 | |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 389 | LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE; |
| 390 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 391 | protected: |
Ian Rogers | b28c1c0 | 2014-11-08 11:21:21 -0800 | [diff] [blame] | 392 | RegStorage TargetReg32(SpecialTargetRegister reg) const; |
Chao-ying Fu | a77ee51 | 2014-07-01 17:43:41 -0700 | [diff] [blame] | 393 | // Casting of RegStorage |
| 394 | RegStorage As32BitReg(RegStorage reg) { |
| 395 | DCHECK(!reg.IsPair()); |
| 396 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) { |
| 397 | if (kFailOnSizeError) { |
| 398 | LOG(FATAL) << "Expected 64b register " << reg.GetReg(); |
| 399 | } else { |
| 400 | LOG(WARNING) << "Expected 64b register " << reg.GetReg(); |
| 401 | return reg; |
| 402 | } |
| 403 | } |
| 404 | RegStorage ret_val = RegStorage(RegStorage::k32BitSolo, |
| 405 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 406 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask) |
| 407 | ->GetReg().GetReg(), |
| 408 | ret_val.GetReg()); |
| 409 | return ret_val; |
| 410 | } |
| 411 | |
| 412 | RegStorage As64BitReg(RegStorage reg) { |
| 413 | DCHECK(!reg.IsPair()); |
| 414 | if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) { |
| 415 | if (kFailOnSizeError) { |
| 416 | LOG(FATAL) << "Expected 32b register " << reg.GetReg(); |
| 417 | } else { |
| 418 | LOG(WARNING) << "Expected 32b register " << reg.GetReg(); |
| 419 | return reg; |
| 420 | } |
| 421 | } |
| 422 | RegStorage ret_val = RegStorage(RegStorage::k64BitSolo, |
| 423 | reg.GetRawBits() & RegStorage::kRegTypeMask); |
| 424 | DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask) |
| 425 | ->GetReg().GetReg(), |
| 426 | ret_val.GetReg()); |
| 427 | return ret_val; |
| 428 | } |
| 429 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 430 | LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement, |
| 431 | RegStorage r_dest, OpSize size); |
| 432 | LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement, |
Jean Christophe Beyler | b5bce7c | 2014-07-25 12:32:18 -0700 | [diff] [blame] | 433 | RegStorage r_src, OpSize size, int opt_flags = 0); |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 434 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 435 | int AssignInsnOffsets(); |
| 436 | void AssignOffsets(); |
| 437 | AssemblerStatus AssembleInstructions(CodeOffset start_addr); |
| 438 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 439 | size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index, |
Ian Rogers | 5aa6e04 | 2014-06-13 16:38:24 -0700 | [diff] [blame] | 440 | int32_t raw_base, int32_t displacement); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 441 | void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg); |
| 442 | void EmitPrefix(const X86EncodingMap* entry, |
Ian Rogers | 5aa6e04 | 2014-06-13 16:38:24 -0700 | [diff] [blame] | 443 | int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 444 | void EmitOpcode(const X86EncodingMap* entry); |
| 445 | void EmitPrefixAndOpcode(const X86EncodingMap* entry, |
Ian Rogers | 5aa6e04 | 2014-06-13 16:38:24 -0700 | [diff] [blame] | 446 | int32_t reg_r, int32_t reg_x, int32_t reg_b); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 447 | void EmitDisp(uint8_t base, int32_t disp); |
| 448 | void EmitModrmThread(uint8_t reg_or_opcode); |
| 449 | void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp); |
| 450 | void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale, |
| 451 | int32_t disp); |
| 452 | void EmitImm(const X86EncodingMap* entry, int64_t imm); |
| 453 | void EmitNullary(const X86EncodingMap* entry); |
| 454 | void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg); |
| 455 | void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg); |
| 456 | void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp); |
| 457 | void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale, |
| 458 | int32_t disp); |
| 459 | void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg); |
| 460 | void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp); |
| 461 | void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, |
| 462 | int32_t raw_index, int scale, int32_t disp); |
| 463 | void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale, |
| 464 | int32_t disp, int32_t raw_reg); |
| 465 | void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm); |
| 466 | void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale, |
| 467 | int32_t raw_disp, int32_t imm); |
| 468 | void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp); |
| 469 | void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2); |
| 470 | void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm); |
| 471 | void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp, |
| 472 | int32_t imm); |
| 473 | void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1, |
| 474 | int32_t imm); |
| 475 | void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm); |
| 476 | void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm); |
| 477 | void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm); |
| 478 | void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm); |
| 479 | void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl); |
| 480 | void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl); |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 481 | void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, |
| 482 | int32_t raw_cl); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 483 | void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm); |
| 484 | void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc); |
| 485 | void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc); |
| 486 | void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc); |
| 487 | void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp, |
| 488 | int32_t cc); |
Razvan A Lupusoru | bd288c2 | 2013-12-20 17:27:23 -0800 | [diff] [blame] | 489 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 490 | void EmitJmp(const X86EncodingMap* entry, int32_t rel); |
| 491 | void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc); |
| 492 | void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp); |
| 493 | void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp); |
| 494 | void EmitCallThread(const X86EncodingMap* entry, int32_t disp); |
| 495 | void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table, |
| 496 | int32_t raw_index, int scale, int32_t table_or_disp); |
| 497 | void EmitMacro(const X86EncodingMap* entry, int32_t raw_reg, int32_t offset); |
| 498 | void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir); |
| 499 | void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1, |
| 500 | int64_t val, ConditionCode ccode); |
| 501 | void GenConstWide(RegLocation rl_dest, int64_t value); |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 502 | void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2); |
| 503 | void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2); |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 504 | void GenShiftByteVector(MIR* mir); |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 505 | void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3, |
| 506 | uint32_t m4); |
| 507 | void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2, |
| 508 | uint32_t m3, uint32_t m4); |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 509 | void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir); |
Mark Mendell | 0a1174e | 2014-09-11 14:51:02 -0400 | [diff] [blame] | 510 | virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize, |
| 511 | int op_mov); |
Mark Mendell | 2637f2e | 2014-04-30 10:10:47 -0400 | [diff] [blame] | 512 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 513 | static bool ProvidesFullMemoryBarrier(X86OpCode opcode); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 514 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 515 | /* |
| 516 | * @brief Ensure that a temporary register is byte addressable. |
| 517 | * @returns a temporary guarenteed to be byte addressable. |
| 518 | */ |
| 519 | virtual RegStorage AllocateByteRegister(); |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 520 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 521 | /* |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 522 | * @brief Use a wide temporary as a 128-bit register |
| 523 | * @returns a 128-bit temporary register. |
| 524 | */ |
| 525 | virtual RegStorage Get128BitRegister(RegStorage reg); |
| 526 | |
| 527 | /* |
Chao-ying Fu | 7e399fd | 2014-06-10 18:11:11 -0700 | [diff] [blame] | 528 | * @brief Check if a register is byte addressable. |
| 529 | * @returns true if a register is byte addressable. |
| 530 | */ |
Ian Rogers | b28c1c0 | 2014-11-08 11:21:21 -0800 | [diff] [blame] | 531 | bool IsByteRegister(RegStorage reg) const; |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 532 | |
| 533 | void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div); |
| 534 | |
DaniilSokolov | 70c4f06 | 2014-06-24 17:34:00 -0700 | [diff] [blame] | 535 | bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE; |
Chao-ying Fu | 7e399fd | 2014-06-10 18:11:11 -0700 | [diff] [blame] | 536 | |
| 537 | /* |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 538 | * @brief generate inline code for fast case of Strng.indexOf. |
| 539 | * @param info Call parameters |
| 540 | * @param zero_based 'true' if the index into the string is 0. |
| 541 | * @returns 'true' if the call was inlined, 'false' if a regular call needs to be |
| 542 | * generated. |
| 543 | */ |
| 544 | bool GenInlinedIndexOf(CallInfo* info, bool zero_based); |
Mark Mendell | e87f9b5 | 2014-04-30 14:13:18 -0400 | [diff] [blame] | 545 | |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 546 | /** |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 547 | * @brief Used to reserve a range of vector registers. |
| 548 | * @see kMirOpReserveVectorRegisters |
| 549 | * @param mir The extended MIR for reservation. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 550 | */ |
| 551 | void ReserveVectorRegisters(MIR* mir); |
| 552 | |
| 553 | /** |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 554 | * @brief Used to return a range of vector registers. |
| 555 | * @see kMirOpReturnVectorRegisters |
| 556 | * @param mir The extended MIR for returning vector regs. |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 557 | */ |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 558 | void ReturnVectorRegisters(MIR* mir); |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 559 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 560 | /* |
| 561 | * @brief Load 128 bit constant into vector register. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 562 | * @param mir The MIR whose opcode is kMirConstVector |
| 563 | * @note vA is the TypeSize for the register. |
| 564 | * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values. |
| 565 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 566 | void GenConst128(MIR* mir); |
Mark Mendell | 4028a6c | 2014-02-19 20:06:20 -0800 | [diff] [blame] | 567 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 568 | /* |
| 569 | * @brief MIR to move a vectorized register to another. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 570 | * @param mir The MIR whose opcode is kMirConstVector. |
| 571 | * @note vA: TypeSize |
| 572 | * @note vB: destination |
| 573 | * @note vC: source |
| 574 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 575 | void GenMoveVector(MIR* mir); |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 576 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 577 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 578 | * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know |
| 579 | * the type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 580 | * @param mir The MIR whose opcode is kMirConstVector. |
| 581 | * @note vA: TypeSize |
| 582 | * @note vB: destination and source |
| 583 | * @note vC: source |
| 584 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 585 | void GenMultiplyVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 586 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 587 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 588 | * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the |
| 589 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 590 | * @param mir The MIR whose opcode is kMirConstVector. |
| 591 | * @note vA: TypeSize |
| 592 | * @note vB: destination and source |
| 593 | * @note vC: source |
| 594 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 595 | void GenAddVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 596 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 597 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 598 | * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the |
| 599 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 600 | * @param mir The MIR whose opcode is kMirConstVector. |
| 601 | * @note vA: TypeSize |
| 602 | * @note vB: destination and source |
| 603 | * @note vC: source |
| 604 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 605 | void GenSubtractVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 606 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 607 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 608 | * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the |
| 609 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 610 | * @param mir The MIR whose opcode is kMirConstVector. |
| 611 | * @note vA: TypeSize |
| 612 | * @note vB: destination and source |
| 613 | * @note vC: immediate |
| 614 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 615 | void GenShiftLeftVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 616 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 617 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 618 | * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to |
| 619 | * know the type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 620 | * @param mir The MIR whose opcode is kMirConstVector. |
| 621 | * @note vA: TypeSize |
| 622 | * @note vB: destination and source |
| 623 | * @note vC: immediate |
| 624 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 625 | void GenSignedShiftRightVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 626 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 627 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 628 | * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA |
| 629 | * to know the type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 630 | * @param mir The MIR whose opcode is kMirConstVector. |
| 631 | * @note vA: TypeSize |
| 632 | * @note vB: destination and source |
| 633 | * @note vC: immediate |
| 634 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 635 | void GenUnsignedShiftRightVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 636 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 637 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 638 | * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the |
| 639 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 640 | * @note vA: TypeSize |
| 641 | * @note vB: destination and source |
| 642 | * @note vC: source |
| 643 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 644 | void GenAndVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 645 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 646 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 647 | * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the |
| 648 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 649 | * @param mir The MIR whose opcode is kMirConstVector. |
| 650 | * @note vA: TypeSize |
| 651 | * @note vB: destination and source |
| 652 | * @note vC: source |
| 653 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 654 | void GenOrVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 655 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 656 | /* |
Yixin Shou | f40f890 | 2014-08-14 14:10:32 -0400 | [diff] [blame] | 657 | * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the |
| 658 | * type of the vector. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 659 | * @param mir The MIR whose opcode is kMirConstVector. |
| 660 | * @note vA: TypeSize |
| 661 | * @note vB: destination and source |
| 662 | * @note vC: source |
| 663 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 664 | void GenXorVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 665 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 666 | /* |
| 667 | * @brief Reduce a 128-bit packed element into a single VR by taking lower bits |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 668 | * @param mir The MIR whose opcode is kMirConstVector. |
| 669 | * @details Instruction does a horizontal addition of the packed elements and then adds it to VR. |
| 670 | * @note vA: TypeSize |
| 671 | * @note vB: destination and source VR (not vector register) |
| 672 | * @note vC: source (vector register) |
| 673 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 674 | void GenAddReduceVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 675 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 676 | /* |
| 677 | * @brief Extract a packed element into a single VR. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 678 | * @param mir The MIR whose opcode is kMirConstVector. |
| 679 | * @note vA: TypeSize |
| 680 | * @note vB: destination VR (not vector register) |
| 681 | * @note vC: source (vector register) |
| 682 | * @note arg[0]: The index to use for extraction from vector register (which packed element). |
| 683 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 684 | void GenReduceVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 685 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 686 | /* |
| 687 | * @brief Create a vector value, with all TypeSize values equal to vC |
| 688 | * @param bb The basic block in which the MIR is from. |
| 689 | * @param mir The MIR whose opcode is kMirConstVector. |
| 690 | * @note vA: TypeSize. |
| 691 | * @note vB: destination vector register. |
| 692 | * @note vC: source VR (not vector register). |
| 693 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 694 | void GenSetVector(MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 695 | |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 696 | /** |
| 697 | * @brief Used to generate code for kMirOpPackedArrayGet. |
| 698 | * @param bb The basic block of MIR. |
| 699 | * @param mir The mir whose opcode is kMirOpPackedArrayGet. |
| 700 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 701 | void GenPackedArrayGet(BasicBlock* bb, MIR* mir); |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 702 | |
| 703 | /** |
| 704 | * @brief Used to generate code for kMirOpPackedArrayPut. |
| 705 | * @param bb The basic block of MIR. |
| 706 | * @param mir The mir whose opcode is kMirOpPackedArrayPut. |
| 707 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 708 | void GenPackedArrayPut(BasicBlock* bb, MIR* mir); |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 709 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 710 | /* |
| 711 | * @brief Generate code for a vector opcode. |
| 712 | * @param bb The basic block in which the MIR is from. |
| 713 | * @param mir The MIR whose opcode is a non-standard opcode. |
| 714 | */ |
| 715 | void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir); |
Mark Mendell | fe94578 | 2014-05-22 09:52:36 -0400 | [diff] [blame] | 716 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 717 | /* |
| 718 | * @brief Return the correct x86 opcode for the Dex operation |
| 719 | * @param op Dex opcode for the operation |
| 720 | * @param loc Register location of the operand |
| 721 | * @param is_high_op 'true' if this is an operation on the high word |
| 722 | * @param value Immediate value for the operation. Used for byte variants |
| 723 | * @returns the correct x86 opcode to perform the operation |
| 724 | */ |
| 725 | X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value); |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 726 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 727 | /* |
| 728 | * @brief Return the correct x86 opcode for the Dex operation |
| 729 | * @param op Dex opcode for the operation |
| 730 | * @param dest location of the destination. May be register or memory. |
| 731 | * @param rhs Location for the rhs of the operation. May be in register or memory. |
| 732 | * @param is_high_op 'true' if this is an operation on the high word |
| 733 | * @returns the correct x86 opcode to perform the operation |
| 734 | * @note at most one location may refer to memory |
| 735 | */ |
| 736 | X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs, |
| 737 | bool is_high_op); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 738 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 739 | /* |
| 740 | * @brief Is this operation a no-op for this opcode and value |
| 741 | * @param op Dex opcode for the operation |
| 742 | * @param value Immediate value for the operation. |
| 743 | * @returns 'true' if the operation will have no effect |
| 744 | */ |
| 745 | bool IsNoOp(Instruction::Code op, int32_t value); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 746 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 747 | /** |
| 748 | * @brief Calculate magic number and shift for a given divisor |
| 749 | * @param divisor divisor number for calculation |
| 750 | * @param magic hold calculated magic number |
| 751 | * @param shift hold calculated shift |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 752 | * @param is_long 'true' if divisor is jlong, 'false' for jint. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 753 | */ |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 754 | void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long); |
Mark Mendell | e02d48f | 2014-01-15 11:19:23 -0800 | [diff] [blame] | 755 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 756 | /* |
| 757 | * @brief Generate an integer div or rem operation. |
| 758 | * @param rl_dest Destination Location. |
| 759 | * @param rl_src1 Numerator Location. |
| 760 | * @param rl_src2 Divisor Location. |
| 761 | * @param is_div 'true' if this is a division, 'false' for a remainder. |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 762 | * @param flags The instruction optimization flags. It can include information |
| 763 | * if exception check can be elided. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 764 | */ |
| 765 | RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 766 | bool is_div, int flags); |
Mark Mendell | 2bf31e6 | 2014-01-23 12:13:40 -0800 | [diff] [blame] | 767 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 768 | /* |
| 769 | * @brief Generate an integer div or rem operation by a literal. |
| 770 | * @param rl_dest Destination Location. |
| 771 | * @param rl_src Numerator Location. |
| 772 | * @param lit Divisor. |
| 773 | * @param is_div 'true' if this is a division, 'false' for a remainder. |
| 774 | */ |
| 775 | RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div); |
Mark Mendell | 2bf31e6 | 2014-01-23 12:13:40 -0800 | [diff] [blame] | 776 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 777 | /* |
| 778 | * Generate code to implement long shift operations. |
| 779 | * @param opcode The DEX opcode to specify the shift type. |
| 780 | * @param rl_dest The destination. |
| 781 | * @param rl_src The value to be shifted. |
| 782 | * @param shift_amount How much to shift. |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 783 | * @param flags The instruction optimization flags. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 784 | * @returns the RegLocation of the result. |
| 785 | */ |
| 786 | RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 787 | RegLocation rl_src, int shift_amount, int flags); |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 788 | /* |
| 789 | * Generate an imul of a register by a constant or a better sequence. |
| 790 | * @param dest Destination Register. |
| 791 | * @param src Source Register. |
| 792 | * @param val Constant multiplier. |
| 793 | */ |
| 794 | void GenImulRegImm(RegStorage dest, RegStorage src, int val); |
Mark Mendell | 4708dcd | 2014-01-22 09:05:18 -0800 | [diff] [blame] | 795 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 796 | /* |
| 797 | * Generate an imul of a memory location by a constant or a better sequence. |
| 798 | * @param dest Destination Register. |
| 799 | * @param sreg Symbolic register. |
| 800 | * @param displacement Displacement on stack of Symbolic Register. |
| 801 | * @param val Constant multiplier. |
| 802 | */ |
| 803 | void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val); |
Mark Mendell | feb2b4e | 2014-01-28 12:59:49 -0800 | [diff] [blame] | 804 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 805 | /* |
| 806 | * @brief Compare memory to immediate, and branch if condition true. |
| 807 | * @param cond The condition code that when true will branch to the target. |
| 808 | * @param temp_reg A temporary register that can be used if compare memory is not |
| 809 | * supported by the architecture. |
| 810 | * @param base_reg The register holding the base address. |
| 811 | * @param offset The offset from the base. |
| 812 | * @param check_value The immediate to compare to. |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame] | 813 | * @param target branch target (or nullptr) |
| 814 | * @param compare output for getting LIR for comparison (or nullptr) |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 815 | */ |
| 816 | LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg, |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame] | 817 | int offset, int check_value, LIR* target, LIR** compare); |
Mark Mendell | 766e929 | 2014-01-27 07:55:47 -0800 | [diff] [blame] | 818 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 819 | void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double); |
| 820 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 821 | /* |
| 822 | * Can this operation be using core registers without temporaries? |
| 823 | * @param rl_lhs Left hand operand. |
| 824 | * @param rl_rhs Right hand operand. |
| 825 | * @returns 'true' if the operation can proceed without needing temporary regs. |
| 826 | */ |
| 827 | bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs); |
Razvan A Lupusoru | 614c2b4 | 2014-01-28 17:05:21 -0800 | [diff] [blame] | 828 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 829 | /** |
| 830 | * @brief Generates inline code for conversion of long to FP by using x87/ |
| 831 | * @param rl_dest The destination of the FP. |
| 832 | * @param rl_src The source of the long. |
| 833 | * @param is_double 'true' if dealing with double, 'false' for float. |
| 834 | */ |
| 835 | virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 836 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 837 | void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset); |
| 838 | void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset); |
| 839 | |
| 840 | LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset); |
| 841 | LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value); |
| 842 | LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value); |
| 843 | LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset); |
| 844 | LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset); |
| 845 | void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset); |
| 846 | void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset); |
| 847 | void OpTlsCmp(ThreadOffset<4> offset, int val); |
| 848 | void OpTlsCmp(ThreadOffset<8> offset, int val); |
| 849 | |
| 850 | void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset); |
| 851 | |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 852 | // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail, |
| 853 | // in which case false will be returned. |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 854 | bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags); |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 855 | void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 856 | RegLocation rl_src2, int flags); |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 857 | void GenNotLong(RegLocation rl_dest, RegLocation rl_src); |
| 858 | void GenNegLong(RegLocation rl_dest, RegLocation rl_src); |
| 859 | void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1, |
Razvan A Lupusoru | 5c5676b | 2014-09-29 16:42:11 -0700 | [diff] [blame] | 860 | RegLocation rl_src2, bool is_div, int flags); |
Andreas Gampe | c76c614 | 2014-08-04 16:30:03 -0700 | [diff] [blame] | 861 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 862 | void SpillCoreRegs(); |
| 863 | void UnSpillCoreRegs(); |
| 864 | void UnSpillFPRegs(); |
| 865 | void SpillFPRegs(); |
| 866 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 867 | /* |
| 868 | * @brief Perform MIR analysis before compiling method. |
| 869 | * @note Invokes Mir2LiR::Materialize after analysis. |
| 870 | */ |
| 871 | void Materialize(); |
Razvan A Lupusoru | 614c2b4 | 2014-01-28 17:05:21 -0800 | [diff] [blame] | 872 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 873 | /* |
| 874 | * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register |
| 875 | * without regard to data type. In practice, this can result in UpdateLoc returning a |
| 876 | * location record for a Dalvik float value in a core register, and vis-versa. For targets |
| 877 | * which can inexpensively move data between core and float registers, this can often be a win. |
| 878 | * However, for x86 this is generally not a win. These variants of UpdateLoc() |
| 879 | * take a register class argument - and will return an in-register location record only if |
| 880 | * the value is live in a temp register of the correct class. Additionally, if the value is in |
| 881 | * a temp register of the wrong register class, it will be clobbered. |
| 882 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 883 | RegLocation UpdateLocTyped(RegLocation loc); |
| 884 | RegLocation UpdateLocWideTyped(RegLocation loc); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 885 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 886 | /* |
| 887 | * @brief Analyze MIR before generating code, to prepare for the code generation. |
| 888 | */ |
| 889 | void AnalyzeMIR(); |
buzbee | 30adc73 | 2014-05-09 15:10:18 -0700 | [diff] [blame] | 890 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 891 | /* |
| 892 | * @brief Analyze one basic block. |
| 893 | * @param bb Basic block to analyze. |
| 894 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 895 | void AnalyzeBB(BasicBlock* bb); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 896 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 897 | /* |
| 898 | * @brief Analyze one extended MIR instruction |
| 899 | * @param opcode MIR instruction opcode. |
| 900 | * @param bb Basic block containing instruction. |
| 901 | * @param mir Extended instruction to analyze. |
| 902 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 903 | void AnalyzeExtendedMIR(int opcode, BasicBlock* bb, MIR* mir); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 904 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 905 | /* |
| 906 | * @brief Analyze one MIR instruction |
| 907 | * @param opcode MIR instruction opcode. |
| 908 | * @param bb Basic block containing instruction. |
| 909 | * @param mir Instruction to analyze. |
| 910 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 911 | virtual void AnalyzeMIR(int opcode, BasicBlock* bb, MIR* mir); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 912 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 913 | /* |
| 914 | * @brief Analyze one MIR float/double instruction |
| 915 | * @param opcode MIR instruction opcode. |
| 916 | * @param bb Basic block containing instruction. |
| 917 | * @param mir Instruction to analyze. |
| 918 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 919 | virtual void AnalyzeFPInstruction(int opcode, BasicBlock* bb, MIR* mir); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 920 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 921 | /* |
| 922 | * @brief Analyze one use of a double operand. |
| 923 | * @param rl_use Double RegLocation for the operand. |
| 924 | */ |
| 925 | void AnalyzeDoubleUse(RegLocation rl_use); |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 926 | |
Yixin Shou | 7071c8d | 2014-03-05 06:07:48 -0500 | [diff] [blame] | 927 | /* |
| 928 | * @brief Analyze one invoke-static MIR instruction |
| 929 | * @param opcode MIR instruction opcode. |
| 930 | * @param bb Basic block containing instruction. |
| 931 | * @param mir Instruction to analyze. |
| 932 | */ |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 933 | void AnalyzeInvokeStatic(int opcode, BasicBlock* bb, MIR* mir); |
Yixin Shou | 7071c8d | 2014-03-05 06:07:48 -0500 | [diff] [blame] | 934 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 935 | // Information derived from analysis of MIR |
Dmitry Petrochenko | 9ee801f | 2014-05-12 11:31:37 +0700 | [diff] [blame] | 936 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 937 | // The compiler temporary for the code address of the method. |
| 938 | CompilerTemp *base_of_code_; |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 939 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 940 | // Have we decided to compute a ptr to code and store in temporary VR? |
| 941 | bool store_method_addr_; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 942 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 943 | // Have we used the stored method address? |
| 944 | bool store_method_addr_used_; |
Mark Mendell | 67c39c4 | 2014-01-31 17:28:00 -0800 | [diff] [blame] | 945 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 946 | // Instructions to remove if we didn't use the stored method address. |
| 947 | LIR* setup_method_address_[2]; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 948 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 949 | // Instructions needing patching with Method* values. |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 950 | ArenaVector<LIR*> method_address_insns_; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 951 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 952 | // Instructions needing patching with Class Type* values. |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 953 | ArenaVector<LIR*> class_type_address_insns_; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 954 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 955 | // Instructions needing patching with PC relative code addresses. |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 956 | ArenaVector<LIR*> call_method_insns_; |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 957 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 958 | // Prologue decrement of stack pointer. |
| 959 | LIR* stack_decrement_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 960 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 961 | // Epilogue increment of stack pointer. |
| 962 | LIR* stack_increment_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 963 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 964 | // The list of const vector literals. |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 965 | LIR* const_vectors_; |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 966 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 967 | /* |
| 968 | * @brief Search for a matching vector literal |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 969 | * @param constants An array of size 4 which contains all of 32-bit constants. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 970 | * @returns pointer to matching LIR constant, or nullptr if not found. |
| 971 | */ |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 972 | LIR* ScanVectorLiteral(int32_t* constants); |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 973 | |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 974 | /* |
| 975 | * @brief Add a constant vector literal |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 976 | * @param constants An array of size 4 which contains all of 32-bit constants. |
Ian Rogers | 0f9b9c5 | 2014-06-09 01:32:12 -0700 | [diff] [blame] | 977 | */ |
Lupusoru, Razvan A | b3a84e2 | 2014-07-28 14:11:01 -0700 | [diff] [blame] | 978 | LIR* AddVectorLiteral(int32_t* constants); |
Mark Mendell | d65c51a | 2014-04-29 16:55:20 -0400 | [diff] [blame] | 979 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 980 | bool WideGPRsAreAliases() const OVERRIDE { |
Serguei Katkov | 59a42af | 2014-07-05 00:55:46 +0700 | [diff] [blame] | 981 | return cu_->target64; // On 64b, we have 64b GPRs. |
| 982 | } |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 983 | |
| 984 | bool WideFPRsAreAliases() const OVERRIDE { |
Serguei Katkov | 59a42af | 2014-07-05 00:55:46 +0700 | [diff] [blame] | 985 | return true; // xmm registers have 64b views even on x86. |
| 986 | } |
| 987 | |
Alexei Zavjalov | 6bbf096 | 2014-07-15 02:19:41 +0700 | [diff] [blame] | 988 | /* |
| 989 | * @brief Dump a RegLocation using printf |
| 990 | * @param loc Register location to dump |
| 991 | */ |
| 992 | static void DumpRegLocation(RegLocation loc); |
| 993 | |
Udayan Banerji | 60bfe7b | 2014-07-08 19:59:43 -0700 | [diff] [blame] | 994 | private: |
Yixin Shou | 8c914c0 | 2014-07-28 14:17:09 -0400 | [diff] [blame] | 995 | void SwapBits(RegStorage result_reg, int shift, int32_t value); |
| 996 | void SwapBits64(RegStorage result_reg, int shift, int64_t value); |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 997 | |
| 998 | static const X86EncodingMap EncodingMap[kX86Last]; |
| 999 | |
| 1000 | friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs); |
| 1001 | |
| 1002 | DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1003 | }; |
| 1004 | |
| 1005 | } // namespace art |
| 1006 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 1007 | #endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ |