Skip to content

Commit 4e3446a

Browse files
MaskRaymahesh-attarde
authored andcommitted
MCFragment: Refactor LEB
* Deduplicate creation of SLEB128/ULEB128 with makeLEB. * Call newFragment to prepare for removing getOrCreateDataFragment.
1 parent 0795dfb commit 4e3446a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/include/llvm/MC/MCSection.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ class MCFragment {
443443
}
444444

445445
//== FT_LEB functions
446+
void makeLEB(bool IsSigned, const MCExpr *Value) {
447+
assert(Kind == FT_Data);
448+
Kind = MCFragment::FT_LEB;
449+
u.leb.IsSigned = IsSigned;
450+
u.leb.Value = Value;
451+
}
446452
const MCExpr &getLEBValue() const {
447453
assert(Kind == FT_LEB);
448454
return *u.leb.Value;
@@ -455,10 +461,6 @@ class MCFragment {
455461
assert(Kind == FT_LEB);
456462
return u.leb.IsSigned;
457463
}
458-
void setLEBSigned(bool S) {
459-
assert(Kind == FT_LEB);
460-
u.leb.IsSigned = S;
461-
}
462464

463465
//== FT_DwarfFrame functions
464466
const MCExpr &getDwarfAddrDelta() const {

llvm/lib/MC/MCObjectStreamer.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,8 @@ void MCObjectStreamer::emitULEB128Value(const MCExpr *Value) {
215215
return;
216216
}
217217
auto *F = getOrCreateDataFragment();
218-
F->Kind = MCFragment::FT_LEB;
219-
F->setLEBSigned(false);
220-
F->setLEBValue(Value);
218+
F->makeLEB(false, Value);
219+
newFragment();
221220
}
222221

223222
void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) {
@@ -227,9 +226,8 @@ void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) {
227226
return;
228227
}
229228
auto *F = getOrCreateDataFragment();
230-
F->Kind = MCFragment::FT_LEB;
231-
F->setLEBSigned(true);
232-
F->setLEBValue(Value);
229+
F->makeLEB(true, Value);
230+
newFragment();
233231
}
234232

235233
void MCObjectStreamer::emitWeakReference(MCSymbol *Alias,

0 commit comments

Comments
 (0)