MC: Remove unneeded context argument to MCExpr::Evaluate*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84233 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-10-16 01:57:52 +00:00
parent 75773ff00d
commit e00b011e6a
4 changed files with 11 additions and 12 deletions

View File

@ -62,14 +62,14 @@ public:
/// ///
/// @param Res - The absolute value, if evaluation succeeds. /// @param Res - The absolute value, if evaluation succeeds.
/// @result - True on success. /// @result - True on success.
bool EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const; bool EvaluateAsAbsolute(int64_t &Res) const;
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
/// value, i.e. an expression of the fixed form (a - b + constant). /// value, i.e. an expression of the fixed form (a - b + constant).
/// ///
/// @param Res - The relocatable value, if evaluation succeeds. /// @param Res - The relocatable value, if evaluation succeeds.
/// @result - True on success. /// @result - True on success.
bool EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const; bool EvaluateAsRelocatable(MCValue &Res) const;
/// @} /// @}

View File

@ -141,10 +141,10 @@ const MCSymbolRefExpr *MCSymbolRefExpr::Create(const StringRef &Name,
/* *** */ /* *** */
bool MCExpr::EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const { bool MCExpr::EvaluateAsAbsolute(int64_t &Res) const {
MCValue Value; MCValue Value;
if (!EvaluateAsRelocatable(Ctx, Value) || !Value.isAbsolute()) if (!EvaluateAsRelocatable(Value) || !Value.isAbsolute())
return false; return false;
Res = Value.getConstant(); Res = Value.getConstant();
@ -173,7 +173,7 @@ static bool EvaluateSymbolicAdd(const MCValue &LHS, const MCSymbol *RHS_A,
return true; return true;
} }
bool MCExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const { bool MCExpr::EvaluateAsRelocatable(MCValue &Res) const {
switch (getKind()) { switch (getKind()) {
case Constant: case Constant:
Res = MCValue::get(cast<MCConstantExpr>(this)->getValue()); Res = MCValue::get(cast<MCConstantExpr>(this)->getValue());
@ -184,7 +184,7 @@ bool MCExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const {
// Evaluate recursively if this is a variable. // Evaluate recursively if this is a variable.
if (Sym.isVariable()) if (Sym.isVariable())
return Sym.getValue()->EvaluateAsRelocatable(Ctx, Res); return Sym.getValue()->EvaluateAsRelocatable(Res);
Res = MCValue::get(&Sym, 0, 0); Res = MCValue::get(&Sym, 0, 0);
return true; return true;
@ -194,7 +194,7 @@ bool MCExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const {
const MCUnaryExpr *AUE = cast<MCUnaryExpr>(this); const MCUnaryExpr *AUE = cast<MCUnaryExpr>(this);
MCValue Value; MCValue Value;
if (!AUE->getSubExpr()->EvaluateAsRelocatable(Ctx, Value)) if (!AUE->getSubExpr()->EvaluateAsRelocatable(Value))
return false; return false;
switch (AUE->getOpcode()) { switch (AUE->getOpcode()) {
@ -227,8 +227,8 @@ bool MCExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const {
const MCBinaryExpr *ABE = cast<MCBinaryExpr>(this); const MCBinaryExpr *ABE = cast<MCBinaryExpr>(this);
MCValue LHSValue, RHSValue; MCValue LHSValue, RHSValue;
if (!ABE->getLHS()->EvaluateAsRelocatable(Ctx, LHSValue) || if (!ABE->getLHS()->EvaluateAsRelocatable(LHSValue) ||
!ABE->getRHS()->EvaluateAsRelocatable(Ctx, RHSValue)) !ABE->getRHS()->EvaluateAsRelocatable(RHSValue))
return false; return false;
// We only support a few operations on non-constant expressions, handle // We only support a few operations on non-constant expressions, handle

View File

@ -346,8 +346,7 @@ void MCMachOStreamer::EmitValueToOffset(const MCExpr *Offset,
unsigned char Value) { unsigned char Value) {
MCValue RelocOffset; MCValue RelocOffset;
if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(getContext(), if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(RelocOffset))
RelocOffset))
return llvm_report_error("expected relocatable expression"); return llvm_report_error("expected relocatable expression");
new MCOrgFragment(RelocOffset, Value, CurSectionData); new MCOrgFragment(RelocOffset, Value, CurSectionData);

View File

@ -292,7 +292,7 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
if (ParseExpression(Expr)) if (ParseExpression(Expr))
return true; return true;
if (!Expr->EvaluateAsAbsolute(Ctx, Res)) if (!Expr->EvaluateAsAbsolute(Res))
return Error(StartLoc, "expected absolute expression"); return Error(StartLoc, "expected absolute expression");
return false; return false;