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)
128 l->xoffset += r->vconst;
138 /* l is the base, r is the index */
160 /* r is the base, l is the index */
165 if(n->addable == 8 && !side(n)) {
167 l = new1(OINDEX, idx.basetree, idx.regtree);
168 l->scale = idx.scale;
170 l->complex = l->right->complex;
171 l->type = l->left->type;
227 r->type = types[TINT];
241 r->type = types[TINT];
252 r->type = types[TINT];
299 if(typechl[n->type->etype])
316 n->complex = l->complex;
318 if(r->complex == n->complex)
319 n->complex = r->complex+1;
321 if(r->complex > n->complex)
322 n->complex = r->complex;
348 if(r->complex >= l->complex) {
349 n->complex = l->complex + 3;
350 if(r->complex > n->complex)
351 n->complex = r->complex;
353 n->complex = r->complex + 3;
354 if(l->complex > n->complex)
355 n->complex = l->complex;
366 if(r->complex >= l->complex) {
367 n->complex = l->complex + 2;
368 if(r->complex > n->complex)
369 n->complex = r->complex;
371 n->complex = r->complex + 2;
372 if(l->complex > n->complex)
373 n->complex = l->complex;
382 * immediate operators, make const on right
384 if(l->op == OCONST) {
401 * compare operators, make const on left
403 if(r->op == OCONST) {
406 n->op = invrel[relindex(n->op)];
422 if(l->addable == 1 || l->addable == 13 || r->complex > l->complex) {
428 if(l->addable != 7) {
432 if(l->right->addable == 20) {
433 idx.regtree = l->left;
434 idx.scale = 1 << l->right->vconst;
436 if(l->left->addable == 20) {
437 idx.regtree = l->right;
438 idx.scale = 1 << l->left->vconst;
440 diag(n, "bad index");
444 print("scale = %d\n", idx.scale);
445 prtree(idx.regtree, "index");
446 prtree(idx.basetree, "base");