Loading libacc/acc.cpp +0 −24 Original line number Original line Diff line number Diff line Loading @@ -586,7 +586,6 @@ class Compiler : public ErrorSink { /* returns address to patch with local variable size /* returns address to patch with local variable size */ */ virtual int functionEntry(Type* pDecl) { virtual int functionEntry(Type* pDecl) { LOG_API("functionEntry(%d);\n", pDecl); mStackUse = 0; mStackUse = 0; // sp -> arg4 arg5 ... // sp -> arg4 arg5 ... // Push our register-based arguments back on the stack // Push our register-based arguments back on the stack Loading @@ -608,7 +607,6 @@ class Compiler : public ErrorSink { } } virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) { virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) { LOG_API("functionExit(%d, %d, %d);\n", argCount, localVariableAddress, localVariableSize); // Round local variable size up to a multiple of stack alignment // Round local variable size up to a multiple of stack alignment localVariableSize = ((localVariableSize + STACK_ALIGNMENT - 1) / localVariableSize = ((localVariableSize + STACK_ALIGNMENT - 1) / STACK_ALIGNMENT) * STACK_ALIGNMENT; STACK_ALIGNMENT) * STACK_ALIGNMENT; Loading Loading @@ -665,13 +663,11 @@ class Compiler : public ErrorSink { } } virtual int gjmp(int t) { virtual int gjmp(int t) { LOG_API("gjmp(%d);\n", t); return o4(0xEA000000 | encodeAddress(t)); // b .L33 return o4(0xEA000000 | encodeAddress(t)); // b .L33 } } /* l = 0: je, l == 1: jne */ /* l = 0: je, l == 1: jne */ virtual int gtst(bool l, int t) { virtual int gtst(bool l, int t) { LOG_API("gtst(%d, %d);\n", l, t); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag tagR0 = pR0Type->tag; TypeTag tagR0 = pR0Type->tag; switch(tagR0) { switch(tagR0) { Loading @@ -690,7 +686,6 @@ class Compiler : public ErrorSink { } } virtual void gcmp(int op, Type* pResultType) { virtual void gcmp(int op, Type* pResultType) { LOG_API("gcmp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); Type* pTOSType = getTOSType(); Type* pTOSType = getTOSType(); TypeTag tagR0 = collapseType(pR0Type->tag); TypeTag tagR0 = collapseType(pR0Type->tag); Loading Loading @@ -784,7 +779,6 @@ class Compiler : public ErrorSink { } } virtual void genOp(int op) { virtual void genOp(int op) { LOG_API("genOp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); Type* pTOSType = getTOSType(); Type* pTOSType = getTOSType(); TypeTag tagR0 = pR0Type->tag; TypeTag tagR0 = pR0Type->tag; Loading Loading @@ -929,7 +923,6 @@ class Compiler : public ErrorSink { } } virtual void gUnaryCmp(int op, Type* pResultType) { virtual void gUnaryCmp(int op, Type* pResultType) { LOG_API("gUnaryCmp(%d);\n", op); if (op != OP_LOGICAL_NOT) { if (op != OP_LOGICAL_NOT) { error("Unknown unary cmp %d", op); error("Unknown unary cmp %d", op); } else { } else { Loading Loading @@ -957,7 +950,6 @@ class Compiler : public ErrorSink { } } virtual void genUnaryOp(int op) { virtual void genUnaryOp(int op) { LOG_API("genOp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag tag = collapseType(pR0Type->tag); TypeTag tag = collapseType(pR0Type->tag); switch(tag) { switch(tag) { Loading Loading @@ -1000,7 +992,6 @@ class Compiler : public ErrorSink { } } virtual void pushR0() { virtual void pushR0() { LOG_API("pushR0();\n"); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag r0ct = collapseType(pR0Type->tag); TypeTag r0ct = collapseType(pR0Type->tag); if (r0ct != TY_DOUBLE) { if (r0ct != TY_DOUBLE) { Loading @@ -1015,7 +1006,6 @@ class Compiler : public ErrorSink { } } virtual void storeR0ToTOS(Type* pPointerType) { virtual void storeR0ToTOS(Type* pPointerType) { LOG_API("storeR0ToTOS(%d);\n", isInt); assert(pPointerType->tag == TY_POINTER); assert(pPointerType->tag == TY_POINTER); o4(0xE8BD0004); // ldmfd sp!,{r2} o4(0xE8BD0004); // ldmfd sp!,{r2} popType(); popType(); Loading @@ -1038,7 +1028,6 @@ class Compiler : public ErrorSink { } } virtual void loadR0FromR0(Type* pPointerType) { virtual void loadR0FromR0(Type* pPointerType) { LOG_API("loadR0FromR0(%d);\n", pPointerType); assert(pPointerType->tag == TY_POINTER); assert(pPointerType->tag == TY_POINTER); switch (pPointerType->pHead->tag) { switch (pPointerType->pHead->tag) { case TY_INT: case TY_INT: Loading @@ -1059,7 +1048,6 @@ class Compiler : public ErrorSink { } } virtual void leaR0(int ea, Type* pPointerType) { virtual void leaR0(int ea, Type* pPointerType) { LOG_API("leaR0(%d);\n", ea); if (ea > -LOCAL && ea < LOCAL) { if (ea > -LOCAL && ea < LOCAL) { // Local, fp relative // Local, fp relative if (ea < -1023 || ea > 1023 || ((ea & 3) != 0)) { if (ea < -1023 || ea > 1023 || ((ea & 3) != 0)) { Loading @@ -1081,7 +1069,6 @@ class Compiler : public ErrorSink { } } virtual void storeR0(int ea, Type* pType) { virtual void storeR0(int ea, Type* pType) { LOG_API("storeR0(%d);\n", ea); convertR0(pType); convertR0(pType); TypeTag tag = pType->tag; TypeTag tag = pType->tag; switch (tag) { switch (tag) { Loading Loading @@ -1163,7 +1150,6 @@ class Compiler : public ErrorSink { } } virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { LOG_API("loadR0(%d, %d, %d, %d);\n", ea, isIncDec, op, pType); TypeTag tag = pType->tag; TypeTag tag = pType->tag; switch (tag) { switch (tag) { case TY_CHAR: case TY_CHAR: Loading Loading @@ -1307,12 +1293,10 @@ class Compiler : public ErrorSink { } } virtual int beginFunctionCallArguments() { virtual int beginFunctionCallArguments() { LOG_API("beginFunctionCallArguments();\n"); return o4(0xE24DDF00); // Placeholder return o4(0xE24DDF00); // Placeholder } } virtual size_t storeR0ToArg(int l, Type* pArgType) { virtual size_t storeR0ToArg(int l, Type* pArgType) { LOG_API("storeR0ToArg(%d);\n", l); convertR0(pArgType); convertR0(pArgType); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag r0ct = collapseType(pR0Type->tag); TypeTag r0ct = collapseType(pR0Type->tag); Loading Loading @@ -1341,7 +1325,6 @@ class Compiler : public ErrorSink { } } virtual void endFunctionCallArguments(Type* pDecl, int a, int l) { virtual void endFunctionCallArguments(Type* pDecl, int a, int l) { LOG_API("endFunctionCallArguments(0x%08x, %d);\n", a, l); int argumentStackUse = l; int argumentStackUse = l; // Have to calculate register arg count from actual stack size, // Have to calculate register arg count from actual stack size, // in order to properly handle ... functions. // in order to properly handle ... functions. Loading Loading @@ -1374,17 +1357,14 @@ class Compiler : public ErrorSink { } } virtual int callForward(int symbol, Type* pFunc) { virtual int callForward(int symbol, Type* pFunc) { LOG_API("callForward(%d);\n", symbol); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); // Forward calls are always short (local) // Forward calls are always short (local) return o4(0xEB000000 | encodeAddress(symbol)); return o4(0xEB000000 | encodeAddress(symbol)); } } virtual void callRelative(int t, Type* pFunc) { virtual void callRelative(int t, Type* pFunc) { LOG_API("callRelative(%d);\n", t); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); int abs = t + getPC() + jumpOffset(); int abs = t + getPC() + jumpOffset(); LOG_API("abs=%d (0x%08x)\n", abs, abs); if (t >= - (1 << 25) && t < (1 << 25)) { if (t >= - (1 << 25) && t < (1 << 25)) { o4(0xEB000000 | encodeAddress(t)); o4(0xEB000000 | encodeAddress(t)); } else { } else { Loading @@ -1398,7 +1378,6 @@ class Compiler : public ErrorSink { } } virtual void callIndirect(int l, Type* pFunc) { virtual void callIndirect(int l, Type* pFunc) { LOG_API("callIndirect(%d);\n", l); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); int argCount = l >> 2; int argCount = l >> 2; int poppedArgs = argCount > 4 ? 4 : argCount; int poppedArgs = argCount > 4 ? 4 : argCount; Loading @@ -1411,7 +1390,6 @@ class Compiler : public ErrorSink { } } virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) { virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) { LOG_API("adjustStackAfterCall(%d, %d);\n", l, isIndirect); int argCount = l >> 2; int argCount = l >> 2; // Have to calculate register arg count from actual stack size, // Have to calculate register arg count from actual stack size, // in order to properly handle ... functions. // in order to properly handle ... functions. Loading @@ -1438,11 +1416,9 @@ class Compiler : public ErrorSink { /* output a symbol and patch all calls to it */ /* output a symbol and patch all calls to it */ virtual void gsym(int t) { virtual void gsym(int t) { LOG_API("gsym(0x%x)\n", t); int n; int n; int base = getBase(); int base = getBase(); int pc = getPC(); int pc = getPC(); LOG_API("pc = 0x%x\n", pc); while (t) { while (t) { int data = * (int*) t; int data = * (int*) t; int decodedOffset = ((BRANCH_REL_ADDRESS_MASK & data) << 2); int decodedOffset = ((BRANCH_REL_ADDRESS_MASK & data) << 2); Loading Loading
libacc/acc.cpp +0 −24 Original line number Original line Diff line number Diff line Loading @@ -586,7 +586,6 @@ class Compiler : public ErrorSink { /* returns address to patch with local variable size /* returns address to patch with local variable size */ */ virtual int functionEntry(Type* pDecl) { virtual int functionEntry(Type* pDecl) { LOG_API("functionEntry(%d);\n", pDecl); mStackUse = 0; mStackUse = 0; // sp -> arg4 arg5 ... // sp -> arg4 arg5 ... // Push our register-based arguments back on the stack // Push our register-based arguments back on the stack Loading @@ -608,7 +607,6 @@ class Compiler : public ErrorSink { } } virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) { virtual void functionExit(Type* pDecl, int localVariableAddress, int localVariableSize) { LOG_API("functionExit(%d, %d, %d);\n", argCount, localVariableAddress, localVariableSize); // Round local variable size up to a multiple of stack alignment // Round local variable size up to a multiple of stack alignment localVariableSize = ((localVariableSize + STACK_ALIGNMENT - 1) / localVariableSize = ((localVariableSize + STACK_ALIGNMENT - 1) / STACK_ALIGNMENT) * STACK_ALIGNMENT; STACK_ALIGNMENT) * STACK_ALIGNMENT; Loading Loading @@ -665,13 +663,11 @@ class Compiler : public ErrorSink { } } virtual int gjmp(int t) { virtual int gjmp(int t) { LOG_API("gjmp(%d);\n", t); return o4(0xEA000000 | encodeAddress(t)); // b .L33 return o4(0xEA000000 | encodeAddress(t)); // b .L33 } } /* l = 0: je, l == 1: jne */ /* l = 0: je, l == 1: jne */ virtual int gtst(bool l, int t) { virtual int gtst(bool l, int t) { LOG_API("gtst(%d, %d);\n", l, t); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag tagR0 = pR0Type->tag; TypeTag tagR0 = pR0Type->tag; switch(tagR0) { switch(tagR0) { Loading @@ -690,7 +686,6 @@ class Compiler : public ErrorSink { } } virtual void gcmp(int op, Type* pResultType) { virtual void gcmp(int op, Type* pResultType) { LOG_API("gcmp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); Type* pTOSType = getTOSType(); Type* pTOSType = getTOSType(); TypeTag tagR0 = collapseType(pR0Type->tag); TypeTag tagR0 = collapseType(pR0Type->tag); Loading Loading @@ -784,7 +779,6 @@ class Compiler : public ErrorSink { } } virtual void genOp(int op) { virtual void genOp(int op) { LOG_API("genOp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); Type* pTOSType = getTOSType(); Type* pTOSType = getTOSType(); TypeTag tagR0 = pR0Type->tag; TypeTag tagR0 = pR0Type->tag; Loading Loading @@ -929,7 +923,6 @@ class Compiler : public ErrorSink { } } virtual void gUnaryCmp(int op, Type* pResultType) { virtual void gUnaryCmp(int op, Type* pResultType) { LOG_API("gUnaryCmp(%d);\n", op); if (op != OP_LOGICAL_NOT) { if (op != OP_LOGICAL_NOT) { error("Unknown unary cmp %d", op); error("Unknown unary cmp %d", op); } else { } else { Loading Loading @@ -957,7 +950,6 @@ class Compiler : public ErrorSink { } } virtual void genUnaryOp(int op) { virtual void genUnaryOp(int op) { LOG_API("genOp(%d);\n", op); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag tag = collapseType(pR0Type->tag); TypeTag tag = collapseType(pR0Type->tag); switch(tag) { switch(tag) { Loading Loading @@ -1000,7 +992,6 @@ class Compiler : public ErrorSink { } } virtual void pushR0() { virtual void pushR0() { LOG_API("pushR0();\n"); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag r0ct = collapseType(pR0Type->tag); TypeTag r0ct = collapseType(pR0Type->tag); if (r0ct != TY_DOUBLE) { if (r0ct != TY_DOUBLE) { Loading @@ -1015,7 +1006,6 @@ class Compiler : public ErrorSink { } } virtual void storeR0ToTOS(Type* pPointerType) { virtual void storeR0ToTOS(Type* pPointerType) { LOG_API("storeR0ToTOS(%d);\n", isInt); assert(pPointerType->tag == TY_POINTER); assert(pPointerType->tag == TY_POINTER); o4(0xE8BD0004); // ldmfd sp!,{r2} o4(0xE8BD0004); // ldmfd sp!,{r2} popType(); popType(); Loading @@ -1038,7 +1028,6 @@ class Compiler : public ErrorSink { } } virtual void loadR0FromR0(Type* pPointerType) { virtual void loadR0FromR0(Type* pPointerType) { LOG_API("loadR0FromR0(%d);\n", pPointerType); assert(pPointerType->tag == TY_POINTER); assert(pPointerType->tag == TY_POINTER); switch (pPointerType->pHead->tag) { switch (pPointerType->pHead->tag) { case TY_INT: case TY_INT: Loading @@ -1059,7 +1048,6 @@ class Compiler : public ErrorSink { } } virtual void leaR0(int ea, Type* pPointerType) { virtual void leaR0(int ea, Type* pPointerType) { LOG_API("leaR0(%d);\n", ea); if (ea > -LOCAL && ea < LOCAL) { if (ea > -LOCAL && ea < LOCAL) { // Local, fp relative // Local, fp relative if (ea < -1023 || ea > 1023 || ((ea & 3) != 0)) { if (ea < -1023 || ea > 1023 || ((ea & 3) != 0)) { Loading @@ -1081,7 +1069,6 @@ class Compiler : public ErrorSink { } } virtual void storeR0(int ea, Type* pType) { virtual void storeR0(int ea, Type* pType) { LOG_API("storeR0(%d);\n", ea); convertR0(pType); convertR0(pType); TypeTag tag = pType->tag; TypeTag tag = pType->tag; switch (tag) { switch (tag) { Loading Loading @@ -1163,7 +1150,6 @@ class Compiler : public ErrorSink { } } virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { LOG_API("loadR0(%d, %d, %d, %d);\n", ea, isIncDec, op, pType); TypeTag tag = pType->tag; TypeTag tag = pType->tag; switch (tag) { switch (tag) { case TY_CHAR: case TY_CHAR: Loading Loading @@ -1307,12 +1293,10 @@ class Compiler : public ErrorSink { } } virtual int beginFunctionCallArguments() { virtual int beginFunctionCallArguments() { LOG_API("beginFunctionCallArguments();\n"); return o4(0xE24DDF00); // Placeholder return o4(0xE24DDF00); // Placeholder } } virtual size_t storeR0ToArg(int l, Type* pArgType) { virtual size_t storeR0ToArg(int l, Type* pArgType) { LOG_API("storeR0ToArg(%d);\n", l); convertR0(pArgType); convertR0(pArgType); Type* pR0Type = getR0Type(); Type* pR0Type = getR0Type(); TypeTag r0ct = collapseType(pR0Type->tag); TypeTag r0ct = collapseType(pR0Type->tag); Loading Loading @@ -1341,7 +1325,6 @@ class Compiler : public ErrorSink { } } virtual void endFunctionCallArguments(Type* pDecl, int a, int l) { virtual void endFunctionCallArguments(Type* pDecl, int a, int l) { LOG_API("endFunctionCallArguments(0x%08x, %d);\n", a, l); int argumentStackUse = l; int argumentStackUse = l; // Have to calculate register arg count from actual stack size, // Have to calculate register arg count from actual stack size, // in order to properly handle ... functions. // in order to properly handle ... functions. Loading Loading @@ -1374,17 +1357,14 @@ class Compiler : public ErrorSink { } } virtual int callForward(int symbol, Type* pFunc) { virtual int callForward(int symbol, Type* pFunc) { LOG_API("callForward(%d);\n", symbol); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); // Forward calls are always short (local) // Forward calls are always short (local) return o4(0xEB000000 | encodeAddress(symbol)); return o4(0xEB000000 | encodeAddress(symbol)); } } virtual void callRelative(int t, Type* pFunc) { virtual void callRelative(int t, Type* pFunc) { LOG_API("callRelative(%d);\n", t); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); int abs = t + getPC() + jumpOffset(); int abs = t + getPC() + jumpOffset(); LOG_API("abs=%d (0x%08x)\n", abs, abs); if (t >= - (1 << 25) && t < (1 << 25)) { if (t >= - (1 << 25) && t < (1 << 25)) { o4(0xEB000000 | encodeAddress(t)); o4(0xEB000000 | encodeAddress(t)); } else { } else { Loading @@ -1398,7 +1378,6 @@ class Compiler : public ErrorSink { } } virtual void callIndirect(int l, Type* pFunc) { virtual void callIndirect(int l, Type* pFunc) { LOG_API("callIndirect(%d);\n", l); setR0Type(pFunc->pHead); setR0Type(pFunc->pHead); int argCount = l >> 2; int argCount = l >> 2; int poppedArgs = argCount > 4 ? 4 : argCount; int poppedArgs = argCount > 4 ? 4 : argCount; Loading @@ -1411,7 +1390,6 @@ class Compiler : public ErrorSink { } } virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) { virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) { LOG_API("adjustStackAfterCall(%d, %d);\n", l, isIndirect); int argCount = l >> 2; int argCount = l >> 2; // Have to calculate register arg count from actual stack size, // Have to calculate register arg count from actual stack size, // in order to properly handle ... functions. // in order to properly handle ... functions. Loading @@ -1438,11 +1416,9 @@ class Compiler : public ErrorSink { /* output a symbol and patch all calls to it */ /* output a symbol and patch all calls to it */ virtual void gsym(int t) { virtual void gsym(int t) { LOG_API("gsym(0x%x)\n", t); int n; int n; int base = getBase(); int base = getBase(); int pc = getPC(); int pc = getPC(); LOG_API("pc = 0x%x\n", pc); while (t) { while (t) { int data = * (int*) t; int data = * (int*) t; int decodedOffset = ((BRANCH_REL_ADDRESS_MASK & data) << 2); int decodedOffset = ((BRANCH_REL_ADDRESS_MASK & data) << 2); Loading