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;
172 l->type = l->left->type;
228 r->type = types[TINT];
242 r->type = types[TINT];
253 r->type = types[TINT];
300 if(typechl[n->type->etype])
317 n->complex = l->complex;
319 if(r->complex == n->complex)
320 n->complex = r->complex+1;
322 if(r->complex > n->complex)
323 n->complex = r->complex;
349 if(r->complex >= l->complex) {
350 n->complex = l->complex + 3;
351 if(r->complex > n->complex)
352 n->complex = r->complex;
354 n->complex = r->complex + 3;
355 if(l->complex > n->complex)
356 n->complex = l->complex;
367 if(r->complex >= l->complex) {
368 n->complex = l->complex + 2;
369 if(r->complex > n->complex)
370 n->complex = r->complex;
372 n->complex = r->complex + 2;
373 if(l->complex > n->complex)
374 n->complex = l->complex;
383 * immediate operators, make const on right
385 if(l->op == OCONST) {
402 * compare operators, make const on left
404 if(r->op == OCONST) {
407 n->op = invrel[relindex(n->op)];
423 if(l->addable == 1 || l->addable == 13 || r->complex > l->complex) {
429 if(l->addable != 7) {
433 if(l->right->addable == 20) {
434 idx.regtree = l->left;
435 idx.scale = 1 << l->right->vconst;
437 if(l->left->addable == 20) {
438 idx.regtree = l->right;
439 idx.scale = 1 << l->left->vconst;
441 diag(n, "bad index");
445 print("scale = %d\n", idx.scale);
446 prtree(idx.regtree, "index");
447 prtree(idx.basetree, "base");