blob: 648c148c15fffae6995f4a3cd29a5f432d9f6839 [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
20#include "dex/compiler_internals.h"
21#include "x86_lir.h"
22
23namespace art {
24
Mark Mendelle87f9b52014-04-30 14:13:18 -040025class X86Mir2Lir : public Mir2Lir {
Brian Carlstrom7940e442013-07-12 13:46:57 -070026 public:
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +070027 X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena, bool gen64bit);
Brian Carlstrom7940e442013-07-12 13:46:57 -070028
29 // Required for target - codegen helpers.
buzbee11b63d12013-08-27 07:34:17 -070030 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
buzbee2700f7e2014-03-07 09:46:20 -080031 RegLocation rl_dest, int lit);
Ian Rogerse2143c02014-03-28 08:47:16 -070032 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Dave Allisonb373e092014-02-20 16:06:36 -080033 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe2f244e92014-05-08 03:35:25 -070034 RegStorage LoadHelper(ThreadOffset<4> offset) OVERRIDE;
35 RegStorage LoadHelper(ThreadOffset<8> offset) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +010036 LIR* LoadBaseDispVolatile(RegStorage r_base, int displacement, RegStorage r_dest,
37 OpSize size) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010038 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
39 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080040 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010041 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080042 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010043 RegStorage r_dest, OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080044 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
45 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Vladimir Marko674744e2014-04-24 15:18:26 +010046 LIR* StoreBaseDispVolatile(RegStorage r_base, int displacement, RegStorage r_src,
47 OpSize size) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010048 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
49 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080050 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010051 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080052 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010053 RegStorage r_src, OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080054 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070055
56 // Required for target - register utilities.
buzbee2700f7e2014-03-07 09:46:20 -080057 RegStorage TargetReg(SpecialTargetRegister reg);
58 RegStorage GetArgMappingToPhysicalReg(int arg_num);
Brian Carlstrom7940e442013-07-12 13:46:57 -070059 RegLocation GetReturnAlt();
60 RegLocation GetReturnWideAlt();
61 RegLocation LocCReturn();
buzbeea0cd2d72014-06-01 09:33:49 -070062 RegLocation LocCReturnRef();
Brian Carlstrom7940e442013-07-12 13:46:57 -070063 RegLocation LocCReturnDouble();
64 RegLocation LocCReturnFloat();
65 RegLocation LocCReturnWide();
buzbee091cc402014-03-31 10:14:40 -070066 uint64_t GetRegMaskCommon(RegStorage reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070067 void AdjustSpillMask();
Vladimir Marko31c2aac2013-12-09 16:31:19 +000068 void ClobberCallerSave();
Brian Carlstrom7940e442013-07-12 13:46:57 -070069 void FreeCallTemps();
Brian Carlstrom7940e442013-07-12 13:46:57 -070070 void LockCallTemps();
buzbee091cc402014-03-31 10:14:40 -070071 void MarkPreservedSingle(int v_reg, RegStorage reg);
72 void MarkPreservedDouble(int v_reg, RegStorage reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070073 void CompilerInitializeRegAlloc();
74
75 // Required for target - miscellaneous.
buzbeeb48819d2013-09-14 16:15:25 -070076 void AssembleLIR();
77 int AssignInsnOffsets();
78 void AssignOffsets();
buzbee0d829482013-10-11 15:24:55 -070079 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
Brian Carlstrom7940e442013-07-12 13:46:57 -070080 void DumpResourceMask(LIR* lir, uint64_t mask, const char* prefix);
buzbeeb48819d2013-09-14 16:15:25 -070081 void SetupTargetResourceMasks(LIR* lir, uint64_t flags);
Brian Carlstrom7940e442013-07-12 13:46:57 -070082 const char* GetTargetInstFmt(int opcode);
83 const char* GetTargetInstName(int opcode);
84 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr);
85 uint64_t GetPCUseDefEncoding();
86 uint64_t GetTargetInstFlags(int opcode);
87 int GetInsnSize(LIR* lir);
88 bool IsUnconditionalBranch(LIR* lir);
89
Vladimir Marko674744e2014-04-24 15:18:26 +010090 // Check support for volatile load/store of a given size.
91 bool SupportsVolatileLoadStore(OpSize size) OVERRIDE;
92 // Get the register class for load/store of a field.
93 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
94
Brian Carlstrom7940e442013-07-12 13:46:57 -070095 // Required for target - Dalvik-level generators.
buzbee2700f7e2014-03-07 09:46:20 -080096 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
97 RegLocation rl_src2);
98 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
99 RegLocation rl_dest, int scale);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700100 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Ian Rogersa9a82542013-10-04 11:17:26 -0700101 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700102 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Ian Rogersa9a82542013-10-04 11:17:26 -0700103 RegLocation rl_src1, RegLocation rl_shift);
buzbee2700f7e2014-03-07 09:46:20 -0800104 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
105 RegLocation rl_src2);
106 void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
107 RegLocation rl_src2);
108 void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
109 RegLocation rl_src2);
110 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700111 RegLocation rl_src2);
buzbee2700f7e2014-03-07 09:46:20 -0800112 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
113 RegLocation rl_src2);
114 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
115 RegLocation rl_src2);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700116 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src);
Vladimir Marko1c282e22013-11-21 14:49:47 +0000117 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700118 bool GenInlinedMinMaxInt(CallInfo* info, bool is_min);
119 bool GenInlinedSqrt(CallInfo* info);
Vladimir Markoe508a202013-11-04 15:24:22 +0000120 bool GenInlinedPeek(CallInfo* info, OpSize size);
121 bool GenInlinedPoke(CallInfo* info, OpSize size);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100122 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700123 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
buzbee2700f7e2014-03-07 09:46:20 -0800124 void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
125 RegLocation rl_src2);
126 void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
127 RegLocation rl_src2);
128 void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
129 RegLocation rl_src2);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100130 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
131 RegLocation rl_src2, bool is_div);
buzbee2700f7e2014-03-07 09:46:20 -0800132 // TODO: collapse reg_lo, reg_hi
133 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div);
134 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700135 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
Mingyao Yange643a172014-04-08 11:02:52 -0700136 void GenDivZeroCheckWide(RegStorage reg);
Mingyao Yang80365d92014-04-18 12:10:58 -0700137 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
138 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700139 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method);
140 void GenExitSequence();
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800141 void GenSpecialExitSequence();
buzbee0d829482013-10-11 15:24:55 -0700142 void GenFillArrayData(DexOffset table_offset, RegLocation rl_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700143 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double);
144 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir);
145 void GenSelect(BasicBlock* bb, MIR* mir);
Andreas Gampeb14329f2014-05-15 11:16:06 -0700146 bool GenMemBarrier(MemBarrierKind barrier_kind);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700147 void GenMoveException(RegLocation rl_dest);
buzbee2700f7e2014-03-07 09:46:20 -0800148 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
149 int first_bit, int second_bit);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700150 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src);
151 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src);
buzbee0d829482013-10-11 15:24:55 -0700152 void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
153 void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800154
Mark Mendelle02d48f2014-01-15 11:19:23 -0800155 /*
156 * @brief Generate a two address long operation with a constant value
157 * @param rl_dest location of result
158 * @param rl_src constant source operand
159 * @param op Opcode to be generated
160 */
161 void GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
162 /*
163 * @brief Generate a three address long operation with a constant value
164 * @param rl_dest location of result
165 * @param rl_src1 source operand
166 * @param rl_src2 constant source operand
167 * @param op Opcode to be generated
168 */
buzbee2700f7e2014-03-07 09:46:20 -0800169 void GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
170 Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800171
172 /**
173 * @brief Generate a long arithmetic operation.
174 * @param rl_dest The destination.
175 * @param rl_src1 First operand.
176 * @param rl_src2 Second operand.
177 * @param op The DEX opcode for the operation.
178 * @param is_commutative The sources can be swapped if needed.
179 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400180 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
181 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800182
183 /**
184 * @brief Generate a two operand long arithmetic operation.
185 * @param rl_dest The destination.
186 * @param rl_src Second operand.
187 * @param op The DEX opcode for the operation.
188 */
189 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
190
191 /**
192 * @brief Generate a long operation.
193 * @param rl_dest The destination. Must be in a register
194 * @param rl_src The other operand. May be in a register or in memory.
195 * @param op The DEX opcode for the operation.
196 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400197 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700198
Mark Mendelldf8ee2e2014-01-27 16:37:47 -0800199 /**
200 * @brief Implement instanceof a final class with x86 specific code.
201 * @param use_declaring_class 'true' if we can use the class itself.
202 * @param type_idx Type index to use if use_declaring_class is 'false'.
203 * @param rl_dest Result to be set to 0 or 1.
204 * @param rl_src Object to be tested.
205 */
buzbee2700f7e2014-03-07 09:46:20 -0800206 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
207 RegLocation rl_src);
Mark Mendell6607d972014-02-10 06:54:18 -0800208 /*
209 *
210 * @brief Implement Set up instanceof a class with x86 specific code.
211 * @param needs_access_check 'true' if we must check the access.
212 * @param type_known_final 'true' if the type is known to be a final class.
213 * @param type_known_abstract 'true' if the type is known to be an abstract class.
214 * @param use_declaring_class 'true' if the type can be loaded off the current Method*.
215 * @param can_assume_type_is_in_dex_cache 'true' if the type is known to be in the cache.
216 * @param type_idx Type index to use if use_declaring_class is 'false'.
217 * @param rl_dest Result to be set to 0 or 1.
218 * @param rl_src Object to be tested.
219 */
220 void GenInstanceofCallingHelper(bool needs_access_check, bool type_known_final,
221 bool type_known_abstract, bool use_declaring_class,
222 bool can_assume_type_is_in_dex_cache,
buzbee2700f7e2014-03-07 09:46:20 -0800223 uint32_t type_idx, RegLocation rl_dest, RegLocation rl_src);
Mark Mendell6607d972014-02-10 06:54:18 -0800224
Brian Carlstrom7940e442013-07-12 13:46:57 -0700225 // Single operation generators.
226 LIR* OpUnconditionalBranch(LIR* target);
buzbee2700f7e2014-03-07 09:46:20 -0800227 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target);
228 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700229 LIR* OpCondBranch(ConditionCode cc, LIR* target);
buzbee2700f7e2014-03-07 09:46:20 -0800230 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target);
231 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700232 LIR* OpIT(ConditionCode cond, const char* guide);
Dave Allison3da67a52014-04-02 17:03:45 -0700233 void OpEndIT(LIR* it);
buzbee2700f7e2014-03-07 09:46:20 -0800234 LIR* OpMem(OpKind op, RegStorage r_base, int disp);
235 LIR* OpPcRelLoad(RegStorage reg, LIR* target);
236 LIR* OpReg(OpKind op, RegStorage r_dest_src);
buzbee7a11ab02014-04-28 20:02:38 -0700237 void OpRegCopy(RegStorage r_dest, RegStorage r_src);
buzbee2700f7e2014-03-07 09:46:20 -0800238 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src);
239 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value);
240 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
241 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800242 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
buzbee2700f7e2014-03-07 09:46:20 -0800243 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2);
244 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type);
245 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type);
246 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src);
247 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value);
248 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700249 LIR* OpTestSuspend(LIR* target);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700250 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset) OVERRIDE;
251 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -0800252 LIR* OpVldm(RegStorage r_base, int count);
253 LIR* OpVstm(RegStorage r_base, int count);
254 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
255 void OpRegCopyWide(RegStorage dest, RegStorage src);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700256 void OpTlsCmp(ThreadOffset<4> offset, int val) OVERRIDE;
257 void OpTlsCmp(ThreadOffset<8> offset, int val) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700258
buzbee091cc402014-03-31 10:14:40 -0700259 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700260 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700261 void SpillCoreRegs();
262 void UnSpillCoreRegs();
263 static const X86EncodingMap EncodingMap[kX86Last];
264 bool InexpensiveConstantInt(int32_t value);
265 bool InexpensiveConstantFloat(int32_t value);
266 bool InexpensiveConstantLong(int64_t value);
267 bool InexpensiveConstantDouble(int64_t value);
268
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800269 /*
Mark Mendelle87f9b52014-04-30 14:13:18 -0400270 * @brief Should try to optimize for two address instructions?
271 * @return true if we try to avoid generating three operand instructions.
272 */
273 virtual bool GenerateTwoOperandInstructions() const { return true; }
274
275 /*
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800276 * @brief x86 specific codegen for int operations.
277 * @param opcode Operation to perform.
278 * @param rl_dest Destination for the result.
279 * @param rl_lhs Left hand operand.
280 * @param rl_rhs Right hand operand.
281 */
buzbee2700f7e2014-03-07 09:46:20 -0800282 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
283 RegLocation rl_rhs);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800284
Mark Mendell55d0eac2014-02-06 11:02:52 -0800285 /*
286 * @brief Dump a RegLocation using printf
287 * @param loc Register location to dump
288 */
289 static void DumpRegLocation(RegLocation loc);
290
291 /*
292 * @brief Load the Method* of a dex method into the register.
Jeff Hao49161ce2014-03-12 11:05:25 -0700293 * @param target_method The MethodReference of the method to be invoked.
Mark Mendell55d0eac2014-02-06 11:02:52 -0800294 * @param type How the method will be invoked.
295 * @param register that will contain the code address.
296 * @note register will be passed to TargetReg to get physical register.
297 */
Jeff Hao49161ce2014-03-12 11:05:25 -0700298 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Mark Mendell55d0eac2014-02-06 11:02:52 -0800299 SpecialTargetRegister symbolic_reg);
300
301 /*
302 * @brief Load the Class* of a Dex Class type into the register.
303 * @param type How the method will be invoked.
304 * @param register that will contain the code address.
305 * @note register will be passed to TargetReg to get physical register.
306 */
307 void LoadClassType(uint32_t type_idx, SpecialTargetRegister symbolic_reg);
308
309 /*
310 * @brief Generate a relative call to the method that will be patched at link time.
Jeff Hao49161ce2014-03-12 11:05:25 -0700311 * @param target_method The MethodReference of the method to be invoked.
Mark Mendell55d0eac2014-02-06 11:02:52 -0800312 * @param type How the method will be invoked.
313 * @returns Call instruction
314 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400315 virtual LIR * CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
Mark Mendell55d0eac2014-02-06 11:02:52 -0800316
317 /*
318 * @brief Handle x86 specific literals
319 */
320 void InstallLiteralPools();
321
Mark Mendellae9fd932014-02-10 16:14:35 -0800322 /*
323 * @brief Generate the debug_frame CFI information.
324 * @returns pointer to vector containing CFE information
325 */
326 static std::vector<uint8_t>* ReturnCommonCallFrameInformation();
327
328 /*
329 * @brief Generate the debug_frame FDE information.
330 * @returns pointer to vector containing CFE information
331 */
332 std::vector<uint8_t>* ReturnCallFrameInformation();
333
Mark Mendelle87f9b52014-04-30 14:13:18 -0400334 protected:
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700335 size_t ComputeSize(const X86EncodingMap* entry, int base, int displacement,
336 int reg_r, int reg_x, bool has_sib);
337 uint8_t LowRegisterBits(uint8_t reg);
338 bool NeedsRex(uint8_t reg);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000339 void EmitPrefix(const X86EncodingMap* entry);
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700340 void EmitPrefix(const X86EncodingMap* entry, uint8_t reg_r, uint8_t reg_x, uint8_t reg_b);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000341 void EmitOpcode(const X86EncodingMap* entry);
342 void EmitPrefixAndOpcode(const X86EncodingMap* entry);
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700343 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
344 uint8_t reg_r, uint8_t reg_x, uint8_t reg_b);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000345 void EmitDisp(uint8_t base, int disp);
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700346 void EmitModrmThread(uint8_t reg_or_opcode);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000347 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int disp);
348 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale, int disp);
Dmitry Petrochenko96992e82014-05-20 04:03:46 +0700349 void EmitImm(const X86EncodingMap* entry, int64_t imm);
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100350 void EmitOpRegOpcode(const X86EncodingMap* entry, uint8_t reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700351 void EmitOpReg(const X86EncodingMap* entry, uint8_t reg);
352 void EmitOpMem(const X86EncodingMap* entry, uint8_t base, int disp);
buzbee2700f7e2014-03-07 09:46:20 -0800353 void EmitOpArray(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700354 void EmitMemReg(const X86EncodingMap* entry, uint8_t base, int disp, uint8_t reg);
Mark Mendell343adb52013-12-18 06:02:17 -0800355 void EmitMemImm(const X86EncodingMap* entry, uint8_t base, int disp, int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700356 void EmitRegMem(const X86EncodingMap* entry, uint8_t reg, uint8_t base, int disp);
357 void EmitRegArray(const X86EncodingMap* entry, uint8_t reg, uint8_t base, uint8_t index,
358 int scale, int disp);
359 void EmitArrayReg(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp,
360 uint8_t reg);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400361 void EmitArrayImm(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp,
362 int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700363 void EmitRegThread(const X86EncodingMap* entry, uint8_t reg, int disp);
364 void EmitRegReg(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2);
365 void EmitRegRegImm(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, int32_t imm);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800366 void EmitRegRegImmRev(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, int32_t imm);
buzbee2700f7e2014-03-07 09:46:20 -0800367 void EmitRegMemImm(const X86EncodingMap* entry, uint8_t reg1, uint8_t base, int disp,
368 int32_t imm);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400369 void EmitMemRegImm(const X86EncodingMap* entry, uint8_t base, int disp, uint8_t reg1, int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700370 void EmitRegImm(const X86EncodingMap* entry, uint8_t reg, int imm);
371 void EmitThreadImm(const X86EncodingMap* entry, int disp, int imm);
Dmitry Petrochenko96992e82014-05-20 04:03:46 +0700372 void EmitMovRegImm(const X86EncodingMap* entry, uint8_t reg, int64_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700373 void EmitShiftRegImm(const X86EncodingMap* entry, uint8_t reg, int imm);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400374 void EmitShiftMemImm(const X86EncodingMap* entry, uint8_t base, int disp, int imm);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800375 void EmitShiftMemCl(const X86EncodingMap* entry, uint8_t base, int displacement, uint8_t cl);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700376 void EmitShiftRegCl(const X86EncodingMap* entry, uint8_t reg, uint8_t cl);
377 void EmitRegCond(const X86EncodingMap* entry, uint8_t reg, uint8_t condition);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400378 void EmitMemCond(const X86EncodingMap* entry, uint8_t base, int displacement, uint8_t condition);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800379
380 /**
381 * @brief Used for encoding conditional register to register operation.
382 * @param entry The entry in the encoding map for the opcode.
383 * @param reg1 The first physical register.
384 * @param reg2 The second physical register.
385 * @param condition The condition code for operation.
386 */
387 void EmitRegRegCond(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, uint8_t condition);
388
Mark Mendell2637f2e2014-04-30 10:10:47 -0400389 /**
390 * @brief Used for encoding conditional register to memory operation.
391 * @param entry The entry in the encoding map for the opcode.
392 * @param reg1 The first physical register.
393 * @param base The memory base register.
394 * @param displacement The memory displacement.
395 * @param condition The condition code for operation.
396 */
397 void EmitRegMemCond(const X86EncodingMap* entry, uint8_t reg1, uint8_t base, int displacement, uint8_t condition);
398
Brian Carlstrom7940e442013-07-12 13:46:57 -0700399 void EmitJmp(const X86EncodingMap* entry, int rel);
400 void EmitJcc(const X86EncodingMap* entry, int rel, uint8_t cc);
401 void EmitCallMem(const X86EncodingMap* entry, uint8_t base, int disp);
Mark Mendell55d0eac2014-02-06 11:02:52 -0800402 void EmitCallImmediate(const X86EncodingMap* entry, int disp);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700403 void EmitCallThread(const X86EncodingMap* entry, int disp);
404 void EmitPcRel(const X86EncodingMap* entry, uint8_t reg, int base_or_table, uint8_t index,
405 int scale, int table_or_disp);
406 void EmitMacro(const X86EncodingMap* entry, uint8_t reg, int offset);
407 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
Mark Mendell412d4f82013-12-18 13:32:36 -0800408 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
409 int64_t val, ConditionCode ccode);
Bill Buzbeed61ba4b2014-01-13 21:44:01 +0000410 void GenConstWide(RegLocation rl_dest, int64_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800411
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800412 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
413
Mark Mendelle02d48f2014-01-15 11:19:23 -0800414 /*
Mark Mendelle87f9b52014-04-30 14:13:18 -0400415 * @brief Ensure that a temporary register is byte addressable.
416 * @returns a temporary guarenteed to be byte addressable.
417 */
418 virtual RegStorage AllocateByteRegister();
419
420 /*
Mark Mendell4028a6c2014-02-19 20:06:20 -0800421 * @brief generate inline code for fast case of Strng.indexOf.
422 * @param info Call parameters
423 * @param zero_based 'true' if the index into the string is 0.
424 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
425 * generated.
426 */
427 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
428
429 /*
Mark Mendelld65c51a2014-04-29 16:55:20 -0400430 * @brief Load 128 bit constant into vector register.
431 * @param bb The basic block in which the MIR is from.
432 * @param mir The MIR whose opcode is kMirConstVector
433 * @note vA is the TypeSize for the register.
434 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
435 */
436 void GenConst128(BasicBlock* bb, MIR* mir);
437
438 /*
Mark Mendellfe945782014-05-22 09:52:36 -0400439 * @brief MIR to move a vectorized register to another.
440 * @param bb The basic block in which the MIR is from.
441 * @param mir The MIR whose opcode is kMirConstVector.
442 * @note vA: TypeSize
443 * @note vB: destination
444 * @note vC: source
445 */
446 void GenMoveVector(BasicBlock *bb, MIR *mir);
447
448 /*
449 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know the type of the vector.
450 * @param bb The basic block in which the MIR is from.
451 * @param mir The MIR whose opcode is kMirConstVector.
452 * @note vA: TypeSize
453 * @note vB: destination and source
454 * @note vC: source
455 */
456 void GenMultiplyVector(BasicBlock *bb, MIR *mir);
457
458 /*
459 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
460 * @param bb The basic block in which the MIR is from.
461 * @param mir The MIR whose opcode is kMirConstVector.
462 * @note vA: TypeSize
463 * @note vB: destination and source
464 * @note vC: source
465 */
466 void GenAddVector(BasicBlock *bb, MIR *mir);
467
468 /*
469 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
470 * @param bb The basic block in which the MIR is from.
471 * @param mir The MIR whose opcode is kMirConstVector.
472 * @note vA: TypeSize
473 * @note vB: destination and source
474 * @note vC: source
475 */
476 void GenSubtractVector(BasicBlock *bb, MIR *mir);
477
478 /*
479 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
480 * @param bb The basic block in which the MIR is from.
481 * @param mir The MIR whose opcode is kMirConstVector.
482 * @note vA: TypeSize
483 * @note vB: destination and source
484 * @note vC: immediate
485 */
486 void GenShiftLeftVector(BasicBlock *bb, MIR *mir);
487
488 /*
489 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
490 * @param bb The basic block in which the MIR is from.
491 * @param mir The MIR whose opcode is kMirConstVector.
492 * @note vA: TypeSize
493 * @note vB: destination and source
494 * @note vC: immediate
495 */
496 void GenSignedShiftRightVector(BasicBlock *bb, MIR *mir);
497
498 /*
499 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
500 * @param bb The basic block in which the MIR is from..
501 * @param mir The MIR whose opcode is kMirConstVector.
502 * @note vA: TypeSize
503 * @note vB: destination and source
504 * @note vC: immediate
505 */
506 void GenUnsignedShiftRightVector(BasicBlock *bb, MIR *mir);
507
508 /*
509 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
510 * @note vA: TypeSize
511 * @note vB: destination and source
512 * @note vC: source
513 */
514 void GenAndVector(BasicBlock *bb, MIR *mir);
515
516 /*
517 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
518 * @param bb The basic block in which the MIR is from.
519 * @param mir The MIR whose opcode is kMirConstVector.
520 * @note vA: TypeSize
521 * @note vB: destination and source
522 * @note vC: source
523 */
524 void GenOrVector(BasicBlock *bb, MIR *mir);
525
526 /*
527 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
528 * @param bb The basic block in which the MIR is from.
529 * @param mir The MIR whose opcode is kMirConstVector.
530 * @note vA: TypeSize
531 * @note vB: destination and source
532 * @note vC: source
533 */
534 void GenXorVector(BasicBlock *bb, MIR *mir);
535
536 /*
537 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
538 * @param bb The basic block in which the MIR is from.
539 * @param mir The MIR whose opcode is kMirConstVector.
540 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
541 * @note vA: TypeSize
542 * @note vB: destination and source VR (not vector register)
543 * @note vC: source (vector register)
544 */
545 void GenAddReduceVector(BasicBlock *bb, MIR *mir);
546
547 /*
548 * @brief Extract a packed element into a single VR.
549 * @param bb The basic block in which the MIR is from.
550 * @param mir The MIR whose opcode is kMirConstVector.
551 * @note vA: TypeSize
552 * @note vB: destination VR (not vector register)
553 * @note vC: source (vector register)
554 * @note arg[0]: The index to use for extraction from vector register (which packed element).
555 */
556 void GenReduceVector(BasicBlock *bb, MIR *mir);
557
558 /*
559 * @brief Create a vector value, with all TypeSize values equal to vC
560 * @param bb The basic block in which the MIR is from.
561 * @param mir The MIR whose opcode is kMirConstVector.
562 * @note vA: TypeSize.
563 * @note vB: destination vector register.
564 * @note vC: source VR (not vector register).
565 */
566 void GenSetVector(BasicBlock *bb, MIR *mir);
567
568 /*
Mark Mendelld65c51a2014-04-29 16:55:20 -0400569 * @brief Generate code for a vector opcode.
570 * @param bb The basic block in which the MIR is from.
571 * @param mir The MIR whose opcode is a non-standard opcode.
572 */
573 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
574
575 /*
Mark Mendelle02d48f2014-01-15 11:19:23 -0800576 * @brief Return the correct x86 opcode for the Dex operation
577 * @param op Dex opcode for the operation
578 * @param loc Register location of the operand
579 * @param is_high_op 'true' if this is an operation on the high word
580 * @param value Immediate value for the operation. Used for byte variants
581 * @returns the correct x86 opcode to perform the operation
582 */
583 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
584
585 /*
586 * @brief Return the correct x86 opcode for the Dex operation
587 * @param op Dex opcode for the operation
588 * @param dest location of the destination. May be register or memory.
589 * @param rhs Location for the rhs of the operation. May be in register or memory.
590 * @param is_high_op 'true' if this is an operation on the high word
591 * @returns the correct x86 opcode to perform the operation
592 * @note at most one location may refer to memory
593 */
594 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
595 bool is_high_op);
596
597 /*
598 * @brief Is this operation a no-op for this opcode and value
599 * @param op Dex opcode for the operation
600 * @param value Immediate value for the operation.
601 * @returns 'true' if the operation will have no effect
602 */
603 bool IsNoOp(Instruction::Code op, int32_t value);
604
Mark Mendell2bf31e62014-01-23 12:13:40 -0800605 /**
606 * @brief Calculate magic number and shift for a given divisor
607 * @param divisor divisor number for calculation
608 * @param magic hold calculated magic number
609 * @param shift hold calculated shift
610 */
611 void CalculateMagicAndShift(int divisor, int& magic, int& shift);
612
613 /*
614 * @brief Generate an integer div or rem operation.
615 * @param rl_dest Destination Location.
616 * @param rl_src1 Numerator Location.
617 * @param rl_src2 Divisor Location.
618 * @param is_div 'true' if this is a division, 'false' for a remainder.
619 * @param check_zero 'true' if an exception should be generated if the divisor is 0.
620 */
buzbee2700f7e2014-03-07 09:46:20 -0800621 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
622 bool is_div, bool check_zero);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800623
624 /*
625 * @brief Generate an integer div or rem operation by a literal.
626 * @param rl_dest Destination Location.
627 * @param rl_src Numerator Location.
628 * @param lit Divisor.
629 * @param is_div 'true' if this is a division, 'false' for a remainder.
630 */
631 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800632
633 /*
634 * Generate code to implement long shift operations.
635 * @param opcode The DEX opcode to specify the shift type.
636 * @param rl_dest The destination.
637 * @param rl_src The value to be shifted.
638 * @param shift_amount How much to shift.
639 * @returns the RegLocation of the result.
640 */
641 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
642 RegLocation rl_src, int shift_amount);
643 /*
644 * Generate an imul of a register by a constant or a better sequence.
645 * @param dest Destination Register.
646 * @param src Source Register.
647 * @param val Constant multiplier.
648 */
buzbee2700f7e2014-03-07 09:46:20 -0800649 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800650
Mark Mendell4708dcd2014-01-22 09:05:18 -0800651 /*
652 * Generate an imul of a memory location by a constant or a better sequence.
653 * @param dest Destination Register.
654 * @param sreg Symbolic register.
655 * @param displacement Displacement on stack of Symbolic Register.
656 * @param val Constant multiplier.
657 */
buzbee2700f7e2014-03-07 09:46:20 -0800658 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendell766e9292014-01-27 07:55:47 -0800659
660 /*
661 * @brief Compare memory to immediate, and branch if condition true.
662 * @param cond The condition code that when true will branch to the target.
663 * @param temp_reg A temporary register that can be used if compare memory is not
664 * supported by the architecture.
665 * @param base_reg The register holding the base address.
666 * @param offset The offset from the base.
667 * @param check_value The immediate to compare to.
668 */
buzbee2700f7e2014-03-07 09:46:20 -0800669 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Mark Mendell766e9292014-01-27 07:55:47 -0800670 int offset, int check_value, LIR* target);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800671
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800672 /*
673 * Can this operation be using core registers without temporaries?
674 * @param rl_lhs Left hand operand.
675 * @param rl_rhs Right hand operand.
676 * @returns 'true' if the operation can proceed without needing temporary regs.
677 */
678 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Mark Mendell67c39c42014-01-31 17:28:00 -0800679
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800680 /**
681 * @brief Generates inline code for conversion of long to FP by using x87/
682 * @param rl_dest The destination of the FP.
683 * @param rl_src The source of the long.
684 * @param is_double 'true' if dealing with double, 'false' for float.
685 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400686 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800687
Mark Mendell67c39c42014-01-31 17:28:00 -0800688 /*
689 * @brief Perform MIR analysis before compiling method.
690 * @note Invokes Mir2LiR::Materialize after analysis.
691 */
692 void Materialize();
693
694 /*
buzbee30adc732014-05-09 15:10:18 -0700695 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
696 * without regard to data type. In practice, this can result in UpdateLoc returning a
697 * location record for a Dalvik float value in a core register, and vis-versa. For targets
698 * which can inexpensively move data between core and float registers, this can often be a win.
699 * However, for x86 this is generally not a win. These variants of UpdateLoc()
700 * take a register class argument - and will return an in-register location record only if
701 * the value is live in a temp register of the correct class. Additionally, if the value is in
702 * a temp register of the wrong register class, it will be clobbered.
703 */
704 RegLocation UpdateLocTyped(RegLocation loc, int reg_class);
705 RegLocation UpdateLocWideTyped(RegLocation loc, int reg_class);
706
707 /*
Mark Mendell67c39c42014-01-31 17:28:00 -0800708 * @brief Analyze MIR before generating code, to prepare for the code generation.
709 */
710 void AnalyzeMIR();
711
712 /*
713 * @brief Analyze one basic block.
714 * @param bb Basic block to analyze.
715 */
716 void AnalyzeBB(BasicBlock * bb);
717
718 /*
719 * @brief Analyze one extended MIR instruction
720 * @param opcode MIR instruction opcode.
721 * @param bb Basic block containing instruction.
722 * @param mir Extended instruction to analyze.
723 */
724 void AnalyzeExtendedMIR(int opcode, BasicBlock * bb, MIR *mir);
725
726 /*
727 * @brief Analyze one MIR instruction
728 * @param opcode MIR instruction opcode.
729 * @param bb Basic block containing instruction.
730 * @param mir Instruction to analyze.
731 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400732 virtual void AnalyzeMIR(int opcode, BasicBlock * bb, MIR *mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800733
734 /*
735 * @brief Analyze one MIR float/double instruction
736 * @param opcode MIR instruction opcode.
737 * @param bb Basic block containing instruction.
738 * @param mir Instruction to analyze.
739 */
740 void AnalyzeFPInstruction(int opcode, BasicBlock * bb, MIR *mir);
741
742 /*
743 * @brief Analyze one use of a double operand.
744 * @param rl_use Double RegLocation for the operand.
745 */
746 void AnalyzeDoubleUse(RegLocation rl_use);
747
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700748 bool Gen64Bit() const { return gen64bit_; }
749
Mark Mendell67c39c42014-01-31 17:28:00 -0800750 // Information derived from analysis of MIR
751
Mark Mendell55d0eac2014-02-06 11:02:52 -0800752 // The compiler temporary for the code address of the method.
753 CompilerTemp *base_of_code_;
754
Mark Mendell67c39c42014-01-31 17:28:00 -0800755 // Have we decided to compute a ptr to code and store in temporary VR?
756 bool store_method_addr_;
757
Mark Mendell55d0eac2014-02-06 11:02:52 -0800758 // Have we used the stored method address?
759 bool store_method_addr_used_;
760
761 // Instructions to remove if we didn't use the stored method address.
762 LIR* setup_method_address_[2];
763
764 // Instructions needing patching with Method* values.
765 GrowableArray<LIR*> method_address_insns_;
766
767 // Instructions needing patching with Class Type* values.
768 GrowableArray<LIR*> class_type_address_insns_;
769
770 // Instructions needing patching with PC relative code addresses.
771 GrowableArray<LIR*> call_method_insns_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800772
773 // Prologue decrement of stack pointer.
774 LIR* stack_decrement_;
775
776 // Epilogue increment of stack pointer.
777 LIR* stack_increment_;
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700778
779 // 64-bit mode
780 bool gen64bit_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400781
782 // The list of const vector literals.
783 LIR *const_vectors_;
784
785 /*
786 * @brief Search for a matching vector literal
787 * @param mir A kMirOpConst128b MIR instruction to match.
788 * @returns pointer to matching LIR constant, or nullptr if not found.
789 */
790 LIR *ScanVectorLiteral(MIR *mir);
791
792 /*
793 * @brief Add a constant vector literal
794 * @param mir A kMirOpConst128b MIR instruction to match.
795 */
796 LIR *AddVectorLiteral(MIR *mir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700797};
798
799} // namespace art
800
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700801#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_