blob: ed92e820499d61900127c454a7221ef60afc299e [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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
17/* This file contains codegen for the Mips ISA */
18
19#include "codegen_mips.h"
Ian Rogersd582fa42014-11-05 23:46:43 -080020
Brian Carlstrom7940e442013-07-12 13:46:57 -070021#include "dex/quick/mir_to_lir-inl.h"
Ian Rogers166db042013-07-26 12:05:57 -070022#include "entrypoints/quick/quick_entrypoints.h"
Ian Rogers576ca0c2014-06-06 15:58:22 -070023#include "gc/accounting/card_table.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070024#include "mips_lir.h"
Andreas Gamped500b532015-01-16 22:09:55 -080025#include "mirror/art_method.h"
26#include "mirror/object_array-inl.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070027
28namespace art {
29
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070030bool MipsMir2Lir::GenSpecialCase(BasicBlock* bb, MIR* mir, const InlineMethod& special) {
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -080031 // TODO
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070032 UNUSED(bb, mir, special);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -080033 return false;
Brian Carlstrom7940e442013-07-12 13:46:57 -070034}
35
36/*
37 * The lack of pc-relative loads on Mips presents somewhat of a challenge
38 * for our PIC switch table strategy. To materialize the current location
buzbee2700f7e2014-03-07 09:46:20 -080039 * we'll do a dummy JAL and reference our tables using rRA as the
40 * base register. Note that rRA will be used both as the base to
Brian Carlstrom7940e442013-07-12 13:46:57 -070041 * locate the switch table data and as the reference base for the switch
42 * target offsets stored in the table. We'll use a special pseudo-instruction
43 * to represent the jal and trigger the construction of the
44 * switch table offsets (which will happen after final assembly and all
45 * labels are fixed).
46 *
47 * The test loop will look something like:
48 *
buzbee2700f7e2014-03-07 09:46:20 -080049 * ori r_end, rZERO, #table_size ; size in bytes
50 * jal BaseLabel ; stores "return address" (BaseLabel) in rRA
Brian Carlstrom7940e442013-07-12 13:46:57 -070051 * nop ; opportunistically fill
52 * BaseLabel:
buzbee2700f7e2014-03-07 09:46:20 -080053 * addiu r_base, rRA, <table> - <BaseLabel> ; table relative to BaseLabel
54 addu r_end, r_end, r_base ; end of table
Brian Carlstrom7940e442013-07-12 13:46:57 -070055 * lw r_val, [rSP, v_reg_off] ; Test Value
56 * loop:
buzbee2700f7e2014-03-07 09:46:20 -080057 * beq r_base, r_end, done
58 * lw r_key, 0(r_base)
59 * addu r_base, 8
Brian Carlstrom7940e442013-07-12 13:46:57 -070060 * bne r_val, r_key, loop
buzbee2700f7e2014-03-07 09:46:20 -080061 * lw r_disp, -4(r_base)
62 * addu rRA, r_disp
Andreas Gampe8d365912015-01-13 11:32:32 -080063 * jalr rZERO, rRA
Brian Carlstrom7940e442013-07-12 13:46:57 -070064 * done:
65 *
66 */
Andreas Gampe48971b32014-08-06 10:09:01 -070067void MipsMir2Lir::GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) {
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -070068 const uint16_t* table = mir_graph_->GetTable(mir, table_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -070069 if (cu_->verbose) {
70 DumpSparseSwitchTable(table);
71 }
72 // Add the table to the list - we'll process it later
buzbee0d829482013-10-11 15:24:55 -070073 SwitchTable* tab_rec =
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000074 static_cast<SwitchTable*>(arena_->Alloc(sizeof(SwitchTable), kArenaAllocData));
Brian Carlstrom7940e442013-07-12 13:46:57 -070075 tab_rec->table = table;
76 tab_rec->vaddr = current_dalvik_offset_;
77 int elements = table[1];
78 tab_rec->targets =
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000079 static_cast<LIR**>(arena_->Alloc(elements * sizeof(LIR*), kArenaAllocLIR));
Vladimir Markoe39c54e2014-09-22 14:50:02 +010080 switch_tables_.push_back(tab_rec);
Brian Carlstrom7940e442013-07-12 13:46:57 -070081
82 // The table is composed of 8-byte key/disp pairs
83 int byte_size = elements * 8;
84
85 int size_hi = byte_size >> 16;
86 int size_lo = byte_size & 0xffff;
87
buzbee2700f7e2014-03-07 09:46:20 -080088 RegStorage r_end = AllocTemp();
Brian Carlstrom7940e442013-07-12 13:46:57 -070089 if (size_hi) {
buzbee2700f7e2014-03-07 09:46:20 -080090 NewLIR2(kMipsLui, r_end.GetReg(), size_hi);
Brian Carlstrom7940e442013-07-12 13:46:57 -070091 }
92 // Must prevent code motion for the curr pc pair
93 GenBarrier(); // Scheduling barrier
94 NewLIR0(kMipsCurrPC); // Really a jal to .+8
95 // Now, fill the branch delay slot
96 if (size_hi) {
buzbee2700f7e2014-03-07 09:46:20 -080097 NewLIR3(kMipsOri, r_end.GetReg(), r_end.GetReg(), size_lo);
Brian Carlstrom7940e442013-07-12 13:46:57 -070098 } else {
buzbee2700f7e2014-03-07 09:46:20 -080099 NewLIR3(kMipsOri, r_end.GetReg(), rZERO, size_lo);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700100 }
101 GenBarrier(); // Scheduling barrier
102
103 // Construct BaseLabel and set up table base register
104 LIR* base_label = NewLIR0(kPseudoTargetLabel);
105 // Remember base label so offsets can be computed later
106 tab_rec->anchor = base_label;
buzbee2700f7e2014-03-07 09:46:20 -0800107 RegStorage r_base = AllocTemp();
108 NewLIR4(kMipsDelta, r_base.GetReg(), 0, WrapPointer(base_label), WrapPointer(tab_rec));
109 OpRegRegReg(kOpAdd, r_end, r_end, r_base);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110
111 // Grab switch test value
112 rl_src = LoadValue(rl_src, kCoreReg);
113
114 // Test loop
buzbee2700f7e2014-03-07 09:46:20 -0800115 RegStorage r_key = AllocTemp();
Brian Carlstrom7940e442013-07-12 13:46:57 -0700116 LIR* loop_label = NewLIR0(kPseudoTargetLabel);
buzbee2700f7e2014-03-07 09:46:20 -0800117 LIR* exit_branch = OpCmpBranch(kCondEq, r_base, r_end, NULL);
buzbee695d13a2014-04-19 13:32:20 -0700118 Load32Disp(r_base, 0, r_key);
buzbee2700f7e2014-03-07 09:46:20 -0800119 OpRegImm(kOpAdd, r_base, 8);
120 OpCmpBranch(kCondNe, rl_src.reg, r_key, loop_label);
121 RegStorage r_disp = AllocTemp();
buzbee695d13a2014-04-19 13:32:20 -0700122 Load32Disp(r_base, -4, r_disp);
buzbee2700f7e2014-03-07 09:46:20 -0800123 OpRegRegReg(kOpAdd, rs_rRA, rs_rRA, r_disp);
124 OpReg(kOpBx, rs_rRA);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700125
126 // Loop exit
127 LIR* exit_label = NewLIR0(kPseudoTargetLabel);
128 exit_branch->target = exit_label;
129}
130
131/*
132 * Code pattern will look something like:
133 *
134 * lw r_val
buzbee2700f7e2014-03-07 09:46:20 -0800135 * jal BaseLabel ; stores "return address" (BaseLabel) in rRA
Brian Carlstrom7940e442013-07-12 13:46:57 -0700136 * nop ; opportunistically fill
137 * [subiu r_val, bias] ; Remove bias if low_val != 0
138 * bound check -> done
buzbee2700f7e2014-03-07 09:46:20 -0800139 * lw r_disp, [rRA, r_val]
140 * addu rRA, r_disp
Andreas Gampe8d365912015-01-13 11:32:32 -0800141 * jalr rZERO, rRA
Brian Carlstrom7940e442013-07-12 13:46:57 -0700142 * done:
143 */
Andreas Gampe48971b32014-08-06 10:09:01 -0700144void MipsMir2Lir::GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) {
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700145 const uint16_t* table = mir_graph_->GetTable(mir, table_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700146 if (cu_->verbose) {
147 DumpPackedSwitchTable(table);
148 }
149 // Add the table to the list - we'll process it later
buzbee0d829482013-10-11 15:24:55 -0700150 SwitchTable* tab_rec =
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000151 static_cast<SwitchTable*>(arena_->Alloc(sizeof(SwitchTable), kArenaAllocData));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700152 tab_rec->table = table;
153 tab_rec->vaddr = current_dalvik_offset_;
154 int size = table[1];
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700155 tab_rec->targets = static_cast<LIR**>(arena_->Alloc(size * sizeof(LIR*),
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000156 kArenaAllocLIR));
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100157 switch_tables_.push_back(tab_rec);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700158
159 // Get the switch value
160 rl_src = LoadValue(rl_src, kCoreReg);
161
162 // Prepare the bias. If too big, handle 1st stage here
163 int low_key = s4FromSwitchData(&table[2]);
164 bool large_bias = false;
buzbee2700f7e2014-03-07 09:46:20 -0800165 RegStorage r_key;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700166 if (low_key == 0) {
buzbee2700f7e2014-03-07 09:46:20 -0800167 r_key = rl_src.reg;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700168 } else if ((low_key & 0xffff) != low_key) {
169 r_key = AllocTemp();
170 LoadConstant(r_key, low_key);
171 large_bias = true;
172 } else {
173 r_key = AllocTemp();
174 }
175
176 // Must prevent code motion for the curr pc pair
177 GenBarrier();
178 NewLIR0(kMipsCurrPC); // Really a jal to .+8
179 // Now, fill the branch delay slot with bias strip
180 if (low_key == 0) {
181 NewLIR0(kMipsNop);
182 } else {
183 if (large_bias) {
buzbee2700f7e2014-03-07 09:46:20 -0800184 OpRegRegReg(kOpSub, r_key, rl_src.reg, r_key);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700185 } else {
buzbee2700f7e2014-03-07 09:46:20 -0800186 OpRegRegImm(kOpSub, r_key, rl_src.reg, low_key);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700187 }
188 }
189 GenBarrier(); // Scheduling barrier
190
191 // Construct BaseLabel and set up table base register
192 LIR* base_label = NewLIR0(kPseudoTargetLabel);
193 // Remember base label so offsets can be computed later
194 tab_rec->anchor = base_label;
195
196 // Bounds check - if < 0 or >= size continue following switch
197 LIR* branch_over = OpCmpImmBranch(kCondHi, r_key, size-1, NULL);
198
199 // Materialize the table base pointer
buzbee2700f7e2014-03-07 09:46:20 -0800200 RegStorage r_base = AllocTemp();
201 NewLIR4(kMipsDelta, r_base.GetReg(), 0, WrapPointer(base_label), WrapPointer(tab_rec));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700202
203 // Load the displacement from the switch table
buzbee2700f7e2014-03-07 09:46:20 -0800204 RegStorage r_disp = AllocTemp();
buzbee695d13a2014-04-19 13:32:20 -0700205 LoadBaseIndexed(r_base, r_key, r_disp, 2, k32);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700206
buzbee2700f7e2014-03-07 09:46:20 -0800207 // Add to rAP and go
208 OpRegRegReg(kOpAdd, rs_rRA, rs_rRA, r_disp);
209 OpReg(kOpBx, rs_rRA);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700210
211 /* branch_over target here */
212 LIR* target = NewLIR0(kPseudoTargetLabel);
213 branch_over->target = target;
214}
215
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700216void MipsMir2Lir::GenMoveException(RegLocation rl_dest) {
Ian Rogersdd7624d2014-03-14 17:43:00 -0700217 int ex_offset = Thread::ExceptionOffset<4>().Int32Value();
buzbeea0cd2d72014-06-01 09:33:49 -0700218 RegLocation rl_result = EvalLoc(rl_dest, kRefReg, true);
219 RegStorage reset_reg = AllocTempRef();
Andreas Gampe3c12c512014-06-24 18:46:29 +0000220 LoadRefDisp(rs_rMIPS_SELF, ex_offset, rl_result.reg, kNotVolatile);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700221 LoadConstant(reset_reg, 0);
Andreas Gampe3c12c512014-06-24 18:46:29 +0000222 StoreRefDisp(rs_rMIPS_SELF, ex_offset, reset_reg, kNotVolatile);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700223 FreeTemp(reset_reg);
224 StoreValue(rl_dest, rl_result);
225}
226
Vladimir Markobf535be2014-11-19 18:52:35 +0000227void MipsMir2Lir::UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) {
buzbee2700f7e2014-03-07 09:46:20 -0800228 RegStorage reg_card_base = AllocTemp();
229 RegStorage reg_card_no = AllocTemp();
buzbee695d13a2014-04-19 13:32:20 -0700230 // NOTE: native pointer.
Ian Rogersdd7624d2014-03-14 17:43:00 -0700231 LoadWordDisp(rs_rMIPS_SELF, Thread::CardTableOffset<4>().Int32Value(), reg_card_base);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700232 OpRegRegImm(kOpLsr, reg_card_no, tgt_addr_reg, gc::accounting::CardTable::kCardShift);
buzbee2700f7e2014-03-07 09:46:20 -0800233 StoreBaseIndexed(reg_card_base, reg_card_no, reg_card_base, 0, kUnsignedByte);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700234 FreeTemp(reg_card_base);
235 FreeTemp(reg_card_no);
236}
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700237
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700238void MipsMir2Lir::GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700239 int spill_count = num_core_spills_ + num_fp_spills_;
240 /*
241 * On entry, rMIPS_ARG0, rMIPS_ARG1, rMIPS_ARG2 & rMIPS_ARG3 are live. Let the register
242 * allocation mechanism know so it doesn't try to use any of them when
243 * expanding the frame or flushing. This leaves the utility
244 * code with a single temp: r12. This should be enough.
245 */
buzbee091cc402014-03-31 10:14:40 -0700246 LockTemp(rs_rMIPS_ARG0);
247 LockTemp(rs_rMIPS_ARG1);
248 LockTemp(rs_rMIPS_ARG2);
249 LockTemp(rs_rMIPS_ARG3);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700250
251 /*
252 * We can safely skip the stack overflow check if we're
253 * a leaf *and* our frame size < fudge factor.
254 */
Dave Allison648d7112014-07-25 16:15:27 -0700255 bool skip_overflow_check = mir_graph_->MethodIsLeaf() && !FrameNeedsStackCheck(frame_size_, kMips);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700256 NewLIR0(kPseudoMethodEntry);
buzbee2700f7e2014-03-07 09:46:20 -0800257 RegStorage check_reg = AllocTemp();
258 RegStorage new_sp = AllocTemp();
Brian Carlstrom7940e442013-07-12 13:46:57 -0700259 if (!skip_overflow_check) {
260 /* Load stack limit */
buzbee695d13a2014-04-19 13:32:20 -0700261 Load32Disp(rs_rMIPS_SELF, Thread::StackEndOffset<4>().Int32Value(), check_reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700262 }
263 /* Spill core callee saves */
264 SpillCoreRegs();
265 /* NOTE: promotion of FP regs currently unsupported, thus no FP spill */
266 DCHECK_EQ(num_fp_spills_, 0);
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700267 const int frame_sub = frame_size_ - spill_count * 4;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700268 if (!skip_overflow_check) {
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700269 class StackOverflowSlowPath : public LIRSlowPath {
270 public:
271 StackOverflowSlowPath(Mir2Lir* m2l, LIR* branch, size_t sp_displace)
272 : LIRSlowPath(m2l, m2l->GetCurrentDexPc(), branch, nullptr), sp_displace_(sp_displace) {
273 }
274 void Compile() OVERRIDE {
275 m2l_->ResetRegPool();
276 m2l_->ResetDefTracking();
Mingyao Yang6ffcfa02014-04-25 11:06:00 -0700277 GenerateTargetLabel(kPseudoThrowTarget);
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700278 // LR is offset 0 since we push in reverse order.
buzbee695d13a2014-04-19 13:32:20 -0700279 m2l_->Load32Disp(rs_rMIPS_SP, 0, rs_rRA);
buzbee2700f7e2014-03-07 09:46:20 -0800280 m2l_->OpRegImm(kOpAdd, rs_rMIPS_SP, sp_displace_);
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700281 m2l_->ClobberCallerSave();
Andreas Gampe98430592014-07-27 19:44:50 -0700282 RegStorage r_tgt = m2l_->CallHelperSetup(kQuickThrowStackOverflow); // Doesn't clobber LR.
283 m2l_->CallHelper(r_tgt, kQuickThrowStackOverflow, false /* MarkSafepointPC */,
284 false /* UseLink */);
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700285 }
286
287 private:
288 const size_t sp_displace_;
289 };
buzbee2700f7e2014-03-07 09:46:20 -0800290 OpRegRegImm(kOpSub, new_sp, rs_rMIPS_SP, frame_sub);
Mathieu Chartier0d507d12014-03-19 10:17:28 -0700291 LIR* branch = OpCmpBranch(kCondUlt, new_sp, check_reg, nullptr);
292 AddSlowPath(new(arena_)StackOverflowSlowPath(this, branch, spill_count * 4));
293 // TODO: avoid copy for small frame sizes.
buzbee2700f7e2014-03-07 09:46:20 -0800294 OpRegCopy(rs_rMIPS_SP, new_sp); // Establish stack
Brian Carlstrom7940e442013-07-12 13:46:57 -0700295 } else {
buzbee2700f7e2014-03-07 09:46:20 -0800296 OpRegImm(kOpSub, rs_rMIPS_SP, frame_sub);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700297 }
298
299 FlushIns(ArgLocs, rl_method);
300
buzbee091cc402014-03-31 10:14:40 -0700301 FreeTemp(rs_rMIPS_ARG0);
302 FreeTemp(rs_rMIPS_ARG1);
303 FreeTemp(rs_rMIPS_ARG2);
304 FreeTemp(rs_rMIPS_ARG3);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700305}
306
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700307void MipsMir2Lir::GenExitSequence() {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700308 /*
309 * In the exit path, rMIPS_RET0/rMIPS_RET1 are live - make sure they aren't
310 * allocated by the register utilities as temps.
311 */
buzbee091cc402014-03-31 10:14:40 -0700312 LockTemp(rs_rMIPS_RET0);
313 LockTemp(rs_rMIPS_RET1);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700314
315 NewLIR0(kPseudoMethodExit);
316 UnSpillCoreRegs();
buzbee2700f7e2014-03-07 09:46:20 -0800317 OpReg(kOpBx, rs_rRA);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700318}
319
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800320void MipsMir2Lir::GenSpecialExitSequence() {
buzbee2700f7e2014-03-07 09:46:20 -0800321 OpReg(kOpBx, rs_rRA);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800322}
323
Andreas Gamped500b532015-01-16 22:09:55 -0800324/*
325 * Bit of a hack here - in the absence of a real scheduling pass,
326 * emit the next instruction in static & direct invoke sequences.
327 */
328static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info ATTRIBUTE_UNUSED,
329 int state, const MethodReference& target_method,
330 uint32_t,
331 uintptr_t direct_code, uintptr_t direct_method,
332 InvokeType type) {
333 Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get());
334 if (direct_code != 0 && direct_method != 0) {
335 switch (state) {
336 case 0: // Get the current Method* [sets kArg0]
337 if (direct_code != static_cast<uintptr_t>(-1)) {
338 cg->LoadConstant(cg->TargetPtrReg(kInvokeTgt), direct_code);
339 } else {
340 cg->LoadCodeAddress(target_method, type, kInvokeTgt);
341 }
342 if (direct_method != static_cast<uintptr_t>(-1)) {
343 cg->LoadConstant(cg->TargetReg(kArg0, kRef), direct_method);
344 } else {
345 cg->LoadMethodAddress(target_method, type, kArg0);
346 }
347 break;
348 default:
349 return -1;
350 }
351 } else {
352 RegStorage arg0_ref = cg->TargetReg(kArg0, kRef);
353 switch (state) {
354 case 0: // Get the current Method* [sets kArg0]
355 // TUNING: we can save a reg copy if Method* has been promoted.
356 cg->LoadCurrMethodDirect(arg0_ref);
357 break;
358 case 1: // Get method->dex_cache_resolved_methods_
359 cg->LoadRefDisp(arg0_ref,
360 mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(),
361 arg0_ref,
362 kNotVolatile);
363 // Set up direct code if known.
364 if (direct_code != 0) {
365 if (direct_code != static_cast<uintptr_t>(-1)) {
366 cg->LoadConstant(cg->TargetPtrReg(kInvokeTgt), direct_code);
367 } else {
368 CHECK_LT(target_method.dex_method_index, target_method.dex_file->NumMethodIds());
369 cg->LoadCodeAddress(target_method, type, kInvokeTgt);
370 }
371 }
372 break;
373 case 2: // Grab target method*
374 CHECK_EQ(cu->dex_file, target_method.dex_file);
375 cg->LoadRefDisp(arg0_ref,
376 mirror::ObjectArray<mirror::Object>::
377 OffsetOfElement(target_method.dex_method_index).Int32Value(),
378 arg0_ref,
379 kNotVolatile);
380 break;
381 case 3: // Grab the code from the method*
382 if (direct_code == 0) {
383 int32_t offset = mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(
384 InstructionSetPointerSize(cu->instruction_set)).Int32Value();
385 // Get the compiled code address [use *alt_from or kArg0, set kInvokeTgt]
386 cg->LoadWordDisp(arg0_ref, offset, cg->TargetPtrReg(kInvokeTgt));
387 }
388 break;
389 default:
390 return -1;
391 }
392 }
393 return state + 1;
394}
395
396NextCallInsn MipsMir2Lir::GetNextSDCallInsn() {
397 return NextSDCallInsn;
398}
399
400LIR* MipsMir2Lir::GenCallInsn(const MirMethodLoweringInfo& method_info ATTRIBUTE_UNUSED) {
401 return OpReg(kOpBlx, TargetPtrReg(kInvokeTgt));
402}
403
Brian Carlstrom7940e442013-07-12 13:46:57 -0700404} // namespace art