@@ -254,30 +254,23 @@ void MCTargetExpr::anchor() {}
254
254
/* *** */
255
255
256
256
bool MCExpr::evaluateAsAbsolute (int64_t &Res) const {
257
- return evaluateAsAbsolute (Res, nullptr , nullptr , false );
258
- }
259
-
260
- bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm,
261
- const SectionAddrMap &Addrs) const {
262
- // Setting InSet causes us to absolutize differences across sections and that
263
- // is what the MachO writer uses Addrs for.
264
- return evaluateAsAbsolute (Res, &Asm, &Addrs, true );
257
+ return evaluateAsAbsolute (Res, nullptr , false );
265
258
}
266
259
267
260
bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler &Asm) const {
268
- return evaluateAsAbsolute (Res, &Asm, nullptr , false );
261
+ return evaluateAsAbsolute (Res, &Asm, false );
269
262
}
270
263
271
264
bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm) const {
272
- return evaluateAsAbsolute (Res, Asm, nullptr , false );
265
+ return evaluateAsAbsolute (Res, Asm, false );
273
266
}
274
267
275
268
bool MCExpr::evaluateKnownAbsolute (int64_t &Res, const MCAssembler &Asm) const {
276
- return evaluateAsAbsolute (Res, &Asm, nullptr , true );
269
+ return evaluateAsAbsolute (Res, &Asm, true );
277
270
}
278
271
279
272
bool MCExpr::evaluateAsAbsolute (int64_t &Res, const MCAssembler *Asm,
280
- const SectionAddrMap *Addrs, bool InSet) const {
273
+ bool InSet) const {
281
274
MCValue Value;
282
275
283
276
// Fast path constants.
@@ -286,7 +279,7 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
286
279
return true ;
287
280
}
288
281
289
- bool IsRelocatable = evaluateAsRelocatableImpl (Value, Asm, Addrs, InSet);
282
+ bool IsRelocatable = evaluateAsRelocatableImpl (Value, Asm, InSet);
290
283
Res = Value.getConstant ();
291
284
// Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered
292
285
// absolute (the value is unknown at parse time), even if it might be resolved
@@ -296,7 +289,6 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
296
289
297
290
// / Helper method for \see EvaluateSymbolAdd().
298
291
static void attemptToFoldSymbolOffsetDifference (const MCAssembler *Asm,
299
- const SectionAddrMap *Addrs,
300
292
bool InSet, const MCSymbol *&A,
301
293
const MCSymbol *&B,
302
294
int64_t &Addend) {
@@ -324,7 +316,7 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
324
316
const MCFragment *FB = SB.getFragment ();
325
317
const MCSection &SecA = *FA->getParent ();
326
318
const MCSection &SecB = *FB->getParent ();
327
- if (( &SecA != &SecB) && !Addrs )
319
+ if (&SecA != &SecB)
328
320
return ;
329
321
330
322
// When layout is available, we can generally compute the difference using the
@@ -345,9 +337,6 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
345
337
346
338
// Eagerly evaluate when layout is finalized.
347
339
Addend += Asm->getSymbolOffset (SA) - Asm->getSymbolOffset (SB);
348
- if (Addrs && (&SecA != &SecB))
349
- Addend += (Addrs->lookup (&SecA) - Addrs->lookup (&SecB));
350
-
351
340
FinalizeFolding ();
352
341
} else {
353
342
// When layout is not finalized, our ability to resolve differences between
@@ -434,8 +423,7 @@ static void attemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
434
423
// NOTE: This function can be used before layout is done (see the object
435
424
// streamer for example) and having the Asm argument lets us avoid relaxations
436
425
// early.
437
- bool MCExpr::evaluateSymbolicAdd (const MCAssembler *Asm,
438
- const SectionAddrMap *Addrs, bool InSet,
426
+ bool MCExpr::evaluateSymbolicAdd (const MCAssembler *Asm, bool InSet,
439
427
const MCValue &LHS, const MCValue &RHS,
440
428
MCValue &Res) {
441
429
const MCSymbol *LHS_A = LHS.getAddSym ();
@@ -456,12 +444,10 @@ bool MCExpr::evaluateSymbolicAdd(const MCAssembler *Asm,
456
444
// Result = (LHS_A - LHS_B + LHS_Cst) + (RHS_A - RHS_B + RHS_Cst).
457
445
// might bring more opportunities.
458
446
if (LHS_A && RHS_B) {
459
- attemptToFoldSymbolOffsetDifference (Asm, Addrs, InSet, LHS_A, RHS_B,
460
- Result_Cst);
447
+ attemptToFoldSymbolOffsetDifference (Asm, InSet, LHS_A, RHS_B, Result_Cst);
461
448
}
462
449
if (RHS_A && LHS_B) {
463
- attemptToFoldSymbolOffsetDifference (Asm, Addrs, InSet, RHS_A, LHS_B,
464
- Result_Cst);
450
+ attemptToFoldSymbolOffsetDifference (Asm, InSet, RHS_A, LHS_B, Result_Cst);
465
451
}
466
452
}
467
453
@@ -481,10 +467,10 @@ bool MCExpr::evaluateSymbolicAdd(const MCAssembler *Asm,
481
467
}
482
468
483
469
bool MCExpr::evaluateAsRelocatable (MCValue &Res, const MCAssembler *Asm) const {
484
- return evaluateAsRelocatableImpl (Res, Asm, nullptr , false );
470
+ return evaluateAsRelocatableImpl (Res, Asm, false );
485
471
}
486
472
bool MCExpr::evaluateAsValue (MCValue &Res, const MCAssembler &Asm) const {
487
- return evaluateAsRelocatableImpl (Res, &Asm, nullptr , true );
473
+ return evaluateAsRelocatableImpl (Res, &Asm, true );
488
474
}
489
475
static bool canExpand (const MCSymbol &Sym, bool InSet) {
490
476
if (Sym.isWeakExternal ())
@@ -503,7 +489,6 @@ static bool canExpand(const MCSymbol &Sym, bool InSet) {
503
489
}
504
490
505
491
bool MCExpr::evaluateAsRelocatableImpl (MCValue &Res, const MCAssembler *Asm,
506
- const SectionAddrMap *Addrs,
507
492
bool InSet) const {
508
493
++stats::MCExprEvaluate;
509
494
switch (getKind ()) {
@@ -523,7 +508,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
523
508
if (Sym.isVariable () && (Kind == MCSymbolRefExpr::VK_None || Layout) &&
524
509
canExpand (Sym, InSet)) {
525
510
bool IsMachO = SRE->hasSubsectionsViaSymbols ();
526
- if (Sym.getVariableValue ()->evaluateAsRelocatableImpl (Res, Asm, Addrs,
511
+ if (Sym.getVariableValue ()->evaluateAsRelocatableImpl (Res, Asm,
527
512
InSet || IsMachO)) {
528
513
if (Kind != MCSymbolRefExpr::VK_None) {
529
514
if (Res.isAbsolute ()) {
@@ -566,7 +551,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
566
551
const MCUnaryExpr *AUE = cast<MCUnaryExpr>(this );
567
552
MCValue Value;
568
553
569
- if (!AUE->getSubExpr ()->evaluateAsRelocatableImpl (Value, Asm, Addrs, InSet))
554
+ if (!AUE->getSubExpr ()->evaluateAsRelocatableImpl (Value, Asm, InSet))
570
555
return false ;
571
556
switch (AUE->getOpcode ()) {
572
557
case MCUnaryExpr::LNot:
@@ -600,10 +585,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
600
585
const MCBinaryExpr *ABE = cast<MCBinaryExpr>(this );
601
586
MCValue LHSValue, RHSValue;
602
587
603
- if (!ABE->getLHS ()->evaluateAsRelocatableImpl (LHSValue, Asm, Addrs,
604
- InSet) ||
605
- !ABE->getRHS ()->evaluateAsRelocatableImpl (RHSValue, Asm, Addrs,
606
- InSet)) {
588
+ if (!ABE->getLHS ()->evaluateAsRelocatableImpl (LHSValue, Asm, InSet) ||
589
+ !ABE->getRHS ()->evaluateAsRelocatableImpl (RHSValue, Asm, InSet)) {
607
590
// Check if both are Target Expressions, see if we can compare them.
608
591
if (const MCTargetExpr *L = dyn_cast<MCTargetExpr>(ABE->getLHS ())) {
609
592
if (const MCTargetExpr *R = dyn_cast<MCTargetExpr>(ABE->getRHS ())) {
@@ -650,7 +633,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
650
633
return false ;
651
634
if (RHSValue.SymB && RHSValue.Specifier )
652
635
return false ;
653
- return evaluateSymbolicAdd (Asm, Addrs, InSet, LHSValue, RHSValue, Res);
636
+ return evaluateSymbolicAdd (Asm, InSet, LHSValue, RHSValue, Res);
654
637
}
655
638
}
656
639
0 commit comments