~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/cmd/5g/peep.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
                if(uniqs(r) == nil)
288
288
                        break;
289
289
                p = r->prog;
 
290
                if(p->as == AVARDEF || p->as == AVARKILL)
 
291
                        continue;
290
292
                proginfo(&info, p);
291
293
                if(info.flags & Call)
292
294
                        return 0;
397
399
                        if(debug['P'])
398
400
                                print("; merge; f=%d", f);
399
401
                }
400
 
                t = copyu(p, v2, A);
 
402
                t = copyu(p, v2, nil);
401
403
                switch(t) {
402
404
                case 2: /* rar, can't split */
403
405
                        if(debug['P'])
435
437
                        break;
436
438
                }
437
439
                if(!f) {
438
 
                        t = copyu(p, v1, A);
 
440
                        t = copyu(p, v1, nil);
439
441
                        if(!f && (t == 2 || t == 3 || t == 4)) {
440
442
                                f = 1;
441
443
                                if(debug['P'])
479
481
                                if(debug['P'])
480
482
                                        print("; sub%D/%D", &p->from, v1);
481
483
                                p->from = *v1;
482
 
                } else if(copyu(p, v1, A) > 1) {
 
484
                } else if(copyu(p, v1, nil) > 1) {
483
485
                        if(debug['P'])
484
486
                                print("; %Dset; return\n", v1);
485
487
                        return;
592
594
                p1 = r1->prog;
593
595
                if(debug['P'])
594
596
                        print("\n%P", p1);
595
 
                switch(copyu(p1, &p->to, A)) {
 
597
                switch(copyu(p1, &p->to, nil)) {
596
598
                case 0: /* not used or set */
597
 
                        if((p->from.type == D_REG && copyu(p1, &p->from, A) > 1) ||
598
 
                           (a.type == D_REG && copyu(p1, &a, A) > 1))
 
599
                        if((p->from.type == D_REG && copyu(p1, &p->from, nil) > 1) ||
 
600
                           (a.type == D_REG && copyu(p1, &a, nil) > 1))
599
601
                                FAIL("args modified");
600
602
                        continue;
601
603
                case 3: /* set, not used */
663
665
                p1 = r1->prog;
664
666
                if(debug['P'])
665
667
                        print("\n%P", p1);
666
 
                switch(copyu(p1, &p->to, A)) {
 
668
                switch(copyu(p1, &p->to, nil)) {
667
669
                case 0: /* not used or set */
668
670
                        continue;
669
671
                case 3: /* set, not used */
719
721
        for(r1=uniqp(r); r1!=nil; r=r1,r1=uniqp(r)) {
720
722
                if(uniqs(r1) != r)
721
723
                        return nil;
722
 
                switch(copyu(r1->prog, v, A)) {
 
724
                switch(copyu(r1->prog, v, nil)) {
723
725
                case 1: /* used */
724
726
                case 2: /* read-alter-rewrite */
725
727
                        return nil;
745
747
        for(r1=uniqs(r); r1!=nil && r1!=r2; r=r1,r1=uniqs(r)) {
746
748
                if(uniqp(r1) != r)
747
749
                        return nil;
748
 
                switch(copyu(r1->prog, v, A)) {
 
750
                switch(copyu(r1->prog, v, nil)) {
749
751
                case 0: /* not touched */
750
752
                        continue;
751
753
                case 4: /* set and used */
787
789
        for(; r!=nil && r!=r2; r=uniqs(r)) {
788
790
                p = r->prog;
789
791
                for(i=0; i<n; i++)
790
 
                        if(copyu(p, &a[i], A) > 1)
 
792
                        if(copyu(p, &a[i], nil) > 1)
791
793
                                return 0;
792
794
        }
793
795
        return 1;
800
802
                if(r->active)
801
803
                        return 0;
802
804
                r->active = 1;
803
 
                switch(copyu(r->prog, v, A)) {
 
805
                switch(copyu(r->prog, v, nil)) {
804
806
                case 1: /* used */
805
807
                case 2: /* read-alter-rewrite */
806
808
                case 4: /* set and used */
943
945
                if(v->type != D_REG)
944
946
                        return 0;
945
947
                if(p->from.type == D_CONST) {   /* read reglist, read/rar */
946
 
                        if(s != A) {
 
948
                        if(s != nil) {
947
949
                                if(p->from.offset&(1<<v->reg))
948
950
                                        return 1;
949
951
                                if(copysub(&p->to, v, s, 1))
958
960
                        if(p->from.offset&(1<<v->reg))
959
961
                                return 1;
960
962
                } else {                        /* read/rar, write reglist */
961
 
                        if(s != A) {
 
963
                        if(s != nil) {
962
964
                                if(p->to.offset&(1<<v->reg))
963
965
                                        return 1;
964
966
                                if(copysub(&p->from, v, s, 1))
1003
1005
                                        return 2;
1004
1006
                        }
1005
1007
                }
1006
 
                if(s != A) {
 
1008
                if(s != nil) {
1007
1009
                        if(copysub(&p->from, v, s, 1))
1008
1010
                                return 1;
1009
1011
                        if(!copyas(&p->to, v))
1063
1065
        case ACMN:
1064
1066
        case ACASE:
1065
1067
        case ATST:      /* read,, */
1066
 
                if(s != A) {
 
1068
                if(s != nil) {
1067
1069
                        if(copysub(&p->from, v, s, 1))
1068
1070
                                return 1;
1069
1071
                        if(copysub1(p, v, s, 1))
1108
1110
        case ABLT:
1109
1111
        case ABGT:
1110
1112
        case ABLE:
1111
 
                if(s != A) {
 
1113
                if(s != nil) {
1112
1114
                        if(copysub(&p->from, v, s, 1))
1113
1115
                                return 1;
1114
1116
                        return copysub1(p, v, s, 1);
1120
1122
                return 0;
1121
1123
 
1122
1124
        case AB:        /* funny */
1123
 
                if(s != A) {
 
1125
                if(s != nil) {
1124
1126
                        if(copysub(&p->to, v, s, 1))
1125
1127
                                return 1;
1126
1128
                        return 0;
1130
1132
                return 0;
1131
1133
 
1132
1134
        case ARET:      /* funny */
1133
 
                if(s != A)
 
1135
                if(s != nil)
1134
1136
                        return 1;
1135
1137
                return 3;
1136
1138
 
1138
1140
                if(v->type == D_REG) {
1139
1141
                        if(v->reg <= REGEXT && v->reg > exregoffset)
1140
1142
                                return 2;
1141
 
                        if(v->reg == (uchar)REGARG)
 
1143
                        if(v->reg == REGARG)
1142
1144
                                return 2;
1143
1145
                }
1144
1146
                if(v->type == D_FREG)
1147
1149
                if(p->from.type == D_REG && v->type == D_REG && p->from.reg == v->reg)
1148
1150
                        return 2;
1149
1151
 
1150
 
                if(s != A) {
 
1152
                if(s != nil) {
1151
1153
                        if(copysub(&p->to, v, s, 1))
1152
1154
                                return 1;
1153
1155
                        return 0;
1155
1157
                if(copyau(&p->to, v))
1156
1158
                        return 4;
1157
1159
                return 3;
1158
 
 
 
1160
        case ADUFFZERO:
 
1161
                // R0 is zero, used by DUFFZERO, cannot be substituted.
 
1162
                // R1 is ptr to memory, used and set, cannot be substituted.
 
1163
                if(v->type == D_REG) {
 
1164
                        if(v->reg == REGALLOC_R0)
 
1165
                                return 1;
 
1166
                        if(v->reg == REGALLOC_R0+1)
 
1167
                                return 2;
 
1168
                }
 
1169
                return 0;
 
1170
        case ADUFFCOPY:
 
1171
                // R0 is scratch, set by DUFFCOPY, cannot be substituted.
 
1172
                // R1, R2 areptr to src, dst, used and set, cannot be substituted.
 
1173
                if(v->type == D_REG) {
 
1174
                        if(v->reg == REGALLOC_R0)
 
1175
                                return 3;
 
1176
                        if(v->reg == REGALLOC_R0+1 || v->reg == REGALLOC_R0+2)
 
1177
                                return 2;
 
1178
                }
 
1179
                return 0;
 
1180
                        
1159
1181
        case ATEXT:     /* funny */
1160
1182
                if(v->type == D_REG)
1161
 
                        if(v->reg == (uchar)REGARG)
 
1183
                        if(v->reg == REGARG)
1162
1184
                                return 3;
1163
1185
                return 0;
1164
1186
 
1165
1187
        case APCDATA:
1166
1188
        case AFUNCDATA:
 
1189
        case AVARDEF:
 
1190
        case AVARKILL:
1167
1191
                return 0;
1168
1192
        }
1169
1193
}
1241
1265
        return 0;
1242
1266
}
1243
1267
 
 
1268
static int
 
1269
a2type(Prog *p)
 
1270
{
 
1271
        if(p->reg == NREG)
 
1272
                return D_NONE;
 
1273
 
 
1274
        switch(p->as) {
 
1275
        default:
 
1276
                fatal("a2type: unhandled %P", p);
 
1277
 
 
1278
        case AAND:
 
1279
        case AEOR:
 
1280
        case ASUB:
 
1281
        case ARSB:
 
1282
        case AADD:
 
1283
        case AADC:
 
1284
        case ASBC:
 
1285
        case ARSC:
 
1286
        case ATST:
 
1287
        case ATEQ:
 
1288
        case ACMP:
 
1289
        case ACMN:
 
1290
        case AORR:
 
1291
        case ABIC:
 
1292
        case AMVN:
 
1293
        case ASRL:
 
1294
        case ASRA:
 
1295
        case ASLL:
 
1296
        case AMULU:
 
1297
        case ADIVU:
 
1298
        case AMUL:
 
1299
        case ADIV:
 
1300
        case AMOD:
 
1301
        case AMODU:
 
1302
        case AMULA:
 
1303
        case AMULL:
 
1304
        case AMULAL:
 
1305
        case AMULLU:
 
1306
        case AMULALU:
 
1307
        case AMULWT:
 
1308
        case AMULWB:
 
1309
        case AMULAWT:
 
1310
        case AMULAWB:
 
1311
                return D_REG;
 
1312
 
 
1313
        case ACMPF:
 
1314
        case ACMPD:
 
1315
        case AADDF:
 
1316
        case AADDD:
 
1317
        case ASUBF:
 
1318
        case ASUBD:
 
1319
        case AMULF:
 
1320
        case AMULD:
 
1321
        case ADIVF:
 
1322
        case ADIVD:
 
1323
        case ASQRTF:
 
1324
        case ASQRTD:
 
1325
        case AABSF:
 
1326
        case AABSD:
 
1327
                return D_FREG;
 
1328
        }
 
1329
}
 
1330
 
1244
1331
/*
1245
1332
 * compare v to the center
1246
1333
 * register in p (p->reg)
1247
 
 * the trick is that this
1248
 
 * register might be D_REG
1249
 
 * D_FREG. there are basically
1250
 
 * two cases,
1251
 
 *      ADD r,r,r
1252
 
 *      CMP r,r,
1253
1334
 */
1254
1335
static int
1255
1336
copyau1(Prog *p, Adr *v)
1256
1337
{
1257
 
 
1258
 
        if(regtyp(v))
1259
 
        if(p->reg == v->reg) {
1260
 
                if(p->to.type != D_NONE) {
1261
 
                        if(v->type == p->to.type)
1262
 
                                return 1;
1263
 
                        return 0;
1264
 
                }
1265
 
                if(p->from.type != D_NONE) {
1266
 
                        if(v->type == p->from.type)
1267
 
                                return 1;
1268
 
                        return 0;
1269
 
                }
1270
 
                print("copyau1: can't tell %P\n", p);
1271
 
        }
1272
 
        return 0;
 
1338
        if(v->type == D_REG && v->reg == NREG)
 
1339
                return 0;
 
1340
        return p->reg == v->reg && a2type(p) == v->type;
1273
1341
}
1274
1342
 
1275
1343
/*