blob: 811d4f5d7b906eae2179d21904d57a4cc587020c [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_
18#define ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
Andreas Gampe0b9203e2015-01-22 20:39:27 -080020#include "base/logging.h"
21#include "dex/compiler_ir.h"
22#include "dex/mir_graph.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070023#include "dex/quick/mir_to_lir.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070024#include "x86_lir.h"
25
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070026#include <map>
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070027#include <vector>
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070028
Brian Carlstrom7940e442013-07-12 13:46:57 -070029namespace art {
30
Mark Mendelle87f9b52014-04-30 14:13:18 -040031class X86Mir2Lir : public Mir2Lir {
Ian Rogers0f9b9c52014-06-09 01:32:12 -070032 protected:
Ian Rogers0f9b9c52014-06-09 01:32:12 -070033 class InToRegStorageX86_64Mapper : public InToRegStorageMapper {
34 public:
Serguei Katkov717a3e42014-11-13 17:19:42 +060035 explicit InToRegStorageX86_64Mapper(Mir2Lir* m2l)
36 : m2l_(m2l), cur_core_reg_(0), cur_fp_reg_(0) {}
37 virtual RegStorage GetNextReg(ShortyArg arg);
38 virtual void Reset() OVERRIDE {
39 cur_core_reg_ = 0;
40 cur_fp_reg_ = 0;
41 }
Chao-ying Fua77ee512014-07-01 17:43:41 -070042 protected:
Serguei Katkov717a3e42014-11-13 17:19:42 +060043 Mir2Lir* m2l_;
Serguei Katkov717a3e42014-11-13 17:19:42 +060044 size_t cur_core_reg_;
45 size_t cur_fp_reg_;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070046 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070047
Mark Mendell3d2c8e72015-01-13 17:32:55 -050048 class InToRegStorageX86Mapper : public InToRegStorageX86_64Mapper {
Ian Rogers0f9b9c52014-06-09 01:32:12 -070049 public:
Mark Mendell3d2c8e72015-01-13 17:32:55 -050050 explicit InToRegStorageX86Mapper(Mir2Lir* m2l)
51 : InToRegStorageX86_64Mapper(m2l) { }
Serguei Katkov717a3e42014-11-13 17:19:42 +060052 virtual RegStorage GetNextReg(ShortyArg arg);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070053 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070054
Serguei Katkov717a3e42014-11-13 17:19:42 +060055 InToRegStorageX86_64Mapper in_to_reg_storage_x86_64_mapper_;
56 InToRegStorageX86Mapper in_to_reg_storage_x86_mapper_;
57 InToRegStorageMapper* GetResetedInToRegStorageMapper() OVERRIDE {
58 InToRegStorageMapper* res;
59 if (cu_->target64) {
60 res = &in_to_reg_storage_x86_64_mapper_;
61 } else {
62 res = &in_to_reg_storage_x86_mapper_;
63 }
64 res->Reset();
65 return res;
66 }
67
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070068 class ExplicitTempRegisterLock {
69 public:
70 ExplicitTempRegisterLock(X86Mir2Lir* mir_to_lir, int n_regs, ...);
71 ~ExplicitTempRegisterLock();
72 protected:
73 std::vector<RegStorage> temp_regs_;
74 X86Mir2Lir* const mir_to_lir_;
75 };
76
Serguei Katkov717a3e42014-11-13 17:19:42 +060077 virtual int GenDalvikArgsBulkCopy(CallInfo* info, int first, int count) OVERRIDE;
78
Ian Rogers0f9b9c52014-06-09 01:32:12 -070079 public:
Elena Sayapinadd644502014-07-01 18:39:52 +070080 X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
Brian Carlstrom7940e442013-07-12 13:46:57 -070081
Ian Rogers0f9b9c52014-06-09 01:32:12 -070082 // Required for target - codegen helpers.
83 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +070084 RegLocation rl_dest, int lit) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070085 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Ningsheng Jian675e09b2014-10-23 13:48:36 +080086 void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1,
87 int32_t constant) OVERRIDE;
88 void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1,
89 int64_t constant) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070090 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -070091 RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070092 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
Andreas Gampe3c12c512014-06-24 18:46:29 +000093 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070094 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010095 OpSize size) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070096 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
97 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Yevgeny Rouban6af82062014-11-26 18:11:54 +060098 void GenLongToInt(RegLocation rl_dest, RegLocation rl_src);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070099 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +0000100 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700101 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
102 OpSize size) OVERRIDE;
Vladimir Markobf535be2014-11-19 18:52:35 +0000103
104 /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage)
105 void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE;
106
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700107 void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700108
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700109 // Required for target - register utilities.
Chao-ying Fua77ee512014-07-01 17:43:41 -0700110 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700111 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
112 if (wide_kind == kWide) {
113 if (cu_->target64) {
114 return As64BitReg(TargetReg32(symbolic_reg));
115 } else {
Mark Mendell3d2c8e72015-01-13 17:32:55 -0500116 if (symbolic_reg >= kFArg0 && symbolic_reg <= kFArg3) {
117 // We want an XMM, not a pair.
118 return As64BitReg(TargetReg32(symbolic_reg));
119 }
Andreas Gampeccc60262014-07-04 18:02:38 -0700120 // x86: construct a pair.
121 DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) ||
Andreas Gampeccc60262014-07-04 18:02:38 -0700122 (kRet0 == symbolic_reg));
123 return RegStorage::MakeRegPair(TargetReg32(symbolic_reg),
124 TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1)));
125 }
126 } else if (wide_kind == kRef && cu_->target64) {
127 return As64BitReg(TargetReg32(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700128 } else {
Andreas Gampeccc60262014-07-04 18:02:38 -0700129 return TargetReg32(symbolic_reg);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700130 }
131 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700132 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700133 return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700134 }
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700135
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700136 RegLocation GetReturnAlt() OVERRIDE;
137 RegLocation GetReturnWideAlt() OVERRIDE;
138 RegLocation LocCReturn() OVERRIDE;
139 RegLocation LocCReturnRef() OVERRIDE;
140 RegLocation LocCReturnDouble() OVERRIDE;
141 RegLocation LocCReturnFloat() OVERRIDE;
142 RegLocation LocCReturnWide() OVERRIDE;
143
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100144 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700145 void AdjustSpillMask() OVERRIDE;
146 void ClobberCallerSave() OVERRIDE;
147 void FreeCallTemps() OVERRIDE;
148 void LockCallTemps() OVERRIDE;
149
150 void CompilerInitializeRegAlloc() OVERRIDE;
151 int VectorRegisterSize() OVERRIDE;
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700152 int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700153
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700154 // Required for target - miscellaneous.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700155 void AssembleLIR() OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100156 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
157 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
158 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700159 const char* GetTargetInstFmt(int opcode) OVERRIDE;
160 const char* GetTargetInstName(int opcode) OVERRIDE;
161 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100162 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700163 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
Ian Rogers5aa6e042014-06-13 16:38:24 -0700164 size_t GetInsnSize(LIR* lir) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700165 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700166
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700167 // Get the register class for load/store of a field.
168 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100169
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700170 // Required for target - Dalvik-level generators.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700171 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700172 RegLocation rl_dest, int scale) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700173 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700174 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
175
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700176 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700177 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700178 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700179 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700180 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700181 RegLocation rl_src2) OVERRIDE;
182 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
183
184 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
185 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
186 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
Yixin Shou8c914c02014-07-28 14:17:09 -0400187 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700188 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
Yixin Shou7071c8d2014-03-05 06:07:48 -0500189 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
190 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700191 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
192 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -0700193 bool GenInlinedCharAt(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700194
195 // Long instructions.
Andreas Gampec76c6142014-08-04 16:30:03 -0700196 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700197 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700198 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700199 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700200 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700201 RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700202 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
203 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
204 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
205 RegLocation rl_src1, RegLocation rl_shift) OVERRIDE;
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800206
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700207 /*
208 * @brief Generate a two address long operation with a constant value
209 * @param rl_dest location of result
210 * @param rl_src constant source operand
211 * @param op Opcode to be generated
212 * @return success or not
213 */
214 bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700215
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700216 /*
217 * @brief Generate a three address long operation with a constant value
218 * @param rl_dest location of result
219 * @param rl_src1 source operand
220 * @param rl_src2 constant source operand
221 * @param op Opcode to be generated
222 * @return success or not
223 */
224 bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
225 Instruction::Code op);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700226 /**
227 * @brief Generate a long arithmetic operation.
228 * @param rl_dest The destination.
229 * @param rl_src1 First operand.
230 * @param rl_src2 Second operand.
231 * @param op The DEX opcode for the operation.
232 * @param is_commutative The sources can be swapped if needed.
233 */
234 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
235 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800236
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700237 /**
238 * @brief Generate a two operand long arithmetic operation.
239 * @param rl_dest The destination.
240 * @param rl_src Second operand.
241 * @param op The DEX opcode for the operation.
242 */
243 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800244
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700245 /**
246 * @brief Generate a long operation.
247 * @param rl_dest The destination. Must be in a register
248 * @param rl_src The other operand. May be in a register or in memory.
249 * @param op The DEX opcode for the operation.
250 */
251 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700252
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700253
254 // TODO: collapse reg_lo, reg_hi
255 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
256 OVERRIDE;
257 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE;
258 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
259 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
260 void GenExitSequence() OVERRIDE;
261 void GenSpecialExitSequence() OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700262 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
263 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
264 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
265 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
266 int32_t true_val, int32_t false_val, RegStorage rs_dest,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700267 RegisterClass dest_reg_class) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700268 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
269 void GenMoveException(RegLocation rl_dest) OVERRIDE;
270 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
271 int first_bit, int second_bit) OVERRIDE;
272 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
273 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Chao-ying Fuda96aed2014-10-27 14:42:00 -0700274 const uint16_t* ConvertPackedSwitchTable(MIR* mir, const uint16_t* table);
Andreas Gampe48971b32014-08-06 10:09:01 -0700275 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
276 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Chao-ying Fuda96aed2014-10-27 14:42:00 -0700277 LIR* InsertCaseLabel(DexOffset vaddr, int keyVal) OVERRIDE;
278 void MarkPackedCaseLabels(Mir2Lir::SwitchTable* tab_rec) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700279
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700280 /**
281 * @brief Implement instanceof a final class with x86 specific code.
282 * @param use_declaring_class 'true' if we can use the class itself.
283 * @param type_idx Type index to use if use_declaring_class is 'false'.
284 * @param rl_dest Result to be set to 0 or 1.
285 * @param rl_src Object to be tested.
286 */
287 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700288 RegLocation rl_src) OVERRIDE;
Chao-ying Fua0147762014-06-06 18:38:49 -0700289
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700290 // Single operation generators.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700291 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
292 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
293 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
294 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
295 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
296 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
297 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
298 void OpEndIT(LIR* it) OVERRIDE;
299 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
300 LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
301 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
302 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
303 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
304 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
305 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
306 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
307 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
308 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
309 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
310 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
311 LIR* OpTestSuspend(LIR* target) OVERRIDE;
312 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
313 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
314 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
315 bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700316
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700317 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
318 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
319 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
320 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700321
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700322 /*
323 * @brief Should try to optimize for two address instructions?
324 * @return true if we try to avoid generating three operand instructions.
325 */
326 virtual bool GenerateTwoOperandInstructions() const { return true; }
Mark Mendelle87f9b52014-04-30 14:13:18 -0400327
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700328 /*
329 * @brief x86 specific codegen for int operations.
330 * @param opcode Operation to perform.
331 * @param rl_dest Destination for the result.
332 * @param rl_lhs Left hand operand.
333 * @param rl_rhs Right hand operand.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700334 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700335 */
336 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700337 RegLocation rl_rhs, int flags) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800338
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700339 /*
340 * @brief Load the Method* of a dex method into the register.
341 * @param target_method The MethodReference of the method to be invoked.
342 * @param type How the method will be invoked.
343 * @param register that will contain the code address.
344 * @note register will be passed to TargetReg to get physical register.
345 */
346 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700347 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800348
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700349 /*
350 * @brief Load the Class* of a Dex Class type into the register.
Fred Shihe7f82e22014-08-06 10:46:37 -0700351 * @param dex DexFile that contains the class type.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700352 * @param type How the method will be invoked.
353 * @param register that will contain the code address.
354 * @note register will be passed to TargetReg to get physical register.
355 */
Fred Shihe7f82e22014-08-06 10:46:37 -0700356 void LoadClassType(const DexFile& dex_file, uint32_t type_idx,
357 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800358
Vladimir Markof4da6752014-08-01 19:04:18 +0100359 NextCallInsn GetNextSDCallInsn() OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800360
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700361 /*
362 * @brief Generate a relative call to the method that will be patched at link time.
363 * @param target_method The MethodReference of the method to be invoked.
364 * @param type How the method will be invoked.
365 * @returns Call instruction
366 */
Vladimir Markof4da6752014-08-01 19:04:18 +0100367 LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
368
369 /*
370 * @brief Generate the actual call insn based on the method info.
371 * @param method_info the lowering info for the method call.
372 * @returns Call instruction
373 */
374 LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800375
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700376 /*
377 * @brief Handle x86 specific literals
378 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700379 void InstallLiteralPools() OVERRIDE;
Mark Mendellae9fd932014-02-10 16:14:35 -0800380
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700381 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700382 * @brief Generate the debug_frame FDE information.
383 * @returns pointer to vector containing CFE information
384 */
Tong Shen547cdfd2014-08-05 01:54:19 -0700385 std::vector<uint8_t>* ReturnFrameDescriptionEntry() OVERRIDE;
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800386
Andreas Gampe98430592014-07-27 19:44:50 -0700387 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
388
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700389 protected:
Ian Rogersb28c1c02014-11-08 11:21:21 -0800390 RegStorage TargetReg32(SpecialTargetRegister reg) const;
Chao-ying Fua77ee512014-07-01 17:43:41 -0700391 // Casting of RegStorage
392 RegStorage As32BitReg(RegStorage reg) {
393 DCHECK(!reg.IsPair());
394 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
395 if (kFailOnSizeError) {
396 LOG(FATAL) << "Expected 64b register " << reg.GetReg();
397 } else {
398 LOG(WARNING) << "Expected 64b register " << reg.GetReg();
399 return reg;
400 }
401 }
402 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
403 reg.GetRawBits() & RegStorage::kRegTypeMask);
404 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
405 ->GetReg().GetReg(),
406 ret_val.GetReg());
407 return ret_val;
408 }
409
410 RegStorage As64BitReg(RegStorage reg) {
411 DCHECK(!reg.IsPair());
412 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
413 if (kFailOnSizeError) {
414 LOG(FATAL) << "Expected 32b register " << reg.GetReg();
415 } else {
416 LOG(WARNING) << "Expected 32b register " << reg.GetReg();
417 return reg;
418 }
419 }
420 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
421 reg.GetRawBits() & RegStorage::kRegTypeMask);
422 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
423 ->GetReg().GetReg(),
424 ret_val.GetReg());
425 return ret_val;
426 }
427
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700428 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
429 RegStorage r_dest, OpSize size);
430 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700431 RegStorage r_src, OpSize size, int opt_flags = 0);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700432
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700433 int AssignInsnOffsets();
434 void AssignOffsets();
435 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
436
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700437 size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700438 int32_t raw_base, int32_t displacement);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700439 void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg);
440 void EmitPrefix(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700441 int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700442 void EmitOpcode(const X86EncodingMap* entry);
443 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700444 int32_t reg_r, int32_t reg_x, int32_t reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700445 void EmitDisp(uint8_t base, int32_t disp);
446 void EmitModrmThread(uint8_t reg_or_opcode);
447 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp);
448 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale,
449 int32_t disp);
450 void EmitImm(const X86EncodingMap* entry, int64_t imm);
451 void EmitNullary(const X86EncodingMap* entry);
452 void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg);
453 void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg);
454 void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
455 void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
456 int32_t disp);
457 void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg);
458 void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp);
459 void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base,
460 int32_t raw_index, int scale, int32_t disp);
461 void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
462 int32_t disp, int32_t raw_reg);
463 void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
464 void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
465 int32_t raw_disp, int32_t imm);
466 void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp);
467 void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2);
468 void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm);
469 void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
470 int32_t imm);
471 void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1,
472 int32_t imm);
473 void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
474 void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm);
475 void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm);
476 void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
477 void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl);
478 void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl);
Yixin Shouf40f8902014-08-14 14:10:32 -0400479 void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2,
480 int32_t raw_cl);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700481 void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
482 void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc);
483 void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc);
484 void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc);
485 void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
486 int32_t cc);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800487
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700488 void EmitJmp(const X86EncodingMap* entry, int32_t rel);
489 void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc);
490 void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
491 void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp);
492 void EmitCallThread(const X86EncodingMap* entry, int32_t disp);
493 void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table,
494 int32_t raw_index, int scale, int32_t table_or_disp);
495 void EmitMacro(const X86EncodingMap* entry, int32_t raw_reg, int32_t offset);
496 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
497 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
498 int64_t val, ConditionCode ccode);
499 void GenConstWide(RegLocation rl_dest, int64_t value);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700500 void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2);
501 void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700502 void GenShiftByteVector(MIR* mir);
Yixin Shouf40f8902014-08-14 14:10:32 -0400503 void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3,
504 uint32_t m4);
505 void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2,
506 uint32_t m3, uint32_t m4);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700507 void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir);
Mark Mendell0a1174e2014-09-11 14:51:02 -0400508 virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize,
509 int op_mov);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400510
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700511 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800512
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700513 /*
514 * @brief Ensure that a temporary register is byte addressable.
515 * @returns a temporary guarenteed to be byte addressable.
516 */
517 virtual RegStorage AllocateByteRegister();
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800518
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700519 /*
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700520 * @brief Use a wide temporary as a 128-bit register
521 * @returns a 128-bit temporary register.
522 */
523 virtual RegStorage Get128BitRegister(RegStorage reg);
524
525 /*
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700526 * @brief Check if a register is byte addressable.
527 * @returns true if a register is byte addressable.
528 */
Ian Rogersb28c1c02014-11-08 11:21:21 -0800529 bool IsByteRegister(RegStorage reg) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700530
531 void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div);
532
DaniilSokolov70c4f062014-06-24 17:34:00 -0700533 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700534
535 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700536 * @brief generate inline code for fast case of Strng.indexOf.
537 * @param info Call parameters
538 * @param zero_based 'true' if the index into the string is 0.
539 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
540 * generated.
541 */
542 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
Mark Mendelle87f9b52014-04-30 14:13:18 -0400543
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700544 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700545 * @brief Used to reserve a range of vector registers.
546 * @see kMirOpReserveVectorRegisters
547 * @param mir The extended MIR for reservation.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700548 */
549 void ReserveVectorRegisters(MIR* mir);
550
551 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700552 * @brief Used to return a range of vector registers.
553 * @see kMirOpReturnVectorRegisters
554 * @param mir The extended MIR for returning vector regs.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700555 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700556 void ReturnVectorRegisters(MIR* mir);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700557
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700558 /*
559 * @brief Load 128 bit constant into vector register.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700560 * @param mir The MIR whose opcode is kMirConstVector
561 * @note vA is the TypeSize for the register.
562 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
563 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700564 void GenConst128(MIR* mir);
Mark Mendell4028a6c2014-02-19 20:06:20 -0800565
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700566 /*
567 * @brief MIR to move a vectorized register to another.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700568 * @param mir The MIR whose opcode is kMirConstVector.
569 * @note vA: TypeSize
570 * @note vB: destination
571 * @note vC: source
572 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700573 void GenMoveVector(MIR* mir);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400574
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700575 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400576 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know
577 * the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700578 * @param mir The MIR whose opcode is kMirConstVector.
579 * @note vA: TypeSize
580 * @note vB: destination and source
581 * @note vC: source
582 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700583 void GenMultiplyVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400584
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700585 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400586 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the
587 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700588 * @param mir The MIR whose opcode is kMirConstVector.
589 * @note vA: TypeSize
590 * @note vB: destination and source
591 * @note vC: source
592 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700593 void GenAddVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400594
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700595 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400596 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the
597 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700598 * @param mir The MIR whose opcode is kMirConstVector.
599 * @note vA: TypeSize
600 * @note vB: destination and source
601 * @note vC: source
602 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700603 void GenSubtractVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400604
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700605 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400606 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the
607 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700608 * @param mir The MIR whose opcode is kMirConstVector.
609 * @note vA: TypeSize
610 * @note vB: destination and source
611 * @note vC: immediate
612 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700613 void GenShiftLeftVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400614
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700615 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400616 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to
617 * know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700618 * @param mir The MIR whose opcode is kMirConstVector.
619 * @note vA: TypeSize
620 * @note vB: destination and source
621 * @note vC: immediate
622 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700623 void GenSignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400624
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700625 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400626 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA
627 * to know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700628 * @param mir The MIR whose opcode is kMirConstVector.
629 * @note vA: TypeSize
630 * @note vB: destination and source
631 * @note vC: immediate
632 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700633 void GenUnsignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400634
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700635 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400636 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the
637 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700638 * @note vA: TypeSize
639 * @note vB: destination and source
640 * @note vC: source
641 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700642 void GenAndVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400643
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700644 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400645 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the
646 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700647 * @param mir The MIR whose opcode is kMirConstVector.
648 * @note vA: TypeSize
649 * @note vB: destination and source
650 * @note vC: source
651 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700652 void GenOrVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400653
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700654 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400655 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the
656 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700657 * @param mir The MIR whose opcode is kMirConstVector.
658 * @note vA: TypeSize
659 * @note vB: destination and source
660 * @note vC: source
661 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700662 void GenXorVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400663
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700664 /*
665 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700666 * @param mir The MIR whose opcode is kMirConstVector.
667 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
668 * @note vA: TypeSize
669 * @note vB: destination and source VR (not vector register)
670 * @note vC: source (vector register)
671 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700672 void GenAddReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400673
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700674 /*
675 * @brief Extract a packed element into a single VR.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700676 * @param mir The MIR whose opcode is kMirConstVector.
677 * @note vA: TypeSize
678 * @note vB: destination VR (not vector register)
679 * @note vC: source (vector register)
680 * @note arg[0]: The index to use for extraction from vector register (which packed element).
681 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700682 void GenReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400683
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700684 /*
685 * @brief Create a vector value, with all TypeSize values equal to vC
686 * @param bb The basic block in which the MIR is from.
687 * @param mir The MIR whose opcode is kMirConstVector.
688 * @note vA: TypeSize.
689 * @note vB: destination vector register.
690 * @note vC: source VR (not vector register).
691 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700692 void GenSetVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400693
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700694 /**
695 * @brief Used to generate code for kMirOpPackedArrayGet.
696 * @param bb The basic block of MIR.
697 * @param mir The mir whose opcode is kMirOpPackedArrayGet.
698 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700699 void GenPackedArrayGet(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700700
701 /**
702 * @brief Used to generate code for kMirOpPackedArrayPut.
703 * @param bb The basic block of MIR.
704 * @param mir The mir whose opcode is kMirOpPackedArrayPut.
705 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700706 void GenPackedArrayPut(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700707
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700708 /*
709 * @brief Generate code for a vector opcode.
710 * @param bb The basic block in which the MIR is from.
711 * @param mir The MIR whose opcode is a non-standard opcode.
712 */
713 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400714
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700715 /*
716 * @brief Return the correct x86 opcode for the Dex operation
717 * @param op Dex opcode for the operation
718 * @param loc Register location of the operand
719 * @param is_high_op 'true' if this is an operation on the high word
720 * @param value Immediate value for the operation. Used for byte variants
721 * @returns the correct x86 opcode to perform the operation
722 */
723 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400724
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700725 /*
726 * @brief Return the correct x86 opcode for the Dex operation
727 * @param op Dex opcode for the operation
728 * @param dest location of the destination. May be register or memory.
729 * @param rhs Location for the rhs of the operation. May be in register or memory.
730 * @param is_high_op 'true' if this is an operation on the high word
731 * @returns the correct x86 opcode to perform the operation
732 * @note at most one location may refer to memory
733 */
734 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
735 bool is_high_op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800736
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700737 /*
738 * @brief Is this operation a no-op for this opcode and value
739 * @param op Dex opcode for the operation
740 * @param value Immediate value for the operation.
741 * @returns 'true' if the operation will have no effect
742 */
743 bool IsNoOp(Instruction::Code op, int32_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800744
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700745 /**
746 * @brief Calculate magic number and shift for a given divisor
747 * @param divisor divisor number for calculation
748 * @param magic hold calculated magic number
749 * @param shift hold calculated shift
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700750 * @param is_long 'true' if divisor is jlong, 'false' for jint.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700751 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700752 void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800753
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700754 /*
755 * @brief Generate an integer div or rem operation.
756 * @param rl_dest Destination Location.
757 * @param rl_src1 Numerator Location.
758 * @param rl_src2 Divisor Location.
759 * @param is_div 'true' if this is a division, 'false' for a remainder.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700760 * @param flags The instruction optimization flags. It can include information
761 * if exception check can be elided.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700762 */
763 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700764 bool is_div, int flags);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800765
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700766 /*
767 * @brief Generate an integer div or rem operation by a literal.
768 * @param rl_dest Destination Location.
769 * @param rl_src Numerator Location.
770 * @param lit Divisor.
771 * @param is_div 'true' if this is a division, 'false' for a remainder.
772 */
773 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800774
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700775 /*
776 * Generate code to implement long shift operations.
777 * @param opcode The DEX opcode to specify the shift type.
778 * @param rl_dest The destination.
779 * @param rl_src The value to be shifted.
780 * @param shift_amount How much to shift.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700781 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700782 * @returns the RegLocation of the result.
783 */
784 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700785 RegLocation rl_src, int shift_amount, int flags);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700786 /*
787 * Generate an imul of a register by a constant or a better sequence.
788 * @param dest Destination Register.
789 * @param src Source Register.
790 * @param val Constant multiplier.
791 */
792 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800793
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700794 /*
795 * Generate an imul of a memory location by a constant or a better sequence.
796 * @param dest Destination Register.
797 * @param sreg Symbolic register.
798 * @param displacement Displacement on stack of Symbolic Register.
799 * @param val Constant multiplier.
800 */
801 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800802
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700803 /*
804 * @brief Compare memory to immediate, and branch if condition true.
805 * @param cond The condition code that when true will branch to the target.
806 * @param temp_reg A temporary register that can be used if compare memory is not
807 * supported by the architecture.
808 * @param base_reg The register holding the base address.
809 * @param offset The offset from the base.
810 * @param check_value The immediate to compare to.
Dave Allison69dfe512014-07-11 17:11:58 +0000811 * @param target branch target (or nullptr)
812 * @param compare output for getting LIR for comparison (or nullptr)
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700813 */
814 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +0000815 int offset, int check_value, LIR* target, LIR** compare);
Mark Mendell766e9292014-01-27 07:55:47 -0800816
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700817 void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double);
818
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700819 /*
820 * Can this operation be using core registers without temporaries?
821 * @param rl_lhs Left hand operand.
822 * @param rl_rhs Right hand operand.
823 * @returns 'true' if the operation can proceed without needing temporary regs.
824 */
825 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800826
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700827 /**
828 * @brief Generates inline code for conversion of long to FP by using x87/
829 * @param rl_dest The destination of the FP.
830 * @param rl_src The source of the long.
831 * @param is_double 'true' if dealing with double, 'false' for float.
832 */
833 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Mark Mendell67c39c42014-01-31 17:28:00 -0800834
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700835 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
836 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
837
838 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
839 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
840 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
841 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset);
842 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset);
843 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
844 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
845 void OpTlsCmp(ThreadOffset<4> offset, int val);
846 void OpTlsCmp(ThreadOffset<8> offset, int val);
847
848 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
849
Andreas Gampec76c6142014-08-04 16:30:03 -0700850 // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail,
851 // in which case false will be returned.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700852 bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700853 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700854 RegLocation rl_src2, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700855 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
856 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
857 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700858 RegLocation rl_src2, bool is_div, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700859
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700860 void SpillCoreRegs();
861 void UnSpillCoreRegs();
862 void UnSpillFPRegs();
863 void SpillFPRegs();
864
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700865 /*
866 * @brief Perform MIR analysis before compiling method.
867 * @note Invokes Mir2LiR::Materialize after analysis.
868 */
869 void Materialize();
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800870
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700871 /*
872 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
873 * without regard to data type. In practice, this can result in UpdateLoc returning a
874 * location record for a Dalvik float value in a core register, and vis-versa. For targets
875 * which can inexpensively move data between core and float registers, this can often be a win.
876 * However, for x86 this is generally not a win. These variants of UpdateLoc()
877 * take a register class argument - and will return an in-register location record only if
878 * the value is live in a temp register of the correct class. Additionally, if the value is in
879 * a temp register of the wrong register class, it will be clobbered.
880 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700881 RegLocation UpdateLocTyped(RegLocation loc);
882 RegLocation UpdateLocWideTyped(RegLocation loc);
Mark Mendell67c39c42014-01-31 17:28:00 -0800883
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700884 /*
885 * @brief Analyze MIR before generating code, to prepare for the code generation.
886 */
887 void AnalyzeMIR();
buzbee30adc732014-05-09 15:10:18 -0700888
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700889 /*
890 * @brief Analyze one basic block.
891 * @param bb Basic block to analyze.
892 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700893 void AnalyzeBB(BasicBlock* bb);
Mark Mendell67c39c42014-01-31 17:28:00 -0800894
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700895 /*
896 * @brief Analyze one extended MIR instruction
897 * @param opcode MIR instruction opcode.
898 * @param bb Basic block containing instruction.
899 * @param mir Extended instruction to analyze.
900 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700901 void AnalyzeExtendedMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800902
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700903 /*
904 * @brief Analyze one MIR instruction
905 * @param opcode MIR instruction opcode.
906 * @param bb Basic block containing instruction.
907 * @param mir Instruction to analyze.
908 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700909 virtual void AnalyzeMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800910
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700911 /*
912 * @brief Analyze one MIR float/double instruction
913 * @param opcode MIR instruction opcode.
914 * @param bb Basic block containing instruction.
915 * @param mir Instruction to analyze.
916 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700917 virtual void AnalyzeFPInstruction(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800918
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700919 /*
920 * @brief Analyze one use of a double operand.
921 * @param rl_use Double RegLocation for the operand.
922 */
923 void AnalyzeDoubleUse(RegLocation rl_use);
Mark Mendell67c39c42014-01-31 17:28:00 -0800924
Yixin Shou7071c8d2014-03-05 06:07:48 -0500925 /*
926 * @brief Analyze one invoke-static MIR instruction
927 * @param opcode MIR instruction opcode.
928 * @param bb Basic block containing instruction.
929 * @param mir Instruction to analyze.
930 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700931 void AnalyzeInvokeStatic(int opcode, BasicBlock* bb, MIR* mir);
Yixin Shou7071c8d2014-03-05 06:07:48 -0500932
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700933 // Information derived from analysis of MIR
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700934
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700935 // The compiler temporary for the code address of the method.
936 CompilerTemp *base_of_code_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800937
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700938 // Have we decided to compute a ptr to code and store in temporary VR?
939 bool store_method_addr_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800940
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700941 // Have we used the stored method address?
942 bool store_method_addr_used_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800943
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700944 // Instructions to remove if we didn't use the stored method address.
945 LIR* setup_method_address_[2];
Mark Mendell55d0eac2014-02-06 11:02:52 -0800946
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700947 // Instructions needing patching with Method* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100948 ArenaVector<LIR*> method_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800949
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700950 // Instructions needing patching with Class Type* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100951 ArenaVector<LIR*> class_type_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800952
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700953 // Instructions needing patching with PC relative code addresses.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100954 ArenaVector<LIR*> call_method_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800955
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700956 // Prologue decrement of stack pointer.
957 LIR* stack_decrement_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800958
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700959 // Epilogue increment of stack pointer.
960 LIR* stack_increment_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800961
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700962 // The list of const vector literals.
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700963 LIR* const_vectors_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400964
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700965 /*
966 * @brief Search for a matching vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700967 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700968 * @returns pointer to matching LIR constant, or nullptr if not found.
969 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700970 LIR* ScanVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400971
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700972 /*
973 * @brief Add a constant vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700974 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700975 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700976 LIR* AddVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400977
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700978 bool WideGPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700979 return cu_->target64; // On 64b, we have 64b GPRs.
980 }
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700981
982 bool WideFPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700983 return true; // xmm registers have 64b views even on x86.
984 }
985
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700986 /*
987 * @brief Dump a RegLocation using printf
988 * @param loc Register location to dump
989 */
990 static void DumpRegLocation(RegLocation loc);
991
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700992 private:
Yixin Shou8c914c02014-07-28 14:17:09 -0400993 void SwapBits(RegStorage result_reg, int shift, int32_t value);
994 void SwapBits64(RegStorage result_reg, int shift, int64_t value);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700995
996 static const X86EncodingMap EncodingMap[kX86Last];
997
998 friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs);
999
1000 DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -07001001};
1002
1003} // namespace art
1004
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001005#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_