[PATCH] D132508: [MC] Let assembler decide the fill value for p2align instead of 0x0

Stephen Long via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 08:04:17 PDT 2022


steplong added a comment.

In D132508#3744078 <https://reviews.llvm.org/D132508#3744078>, @efriedma wrote:

> Reinterpreting `Value == 0` to mean the user didn't specify a value is wrong.  We should distinguish between "no fill specified" and "fill zero specified".  (At least, that's how it should work, as far as I can tell.)
>
> In the "no fill specified" case, we should end up in emitCodeAlignment; we can emit the correct directive from there, instead of throwing away the information.

That makes sense. Do you know how I can get the min byte width of the Value? The nop value for ARM64 is 0xd503201f which is 4 bytes, but X86's nop value is 0x90 which is 1 byte. Currently emitCodeAlignment looks like:

  void emitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
                            unsigned ValueSize = 1,
                            unsigned MaxBytesToEmit = 0) override;
  
  void MCAsmStreamer::emitCodeAlignment(unsigned ByteAlignment,
                                        const MCSubtargetInfo *STI,
                                        unsigned MaxBytesToEmit) {
    // Emit with a text fill value.
    emitValueToAlignment(ByteAlignment, MAI->getTextAlignFillValue(),
                         1, MaxBytesToEmit);
  }

ValueSize is hardcoded to 1, but for ARM64 we would have to pass 4.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132508/new/

https://reviews.llvm.org/D132508



More information about the llvm-commits mailing list