blob: f14ebab81a3c83e595eba55f0f0e06f9436eaeb4 [file] [log] [blame]
buzbeeefc63692012-11-14 16:31:52 -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
17/* This file contains codegen for the Mips ISA */
18
19#include "oat/runtime/oat_support_entrypoints.h"
buzbee1bc37c62012-11-20 13:35:41 -080020#include "mips_lir.h"
buzbee02031b12012-11-23 09:41:35 -080021#include "codegen_mips.h"
buzbee1bc37c62012-11-20 13:35:41 -080022#include "../codegen_util.h"
23#include "../ralloc_util.h"
buzbeeefc63692012-11-14 16:31:52 -080024
25namespace art {
26
buzbee02031b12012-11-23 09:41:35 -080027void MipsCodegen::GenSpecialCase(CompilationUnit* cu, BasicBlock* bb, MIR* mir,
28 SpecialCaseHandler special_case)
buzbeeefc63692012-11-14 16:31:52 -080029{
30 // TODO
31}
32
33/*
34 * The lack of pc-relative loads on Mips presents somewhat of a challenge
35 * for our PIC switch table strategy. To materialize the current location
36 * we'll do a dummy JAL and reference our tables using r_RA as the
37 * base register. Note that r_RA will be used both as the base to
38 * locate the switch table data and as the reference base for the switch
39 * target offsets stored in the table. We'll use a special pseudo-instruction
40 * to represent the jal and trigger the construction of the
41 * switch table offsets (which will happen after final assembly and all
42 * labels are fixed).
43 *
44 * The test loop will look something like:
45 *
buzbeefa57c472012-11-21 12:06:18 -080046 * ori rEnd, r_ZERO, #table_size ; size in bytes
buzbeeefc63692012-11-14 16:31:52 -080047 * jal BaseLabel ; stores "return address" (BaseLabel) in r_RA
48 * nop ; opportunistically fill
49 * BaseLabel:
50 * addiu rBase, r_RA, <table> - <BaseLabel> ; table relative to BaseLabel
51 addu rEnd, rEnd, rBase ; end of table
buzbeefa57c472012-11-21 12:06:18 -080052 * lw r_val, [rSP, v_reg_off] ; Test Value
buzbeeefc63692012-11-14 16:31:52 -080053 * loop:
54 * beq rBase, rEnd, done
buzbeefa57c472012-11-21 12:06:18 -080055 * lw r_key, 0(rBase)
buzbeeefc63692012-11-14 16:31:52 -080056 * addu rBase, 8
buzbeefa57c472012-11-21 12:06:18 -080057 * bne r_val, r_key, loop
58 * lw r_disp, -4(rBase)
59 * addu r_RA, r_disp
buzbeeefc63692012-11-14 16:31:52 -080060 * jr r_RA
61 * done:
62 *
63 */
buzbee02031b12012-11-23 09:41:35 -080064void MipsCodegen::GenSparseSwitch(CompilationUnit* cu, uint32_t table_offset, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -080065{
buzbeefa57c472012-11-21 12:06:18 -080066 const uint16_t* table = cu->insns + cu->current_dalvik_offset + table_offset;
67 if (cu->verbose) {
buzbee52a77fc2012-11-20 19:50:46 -080068 DumpSparseSwitchTable(table);
buzbeeefc63692012-11-14 16:31:52 -080069 }
70 // Add the table to the list - we'll process it later
buzbeefa57c472012-11-21 12:06:18 -080071 SwitchTable *tab_rec =
72 static_cast<SwitchTable*>(NewMem(cu, sizeof(SwitchTable), true, kAllocData));
73 tab_rec->table = table;
74 tab_rec->vaddr = cu->current_dalvik_offset;
buzbeeefc63692012-11-14 16:31:52 -080075 int elements = table[1];
buzbeefa57c472012-11-21 12:06:18 -080076 tab_rec->targets =
77 static_cast<LIR**>(NewMem(cu, elements * sizeof(LIR*), true, kAllocLIR));
78 InsertGrowableList(cu, &cu->switch_tables, reinterpret_cast<uintptr_t>(tab_rec));
buzbeeefc63692012-11-14 16:31:52 -080079
80 // The table is composed of 8-byte key/disp pairs
buzbeefa57c472012-11-21 12:06:18 -080081 int byte_size = elements * 8;
buzbeeefc63692012-11-14 16:31:52 -080082
buzbeefa57c472012-11-21 12:06:18 -080083 int size_hi = byte_size >> 16;
84 int size_lo = byte_size & 0xffff;
buzbeeefc63692012-11-14 16:31:52 -080085
buzbeefa57c472012-11-21 12:06:18 -080086 int rEnd = AllocTemp(cu);
87 if (size_hi) {
88 NewLIR2(cu, kMipsLui, rEnd, size_hi);
buzbeeefc63692012-11-14 16:31:52 -080089 }
90 // Must prevent code motion for the curr pc pair
buzbeefa57c472012-11-21 12:06:18 -080091 GenBarrier(cu); // Scheduling barrier
92 NewLIR0(cu, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -080093 // Now, fill the branch delay slot
buzbeefa57c472012-11-21 12:06:18 -080094 if (size_hi) {
95 NewLIR3(cu, kMipsOri, rEnd, rEnd, size_lo);
buzbeeefc63692012-11-14 16:31:52 -080096 } else {
buzbeefa57c472012-11-21 12:06:18 -080097 NewLIR3(cu, kMipsOri, rEnd, r_ZERO, size_lo);
buzbeeefc63692012-11-14 16:31:52 -080098 }
buzbeefa57c472012-11-21 12:06:18 -080099 GenBarrier(cu); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800100
101 // Construct BaseLabel and set up table base register
buzbeefa57c472012-11-21 12:06:18 -0800102 LIR* base_label = NewLIR0(cu, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800103 // Remember base label so offsets can be computed later
buzbeefa57c472012-11-21 12:06:18 -0800104 tab_rec->anchor = base_label;
105 int rBase = AllocTemp(cu);
106 NewLIR4(cu, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(base_label),
107 reinterpret_cast<uintptr_t>(tab_rec));
108 OpRegRegReg(cu, kOpAdd, rEnd, rEnd, rBase);
buzbeeefc63692012-11-14 16:31:52 -0800109
110 // Grab switch test value
buzbeefa57c472012-11-21 12:06:18 -0800111 rl_src = LoadValue(cu, rl_src, kCoreReg);
buzbeeefc63692012-11-14 16:31:52 -0800112
113 // Test loop
buzbeefa57c472012-11-21 12:06:18 -0800114 int r_key = AllocTemp(cu);
115 LIR* loop_label = NewLIR0(cu, kPseudoTargetLabel);
116 LIR* exit_branch = OpCmpBranch(cu , kCondEq, rBase, rEnd, NULL);
117 LoadWordDisp(cu, rBase, 0, r_key);
118 OpRegImm(cu, kOpAdd, rBase, 8);
119 OpCmpBranch(cu, kCondNe, rl_src.low_reg, r_key, loop_label);
120 int r_disp = AllocTemp(cu);
121 LoadWordDisp(cu, rBase, -4, r_disp);
122 OpRegRegReg(cu, kOpAdd, r_RA, r_RA, r_disp);
123 OpReg(cu, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800124
125 // Loop exit
buzbeefa57c472012-11-21 12:06:18 -0800126 LIR* exit_label = NewLIR0(cu, kPseudoTargetLabel);
127 exit_branch->target = exit_label;
buzbeeefc63692012-11-14 16:31:52 -0800128}
129
130/*
131 * Code pattern will look something like:
132 *
buzbeefa57c472012-11-21 12:06:18 -0800133 * lw r_val
buzbeeefc63692012-11-14 16:31:52 -0800134 * jal BaseLabel ; stores "return address" (BaseLabel) in r_RA
135 * nop ; opportunistically fill
buzbeefa57c472012-11-21 12:06:18 -0800136 * [subiu r_val, bias] ; Remove bias if low_val != 0
buzbeeefc63692012-11-14 16:31:52 -0800137 * bound check -> done
buzbeefa57c472012-11-21 12:06:18 -0800138 * lw r_disp, [r_RA, r_val]
139 * addu r_RA, r_disp
buzbeeefc63692012-11-14 16:31:52 -0800140 * jr r_RA
141 * done:
142 */
buzbee02031b12012-11-23 09:41:35 -0800143void MipsCodegen::GenPackedSwitch(CompilationUnit* cu, uint32_t table_offset, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800144{
buzbeefa57c472012-11-21 12:06:18 -0800145 const uint16_t* table = cu->insns + cu->current_dalvik_offset + table_offset;
146 if (cu->verbose) {
buzbee52a77fc2012-11-20 19:50:46 -0800147 DumpPackedSwitchTable(table);
buzbeeefc63692012-11-14 16:31:52 -0800148 }
149 // Add the table to the list - we'll process it later
buzbeefa57c472012-11-21 12:06:18 -0800150 SwitchTable *tab_rec =
151 static_cast<SwitchTable*>(NewMem(cu, sizeof(SwitchTable), true, kAllocData));
152 tab_rec->table = table;
153 tab_rec->vaddr = cu->current_dalvik_offset;
buzbeeefc63692012-11-14 16:31:52 -0800154 int size = table[1];
buzbeefa57c472012-11-21 12:06:18 -0800155 tab_rec->targets = static_cast<LIR**>(NewMem(cu, size * sizeof(LIR*), true, kAllocLIR));
156 InsertGrowableList(cu, &cu->switch_tables, reinterpret_cast<uintptr_t>(tab_rec));
buzbeeefc63692012-11-14 16:31:52 -0800157
158 // Get the switch value
buzbeefa57c472012-11-21 12:06:18 -0800159 rl_src = LoadValue(cu, rl_src, kCoreReg);
buzbeeefc63692012-11-14 16:31:52 -0800160
161 // Prepare the bias. If too big, handle 1st stage here
buzbeefa57c472012-11-21 12:06:18 -0800162 int low_key = s4FromSwitchData(&table[2]);
163 bool large_bias = false;
164 int r_key;
165 if (low_key == 0) {
166 r_key = rl_src.low_reg;
167 } else if ((low_key & 0xffff) != low_key) {
168 r_key = AllocTemp(cu);
169 LoadConstant(cu, r_key, low_key);
170 large_bias = true;
buzbeeefc63692012-11-14 16:31:52 -0800171 } else {
buzbeefa57c472012-11-21 12:06:18 -0800172 r_key = AllocTemp(cu);
buzbeeefc63692012-11-14 16:31:52 -0800173 }
174
175 // Must prevent code motion for the curr pc pair
buzbeefa57c472012-11-21 12:06:18 -0800176 GenBarrier(cu);
177 NewLIR0(cu, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -0800178 // Now, fill the branch delay slot with bias strip
buzbeefa57c472012-11-21 12:06:18 -0800179 if (low_key == 0) {
180 NewLIR0(cu, kMipsNop);
buzbeeefc63692012-11-14 16:31:52 -0800181 } else {
buzbeefa57c472012-11-21 12:06:18 -0800182 if (large_bias) {
183 OpRegRegReg(cu, kOpSub, r_key, rl_src.low_reg, r_key);
buzbeeefc63692012-11-14 16:31:52 -0800184 } else {
buzbeefa57c472012-11-21 12:06:18 -0800185 OpRegRegImm(cu, kOpSub, r_key, rl_src.low_reg, low_key);
buzbeeefc63692012-11-14 16:31:52 -0800186 }
187 }
buzbeefa57c472012-11-21 12:06:18 -0800188 GenBarrier(cu); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800189
190 // Construct BaseLabel and set up table base register
buzbeefa57c472012-11-21 12:06:18 -0800191 LIR* base_label = NewLIR0(cu, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800192 // Remember base label so offsets can be computed later
buzbeefa57c472012-11-21 12:06:18 -0800193 tab_rec->anchor = base_label;
buzbeeefc63692012-11-14 16:31:52 -0800194
195 // Bounds check - if < 0 or >= size continue following switch
buzbeefa57c472012-11-21 12:06:18 -0800196 LIR* branch_over = OpCmpImmBranch(cu, kCondHi, r_key, size-1, NULL);
buzbeeefc63692012-11-14 16:31:52 -0800197
198 // Materialize the table base pointer
buzbeefa57c472012-11-21 12:06:18 -0800199 int rBase = AllocTemp(cu);
200 NewLIR4(cu, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(base_label),
201 reinterpret_cast<uintptr_t>(tab_rec));
buzbeeefc63692012-11-14 16:31:52 -0800202
203 // Load the displacement from the switch table
buzbeefa57c472012-11-21 12:06:18 -0800204 int r_disp = AllocTemp(cu);
205 LoadBaseIndexed(cu, rBase, r_key, r_disp, 2, kWord);
buzbeeefc63692012-11-14 16:31:52 -0800206
207 // Add to r_AP and go
buzbeefa57c472012-11-21 12:06:18 -0800208 OpRegRegReg(cu, kOpAdd, r_RA, r_RA, r_disp);
209 OpReg(cu, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800210
buzbeefa57c472012-11-21 12:06:18 -0800211 /* branch_over target here */
212 LIR* target = NewLIR0(cu, kPseudoTargetLabel);
213 branch_over->target = target;
buzbeeefc63692012-11-14 16:31:52 -0800214}
215
216/*
217 * Array data table format:
218 * ushort ident = 0x0300 magic value
219 * ushort width width of each element in the table
220 * uint size number of elements in the table
221 * ubyte data[size*width] table of data values (may contain a single-byte
222 * padding at the end)
223 *
224 * Total size is 4+(width * size + 1)/2 16-bit code units.
225 */
buzbee02031b12012-11-23 09:41:35 -0800226void MipsCodegen::GenFillArrayData(CompilationUnit* cu, uint32_t table_offset, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800227{
buzbeefa57c472012-11-21 12:06:18 -0800228 const uint16_t* table = cu->insns + cu->current_dalvik_offset + table_offset;
buzbeeefc63692012-11-14 16:31:52 -0800229 // Add the table to the list - we'll process it later
buzbeefa57c472012-11-21 12:06:18 -0800230 FillArrayData *tab_rec =
231 reinterpret_cast<FillArrayData*>(NewMem(cu, sizeof(FillArrayData), true, kAllocData));
232 tab_rec->table = table;
233 tab_rec->vaddr = cu->current_dalvik_offset;
234 uint16_t width = tab_rec->table[1];
235 uint32_t size = tab_rec->table[2] | ((static_cast<uint32_t>(tab_rec->table[3])) << 16);
236 tab_rec->size = (size * width) + 8;
buzbeeefc63692012-11-14 16:31:52 -0800237
buzbeefa57c472012-11-21 12:06:18 -0800238 InsertGrowableList(cu, &cu->fill_array_data, reinterpret_cast<uintptr_t>(tab_rec));
buzbeeefc63692012-11-14 16:31:52 -0800239
240 // Making a call - use explicit registers
buzbeefa57c472012-11-21 12:06:18 -0800241 FlushAllRegs(cu); /* Everything to home location */
242 LockCallTemps(cu);
243 LoadValueDirectFixed(cu, rl_src, rMIPS_ARG0);
buzbeeefc63692012-11-14 16:31:52 -0800244
245 // Must prevent code motion for the curr pc pair
buzbeefa57c472012-11-21 12:06:18 -0800246 GenBarrier(cu);
247 NewLIR0(cu, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -0800248 // Now, fill the branch delay slot with the helper load
buzbeefa57c472012-11-21 12:06:18 -0800249 int r_tgt = LoadHelper(cu, ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode));
250 GenBarrier(cu); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800251
252 // Construct BaseLabel and set up table base register
buzbeefa57c472012-11-21 12:06:18 -0800253 LIR* base_label = NewLIR0(cu, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800254
255 // Materialize a pointer to the fill data image
buzbeefa57c472012-11-21 12:06:18 -0800256 NewLIR4(cu, kMipsDelta, rMIPS_ARG1, 0, reinterpret_cast<uintptr_t>(base_label),
257 reinterpret_cast<uintptr_t>(tab_rec));
buzbeeefc63692012-11-14 16:31:52 -0800258
259 // And go...
buzbeefa57c472012-11-21 12:06:18 -0800260 ClobberCalleeSave(cu);
261 LIR* call_inst = OpReg(cu, kOpBlx, r_tgt); // ( array*, fill_data* )
262 MarkSafepointPC(cu, call_inst);
buzbeeefc63692012-11-14 16:31:52 -0800263}
264
265/*
266 * TODO: implement fast path to short-circuit thin-lock case
267 */
buzbee02031b12012-11-23 09:41:35 -0800268void MipsCodegen::GenMonitorEnter(CompilationUnit* cu, int opt_flags, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800269{
buzbeefa57c472012-11-21 12:06:18 -0800270 FlushAllRegs(cu);
271 LoadValueDirectFixed(cu, rl_src, rMIPS_ARG0); // Get obj
272 LockCallTemps(cu); // Prepare for explicit register usage
273 GenNullCheck(cu, rl_src.s_reg_low, rMIPS_ARG0, opt_flags);
buzbeeefc63692012-11-14 16:31:52 -0800274 // Go expensive route - artLockObjectFromCode(self, obj);
buzbeefa57c472012-11-21 12:06:18 -0800275 int r_tgt = LoadHelper(cu, ENTRYPOINT_OFFSET(pLockObjectFromCode));
276 ClobberCalleeSave(cu);
277 LIR* call_inst = OpReg(cu, kOpBlx, r_tgt);
278 MarkSafepointPC(cu, call_inst);
buzbeeefc63692012-11-14 16:31:52 -0800279}
280
281/*
282 * TODO: implement fast path to short-circuit thin-lock case
283 */
buzbee02031b12012-11-23 09:41:35 -0800284void MipsCodegen::GenMonitorExit(CompilationUnit* cu, int opt_flags, RegLocation rl_src)
buzbeeefc63692012-11-14 16:31:52 -0800285{
buzbeefa57c472012-11-21 12:06:18 -0800286 FlushAllRegs(cu);
287 LoadValueDirectFixed(cu, rl_src, rMIPS_ARG0); // Get obj
288 LockCallTemps(cu); // Prepare for explicit register usage
289 GenNullCheck(cu, rl_src.s_reg_low, rMIPS_ARG0, opt_flags);
buzbeeefc63692012-11-14 16:31:52 -0800290 // Go expensive route - UnlockObjectFromCode(obj);
buzbeefa57c472012-11-21 12:06:18 -0800291 int r_tgt = LoadHelper(cu, ENTRYPOINT_OFFSET(pUnlockObjectFromCode));
292 ClobberCalleeSave(cu);
293 LIR* call_inst = OpReg(cu, kOpBlx, r_tgt);
294 MarkSafepointPC(cu, call_inst);
buzbeeefc63692012-11-14 16:31:52 -0800295}
296
297/*
298 * Mark garbage collection card. Skip if the value we're storing is null.
299 */
buzbee02031b12012-11-23 09:41:35 -0800300void MipsCodegen::MarkGCCard(CompilationUnit* cu, int val_reg, int tgt_addr_reg)
buzbeeefc63692012-11-14 16:31:52 -0800301{
buzbeefa57c472012-11-21 12:06:18 -0800302 int reg_card_base = AllocTemp(cu);
303 int reg_card_no = AllocTemp(cu);
304 LIR* branch_over = OpCmpImmBranch(cu, kCondEq, val_reg, 0, NULL);
305 LoadWordDisp(cu, rMIPS_SELF, Thread::CardTableOffset().Int32Value(), reg_card_base);
306 OpRegRegImm(cu, kOpLsr, reg_card_no, tgt_addr_reg, CardTable::kCardShift);
307 StoreBaseIndexed(cu, reg_card_base, reg_card_no, reg_card_base, 0,
buzbeeefc63692012-11-14 16:31:52 -0800308 kUnsignedByte);
buzbeefa57c472012-11-21 12:06:18 -0800309 LIR* target = NewLIR0(cu, kPseudoTargetLabel);
310 branch_over->target = target;
311 FreeTemp(cu, reg_card_base);
312 FreeTemp(cu, reg_card_no);
buzbeeefc63692012-11-14 16:31:52 -0800313}
buzbee02031b12012-11-23 09:41:35 -0800314void MipsCodegen::GenEntrySequence(CompilationUnit* cu, RegLocation* ArgLocs, RegLocation rl_method)
buzbeeefc63692012-11-14 16:31:52 -0800315{
buzbeefa57c472012-11-21 12:06:18 -0800316 int spill_count = cu->num_core_spills + cu->num_fp_spills;
buzbeeefc63692012-11-14 16:31:52 -0800317 /*
318 * On entry, rMIPS_ARG0, rMIPS_ARG1, rMIPS_ARG2 & rMIPS_ARG3 are live. Let the register
319 * allocation mechanism know so it doesn't try to use any of them when
320 * expanding the frame or flushing. This leaves the utility
321 * code with a single temp: r12. This should be enough.
322 */
buzbeefa57c472012-11-21 12:06:18 -0800323 LockTemp(cu, rMIPS_ARG0);
324 LockTemp(cu, rMIPS_ARG1);
325 LockTemp(cu, rMIPS_ARG2);
326 LockTemp(cu, rMIPS_ARG3);
buzbeeefc63692012-11-14 16:31:52 -0800327
328 /*
329 * We can safely skip the stack overflow check if we're
330 * a leaf *and* our frame size < fudge factor.
331 */
buzbeefa57c472012-11-21 12:06:18 -0800332 bool skip_overflow_check = ((cu->attrs & METHOD_IS_LEAF) &&
333 (static_cast<size_t>(cu->frame_size) < Thread::kStackOverflowReservedBytes));
334 NewLIR0(cu, kPseudoMethodEntry);
335 int check_reg = AllocTemp(cu);
336 int new_sp = AllocTemp(cu);
337 if (!skip_overflow_check) {
buzbeeefc63692012-11-14 16:31:52 -0800338 /* Load stack limit */
buzbeefa57c472012-11-21 12:06:18 -0800339 LoadWordDisp(cu, rMIPS_SELF, Thread::StackEndOffset().Int32Value(), check_reg);
buzbeeefc63692012-11-14 16:31:52 -0800340 }
341 /* Spill core callee saves */
buzbeefa57c472012-11-21 12:06:18 -0800342 SpillCoreRegs(cu);
buzbeeefc63692012-11-14 16:31:52 -0800343 /* NOTE: promotion of FP regs currently unsupported, thus no FP spill */
buzbeefa57c472012-11-21 12:06:18 -0800344 DCHECK_EQ(cu->num_fp_spills, 0);
345 if (!skip_overflow_check) {
346 OpRegRegImm(cu, kOpSub, new_sp, rMIPS_SP, cu->frame_size - (spill_count * 4));
347 GenRegRegCheck(cu, kCondCc, new_sp, check_reg, kThrowStackOverflow);
348 OpRegCopy(cu, rMIPS_SP, new_sp); // Establish stack
buzbeeefc63692012-11-14 16:31:52 -0800349 } else {
buzbeefa57c472012-11-21 12:06:18 -0800350 OpRegImm(cu, kOpSub, rMIPS_SP, cu->frame_size - (spill_count * 4));
buzbeeefc63692012-11-14 16:31:52 -0800351 }
352
buzbeefa57c472012-11-21 12:06:18 -0800353 FlushIns(cu, ArgLocs, rl_method);
buzbeeefc63692012-11-14 16:31:52 -0800354
buzbeefa57c472012-11-21 12:06:18 -0800355 FreeTemp(cu, rMIPS_ARG0);
356 FreeTemp(cu, rMIPS_ARG1);
357 FreeTemp(cu, rMIPS_ARG2);
358 FreeTemp(cu, rMIPS_ARG3);
buzbeeefc63692012-11-14 16:31:52 -0800359}
360
buzbee02031b12012-11-23 09:41:35 -0800361void MipsCodegen::GenExitSequence(CompilationUnit* cu)
buzbeeefc63692012-11-14 16:31:52 -0800362{
363 /*
364 * In the exit path, rMIPS_RET0/rMIPS_RET1 are live - make sure they aren't
365 * allocated by the register utilities as temps.
366 */
buzbeefa57c472012-11-21 12:06:18 -0800367 LockTemp(cu, rMIPS_RET0);
368 LockTemp(cu, rMIPS_RET1);
buzbeeefc63692012-11-14 16:31:52 -0800369
buzbeefa57c472012-11-21 12:06:18 -0800370 NewLIR0(cu, kPseudoMethodExit);
371 UnSpillCoreRegs(cu);
372 OpReg(cu, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800373}
374
375} // namespace art