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

« back to all changes in this revision

Viewing changes to src/cmd/5g/gsubr.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:
50
50
        p->to.type = D_NONE;
51
51
        p->to.name = D_NONE;
52
52
        p->to.reg = NREG;
53
 
        p->loc = pcloc;
 
53
        p->pc = pcloc;
54
54
        pcloc++;
55
55
}
56
56
 
138
138
        if(p->to.type != D_BRANCH)
139
139
                fatal("patch: not a branch");
140
140
        p->to.u.branch = to;
141
 
        p->to.offset = to->loc;
 
141
        p->to.offset = to->pc;
142
142
}
143
143
 
144
144
Prog*
162
162
{
163
163
        Plist *pl;
164
164
 
165
 
        pl = mal(sizeof(*pl));
166
 
        if(plist == nil)
167
 
                plist = pl;
168
 
        else
169
 
                plast->link = pl;
170
 
        plast = pl;
 
165
        pl = linknewplist(ctxt);
171
166
 
172
167
        pc = mal(sizeof(*pc));
173
168
        clearp(pc);
200
195
 
201
196
        p = gins(AGLOBL, nam, N);
202
197
        p->lineno = nam->lineno;
203
 
        p->from.gotype = ngotype(nam);
204
 
        p->to.sym = S;
 
198
        p->from.sym->gotype = linksym(ngotype(nam));
 
199
        p->to.sym = nil;
205
200
        p->to.type = D_CONST;
206
201
        p->to.offset = nam->type->width;
207
202
        if(nam->readonly)
228
223
        p = gins(AGLOBL, N, N);
229
224
        p->from.type = D_OREG;
230
225
        p->from.name = D_EXTERN;
231
 
        p->from.sym = s;
 
226
        p->from.sym = linksym(s);
232
227
        p->to.type = D_CONST;
233
228
        p->to.name = D_NONE;
234
229
        p->to.offset = width;
246
241
        p = gins(AUSEFIELD, N, N);
247
242
        p->from.type = D_OREG;
248
243
        p->from.name = D_EXTERN;
249
 
        p->from.sym = s;
 
244
        p->from.sym = linksym(s);
250
245
}
251
246
 
252
247
int
275
270
        if(a->type == D_CONST && a->name == D_EXTERN || a->type == D_REG) {
276
271
                a->type = D_OREG;
277
272
                if(n->op == ONAME)
278
 
                        a->sym = n->sym;
 
273
                        a->sym = linksym(n->sym);
279
274
        }
280
275
}
281
276
 
475
470
nodarg(Type *t, int fp)
476
471
{
477
472
        Node *n;
 
473
        NodeList *l;
478
474
        Type *first;
479
475
        Iter savet;
480
476
 
496
492
        if(t->etype != TFIELD)
497
493
                fatal("nodarg: not field %T", t);
498
494
 
 
495
        if(fp == 1) {
 
496
                for(l=curfn->dcl; l; l=l->next) {
 
497
                        n = l->n;
 
498
                        if((n->class == PPARAM || n->class == PPARAMOUT) && !isblanksym(t->sym) && n->sym == t->sym)
 
499
                                return n;
 
500
                }
 
501
        }
 
502
 
499
503
        n = nod(ONAME, N, N);
500
504
        n->type = t->type;
501
505
        n->sym = t->sym;
1196
1200
void
1197
1201
naddr(Node *n, Addr *a, int canemitcode)
1198
1202
{
 
1203
        Sym *s;
 
1204
 
1199
1205
        a->type = D_NONE;
1200
1206
        a->name = D_NONE;
1201
1207
        a->reg = NREG;
1202
 
        a->gotype = S;
 
1208
        a->gotype = nil;
1203
1209
        a->node = N;
1204
1210
        a->etype = 0;
1205
1211
        if(n == N)
1223
1229
                        a->type = D_FREG;
1224
1230
                        a->reg = n->val.u.reg - REGALLOC_F0;
1225
1231
                }
1226
 
                a->sym = S;
 
1232
                a->sym = nil;
1227
1233
                break;
1228
1234
 
1229
1235
        case OINDEX:
1250
1256
        case OINDREG:
1251
1257
                a->type = D_OREG;
1252
1258
                a->reg = n->val.u.reg;
1253
 
                a->sym = n->sym;
 
1259
                a->sym = linksym(n->sym);
1254
1260
                a->offset = n->xoffset;
1255
1261
                break;
1256
1262
 
1260
1266
                a->etype = simtype[n->left->type->etype];
1261
1267
                a->width = n->left->type->width;
1262
1268
                a->offset = n->xoffset;
1263
 
                a->sym = n->left->sym;
 
1269
                a->sym = linksym(n->left->sym);
1264
1270
                a->type = D_OREG;
1265
1271
                a->name = D_PARAM;
1266
1272
                a->node = n->left->orig;
1267
1273
                break;
1268
1274
        
1269
1275
        case OCLOSUREVAR:
 
1276
                if(!curfn->needctxt)
 
1277
                        fatal("closurevar without needctxt");
1270
1278
                a->type = D_OREG;
1271
1279
                a->reg = 7;
1272
1280
                a->offset = n->xoffset;
1273
 
                a->sym = S;
 
1281
                a->sym = nil;
1274
1282
                break;          
1275
1283
 
1276
1284
        case OCFUNC:
1277
1285
                naddr(n->left, a, canemitcode);
1278
 
                a->sym = n->left->sym;
 
1286
                a->sym = linksym(n->left->sym);
1279
1287
                break;
1280
1288
 
1281
1289
        case ONAME:
1287
1295
                        a->width = n->type->width;
1288
1296
                }
1289
1297
                a->offset = n->xoffset;
1290
 
                a->sym = n->sym;
 
1298
                s = n->sym;
1291
1299
                a->node = n->orig;
1292
1300
                //if(a->node >= (Node*)&n)
1293
1301
                //      fatal("stack node");
1294
 
                if(a->sym == S)
1295
 
                        a->sym = lookup(".noname");
 
1302
                if(s == S)
 
1303
                        s = lookup(".noname");
1296
1304
                if(n->method) {
1297
1305
                        if(n->type != T)
1298
1306
                        if(n->type->sym != S)
1299
1307
                        if(n->type->sym->pkg != nil)
1300
 
                                a->sym = pkglookup(a->sym->name, n->type->sym->pkg);
 
1308
                                s = pkglookup(s->name, n->type->sym->pkg);
1301
1309
                }
1302
1310
 
1303
1311
                a->type = D_OREG;
1317
1325
                case PFUNC:
1318
1326
                        a->name = D_EXTERN;
1319
1327
                        a->type = D_CONST;
1320
 
                        a->sym = funcsym(a->sym);
 
1328
                        s = funcsym(s);
1321
1329
                        break;
1322
1330
                }
 
1331
                a->sym = linksym(s);
1323
1332
                break;
1324
1333
 
1325
1334
        case OLITERAL:
1333
1342
                        break;
1334
1343
                case CTINT:
1335
1344
                case CTRUNE:
1336
 
                        a->sym = S;
 
1345
                        a->sym = nil;
1337
1346
                        a->type = D_CONST;
1338
1347
                        a->offset = mpgetfix(n->val.u.xval);
1339
1348
                        break;
1341
1350
                        datagostring(n->val.u.sval, a);
1342
1351
                        break;
1343
1352
                case CTBOOL:
1344
 
                        a->sym = S;
 
1353
                        a->sym = nil;
1345
1354
                        a->type = D_CONST;
1346
1355
                        a->offset = n->val.u.bval;
1347
1356
                        break;
1348
1357
                case CTNIL:
1349
 
                        a->sym = S;
 
1358
                        a->sym = nil;
1350
1359
                        a->type = D_CONST;
1351
1360
                        a->offset = 0;
1352
1361
                        break;
1366
1375
                naddr(n->left, a, canemitcode);
1367
1376
                if(a->type == D_CONST && a->offset == 0)
1368
1377
                        break;  // ptr(nil)
1369
 
                a->etype = simtype[TUINTPTR];
 
1378
                a->etype = simtype[tptr];
1370
1379
                a->offset += Array_array;
1371
1380
                a->width = widthptr;
1372
1381
                break;
1592
1601
        case CASE(OADD, TINT32):
1593
1602
        case CASE(OADD, TUINT32):
1594
1603
        case CASE(OADD, TPTR32):
 
1604
        case CASE(OADDPTR, TPTR32):
1595
1605
                a = AADD;
1596
1606
                break;
1597
1607