diff options
author | Fangrui Song <i@maskray.me> | 2025-07-19 09:59:27 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-07-19 09:59:27 -0700 |
commit | ecf0cbda18d41939952ac1ee5a320e8920cf9e50 (patch) | |
tree | 8e647a864b43457afbaa739a95e27c1ba01921c7 | |
parent | 64220357b45b2c262eece817e797a29b8daabdd5 (diff) | |
download | llvm-ecf0cbda18d41939952ac1ee5a320e8920cf9e50.zip llvm-ecf0cbda18d41939952ac1ee5a320e8920cf9e50.tar.gz llvm-ecf0cbda18d41939952ac1ee5a320e8920cf9e50.tar.bz2 |
MCFragment: Refactor LEB
* Deduplicate creation of SLEB128/ULEB128 with makeLEB.
* Call newFragment to prepare for removing getOrCreateDataFragment.
-rw-r--r-- | llvm/include/llvm/MC/MCSection.h | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h index 313071e..63a23b1 100644 --- a/llvm/include/llvm/MC/MCSection.h +++ b/llvm/include/llvm/MC/MCSection.h @@ -443,6 +443,12 @@ public: } //== FT_LEB functions + void makeLEB(bool IsSigned, const MCExpr *Value) { + assert(Kind == FT_Data); + Kind = MCFragment::FT_LEB; + u.leb.IsSigned = IsSigned; + u.leb.Value = Value; + } const MCExpr &getLEBValue() const { assert(Kind == FT_LEB); return *u.leb.Value; @@ -455,10 +461,6 @@ public: assert(Kind == FT_LEB); return u.leb.IsSigned; } - void setLEBSigned(bool S) { - assert(Kind == FT_LEB); - u.leb.IsSigned = S; - } //== FT_DwarfFrame functions const MCExpr &getDwarfAddrDelta() const { diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index d5b8f22..f61dda6 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -215,9 +215,8 @@ void MCObjectStreamer::emitULEB128Value(const MCExpr *Value) { return; } auto *F = getOrCreateDataFragment(); - F->Kind = MCFragment::FT_LEB; - F->setLEBSigned(false); - F->setLEBValue(Value); + F->makeLEB(false, Value); + newFragment(); } void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) { @@ -227,9 +226,8 @@ void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) { return; } auto *F = getOrCreateDataFragment(); - F->Kind = MCFragment::FT_LEB; - F->setLEBSigned(true); - F->setLEBValue(Value); + F->makeLEB(true, Value); + newFragment(); } void MCObjectStreamer::emitWeakReference(MCSymbol *Alias, |