[PATCH] D20337: [MC] Support symbolic expressions in assembly directives

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 18:02:21 PDT 2016


Should this be limited only to the `.space` case or `.fill` as well? The
`.fill` implementation currently emits multiple directives in the constant
case, we could instead just emit `.fill` directive so it's the same both in
absolute and symbol case, but that means we'd have to change the current
behavior, is that fine with you?

On Tue, May 24, 2016 at 11:52 AM Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 24 May 2016 at 14:29, Petr Hosek <phosek at chromium.org> wrote:
> > phosek added inline comments.
> >
> > ================
> > Comment at: lib/MC/MCAsmStreamer.cpp:823
> > @@ +822,3 @@
> > +  int64_t IntNumBytes;
> > +  if (NumBytes->evaluateAsAbsolute(IntNumBytes)) {
> > +    EmitFill(IntNumBytes, Value);
> > ----------------
> > rafael wrote:
> >> You don't need to this in the asm streamer. My suggestion would be to
> just make this a variant of emitFill. We would have one overload that takes
> a number and one that takes an expression. The implementations would be:
> >>
> >> * In the asm streamer: the ones taking an MCExpr does the printing. The
> other one creates an MCExpr and forwards.
> >> * In the obj streamer: what you have now. Try to evaluate the expr and
> maybe fail. If it works, forward to the overload that takes a number.
> > In case of `MCAsmStreamer`, where would we evaluate the `MCExpr`
> expression then? Does it mean we should always print out the expression
> even if it's absolute?
>
> Even is's *not* absolute? Correct. In the patch we already have
> different views of what is absolute:
>
> if (!NumBytes->evaluateAsAbsolute(IntNumBytes, getAssembler()))
>
> versus
>
> if (NumBytes->evaluateAsAbsolute(IntNumBytes))
>
> passing an assemble enables more expressions to be evaluated as constants.
>
> I think the reasonable options are
>
> * Bath asm and obj streamers have exactly the same idea of what is
> absolute.
> * The asm streamer doesn't even try to find out if something is absolute.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/b2672438/attachment.html>


More information about the llvm-commits mailing list