• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revision8537cc56bb10b8c62dc82cf7e494566c0d942c49 (tree)
Zeit2009-05-16 07:19:52
AutorAndroid (Google) Code Review <android-gerrit@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge change 1821

* changes:

ACC ARM codegen: implement /, %

Ändern Zusammenfassung

Diff

--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -359,6 +359,12 @@ class compiler {
359359 case OP_MUL:
360360 o4(0x0E0000091); // mul r0,r1,r0
361361 break;
362+ case OP_DIV:
363+ callRuntime(runtime_DIV);
364+ break;
365+ case OP_MOD:
366+ callRuntime(runtime_MOD);
367+ break;
362368 case OP_PLUS:
363369 o4(0xE0810000); // add r0,r1,r0
364370 break;
@@ -670,6 +676,22 @@ class compiler {
670676 return BRANCH_REL_ADDRESS_MASK & (value >> 2);
671677 }
672678
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+
673695 void error(const char* fmt,...) {
674696 va_list ap;
675697 va_start(ap, fmt);
@@ -1189,7 +1211,7 @@ class compiler {
11891211 } else {
11901212 pGen->callRelative(n - codeBuf.getPC() - pGen->jumpOffset());
11911213 }
1192- if (l || n == 1)
1214+ if (l | (n == 1))
11931215 pGen->adjustStackAfterCall(l, n == 1);
11941216 }
11951217 }