system/corennnnn
Revisão | 243fb9ff0fb9fad9d242d9c10cfecb31aa0210f8 (tree) |
---|---|
Hora | 2009-05-15 11:42:17 |
Autor | Android (Google) Code Review <android-gerrit@goog...> |
Commiter | Android (Google) Code Review |
Merge change 1740
* changes:
@@ -269,7 +269,7 @@ class compiler { | ||
269 | 269 | fprintf(stderr, "functionExit(%d, %d, %d);\n", argCount, localVariableAddress, localVariableSize); |
270 | 270 | // Patch local variable allocation code: |
271 | 271 | if (localVariableSize < 0 || localVariableSize > 255) { |
272 | - error("LocalVariableSize"); | |
272 | + error("localVariables out of range: %d", localVariableSize); | |
273 | 273 | } |
274 | 274 | *(char*) (localVariableAddress) = localVariableSize; |
275 | 275 |
@@ -282,7 +282,7 @@ class compiler { | ||
282 | 282 | // sp -> arg0 .... |
283 | 283 | if (argCount > 0) { |
284 | 284 | // We store the PC into the lr so we can adjust the sp before |
285 | - // returning. (We need to pull off the registers we pushed | |
285 | + // returning. We need to pull off the registers we pushed | |
286 | 286 | // earlier. We don't need to actually store them anywhere, |
287 | 287 | // just adjust the stack. |
288 | 288 | int regArgCount = argCount <= 4 ? argCount : 4; |
@@ -309,28 +309,49 @@ class compiler { | ||
309 | 309 | |
310 | 310 | virtual int gjmp(int t) { |
311 | 311 | fprintf(stderr, "gjmp(%d);\n", t); |
312 | - return o4(0xEA000000 + encodeAddress(t)); // b .L33 | |
312 | + return o4(0xEA000000 | encodeAddress(t)); // b .L33 | |
313 | 313 | } |
314 | 314 | |
315 | 315 | /* l = 0: je, l == 1: jne */ |
316 | 316 | virtual int gtst(bool l, int t) { |
317 | 317 | fprintf(stderr, "gtst(%d, %d);\n", l, t); |
318 | - error("Unimplemented"); | |
319 | - o(0x0fc085); /* test %eax, %eax, je/jne xxx */ | |
320 | - return psym(0x84 + l, t); | |
318 | + o4(0xE3500000); // cmp r0,#0 | |
319 | + int branch = l ? 0x1A000000 : 0x0A000000; // bne : beq | |
320 | + return o4(branch | encodeAddress(t)); | |
321 | 321 | } |
322 | 322 | |
323 | 323 | virtual void gcmp(int op) { |
324 | 324 | fprintf(stderr, "gcmp(%d);\n", op); |
325 | - error("Unimplemented"); | |
326 | -#if 0 | |
327 | - int t = decodeOp(op); | |
328 | - o(0xc139); /* cmp %eax,%ecx */ | |
329 | - li(0); | |
330 | - o(0x0f); /* setxx %al */ | |
331 | - o(t + 0x90); | |
332 | - o(0xc0); | |
333 | -#endif | |
325 | + o4(0xE1510000); // cmp r1, r1 | |
326 | + switch(op) { | |
327 | + case OP_EQUALS: | |
328 | + o4(0x03A00001); // moveq r0,#1 | |
329 | + o4(0x13A00000); // movne r0,#0 | |
330 | + break; | |
331 | + case OP_NOT_EQUALS: | |
332 | + o4(0x03A00000); // moveq r0,#0 | |
333 | + o4(0x13A00001); // movne r0,#1 | |
334 | + break; | |
335 | + case OP_LESS_EQUAL: | |
336 | + o4(0xD3A00001); // movle r0,#1 | |
337 | + o4(0xC3A00000); // movgt r0,#0 | |
338 | + break; | |
339 | + case OP_GREATER: | |
340 | + o4(0xD3A00000); // movle r0,#0 | |
341 | + o4(0xC3A00001); // movgt r0,#1 | |
342 | + break; | |
343 | + case OP_GREATER_EQUAL: | |
344 | + o4(0xA3A00001); // movge r0,#1 | |
345 | + o4(0xB3A00000); // movlt r0,#0 | |
346 | + break; | |
347 | + case OP_LESS: | |
348 | + o4(0xA3A00000); // movge r0,#0 | |
349 | + o4(0xB3A00001); // movlt r0,#1 | |
350 | + break; | |
351 | + default: | |
352 | + error("Unknown comparison op %d", op); | |
353 | + break; | |
354 | + } | |
334 | 355 | } |
335 | 356 | |
336 | 357 | virtual void genOp(int op) { |