17 /* welcome to commute */
25 if(r->complex > l->complex) {
36 if(!typechlpv[n->type->etype])
39 if(n->op == OASHL && n->right->op == OCONST){
47 * calculate addressability as follows
48 * NAME ==> 10/11 name+value(SB/SP)
49 * REGISTER ==> 12 register
52 * &(10) ==> 13 $name+value(SB)
53 * &(11) ==> 1 $name+value(SP)
54 * (13) + (20) ==> 13 fold constants
55 * (1) + (20) ==> 1 fold constants
56 * *(13) ==> 10 back to name
57 * *(1) ==> 11 back to name
59 * (20) * (X) ==> 7 multiplier in indexing
60 * (X,7) + (13,1) ==> 8 adder in indexing (addresses)
61 * (8) ==> &9(OINDEX) index, almost addressable
63 * calculate complexity (number of registers)
84 if(n->class == CPARAM || n->class == CAUTO)
108 if(n->type->etype != TIND)
121 l->xoffset += r->vconst;
131 /* l is the base, r is the index */
153 /* r is the base, l is the index */
158 if(n->addable == 8 && !side(n)) {
160 l = new1(OINDEX, idx.basetree, idx.regtree);
161 l->scale = idx.scale;
163 l->complex = l->right->complex;
164 l->type = l->left->type;
220 r->type = types[TINT];
234 r->type = types[TINT];
245 r->type = types[TINT];
308 n->complex = l->complex;
310 if(r->complex == n->complex)
311 n->complex = r->complex+1;
313 if(r->complex > n->complex)
314 n->complex = r->complex;
326 if(l->type->etype == TUVLONG && typefd[n->type->etype])
342 if(r->complex >= l->complex) {
343 n->complex = l->complex + 3;
344 if(r->complex > n->complex)
345 n->complex = r->complex;
347 n->complex = r->complex + 3;
348 if(l->complex > n->complex)
349 n->complex = l->complex;
360 if(r->complex >= l->complex) {
361 n->complex = l->complex + 2;
362 if(r->complex > n->complex)
363 n->complex = r->complex;
365 n->complex = r->complex + 2;
366 if(l->complex > n->complex)
367 n->complex = l->complex;
376 * immediate operators, make const on right
378 if(l->op == OCONST) {
395 * compare operators, make const on left
397 if(r->op == OCONST) {
400 n->op = invrel[relindex(n->op)];
416 if(l->addable == 1 || l->addable == 13 || r->complex > l->complex) {
422 if(l->addable != 7) {
426 if(l->right->addable == 20) {
427 idx.regtree = l->left;
428 idx.scale = 1 << l->right->vconst;
430 if(l->left->addable == 20) {
431 idx.regtree = l->right;
432 idx.scale = 1 << l->left->vconst;
434 diag(n, "bad index");
438 print("scale = %d\n", idx.scale);
439 prtree(idx.regtree, "index");
440 prtree(idx.basetree, "base");