diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-15 15:19:52 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-15 15:19:52 -0700 |
| commit | 8537cc56bb10b8c62dc82cf7e494566c0d942c49 (patch) | |
| tree | cf5bcce1a7c9e0ca3bf69549c9512dc428df7292 /libacc/acc.cpp | |
| parent | 986145c5235ee9088960cee4883ac73cd05667ec (diff) | |
| parent | 3d474a74a7aad537f596d3978be7ec0cb79d4e64 (diff) | |
| download | system_core-8537cc56bb10b8c62dc82cf7e494566c0d942c49.zip system_core-8537cc56bb10b8c62dc82cf7e494566c0d942c49.tar.gz system_core-8537cc56bb10b8c62dc82cf7e494566c0d942c49.tar.bz2 | |
Merge change 1821
* changes:
ACC ARM codegen: implement /, %
Diffstat (limited to 'libacc/acc.cpp')
| -rw-r--r-- | libacc/acc.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 59ce9b4..567e25e 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -359,6 +359,12 @@ class compiler { case OP_MUL: o4(0x0E0000091); // mul r0,r1,r0 break; + case OP_DIV: + callRuntime(runtime_DIV); + break; + case OP_MOD: + callRuntime(runtime_MOD); + break; case OP_PLUS: o4(0xE0810000); // add r0,r1,r0 break; @@ -670,6 +676,22 @@ class compiler { return BRANCH_REL_ADDRESS_MASK & (value >> 2); } + typedef int (*int2FnPtr)(int a, int b); + void callRuntime(int2FnPtr fn) { + o4(0xE59F2000); // ldr r2, .L1 + o4(0xEA000000); // b .L99 + o4((int) fn); //.L1: .word fn + o4(0xE12FFF32); //.L99: blx r2 + } + + static int runtime_DIV(int a, int b) { + return b / a; + } + + static int runtime_MOD(int a, int b) { + return b % a; + } + void error(const char* fmt,...) { va_list ap; va_start(ap, fmt); @@ -1189,7 +1211,7 @@ class compiler { } else { pGen->callRelative(n - codeBuf.getPC() - pGen->jumpOffset()); } - if (l || n == 1) + if (l | (n == 1)) pGen->adjustStackAfterCall(l, n == 1); } } |
