16 if(thisfn && thisfn->link && typefd[thisfn->link->etype])
20 /* welcome to commute */
28 if(r->complex > l->complex) {
39 if(!typechlp[n->type->etype])
42 if(n->op == OASHL && n->right->op == OCONST){
50 * calculate addressability as follows
51 * NAME ==> 10/11 name+value(SB/SP)
52 * REGISTER ==> 12 register
55 * &(10) ==> 13 $name+value(SB)
56 * &(11) ==> 1 $name+value(SP)
57 * (13) + (20) ==> 13 fold constants
58 * (1) + (20) ==> 1 fold constants
59 * *(13) ==> 10 back to name
60 * *(1) ==> 11 back to name
62 * (20) * (X) ==> 7 multiplier in indexing
63 * (X,7) + (13,1) ==> 8 adder in indexing (addresses)
64 * (8) ==> &9(OINDEX) index, almost addressable
66 * calculate complexity (number of registers)
87 if(n->class == CPARAM || n->class == CAUTO)
115 if(n->type->etype != TIND &&
116 !(l->type->etype == TIND && r->type->etype == TIND))
129 l->xoffset += r->vconst;
139 /* l is the base, r is the index */
161 /* r is the base, l is the index */
166 if(n->addable == 8 && !side(n)) {
168 l = new1(OINDEX, idx.basetree, idx.regtree);
169 l->scale = idx.scale;
171 l->complex = l->right->complex;
174 l->type = l->left->type;
230 r->type = types[TINT];
244 r->type = types[TINT];
255 r->type = types[TINT];
302 if(typechl[n->type->etype])
319 n->complex = l->complex;
321 if(r->complex == n->complex)
322 n->complex = r->complex+1;
324 if(r->complex > n->complex)
325 n->complex = r->complex;
351 if(r->complex >= l->complex) {
352 n->complex = l->complex + 3;
353 if(r->complex > n->complex)
354 n->complex = r->complex;
356 n->complex = r->complex + 3;
357 if(l->complex > n->complex)
358 n->complex = l->complex;
369 if(r->complex >= l->complex) {
370 n->complex = l->complex + 2;
371 if(r->complex > n->complex)
372 n->complex = r->complex;
374 n->complex = r->complex + 2;
375 if(l->complex > n->complex)
376 n->complex = l->complex;
385 * immediate operators, make const on right
387 if(l->op == OCONST) {
404 * compare operators, make const on left
406 if(r->op == OCONST) {
409 n->op = invrel[relindex(n->op)];
425 if(l->addable == 1 || l->addable == 13 || r->complex > l->complex) {
431 if(l->addable != 7) {
435 if(l->right->addable == 20) {
436 idx.regtree = l->left;
437 idx.scale = 1 << l->right->vconst;
439 if(l->left->addable == 20) {
440 idx.regtree = l->right;
441 idx.scale = 1 << l->left->vconst;
443 diag(n, "bad index");
447 print("scale = %d\n", idx.scale);
448 prtree(idx.regtree, "index");
449 prtree(idx.basetree, "base");