system/corennnnn
Revision | 8537cc56bb10b8c62dc82cf7e494566c0d942c49 (tree) |
---|---|
Zeit | 2009-05-16 07:19:52 |
Autor | Android (Google) Code Review <android-gerrit@goog...> |
Commiter | Android (Google) Code Review |
Merge change 1821
* changes:
@@ -359,6 +359,12 @@ class compiler { | ||
359 | 359 | case OP_MUL: |
360 | 360 | o4(0x0E0000091); // mul r0,r1,r0 |
361 | 361 | break; |
362 | + case OP_DIV: | |
363 | + callRuntime(runtime_DIV); | |
364 | + break; | |
365 | + case OP_MOD: | |
366 | + callRuntime(runtime_MOD); | |
367 | + break; | |
362 | 368 | case OP_PLUS: |
363 | 369 | o4(0xE0810000); // add r0,r1,r0 |
364 | 370 | break; |
@@ -670,6 +676,22 @@ class compiler { | ||
670 | 676 | return BRANCH_REL_ADDRESS_MASK & (value >> 2); |
671 | 677 | } |
672 | 678 | |
679 | + typedef int (*int2FnPtr)(int a, int b); | |
680 | + void callRuntime(int2FnPtr fn) { | |
681 | + o4(0xE59F2000); // ldr r2, .L1 | |
682 | + o4(0xEA000000); // b .L99 | |
683 | + o4((int) fn); //.L1: .word fn | |
684 | + o4(0xE12FFF32); //.L99: blx r2 | |
685 | + } | |
686 | + | |
687 | + static int runtime_DIV(int a, int b) { | |
688 | + return b / a; | |
689 | + } | |
690 | + | |
691 | + static int runtime_MOD(int a, int b) { | |
692 | + return b % a; | |
693 | + } | |
694 | + | |
673 | 695 | void error(const char* fmt,...) { |
674 | 696 | va_list ap; |
675 | 697 | va_start(ap, fmt); |
@@ -1189,7 +1211,7 @@ class compiler { | ||
1189 | 1211 | } else { |
1190 | 1212 | pGen->callRelative(n - codeBuf.getPC() - pGen->jumpOffset()); |
1191 | 1213 | } |
1192 | - if (l || n == 1) | |
1214 | + if (l | (n == 1)) | |
1193 | 1215 | pGen->adjustStackAfterCall(l, n == 1); |
1194 | 1216 | } |
1195 | 1217 | } |