system/corennnnn
リビジョン | dc61060547e3dc15ca51d74167d75b1513da16ac (tree) |
---|---|
日時 | 2009-07-14 10:49:02 |
作者 | Android (Google) Code Review <android-gerrit@goog...> |
コミッター | Android (Google) Code Review |
Merge change 7049
* changes:
@@ -1019,6 +1019,25 @@ class Compiler : public ErrorSink { | ||
1019 | 1019 | LOG_API("storeR0(%d);\n", ea); |
1020 | 1020 | TypeTag tag = pType->tag; |
1021 | 1021 | switch (tag) { |
1022 | + case TY_CHAR: | |
1023 | + if (ea > -LOCAL && ea < LOCAL) { | |
1024 | + // Local, fp relative | |
1025 | + if (ea < -4095 || ea > 4095) { | |
1026 | + error("Offset out of range: %08x", ea); | |
1027 | + } | |
1028 | + if (ea < 0) { | |
1029 | + o4(0xE54B0000 | (0xfff & (-ea))); // strb r0, [fp,#-ea] | |
1030 | + } else { | |
1031 | + o4(0xE5CB0000 | (0xfff & ea)); // strb r0, [fp,#ea] | |
1032 | + } | |
1033 | + } else{ | |
1034 | + // Global, absolute | |
1035 | + o4(0xE59F1000); // ldr r1, .L1 | |
1036 | + o4(0xEA000000); // b .L99 | |
1037 | + o4(ea); // .L1: .word 0 | |
1038 | + o4(0xE5C10000); // .L99: strb r0, [r1] | |
1039 | + } | |
1040 | + break; | |
1022 | 1041 | case TY_POINTER: |
1023 | 1042 | case TY_INT: |
1024 | 1043 | case TY_FLOAT: |
@@ -1079,8 +1098,32 @@ class Compiler : public ErrorSink { | ||
1079 | 1098 | |
1080 | 1099 | virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { |
1081 | 1100 | LOG_API("loadR0(%d, %d, %d, %d);\n", ea, isIncDec, op, pType); |
1082 | - TypeTag tag = collapseType(pType->tag); | |
1101 | + TypeTag tag = pType->tag; | |
1083 | 1102 | switch (tag) { |
1103 | + case TY_CHAR: | |
1104 | + if (ea < LOCAL) { | |
1105 | + // Local, fp relative | |
1106 | + if (ea < -4095 || ea > 4095) { | |
1107 | + error("Offset out of range: %08x", ea); | |
1108 | + } | |
1109 | + if (ea < 0) { | |
1110 | + o4(0xE55B0000 | (0xfff & (-ea))); // ldrb r0, [fp,#-ea] | |
1111 | + } else { | |
1112 | + o4(0xE5DB0000 | (0xfff & ea)); // ldrb r0, [fp,#ea] | |
1113 | + } | |
1114 | + } else { | |
1115 | + // Global, absolute | |
1116 | + o4(0xE59F2000); // ldr r2, .L1 | |
1117 | + o4(0xEA000000); // b .L99 | |
1118 | + o4(ea); // .L1: .word ea | |
1119 | + o4(0xE5D20000); // .L99: ldrb r0, [r2] | |
1120 | + } | |
1121 | + | |
1122 | + if (isIncDec) { | |
1123 | + error("inc/dec not implemented for char."); | |
1124 | + } | |
1125 | + break; | |
1126 | + case TY_POINTER: | |
1084 | 1127 | case TY_INT: |
1085 | 1128 | case TY_FLOAT: |
1086 | 1129 | if (ea < LOCAL) { |
@@ -2027,6 +2070,13 @@ class Compiler : public ErrorSink { | ||
2027 | 2070 | virtual void storeR0(int ea, Type* pType) { |
2028 | 2071 | TypeTag tag = pType->tag; |
2029 | 2072 | switch (tag) { |
2073 | + case TY_CHAR: | |
2074 | + if (ea < -LOCAL || ea > LOCAL) { | |
2075 | + oad(0xa2, ea); // movb %al,ea | |
2076 | + } else { | |
2077 | + oad(0x8588, ea); // movb %al,ea(%ebp) | |
2078 | + } | |
2079 | + break; | |
2030 | 2080 | case TY_INT: |
2031 | 2081 | case TY_POINTER: |
2032 | 2082 | gmov(6, ea); /* mov %eax, EA */ |
@@ -2052,10 +2102,24 @@ class Compiler : public ErrorSink { | ||
2052 | 2102 | } |
2053 | 2103 | |
2054 | 2104 | virtual void loadR0(int ea, bool isIncDec, int op, Type* pType) { |
2055 | - TypeTag tag = collapseType(pType->tag); | |
2105 | + TypeTag tag = pType->tag; | |
2056 | 2106 | switch (tag) { |
2107 | + case TY_CHAR: | |
2108 | + if (ea < -LOCAL || ea > LOCAL) { | |
2109 | + oad(0x05BE0F, ea); // movsbl ea,%eax | |
2110 | + } else { | |
2111 | + oad(0x85BE0F, ea); // movsbl ea(%ebp),%eax | |
2112 | + } | |
2113 | + if (isIncDec) { | |
2114 | + error("inc/dec not implemented for char."); | |
2115 | + } | |
2116 | + break; | |
2057 | 2117 | case TY_INT: |
2058 | - gmov(8, ea); /* mov EA, %eax */ | |
2118 | + case TY_POINTER: | |
2119 | + if (tag == TY_CHAR) { | |
2120 | + } else { | |
2121 | + gmov(8, ea); /* mov EA, %eax */ | |
2122 | + } | |
2059 | 2123 | if (isIncDec) { |
2060 | 2124 | /* Implement post-increment or post decrement. |
2061 | 2125 | */ |
@@ -0,0 +1,13 @@ | ||
1 | +char ga; | |
2 | +char gb; | |
3 | + | |
4 | +int main() { | |
5 | + char a = 'c'; | |
6 | + char b = a * 3; | |
7 | + printf("a = %d, b = %d\n", a, b); | |
8 | + ga = 'd'; | |
9 | + gb = ga * 3; | |
10 | + printf("ga = %d, gb = %d\n", ga, gb); | |
11 | + return 0; | |
12 | +} | |
13 | + |
@@ -250,6 +250,12 @@ Testing read/write (float*): 8.8 9.9 | ||
250 | 250 | Testing read/write (double*): 8.8 9.9 |
251 | 251 | """) |
252 | 252 | |
253 | + def testChar(self): | |
254 | + self.compileCheck(["-R", "data/char.c"], """Executing compiled code: | |
255 | +result: 0""", """a = 99, b = 41 | |
256 | +ga = 100, gb = 44""") | |
257 | + | |
258 | + | |
253 | 259 | if __name__ == '__main__': |
254 | 260 | if not outputCanRun(): |
255 | 261 | print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable." |