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

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 11:51:59 PDT 2016


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


More information about the llvm-commits mailing list