Beispiel #1
0
/// Emit something like ".long Hi+Offset-Lo" where the size in bytes of the
/// directive is specified by Size and Hi/Lo specify the labels.
static void emitLabelOffsetDifference(MCStreamer &Streamer, const MCSymbol *Hi,
                                      uint64_t Offset, const MCSymbol *Lo,
                                      unsigned Size) {
  MCContext &Context = Streamer.getContext();

  // Emit Hi+Offset - Lo
  // Get the Hi+Offset expression.
  const MCExpr *Plus =
      MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Hi, Context),
                              MCConstantExpr::Create(Offset, Context), Context);

  // Get the Hi+Offset-Lo expression.
  const MCExpr *Diff = MCBinaryExpr::CreateSub(
      Plus, MCSymbolRefExpr::Create(Lo, Context), Context);

  // Otherwise, emit with .set (aka assignment).
  MCSymbol *SetLabel = Context.CreateTempSymbol();
  Streamer.EmitAssignment(SetLabel, Diff);
  Streamer.EmitSymbolValue(SetLabel, Size);
}
Beispiel #2
0
void MCContext::setSymbolValue(MCStreamer &Streamer,
                              StringRef Sym,
                              uint64_t Val) {
  auto Symbol = getOrCreateSymbol(Sym);
  Streamer.EmitAssignment(Symbol, MCConstantExpr::create(Val, *this));
}