Use references to simplify the code a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121050 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-12-06 22:30:54 +00:00
parent a3b2200472
commit 22373b230a
4 changed files with 15 additions and 18 deletions

View File

@ -41,6 +41,8 @@ private:
MCExpr(const MCExpr&); // DO NOT IMPLEMENT
void operator=(const MCExpr&); // DO NOT IMPLEMENT
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout) const;
protected:
explicit MCExpr(ExprKind _Kind) : Kind(_Kind) {}
@ -72,10 +74,8 @@ public:
/// evaluated.
/// @result - True on success.
bool EvaluateAsAbsolute(int64_t &Res) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
const MCAsmLayout *Layout) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
/// value, i.e. an expression of the fixed form (a - b + constant).

View File

@ -780,7 +780,7 @@ bool MCAssembler::RelaxOrg(const MCObjectWriter &Writer,
MCAsmLayout &Layout,
MCOrgFragment &OF) {
int64_t TargetLocation;
if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout))
if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, Layout))
report_fatal_error("expected assembly-time absolute expression");
// FIXME: We need a way to communicate this error.
@ -800,7 +800,7 @@ bool MCAssembler::RelaxLEB(const MCObjectWriter &Writer,
MCLEBFragment &LF) {
int64_t Value = 0;
uint64_t OldSize = LF.getContents().size();
LF.getValue().EvaluateAsAbsolute(Value, &Layout);
LF.getValue().EvaluateAsAbsolute(Value, Layout);
SmallString<8> &Data = LF.getContents();
Data.clear();
raw_svector_ostream OSE(Data);
@ -817,7 +817,7 @@ bool MCAssembler::RelaxDwarfLineAddr(const MCObjectWriter &Writer,
MCDwarfLineAddrFragment &DF) {
int64_t AddrDelta = 0;
uint64_t OldSize = DF.getContents().size();
DF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, &Layout);
DF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, Layout);
int64_t LineDelta;
LineDelta = DF.getLineDelta();
SmallString<8> &Data = DF.getContents();

View File

@ -242,15 +242,12 @@ bool MCExpr::EvaluateAsAbsolute(int64_t &Res) const {
}
bool MCExpr::EvaluateAsAbsolute(int64_t &Res,
const MCAsmLayout *Layout) const {
if (Layout)
return EvaluateAsAbsolute(Res, &Layout->getAssembler(), Layout);
else
return EvaluateAsAbsolute(Res, 0, 0);
const MCAsmLayout &Layout) const {
return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout);
}
bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const {
return EvaluateAsAbsolute(Res, Asm, 0);
bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const {
return EvaluateAsAbsolute(Res, &Asm, 0);
}
bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,

View File

@ -83,7 +83,7 @@ void MCObjectStreamer::EmitValue(const MCExpr *Value, unsigned Size,
// Avoid fixups when possible.
int64_t AbsValue;
if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, &getAssembler())) {
if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, getAssembler())) {
EmitIntValue(AbsValue, Size, AddrSpace);
return;
}
@ -114,7 +114,7 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value,
unsigned AddrSpace) {
int64_t IntValue;
if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) {
if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) {
EmitULEB128IntValue(IntValue, AddrSpace);
return;
}
@ -124,7 +124,7 @@ void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value,
void MCObjectStreamer::EmitSLEB128Value(const MCExpr *Value,
unsigned AddrSpace) {
int64_t IntValue;
if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) {
if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) {
EmitSLEB128IntValue(IntValue, AddrSpace);
return;
}
@ -204,7 +204,7 @@ void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta,
MCBinaryExpr::Create(MCBinaryExpr::Sub, LabelRef, LastLabelRef,
getContext());
int64_t Res;
if (AddrDelta->EvaluateAsAbsolute(Res, &getAssembler())) {
if (AddrDelta->EvaluateAsAbsolute(Res, getAssembler())) {
MCDwarfLineAddr::Emit(this, LineDelta, Res);
return;
}