mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
MCFragment: Refactor LEB
* Deduplicate creation of SLEB128/ULEB128 with makeLEB. * Call newFragment to prepare for removing getOrCreateDataFragment.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user