History

i386: do not 'lexpand' into registers necessarily

Previously, long longs were 'lexpand'ed into two registers always. Now, it expands - constants into two constants (lo-part, hi-part) - variables into two lvalues with offset+4 for the hi-part. This makes long long operations look a bit nicer.

grischka committed 10 years ago

Commit d9b7f011 parent 6245db92 files · +18 −12Browse files

Unified · Split

2 files
  1. i386-gen.c +2 −2
  2. tccgen.c +16 −10
i386-gen.c+2−2
@@ -754,9 +754,9 @@ ST_FUNC void gen_opi(int op) · 753 unmodified lines
754754 c = vtop->c.i;
755755 if (c == (char)c) {
756756 /* generate inc and dec for smaller code */
757− if (c==1 && opc==0) {
757+ if (c==1 && opc==0 && op != TOK_ADDC1) {
758758 o (0x40 | r); // inc
759− } else if (c==1 && opc==5) {
759+ } else if (c==1 && opc==5 && op != TOK_SUBC1) {
760760 o (0x48 | r); // dec
761761 } else {
762762 o(0x83);
tccgen.c+16−10
@@ -1209,19 +1209,25 @@ static int reg_fret(int t) · 1208 unmodified lines
12091209 return REG_FRET;
12101210 }
12111211
1212−/* expand long long on stack in two int registers */
1212+/* expand long long on stack in two ints */
12131213 static void lexpand(void)
12141214 {
1215− int u;
1216−
1215+ int u, v;
12171216 u = vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED);
1218− gv(RC_INT);
1219− vdup();
1220− vtop[0].r = vtop[-1].r2;
1221− vtop[0].r2 = VT_CONST;
1222− vtop[-1].r2 = VT_CONST;
1223− vtop[0].type.t = VT_INT | u;
1224− vtop[-1].type.t = VT_INT | u;
1217+ v = vtop->r & (VT_VALMASK | VT_LVAL);
1218+ if (v == VT_CONST) {
1219+ vdup();
1220+ vtop[0].c.i >>= 32;
1221+ } else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
1222+ vdup();
1223+ vtop[0].c.i += 4;
1224+ } else {
1225+ gv(RC_INT);
1226+ vdup();
1227+ vtop[0].r = vtop[-1].r2;
1228+ vtop[0].r2 = vtop[-1].r2 = VT_CONST;
1229+ }
1230+ vtop[0].type.t = vtop[-1].type.t = VT_INT | u;
12251231 }
12261232
12271233 #ifdef TCC_TARGET_ARM

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t