blob: 33a7aed9d265922b18b40a177c9e493acb5c79dc [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"
21#include "../codegen_util.h"
22#include "../ralloc_util.h"
buzbeeefc63692012-11-14 16:31:52 -080023
24namespace art {
25
buzbee52a77fc2012-11-20 19:50:46 -080026void GenSpecialCase(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir,
buzbeeefc63692012-11-14 16:31:52 -080027 SpecialCaseHandler specialCase)
28{
29 // TODO
30}
31
32/*
33 * The lack of pc-relative loads on Mips presents somewhat of a challenge
34 * for our PIC switch table strategy. To materialize the current location
35 * we'll do a dummy JAL and reference our tables using r_RA as the
36 * base register. Note that r_RA will be used both as the base to
37 * locate the switch table data and as the reference base for the switch
38 * target offsets stored in the table. We'll use a special pseudo-instruction
39 * to represent the jal and trigger the construction of the
40 * switch table offsets (which will happen after final assembly and all
41 * labels are fixed).
42 *
43 * The test loop will look something like:
44 *
45 * ori rEnd, r_ZERO, #tableSize ; size in bytes
46 * jal BaseLabel ; stores "return address" (BaseLabel) in r_RA
47 * nop ; opportunistically fill
48 * BaseLabel:
49 * addiu rBase, r_RA, <table> - <BaseLabel> ; table relative to BaseLabel
50 addu rEnd, rEnd, rBase ; end of table
51 * lw rVal, [rSP, vRegOff] ; Test Value
52 * loop:
53 * beq rBase, rEnd, done
54 * lw rKey, 0(rBase)
55 * addu rBase, 8
56 * bne rVal, rKey, loop
57 * lw rDisp, -4(rBase)
58 * addu r_RA, rDisp
59 * jr r_RA
60 * done:
61 *
62 */
buzbee52a77fc2012-11-20 19:50:46 -080063void GenSparseSwitch(CompilationUnit* cUnit, uint32_t tableOffset,
buzbeeefc63692012-11-14 16:31:52 -080064 RegLocation rlSrc)
65{
buzbeeeaf09bc2012-11-15 14:51:41 -080066 const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
buzbeeefc63692012-11-14 16:31:52 -080067 if (cUnit->printMe) {
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
buzbeecbd6d442012-11-17 14:11:25 -080071 SwitchTable *tabRec =
buzbee52a77fc2012-11-20 19:50:46 -080072 static_cast<SwitchTable*>(NewMem(cUnit, sizeof(SwitchTable), true, kAllocData));
buzbeeefc63692012-11-14 16:31:52 -080073 tabRec->table = table;
74 tabRec->vaddr = cUnit->currentDalvikOffset;
75 int elements = table[1];
buzbeecbd6d442012-11-17 14:11:25 -080076 tabRec->targets =
buzbee52a77fc2012-11-20 19:50:46 -080077 static_cast<LIR**>(NewMem(cUnit, elements * sizeof(LIR*), true, kAllocLIR));
78 InsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
buzbeeefc63692012-11-14 16:31:52 -080079
80 // The table is composed of 8-byte key/disp pairs
81 int byteSize = elements * 8;
82
83 int sizeHi = byteSize >> 16;
84 int sizeLo = byteSize & 0xffff;
85
buzbee52a77fc2012-11-20 19:50:46 -080086 int rEnd = AllocTemp(cUnit);
buzbeeefc63692012-11-14 16:31:52 -080087 if (sizeHi) {
buzbee52a77fc2012-11-20 19:50:46 -080088 NewLIR2(cUnit, kMipsLui, rEnd, sizeHi);
buzbeeefc63692012-11-14 16:31:52 -080089 }
90 // Must prevent code motion for the curr pc pair
buzbee52a77fc2012-11-20 19:50:46 -080091 GenBarrier(cUnit); // Scheduling barrier
92 NewLIR0(cUnit, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -080093 // Now, fill the branch delay slot
94 if (sizeHi) {
buzbee52a77fc2012-11-20 19:50:46 -080095 NewLIR3(cUnit, kMipsOri, rEnd, rEnd, sizeLo);
buzbeeefc63692012-11-14 16:31:52 -080096 } else {
buzbee52a77fc2012-11-20 19:50:46 -080097 NewLIR3(cUnit, kMipsOri, rEnd, r_ZERO, sizeLo);
buzbeeefc63692012-11-14 16:31:52 -080098 }
buzbee52a77fc2012-11-20 19:50:46 -080099 GenBarrier(cUnit); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800100
101 // Construct BaseLabel and set up table base register
buzbee52a77fc2012-11-20 19:50:46 -0800102 LIR* baseLabel = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800103 // Remember base label so offsets can be computed later
104 tabRec->anchor = baseLabel;
buzbee52a77fc2012-11-20 19:50:46 -0800105 int rBase = AllocTemp(cUnit);
106 NewLIR4(cUnit, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(baseLabel),
buzbeecbd6d442012-11-17 14:11:25 -0800107 reinterpret_cast<uintptr_t>(tabRec));
buzbee52a77fc2012-11-20 19:50:46 -0800108 OpRegRegReg(cUnit, kOpAdd, rEnd, rEnd, rBase);
buzbeeefc63692012-11-14 16:31:52 -0800109
110 // Grab switch test value
buzbee52a77fc2012-11-20 19:50:46 -0800111 rlSrc = LoadValue(cUnit, rlSrc, kCoreReg);
buzbeeefc63692012-11-14 16:31:52 -0800112
113 // Test loop
buzbee52a77fc2012-11-20 19:50:46 -0800114 int rKey = AllocTemp(cUnit);
115 LIR* loopLabel = NewLIR0(cUnit, kPseudoTargetLabel);
116 LIR* exitBranch = OpCmpBranch(cUnit , kCondEq, rBase, rEnd, NULL);
117 LoadWordDisp(cUnit, rBase, 0, rKey);
118 OpRegImm(cUnit, kOpAdd, rBase, 8);
119 OpCmpBranch(cUnit, kCondNe, rlSrc.lowReg, rKey, loopLabel);
120 int rDisp = AllocTemp(cUnit);
121 LoadWordDisp(cUnit, rBase, -4, rDisp);
122 OpRegRegReg(cUnit, kOpAdd, r_RA, r_RA, rDisp);
123 OpReg(cUnit, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800124
125 // Loop exit
buzbee52a77fc2012-11-20 19:50:46 -0800126 LIR* exitLabel = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800127 exitBranch->target = exitLabel;
128}
129
130/*
131 * Code pattern will look something like:
132 *
133 * lw rVal
134 * jal BaseLabel ; stores "return address" (BaseLabel) in r_RA
135 * nop ; opportunistically fill
136 * [subiu rVal, bias] ; Remove bias if lowVal != 0
137 * bound check -> done
138 * lw rDisp, [r_RA, rVal]
139 * addu r_RA, rDisp
140 * jr r_RA
141 * done:
142 */
buzbee52a77fc2012-11-20 19:50:46 -0800143void GenPackedSwitch(CompilationUnit* cUnit, uint32_t tableOffset,
buzbeeefc63692012-11-14 16:31:52 -0800144 RegLocation rlSrc)
145{
buzbeeeaf09bc2012-11-15 14:51:41 -0800146 const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
buzbeeefc63692012-11-14 16:31:52 -0800147 if (cUnit->printMe) {
buzbee52a77fc2012-11-20 19:50:46 -0800148 DumpPackedSwitchTable(table);
buzbeeefc63692012-11-14 16:31:52 -0800149 }
150 // Add the table to the list - we'll process it later
buzbeecbd6d442012-11-17 14:11:25 -0800151 SwitchTable *tabRec =
buzbee52a77fc2012-11-20 19:50:46 -0800152 static_cast<SwitchTable*>(NewMem(cUnit, sizeof(SwitchTable), true, kAllocData));
buzbeeefc63692012-11-14 16:31:52 -0800153 tabRec->table = table;
154 tabRec->vaddr = cUnit->currentDalvikOffset;
155 int size = table[1];
buzbee52a77fc2012-11-20 19:50:46 -0800156 tabRec->targets = static_cast<LIR**>(NewMem(cUnit, size * sizeof(LIR*), true, kAllocLIR));
157 InsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
buzbeeefc63692012-11-14 16:31:52 -0800158
159 // Get the switch value
buzbee52a77fc2012-11-20 19:50:46 -0800160 rlSrc = LoadValue(cUnit, rlSrc, kCoreReg);
buzbeeefc63692012-11-14 16:31:52 -0800161
162 // Prepare the bias. If too big, handle 1st stage here
163 int lowKey = s4FromSwitchData(&table[2]);
164 bool largeBias = false;
165 int rKey;
166 if (lowKey == 0) {
167 rKey = rlSrc.lowReg;
168 } else if ((lowKey & 0xffff) != lowKey) {
buzbee52a77fc2012-11-20 19:50:46 -0800169 rKey = AllocTemp(cUnit);
170 LoadConstant(cUnit, rKey, lowKey);
buzbeeefc63692012-11-14 16:31:52 -0800171 largeBias = true;
172 } else {
buzbee52a77fc2012-11-20 19:50:46 -0800173 rKey = AllocTemp(cUnit);
buzbeeefc63692012-11-14 16:31:52 -0800174 }
175
176 // Must prevent code motion for the curr pc pair
buzbee52a77fc2012-11-20 19:50:46 -0800177 GenBarrier(cUnit);
178 NewLIR0(cUnit, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -0800179 // Now, fill the branch delay slot with bias strip
180 if (lowKey == 0) {
buzbee52a77fc2012-11-20 19:50:46 -0800181 NewLIR0(cUnit, kMipsNop);
buzbeeefc63692012-11-14 16:31:52 -0800182 } else {
183 if (largeBias) {
buzbee52a77fc2012-11-20 19:50:46 -0800184 OpRegRegReg(cUnit, kOpSub, rKey, rlSrc.lowReg, rKey);
buzbeeefc63692012-11-14 16:31:52 -0800185 } else {
buzbee52a77fc2012-11-20 19:50:46 -0800186 OpRegRegImm(cUnit, kOpSub, rKey, rlSrc.lowReg, lowKey);
buzbeeefc63692012-11-14 16:31:52 -0800187 }
188 }
buzbee52a77fc2012-11-20 19:50:46 -0800189 GenBarrier(cUnit); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800190
191 // Construct BaseLabel and set up table base register
buzbee52a77fc2012-11-20 19:50:46 -0800192 LIR* baseLabel = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800193 // Remember base label so offsets can be computed later
194 tabRec->anchor = baseLabel;
195
196 // Bounds check - if < 0 or >= size continue following switch
buzbee52a77fc2012-11-20 19:50:46 -0800197 LIR* branchOver = OpCmpImmBranch(cUnit, kCondHi, rKey, size-1, NULL);
buzbeeefc63692012-11-14 16:31:52 -0800198
199 // Materialize the table base pointer
buzbee52a77fc2012-11-20 19:50:46 -0800200 int rBase = AllocTemp(cUnit);
201 NewLIR4(cUnit, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(baseLabel),
buzbeecbd6d442012-11-17 14:11:25 -0800202 reinterpret_cast<uintptr_t>(tabRec));
buzbeeefc63692012-11-14 16:31:52 -0800203
204 // Load the displacement from the switch table
buzbee52a77fc2012-11-20 19:50:46 -0800205 int rDisp = AllocTemp(cUnit);
206 LoadBaseIndexed(cUnit, rBase, rKey, rDisp, 2, kWord);
buzbeeefc63692012-11-14 16:31:52 -0800207
208 // Add to r_AP and go
buzbee52a77fc2012-11-20 19:50:46 -0800209 OpRegRegReg(cUnit, kOpAdd, r_RA, r_RA, rDisp);
210 OpReg(cUnit, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800211
212 /* branchOver target here */
buzbee52a77fc2012-11-20 19:50:46 -0800213 LIR* target = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeecbd6d442012-11-17 14:11:25 -0800214 branchOver->target = target;
buzbeeefc63692012-11-14 16:31:52 -0800215}
216
217/*
218 * Array data table format:
219 * ushort ident = 0x0300 magic value
220 * ushort width width of each element in the table
221 * uint size number of elements in the table
222 * ubyte data[size*width] table of data values (may contain a single-byte
223 * padding at the end)
224 *
225 * Total size is 4+(width * size + 1)/2 16-bit code units.
226 */
buzbee52a77fc2012-11-20 19:50:46 -0800227void GenFillArrayData(CompilationUnit* cUnit, uint32_t tableOffset,
buzbeeefc63692012-11-14 16:31:52 -0800228 RegLocation rlSrc)
229{
buzbeeeaf09bc2012-11-15 14:51:41 -0800230 const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
buzbeeefc63692012-11-14 16:31:52 -0800231 // Add the table to the list - we'll process it later
buzbeecbd6d442012-11-17 14:11:25 -0800232 FillArrayData *tabRec =
buzbee52a77fc2012-11-20 19:50:46 -0800233 reinterpret_cast<FillArrayData*>(NewMem(cUnit, sizeof(FillArrayData), true, kAllocData));
buzbeeefc63692012-11-14 16:31:52 -0800234 tabRec->table = table;
235 tabRec->vaddr = cUnit->currentDalvikOffset;
buzbeeeaf09bc2012-11-15 14:51:41 -0800236 uint16_t width = tabRec->table[1];
237 uint32_t size = tabRec->table[2] | ((static_cast<uint32_t>(tabRec->table[3])) << 16);
buzbeeefc63692012-11-14 16:31:52 -0800238 tabRec->size = (size * width) + 8;
239
buzbee52a77fc2012-11-20 19:50:46 -0800240 InsertGrowableList(cUnit, &cUnit->fillArrayData, reinterpret_cast<uintptr_t>(tabRec));
buzbeeefc63692012-11-14 16:31:52 -0800241
242 // Making a call - use explicit registers
buzbee52a77fc2012-11-20 19:50:46 -0800243 FlushAllRegs(cUnit); /* Everything to home location */
244 LockCallTemps(cUnit);
245 LoadValueDirectFixed(cUnit, rlSrc, rMIPS_ARG0);
buzbeeefc63692012-11-14 16:31:52 -0800246
247 // Must prevent code motion for the curr pc pair
buzbee52a77fc2012-11-20 19:50:46 -0800248 GenBarrier(cUnit);
249 NewLIR0(cUnit, kMipsCurrPC); // Really a jal to .+8
buzbeeefc63692012-11-14 16:31:52 -0800250 // Now, fill the branch delay slot with the helper load
buzbee52a77fc2012-11-20 19:50:46 -0800251 int rTgt = LoadHelper(cUnit, ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode));
252 GenBarrier(cUnit); // Scheduling barrier
buzbeeefc63692012-11-14 16:31:52 -0800253
254 // Construct BaseLabel and set up table base register
buzbee52a77fc2012-11-20 19:50:46 -0800255 LIR* baseLabel = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeeefc63692012-11-14 16:31:52 -0800256
257 // Materialize a pointer to the fill data image
buzbee52a77fc2012-11-20 19:50:46 -0800258 NewLIR4(cUnit, kMipsDelta, rMIPS_ARG1, 0, reinterpret_cast<uintptr_t>(baseLabel),
buzbeecbd6d442012-11-17 14:11:25 -0800259 reinterpret_cast<uintptr_t>(tabRec));
buzbeeefc63692012-11-14 16:31:52 -0800260
261 // And go...
buzbee52a77fc2012-11-20 19:50:46 -0800262 ClobberCalleeSave(cUnit);
263 LIR* callInst = OpReg(cUnit, kOpBlx, rTgt); // ( array*, fill_data* )
264 MarkSafepointPC(cUnit, callInst);
buzbeeefc63692012-11-14 16:31:52 -0800265}
266
267/*
268 * TODO: implement fast path to short-circuit thin-lock case
269 */
buzbee52a77fc2012-11-20 19:50:46 -0800270void GenMonitorEnter(CompilationUnit* cUnit, int optFlags, RegLocation rlSrc)
buzbeeefc63692012-11-14 16:31:52 -0800271{
buzbee52a77fc2012-11-20 19:50:46 -0800272 FlushAllRegs(cUnit);
273 LoadValueDirectFixed(cUnit, rlSrc, rMIPS_ARG0); // Get obj
274 LockCallTemps(cUnit); // Prepare for explicit register usage
275 GenNullCheck(cUnit, rlSrc.sRegLow, rMIPS_ARG0, optFlags);
buzbeeefc63692012-11-14 16:31:52 -0800276 // Go expensive route - artLockObjectFromCode(self, obj);
buzbee52a77fc2012-11-20 19:50:46 -0800277 int rTgt = LoadHelper(cUnit, ENTRYPOINT_OFFSET(pLockObjectFromCode));
278 ClobberCalleeSave(cUnit);
279 LIR* callInst = OpReg(cUnit, kOpBlx, rTgt);
280 MarkSafepointPC(cUnit, callInst);
buzbeeefc63692012-11-14 16:31:52 -0800281}
282
283/*
284 * TODO: implement fast path to short-circuit thin-lock case
285 */
buzbee52a77fc2012-11-20 19:50:46 -0800286void GenMonitorExit(CompilationUnit* cUnit, int optFlags, RegLocation rlSrc)
buzbeeefc63692012-11-14 16:31:52 -0800287{
buzbee52a77fc2012-11-20 19:50:46 -0800288 FlushAllRegs(cUnit);
289 LoadValueDirectFixed(cUnit, rlSrc, rMIPS_ARG0); // Get obj
290 LockCallTemps(cUnit); // Prepare for explicit register usage
291 GenNullCheck(cUnit, rlSrc.sRegLow, rMIPS_ARG0, optFlags);
buzbeeefc63692012-11-14 16:31:52 -0800292 // Go expensive route - UnlockObjectFromCode(obj);
buzbee52a77fc2012-11-20 19:50:46 -0800293 int rTgt = LoadHelper(cUnit, ENTRYPOINT_OFFSET(pUnlockObjectFromCode));
294 ClobberCalleeSave(cUnit);
295 LIR* callInst = OpReg(cUnit, kOpBlx, rTgt);
296 MarkSafepointPC(cUnit, callInst);
buzbeeefc63692012-11-14 16:31:52 -0800297}
298
299/*
300 * Mark garbage collection card. Skip if the value we're storing is null.
301 */
buzbee52a77fc2012-11-20 19:50:46 -0800302void MarkGCCard(CompilationUnit* cUnit, int valReg, int tgtAddrReg)
buzbeeefc63692012-11-14 16:31:52 -0800303{
buzbee52a77fc2012-11-20 19:50:46 -0800304 int regCardBase = AllocTemp(cUnit);
305 int regCardNo = AllocTemp(cUnit);
306 LIR* branchOver = OpCmpImmBranch(cUnit, kCondEq, valReg, 0, NULL);
307 LoadWordDisp(cUnit, rMIPS_SELF, Thread::CardTableOffset().Int32Value(), regCardBase);
308 OpRegRegImm(cUnit, kOpLsr, regCardNo, tgtAddrReg, CardTable::kCardShift);
309 StoreBaseIndexed(cUnit, regCardBase, regCardNo, regCardBase, 0,
buzbeeefc63692012-11-14 16:31:52 -0800310 kUnsignedByte);
buzbee52a77fc2012-11-20 19:50:46 -0800311 LIR* target = NewLIR0(cUnit, kPseudoTargetLabel);
buzbeecbd6d442012-11-17 14:11:25 -0800312 branchOver->target = target;
buzbee52a77fc2012-11-20 19:50:46 -0800313 FreeTemp(cUnit, regCardBase);
314 FreeTemp(cUnit, regCardNo);
buzbeeefc63692012-11-14 16:31:52 -0800315}
buzbee52a77fc2012-11-20 19:50:46 -0800316void GenEntrySequence(CompilationUnit* cUnit, RegLocation* ArgLocs,
buzbeeefc63692012-11-14 16:31:52 -0800317 RegLocation rlMethod)
318{
319 int spillCount = cUnit->numCoreSpills + cUnit->numFPSpills;
320 /*
321 * On entry, rMIPS_ARG0, rMIPS_ARG1, rMIPS_ARG2 & rMIPS_ARG3 are live. Let the register
322 * allocation mechanism know so it doesn't try to use any of them when
323 * expanding the frame or flushing. This leaves the utility
324 * code with a single temp: r12. This should be enough.
325 */
buzbee52a77fc2012-11-20 19:50:46 -0800326 LockTemp(cUnit, rMIPS_ARG0);
327 LockTemp(cUnit, rMIPS_ARG1);
328 LockTemp(cUnit, rMIPS_ARG2);
329 LockTemp(cUnit, rMIPS_ARG3);
buzbeeefc63692012-11-14 16:31:52 -0800330
331 /*
332 * We can safely skip the stack overflow check if we're
333 * a leaf *and* our frame size < fudge factor.
334 */
335 bool skipOverflowCheck = ((cUnit->attrs & METHOD_IS_LEAF) &&
buzbeecbd6d442012-11-17 14:11:25 -0800336 (static_cast<size_t>(cUnit->frameSize) < Thread::kStackOverflowReservedBytes));
buzbee52a77fc2012-11-20 19:50:46 -0800337 NewLIR0(cUnit, kPseudoMethodEntry);
338 int checkReg = AllocTemp(cUnit);
339 int newSP = AllocTemp(cUnit);
buzbeeefc63692012-11-14 16:31:52 -0800340 if (!skipOverflowCheck) {
341 /* Load stack limit */
buzbee52a77fc2012-11-20 19:50:46 -0800342 LoadWordDisp(cUnit, rMIPS_SELF, Thread::StackEndOffset().Int32Value(), checkReg);
buzbeeefc63692012-11-14 16:31:52 -0800343 }
344 /* Spill core callee saves */
buzbee52a77fc2012-11-20 19:50:46 -0800345 SpillCoreRegs(cUnit);
buzbeeefc63692012-11-14 16:31:52 -0800346 /* NOTE: promotion of FP regs currently unsupported, thus no FP spill */
347 DCHECK_EQ(cUnit->numFPSpills, 0);
348 if (!skipOverflowCheck) {
buzbee52a77fc2012-11-20 19:50:46 -0800349 OpRegRegImm(cUnit, kOpSub, newSP, rMIPS_SP, cUnit->frameSize - (spillCount * 4));
350 GenRegRegCheck(cUnit, kCondCc, newSP, checkReg, kThrowStackOverflow);
351 OpRegCopy(cUnit, rMIPS_SP, newSP); // Establish stack
buzbeeefc63692012-11-14 16:31:52 -0800352 } else {
buzbee52a77fc2012-11-20 19:50:46 -0800353 OpRegImm(cUnit, kOpSub, rMIPS_SP, cUnit->frameSize - (spillCount * 4));
buzbeeefc63692012-11-14 16:31:52 -0800354 }
355
buzbee52a77fc2012-11-20 19:50:46 -0800356 FlushIns(cUnit, ArgLocs, rlMethod);
buzbeeefc63692012-11-14 16:31:52 -0800357
buzbee52a77fc2012-11-20 19:50:46 -0800358 FreeTemp(cUnit, rMIPS_ARG0);
359 FreeTemp(cUnit, rMIPS_ARG1);
360 FreeTemp(cUnit, rMIPS_ARG2);
361 FreeTemp(cUnit, rMIPS_ARG3);
buzbeeefc63692012-11-14 16:31:52 -0800362}
363
buzbee52a77fc2012-11-20 19:50:46 -0800364void GenExitSequence(CompilationUnit* cUnit)
buzbeeefc63692012-11-14 16:31:52 -0800365{
366 /*
367 * In the exit path, rMIPS_RET0/rMIPS_RET1 are live - make sure they aren't
368 * allocated by the register utilities as temps.
369 */
buzbee52a77fc2012-11-20 19:50:46 -0800370 LockTemp(cUnit, rMIPS_RET0);
371 LockTemp(cUnit, rMIPS_RET1);
buzbeeefc63692012-11-14 16:31:52 -0800372
buzbee52a77fc2012-11-20 19:50:46 -0800373 NewLIR0(cUnit, kPseudoMethodExit);
374 UnSpillCoreRegs(cUnit);
375 OpReg(cUnit, kOpBx, r_RA);
buzbeeefc63692012-11-14 16:31:52 -0800376}
377
378} // namespace art