blob: 00c2f536d51c395c7a4b43502894a26eba3545a3 [file] [log] [blame]
buzbeee88dfbf2012-03-05 11:19:57 -08001/*
2 * Copyright (C) 2012 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
buzbee02031b12012-11-23 09:41:35 -080017#include "codegen_x86.h"
Brian Carlstrom641ce032013-01-31 15:21:37 -080018#include "compiler/codegen/codegen_util.h"
19#include "compiler/codegen/ralloc_util.h"
20#include "x86_lir.h"
buzbee1bc37c62012-11-20 13:35:41 -080021
buzbeee88dfbf2012-03-05 11:19:57 -080022namespace art {
23
buzbee02031b12012-11-23 09:41:35 -080024bool X86Codegen::GenArithOpFloat(CompilationUnit *cu, Instruction::Code opcode,
25 RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) {
Ian Rogersb5d09b22012-03-06 22:14:17 -080026 X86OpCode op = kX86Nop;
buzbeefa57c472012-11-21 12:06:18 -080027 RegLocation rl_result;
buzbeee88dfbf2012-03-05 11:19:57 -080028
Ian Rogersb5d09b22012-03-06 22:14:17 -080029 /*
30 * Don't attempt to optimize register usage since these opcodes call out to
31 * the handlers.
32 */
buzbee408ad162012-06-06 16:45:18 -070033 switch (opcode) {
Ian Rogersb5d09b22012-03-06 22:14:17 -080034 case Instruction::ADD_FLOAT_2ADDR:
35 case Instruction::ADD_FLOAT:
36 op = kX86AddssRR;
37 break;
38 case Instruction::SUB_FLOAT_2ADDR:
39 case Instruction::SUB_FLOAT:
40 op = kX86SubssRR;
41 break;
42 case Instruction::DIV_FLOAT_2ADDR:
43 case Instruction::DIV_FLOAT:
44 op = kX86DivssRR;
45 break;
46 case Instruction::MUL_FLOAT_2ADDR:
47 case Instruction::MUL_FLOAT:
48 op = kX86MulssRR;
49 break;
Ian Rogersb5d09b22012-03-06 22:14:17 -080050 case Instruction::REM_FLOAT_2ADDR:
jeffhaobabda952012-08-02 15:55:30 -070051 case Instruction::REM_FLOAT:
buzbeea3a82b22012-11-27 16:09:55 -080052 FlushAllRegs(cu); // Send everything to home location
53 CallRuntimeHelperRegLocationRegLocation(cu, ENTRYPOINT_OFFSET(pFmodf), rl_src1, rl_src2, false);
54 rl_result = GetReturn(cu, true);
55 StoreValue(cu, rl_dest, rl_result);
56 return false;
57 case Instruction::NEG_FLOAT:
58 GenNegFloat(cu, rl_dest, rl_src1);
59 return false;
Ian Rogersb5d09b22012-03-06 22:14:17 -080060 default:
61 return true;
62 }
buzbeefa57c472012-11-21 12:06:18 -080063 rl_src1 = LoadValue(cu, rl_src1, kFPReg);
64 rl_src2 = LoadValue(cu, rl_src2, kFPReg);
65 rl_result = EvalLoc(cu, rl_dest, kFPReg, true);
66 int r_dest = rl_result.low_reg;
67 int r_src1 = rl_src1.low_reg;
68 int r_src2 = rl_src2.low_reg;
69 if (r_dest == r_src2) {
70 r_src2 = AllocTempFloat(cu);
71 OpRegCopy(cu, r_src2, r_dest);
jeffhao4abb1a92012-06-08 17:02:08 -070072 }
buzbeefa57c472012-11-21 12:06:18 -080073 OpRegCopy(cu, r_dest, r_src1);
74 NewLIR2(cu, op, r_dest, r_src2);
75 StoreValue(cu, rl_dest, rl_result);
buzbeee88dfbf2012-03-05 11:19:57 -080076
Ian Rogersb5d09b22012-03-06 22:14:17 -080077 return false;
buzbeee88dfbf2012-03-05 11:19:57 -080078}
79
buzbee02031b12012-11-23 09:41:35 -080080bool X86Codegen::GenArithOpDouble(CompilationUnit *cu, Instruction::Code opcode,
81 RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) {
Ian Rogersb5d09b22012-03-06 22:14:17 -080082 X86OpCode op = kX86Nop;
buzbeefa57c472012-11-21 12:06:18 -080083 RegLocation rl_result;
buzbeee88dfbf2012-03-05 11:19:57 -080084
buzbee408ad162012-06-06 16:45:18 -070085 switch (opcode) {
Ian Rogersb5d09b22012-03-06 22:14:17 -080086 case Instruction::ADD_DOUBLE_2ADDR:
87 case Instruction::ADD_DOUBLE:
88 op = kX86AddsdRR;
89 break;
90 case Instruction::SUB_DOUBLE_2ADDR:
91 case Instruction::SUB_DOUBLE:
92 op = kX86SubsdRR;
93 break;
94 case Instruction::DIV_DOUBLE_2ADDR:
95 case Instruction::DIV_DOUBLE:
96 op = kX86DivsdRR;
97 break;
98 case Instruction::MUL_DOUBLE_2ADDR:
99 case Instruction::MUL_DOUBLE:
100 op = kX86MulsdRR;
101 break;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800102 case Instruction::REM_DOUBLE_2ADDR:
jeffhaobabda952012-08-02 15:55:30 -0700103 case Instruction::REM_DOUBLE:
buzbeea3a82b22012-11-27 16:09:55 -0800104 FlushAllRegs(cu); // Send everything to home location
105 CallRuntimeHelperRegLocationRegLocation(cu, ENTRYPOINT_OFFSET(pFmod), rl_src1, rl_src2, false);
106 rl_result = GetReturnWide(cu, true);
107 StoreValueWide(cu, rl_dest, rl_result);
108 return false;
109 case Instruction::NEG_DOUBLE:
110 GenNegDouble(cu, rl_dest, rl_src1);
111 return false;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800112 default:
113 return true;
114 }
buzbeefa57c472012-11-21 12:06:18 -0800115 rl_src1 = LoadValueWide(cu, rl_src1, kFPReg);
116 DCHECK(rl_src1.wide);
117 rl_src2 = LoadValueWide(cu, rl_src2, kFPReg);
118 DCHECK(rl_src2.wide);
119 rl_result = EvalLoc(cu, rl_dest, kFPReg, true);
120 DCHECK(rl_dest.wide);
121 DCHECK(rl_result.wide);
122 int r_dest = S2d(rl_result.low_reg, rl_result.high_reg);
123 int r_src1 = S2d(rl_src1.low_reg, rl_src1.high_reg);
124 int r_src2 = S2d(rl_src2.low_reg, rl_src2.high_reg);
125 if (r_dest == r_src2) {
126 r_src2 = AllocTempDouble(cu) | X86_FP_DOUBLE;
127 OpRegCopy(cu, r_src2, r_dest);
jeffhao4abb1a92012-06-08 17:02:08 -0700128 }
buzbeefa57c472012-11-21 12:06:18 -0800129 OpRegCopy(cu, r_dest, r_src1);
130 NewLIR2(cu, op, r_dest, r_src2);
131 StoreValueWide(cu, rl_dest, rl_result);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800132 return false;
buzbeee88dfbf2012-03-05 11:19:57 -0800133}
134
buzbee02031b12012-11-23 09:41:35 -0800135bool X86Codegen::GenConversion(CompilationUnit *cu, Instruction::Code opcode, RegLocation rl_dest,
136 RegLocation rl_src) {
jeffhao5121e0b2012-05-08 18:23:38 -0700137 RegisterClass rcSrc = kFPReg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800138 X86OpCode op = kX86Nop;
buzbeefa57c472012-11-21 12:06:18 -0800139 int src_reg;
140 RegLocation rl_result;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800141 switch (opcode) {
142 case Instruction::INT_TO_FLOAT:
jeffhao5121e0b2012-05-08 18:23:38 -0700143 rcSrc = kCoreReg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800144 op = kX86Cvtsi2ssRR;
145 break;
146 case Instruction::DOUBLE_TO_FLOAT:
jeffhao5121e0b2012-05-08 18:23:38 -0700147 rcSrc = kFPReg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800148 op = kX86Cvtsd2ssRR;
149 break;
150 case Instruction::FLOAT_TO_DOUBLE:
jeffhao5121e0b2012-05-08 18:23:38 -0700151 rcSrc = kFPReg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800152 op = kX86Cvtss2sdRR;
153 break;
154 case Instruction::INT_TO_DOUBLE:
jeffhao5121e0b2012-05-08 18:23:38 -0700155 rcSrc = kCoreReg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800156 op = kX86Cvtsi2sdRR;
157 break;
jeffhao292188d2012-05-17 15:45:04 -0700158 case Instruction::FLOAT_TO_INT: {
buzbeefa57c472012-11-21 12:06:18 -0800159 rl_src = LoadValue(cu, rl_src, kFPReg);
160 src_reg = rl_src.low_reg;
buzbee078fa452012-12-03 15:51:33 -0800161 // In case result vreg is also src vreg, break association to avoid useless copy by EvalLoc()
buzbeefa57c472012-11-21 12:06:18 -0800162 ClobberSReg(cu, rl_dest.s_reg_low);
163 rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
164 int temp_reg = AllocTempFloat(cu);
jeffhao41005dd2012-05-09 17:58:52 -0700165
buzbeefa57c472012-11-21 12:06:18 -0800166 LoadConstant(cu, rl_result.low_reg, 0x7fffffff);
167 NewLIR2(cu, kX86Cvtsi2ssRR, temp_reg, rl_result.low_reg);
168 NewLIR2(cu, kX86ComissRR, src_reg, temp_reg);
169 LIR* branch_pos_overflow = NewLIR2(cu, kX86Jcc8, 0, kX86CondA);
170 LIR* branch_na_n = NewLIR2(cu, kX86Jcc8, 0, kX86CondP);
171 NewLIR2(cu, kX86Cvttss2siRR, rl_result.low_reg, src_reg);
172 LIR* branch_normal = NewLIR1(cu, kX86Jmp8, 0);
173 branch_na_n->target = NewLIR0(cu, kPseudoTargetLabel);
174 NewLIR2(cu, kX86Xor32RR, rl_result.low_reg, rl_result.low_reg);
175 branch_pos_overflow->target = NewLIR0(cu, kPseudoTargetLabel);
176 branch_normal->target = NewLIR0(cu, kPseudoTargetLabel);
177 StoreValue(cu, rl_dest, rl_result);
jeffhao41005dd2012-05-09 17:58:52 -0700178 return false;
jeffhao292188d2012-05-17 15:45:04 -0700179 }
180 case Instruction::DOUBLE_TO_INT: {
buzbeefa57c472012-11-21 12:06:18 -0800181 rl_src = LoadValueWide(cu, rl_src, kFPReg);
182 src_reg = rl_src.low_reg;
buzbee078fa452012-12-03 15:51:33 -0800183 // In case result vreg is also src vreg, break association to avoid useless copy by EvalLoc()
buzbeefa57c472012-11-21 12:06:18 -0800184 ClobberSReg(cu, rl_dest.s_reg_low);
185 rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
186 int temp_reg = AllocTempDouble(cu) | X86_FP_DOUBLE;
jeffhao41005dd2012-05-09 17:58:52 -0700187
buzbeefa57c472012-11-21 12:06:18 -0800188 LoadConstant(cu, rl_result.low_reg, 0x7fffffff);
189 NewLIR2(cu, kX86Cvtsi2sdRR, temp_reg, rl_result.low_reg);
190 NewLIR2(cu, kX86ComisdRR, src_reg, temp_reg);
191 LIR* branch_pos_overflow = NewLIR2(cu, kX86Jcc8, 0, kX86CondA);
192 LIR* branch_na_n = NewLIR2(cu, kX86Jcc8, 0, kX86CondP);
193 NewLIR2(cu, kX86Cvttsd2siRR, rl_result.low_reg, src_reg);
194 LIR* branch_normal = NewLIR1(cu, kX86Jmp8, 0);
195 branch_na_n->target = NewLIR0(cu, kPseudoTargetLabel);
196 NewLIR2(cu, kX86Xor32RR, rl_result.low_reg, rl_result.low_reg);
197 branch_pos_overflow->target = NewLIR0(cu, kPseudoTargetLabel);
198 branch_normal->target = NewLIR0(cu, kPseudoTargetLabel);
199 StoreValue(cu, rl_dest, rl_result);
jeffhao41005dd2012-05-09 17:58:52 -0700200 return false;
jeffhao292188d2012-05-17 15:45:04 -0700201 }
Ian Rogersb5d09b22012-03-06 22:14:17 -0800202 case Instruction::LONG_TO_DOUBLE:
buzbeea3a82b22012-11-27 16:09:55 -0800203 return GenConversionCall(cu, ENTRYPOINT_OFFSET(pL2d), rl_dest, rl_src);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800204 case Instruction::LONG_TO_FLOAT:
jeffhaobabda952012-08-02 15:55:30 -0700205 // TODO: inline by using memory as a 64-bit source. Be careful about promoted registers.
buzbeea3a82b22012-11-27 16:09:55 -0800206 return GenConversionCall(cu, ENTRYPOINT_OFFSET(pL2f), rl_dest, rl_src);
jeffhao41005dd2012-05-09 17:58:52 -0700207 case Instruction::FLOAT_TO_LONG:
buzbeea3a82b22012-11-27 16:09:55 -0800208 return GenConversionCall(cu, ENTRYPOINT_OFFSET(pF2l), rl_dest, rl_src);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800209 case Instruction::DOUBLE_TO_LONG:
buzbeea3a82b22012-11-27 16:09:55 -0800210 return GenConversionCall(cu, ENTRYPOINT_OFFSET(pD2l), rl_dest, rl_src);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800211 default:
212 return true;
213 }
buzbeefa57c472012-11-21 12:06:18 -0800214 if (rl_src.wide) {
215 rl_src = LoadValueWide(cu, rl_src, rcSrc);
216 src_reg = S2d(rl_src.low_reg, rl_src.high_reg);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800217 } else {
buzbeefa57c472012-11-21 12:06:18 -0800218 rl_src = LoadValue(cu, rl_src, rcSrc);
219 src_reg = rl_src.low_reg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800220 }
buzbeefa57c472012-11-21 12:06:18 -0800221 if (rl_dest.wide) {
222 rl_result = EvalLoc(cu, rl_dest, kFPReg, true);
223 NewLIR2(cu, op, S2d(rl_result.low_reg, rl_result.high_reg), src_reg);
224 StoreValueWide(cu, rl_dest, rl_result);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800225 } else {
buzbeefa57c472012-11-21 12:06:18 -0800226 rl_result = EvalLoc(cu, rl_dest, kFPReg, true);
227 NewLIR2(cu, op, rl_result.low_reg, src_reg);
228 StoreValue(cu, rl_dest, rl_result);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800229 }
230 return false;
buzbeee88dfbf2012-03-05 11:19:57 -0800231}
232
buzbee02031b12012-11-23 09:41:35 -0800233bool X86Codegen::GenCmpFP(CompilationUnit *cu, Instruction::Code code, RegLocation rl_dest,
234 RegLocation rl_src1, RegLocation rl_src2) {
Ian Rogersb5d09b22012-03-06 22:14:17 -0800235 bool single = (code == Instruction::CMPL_FLOAT) || (code == Instruction::CMPG_FLOAT);
buzbeefa57c472012-11-21 12:06:18 -0800236 bool unordered_gt = (code == Instruction::CMPG_DOUBLE) || (code == Instruction::CMPG_FLOAT);
237 int src_reg1;
238 int src_reg2;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800239 if (single) {
buzbeefa57c472012-11-21 12:06:18 -0800240 rl_src1 = LoadValue(cu, rl_src1, kFPReg);
241 src_reg1 = rl_src1.low_reg;
242 rl_src2 = LoadValue(cu, rl_src2, kFPReg);
243 src_reg2 = rl_src2.low_reg;
Ian Rogersb5d09b22012-03-06 22:14:17 -0800244 } else {
buzbeefa57c472012-11-21 12:06:18 -0800245 rl_src1 = LoadValueWide(cu, rl_src1, kFPReg);
246 src_reg1 = S2d(rl_src1.low_reg, rl_src1.high_reg);
247 rl_src2 = LoadValueWide(cu, rl_src2, kFPReg);
248 src_reg2 = S2d(rl_src2.low_reg, rl_src2.high_reg);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800249 }
buzbee078fa452012-12-03 15:51:33 -0800250 // In case result vreg is also src vreg, break association to avoid useless copy by EvalLoc()
buzbeefa57c472012-11-21 12:06:18 -0800251 ClobberSReg(cu, rl_dest.s_reg_low);
252 RegLocation rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
253 LoadConstantNoClobber(cu, rl_result.low_reg, unordered_gt ? 1 : 0);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800254 if (single) {
buzbeefa57c472012-11-21 12:06:18 -0800255 NewLIR2(cu, kX86UcomissRR, src_reg1, src_reg2);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800256 } else {
buzbeefa57c472012-11-21 12:06:18 -0800257 NewLIR2(cu, kX86UcomisdRR, src_reg1, src_reg2);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800258 }
259 LIR* branch = NULL;
buzbeefa57c472012-11-21 12:06:18 -0800260 if (unordered_gt) {
261 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800262 }
jeffhao703f2cd2012-07-13 17:25:52 -0700263 // If the result reg can't be byte accessed, use a jump and move instead of a set.
buzbeefa57c472012-11-21 12:06:18 -0800264 if (rl_result.low_reg >= 4) {
jeffhao703f2cd2012-07-13 17:25:52 -0700265 LIR* branch2 = NULL;
buzbeefa57c472012-11-21 12:06:18 -0800266 if (unordered_gt) {
267 branch2 = NewLIR2(cu, kX86Jcc8, 0, kX86CondA);
268 NewLIR2(cu, kX86Mov32RI, rl_result.low_reg, 0x0);
jeffhao703f2cd2012-07-13 17:25:52 -0700269 } else {
buzbeefa57c472012-11-21 12:06:18 -0800270 branch2 = NewLIR2(cu, kX86Jcc8, 0, kX86CondBe);
271 NewLIR2(cu, kX86Mov32RI, rl_result.low_reg, 0x1);
jeffhao703f2cd2012-07-13 17:25:52 -0700272 }
buzbeefa57c472012-11-21 12:06:18 -0800273 branch2->target = NewLIR0(cu, kPseudoTargetLabel);
jeffhao703f2cd2012-07-13 17:25:52 -0700274 } else {
buzbeefa57c472012-11-21 12:06:18 -0800275 NewLIR2(cu, kX86Set8R, rl_result.low_reg, kX86CondA /* above - unsigned > */);
jeffhao703f2cd2012-07-13 17:25:52 -0700276 }
buzbeefa57c472012-11-21 12:06:18 -0800277 NewLIR2(cu, kX86Sbb32RI, rl_result.low_reg, 0);
278 if (unordered_gt) {
279 branch->target = NewLIR0(cu, kPseudoTargetLabel);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800280 }
buzbeefa57c472012-11-21 12:06:18 -0800281 StoreValue(cu, rl_dest, rl_result);
Ian Rogersb5d09b22012-03-06 22:14:17 -0800282 return false;
buzbeee88dfbf2012-03-05 11:19:57 -0800283}
284
buzbee02031b12012-11-23 09:41:35 -0800285void X86Codegen::GenFusedFPCmpBranch(CompilationUnit* cu, BasicBlock* bb, MIR* mir, bool gt_bias,
286 bool is_double) {
buzbeefa57c472012-11-21 12:06:18 -0800287 LIR* label_list = cu->block_label_list;
288 LIR* taken = &label_list[bb->taken->id];
289 LIR* not_taken = &label_list[bb->fall_through->id];
jeffhao4b771a02012-07-25 15:07:21 -0700290 LIR* branch = NULL;
buzbeefa57c472012-11-21 12:06:18 -0800291 RegLocation rl_src1;
292 RegLocation rl_src2;
293 if (is_double) {
294 rl_src1 = GetSrcWide(cu, mir, 0);
295 rl_src2 = GetSrcWide(cu, mir, 2);
296 rl_src1 = LoadValueWide(cu, rl_src1, kFPReg);
297 rl_src2 = LoadValueWide(cu, rl_src2, kFPReg);
298 NewLIR2(cu, kX86UcomisdRR, S2d(rl_src1.low_reg, rl_src1.high_reg),
299 S2d(rl_src2.low_reg, rl_src2.high_reg));
jeffhao4b771a02012-07-25 15:07:21 -0700300 } else {
buzbeefa57c472012-11-21 12:06:18 -0800301 rl_src1 = GetSrc(cu, mir, 0);
302 rl_src2 = GetSrc(cu, mir, 1);
303 rl_src1 = LoadValue(cu, rl_src1, kFPReg);
304 rl_src2 = LoadValue(cu, rl_src2, kFPReg);
305 NewLIR2(cu, kX86UcomissRR, rl_src1.low_reg, rl_src2.low_reg);
jeffhao4b771a02012-07-25 15:07:21 -0700306 }
307 ConditionCode ccode = static_cast<ConditionCode>(mir->dalvikInsn.arg[0]);
308 switch (ccode) {
309 case kCondEq:
buzbeefa57c472012-11-21 12:06:18 -0800310 if (!gt_bias) {
311 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
312 branch->target = not_taken;
jeffhao4b771a02012-07-25 15:07:21 -0700313 }
314 break;
315 case kCondNe:
buzbeefa57c472012-11-21 12:06:18 -0800316 if (!gt_bias) {
317 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
jeffhao4b771a02012-07-25 15:07:21 -0700318 branch->target = taken;
319 }
320 break;
321 case kCondLt:
buzbeefa57c472012-11-21 12:06:18 -0800322 if (gt_bias) {
323 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
324 branch->target = not_taken;
jeffhao4b771a02012-07-25 15:07:21 -0700325 }
326 ccode = kCondCs;
327 break;
328 case kCondLe:
buzbeefa57c472012-11-21 12:06:18 -0800329 if (gt_bias) {
330 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
331 branch->target = not_taken;
jeffhao4b771a02012-07-25 15:07:21 -0700332 }
333 ccode = kCondLs;
334 break;
335 case kCondGt:
buzbeefa57c472012-11-21 12:06:18 -0800336 if (gt_bias) {
337 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
jeffhao4b771a02012-07-25 15:07:21 -0700338 branch->target = taken;
339 }
340 ccode = kCondHi;
341 break;
342 case kCondGe:
buzbeefa57c472012-11-21 12:06:18 -0800343 if (gt_bias) {
344 branch = NewLIR2(cu, kX86Jcc8, 0, kX86CondPE);
jeffhao4b771a02012-07-25 15:07:21 -0700345 branch->target = taken;
346 }
347 ccode = kCondCc;
348 break;
349 default:
buzbeecbd6d442012-11-17 14:11:25 -0800350 LOG(FATAL) << "Unexpected ccode: " << ccode;
jeffhao4b771a02012-07-25 15:07:21 -0700351 }
buzbeefa57c472012-11-21 12:06:18 -0800352 OpCondBranch(cu, ccode, taken);
jeffhao4b771a02012-07-25 15:07:21 -0700353}
354
buzbee02031b12012-11-23 09:41:35 -0800355void X86Codegen::GenNegFloat(CompilationUnit *cu, RegLocation rl_dest, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800356{
buzbeefa57c472012-11-21 12:06:18 -0800357 RegLocation rl_result;
358 rl_src = LoadValue(cu, rl_src, kCoreReg);
359 rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
360 OpRegRegImm(cu, kOpAdd, rl_result.low_reg, rl_src.low_reg, 0x80000000);
361 StoreValue(cu, rl_dest, rl_result);
buzbeeefc63692012-11-14 16:31:52 -0800362}
363
buzbee02031b12012-11-23 09:41:35 -0800364void X86Codegen::GenNegDouble(CompilationUnit *cu, RegLocation rl_dest, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800365{
buzbeefa57c472012-11-21 12:06:18 -0800366 RegLocation rl_result;
367 rl_src = LoadValueWide(cu, rl_src, kCoreReg);
368 rl_result = EvalLoc(cu, rl_dest, kCoreReg, true);
369 OpRegRegImm(cu, kOpAdd, rl_result.high_reg, rl_src.high_reg, 0x80000000);
370 OpRegCopy(cu, rl_result.low_reg, rl_src.low_reg);
371 StoreValueWide(cu, rl_dest, rl_result);
buzbeeefc63692012-11-14 16:31:52 -0800372}
373
buzbee02031b12012-11-23 09:41:35 -0800374bool X86Codegen::GenInlinedSqrt(CompilationUnit* cu, CallInfo* info) {
buzbeefa57c472012-11-21 12:06:18 -0800375 DCHECK_NE(cu->instruction_set, kThumb2);
buzbeeefc63692012-11-14 16:31:52 -0800376 return false;
377}
378
379
380
buzbeee88dfbf2012-03-05 11:19:57 -0800381} // namespace art