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