diff options
author | Fangrui Song <i@maskray.me> | 2025-07-13 14:07:09 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-07-13 14:07:10 -0700 |
commit | 1fbfa333f64bf714efa84db6b1075fc864d53bf8 (patch) | |
tree | bff5046fb6db84b03585312e5ec0831599a5eecd /llvm/lib/MC/MCAssembler.cpp | |
parent | b56aebaf82f250ac35d18bcb4d4bf6806af91f49 (diff) | |
download | llvm-1fbfa333f64bf714efa84db6b1075fc864d53bf8.zip llvm-1fbfa333f64bf714efa84db6b1075fc864d53bf8.tar.gz llvm-1fbfa333f64bf714efa84db6b1075fc864d53bf8.tar.bz2 |
MCAlignFragment: Rename fields and use uint8_t FillLen
* Rename the vague `Value` to `Fill`.
* FillLen is at most 8. Making the field smaller to facilitate encoding
MCAlignFragment as a MCFragment union member.
* Replace an unreachable report_fatal_error with assert.
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 480e6fe..fd8a8c3 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -553,18 +553,11 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, case MCFragment::FT_Align: { ++stats::EmittedAlignFragments; const MCAlignFragment &AF = cast<MCAlignFragment>(F); - assert(AF.getValueSize() && "Invalid virtual align in concrete fragment!"); + assert(AF.getFillLen() && "Invalid virtual align in concrete fragment!"); - uint64_t Count = FragmentSize / AF.getValueSize(); - - // FIXME: This error shouldn't actually occur (the front end should emit - // multiple .align directives to enforce the semantics it wants), but is - // severe enough that we want to report it. How to handle this? - if (Count * AF.getValueSize() != FragmentSize) - report_fatal_error("undefined .align directive, value size '" + - Twine(AF.getValueSize()) + - "' is not a divisor of padding size '" + - Twine(FragmentSize) + "'"); + uint64_t Count = FragmentSize / AF.getFillLen(); + assert(FragmentSize % AF.getFillLen() == 0 && + "computeFragmentSize computed size is incorrect"); // See if we are aligning with nops, and if so do that first to try to fill // the Count bytes. Then if that did not fill any bytes or there are any @@ -579,17 +572,19 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, // Otherwise, write out in multiples of the value size. for (uint64_t i = 0; i != Count; ++i) { - switch (AF.getValueSize()) { + switch (AF.getFillLen()) { default: llvm_unreachable("Invalid size!"); - case 1: OS << char(AF.getValue()); break; + case 1: + OS << char(AF.getFill()); + break; case 2: - support::endian::write<uint16_t>(OS, AF.getValue(), Endian); + support::endian::write<uint16_t>(OS, AF.getFill(), Endian); break; case 4: - support::endian::write<uint32_t>(OS, AF.getValue(), Endian); + support::endian::write<uint32_t>(OS, AF.getFill(), Endian); break; case 8: - support::endian::write<uint64_t>(OS, AF.getValue(), Endian); + support::endian::write<uint64_t>(OS, AF.getFill(), Endian); break; } } @@ -733,8 +728,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS, case MCFragment::FT_Align: // Check that we aren't trying to write a non-zero value into a virtual // section. - assert((cast<MCAlignFragment>(F).getValueSize() == 0 || - cast<MCAlignFragment>(F).getValue() == 0) && + assert((cast<MCAlignFragment>(F).getFillLen() == 0 || + cast<MCAlignFragment>(F).getFill() == 0) && "Invalid align in virtual section!"); break; case MCFragment::FT_Fill: |