diff options
| author | Charles Forsyth <charles.forsyth@gmail.com> | 2013-06-04 08:30:04 +0000 |
|---|---|---|
| committer | Charles Forsyth <charles.forsyth@gmail.com> | 2013-06-04 08:30:04 +0000 |
| commit | 4a4256626644b5e413cfb1c228d396d27364030b (patch) | |
| tree | 5106c854262a2b88b4c56c9bbbefbf237cb17279 /libinterp | |
| parent | 6fd2624083b72690a3c4d9f61f5c51a61d0f2b00 (diff) | |
adjust code to size of Runes
Diffstat (limited to 'libinterp')
| -rw-r--r-- | libinterp/comp-386.c | 27 | ||||
| -rw-r--r-- | libinterp/comp-arm.c | 9 | ||||
| -rw-r--r-- | libinterp/comp-power.c | 10 |
3 files changed, 33 insertions, 13 deletions
diff --git a/libinterp/comp-386.c b/libinterp/comp-386.c index 916e3c34..21a12718 100644 --- a/libinterp/comp-386.c +++ b/libinterp/comp-386.c @@ -1406,13 +1406,18 @@ comp(Inst *i) genb(0x0f); gen2(Omovzxb, (1<<6)|(0<<3)|4); gen2((0<<6)|(RBX<<3)|RAX, O(String, data)); - gen2(Ojmpb, 11); + gen2(Ojmpb, sizeof(Rune)==4? 10: 11); gen2(Oneg, (3<<6)|(3<<3)|RTA); gen2(0x3b, (3<<6)|(RBX<<3)|RTA); /* cmp index, len */ gen2(0x73, 0xee); /* JNB */ - genb(0x0f); - gen2(Omovzxw, (1<<6)|(0<<3)|4); - gen2((1<<6)|(RBX<<3)|RAX, O(String, data)); + if(sizeof(Rune) == 4){ + gen2(Oldw, (1<<6)|(0<<3)|4); + gen2((2<<6)|(RBX<<3)|RAX, O(String, data)); + }else{ + genb(0x0f); + gen2(Omovzxw, (1<<6)|(0<<3)|4); + gen2((1<<6)|(RBX<<3)|RAX, O(String, data)); + } opwst(i, Ostw, RAX); break; } @@ -1422,10 +1427,16 @@ comp(Inst *i) genb(0x0f); gen2(Omovzxb, (1<<6)|(0<<3)|4); /* movzbx 12(AX)(RBX*1), RAX */ gen2((0<<6)|(RBX<<3)|RAX, O(String, data)); - gen2(Ojmpb, 5); - genb(0x0f); - gen2(Omovzxw, (1<<6)|(0<<3)|4); /* movzwx 12(AX)(RBX*2), RAX */ - gen2((1<<6)|(RBX<<3)|RAX, O(String, data)); + if(sizeof(Rune) == 4){ + gen2(Ojmpb, 4); + gen2(Oldw, (1<<6)|(0<<3)|4); /* movl 12(AX)(RBX*4), RAX */ + gen2((2<<6)|(RBX<<3)|RAX, O(String, data)); + }else{ + gen2(Ojmpb, 5); + genb(0x0f); + gen2(Omovzxw, (1<<6)|(0<<3)|4); /* movzwx 12(AX)(RBX*2), RAX */ + gen2((1<<6)|(RBX<<3)|RAX, O(String, data)); + } opwst(i, Ostw, RAX); break; case ICASE: diff --git a/libinterp/comp-arm.c b/libinterp/comp-arm.c index 57ab31d4..a7445bd7 100644 --- a/libinterp/comp-arm.c +++ b/libinterp/comp-arm.c @@ -1564,8 +1564,13 @@ comp(Inst *i) BCKI(i->reg, RA0); } else { LDRB(GE, RA1, RA3, 0, RA2); - DP(LT, Mov, 0, RA2, (1<<3), RA2); - LDRH(LT, RA1, RA3, RA2); + if(sizeof(Rune) == 4){ + DP(LT, Mov, 0, RA2, (2<<3), RA2); + LDRW(LT, RA1, RA3, RA2); + }else{ + DP(LT, Mov, 0, RA2, (1<<3), RA2); + LDRH(LT, RA1, RA3, RA2); + } if(bflag) BCK(RA2, RA0); } diff --git a/libinterp/comp-power.c b/libinterp/comp-power.c index 25cc9f5b..ec8835a1 100644 --- a/libinterp/comp-power.c +++ b/libinterp/comp-power.c @@ -184,6 +184,7 @@ enum DBRAN = (1<<5), /* dest is branch */ THREOP = (1<<6), + Lg2Rune = sizeof(Rune)==4? 2: 1, ANDAND = 1, OROR, EQAND, @@ -1557,10 +1558,13 @@ comp(Inst *i) cp = code; br(Obge, 0); if((i->add&ARM) != AXIMM){ - SLWI(Ro2, Ro2, 1); - ARRR(Olhzx, Ro3, Ro1, Ro2); + SLWI(Ro2, Ro2, Lg2Rune); + if(sizeof(Rune) == 4) + ARRR(Olwz, Ro3, Ro1, Ro2); + else + ARRR(Olhzx, Ro3, Ro1, Ro2); } else - mem(Olhz, (short)i->reg<<1, Ro1, Ro3); + mem(Olhz, (short)i->reg<<Lg2Rune, Ro1, Ro3); /* BUG: TO DO: 16-bit signed displacement */ gen(Ob | (2*4)); // skip PATCH(cp); if((i->add&ARM) != AXIMM) |
