[llvm-commits] [llvm] r80577 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCNullStreamer.cpp test/MC/AsmParser/directive_include.s test/MC/AsmParser/directive_set.s test/MC/AsmParser/labels.s tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h
Daniel Dunbar
daniel at zuster.org
Mon Aug 31 01:09:09 PDT 2009
Author: ddunbar
Date: Mon Aug 31 03:09:09 2009
New Revision: 80577
URL: http://llvm.org/viewvc/llvm-project?rev=80577&view=rev
Log:
llvm-mc: Simplify EmitAssignment ('.set' is identical to '=').
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCNullStreamer.cpp
llvm/trunk/test/MC/AsmParser/directive_include.s
llvm/trunk/test/MC/AsmParser/directive_set.s
llvm/trunk/test/MC/AsmParser/labels.s
llvm/trunk/tools/llvm-mc/AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmParser.h
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Aug 31 03:09:09 2009
@@ -116,11 +116,7 @@
///
/// @param Symbol - The symbol being assigned to.
/// @param Value - The value for the symbol.
- /// @param MakeAbsolute - If true, then the symbol should be given the
- /// absolute value of @param Value, even if @param Value would be
- /// relocatable expression. This corresponds to the ".set" directive.
- virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
- bool MakeAbsolute = false) = 0;
+ virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value) = 0;
/// EmitSymbolAttribute - Add the given @param Attribute to @param Symbol.
virtual void EmitSymbolAttribute(MCSymbol *Symbol,
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon Aug 31 03:09:09 2009
@@ -47,8 +47,7 @@
virtual void EmitAssemblerFlag(AssemblerFlag Flag);
- virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
- bool MakeAbsolute = false);
+ virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value);
virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute);
@@ -126,26 +125,12 @@
OS << '\n';
}
-void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
- bool MakeAbsolute) {
+void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value) {
// Only absolute symbols can be redefined.
assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
"Cannot define a symbol twice!");
- if (MakeAbsolute) {
- OS << ".set " << Symbol << ", " << Value << '\n';
-
- // HACK: If the value isn't already absolute, set the symbol value to
- // itself, we want to use the .set absolute value, not the actual
- // expression.
- if (!Value.isAbsolute())
- getContext().SetSymbolValue(Symbol, MCValue::get(Symbol));
- else
- getContext().SetSymbolValue(Symbol, Value);
- } else {
- OS << Symbol << " = " << Value << '\n';
- getContext().SetSymbolValue(Symbol, Value);
- }
+ OS << Symbol << " = " << Value << '\n';
}
void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon Aug 31 03:09:09 2009
@@ -129,8 +129,7 @@
virtual void EmitAssemblerFlag(AssemblerFlag Flag);
- virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
- bool MakeAbsolute = false);
+ virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value);
virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute);
@@ -201,9 +200,7 @@
assert(0 && "invalid assembler flag!");
}
-void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol,
- const MCValue &Value,
- bool MakeAbsolute) {
+void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value) {
// Only absolute symbols can be redefined.
assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
"Cannot define a symbol twice!");
Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCNullStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCNullStreamer.cpp Mon Aug 31 03:09:09 2009
@@ -34,8 +34,7 @@
virtual void EmitAssemblerFlag(AssemblerFlag Flag) {}
- virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
- bool MakeAbsolute = false) {}
+ virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value) {}
virtual void EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute) {}
Modified: llvm/trunk/test/MC/AsmParser/directive_include.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_include.s?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_include.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_include.s Mon Aug 31 03:09:09 2009
@@ -2,7 +2,7 @@
# CHECK: TESTA:
# CHECK: TEST0:
-# CHECK: .set a, 0
+# CHECK: a = 0
# CHECK: TESTB:
TESTA:
.include "directive_set.s"
Modified: llvm/trunk/test/MC/AsmParser/directive_set.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_set.s?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_set.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_set.s Mon Aug 31 03:09:09 2009
@@ -1,7 +1,7 @@
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK: TEST0:
-# CHECK: .set a, 0
+# CHECK: a = 0
TEST0:
.set a, 0
Modified: llvm/trunk/test/MC/AsmParser/labels.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/labels.s?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/labels.s (original)
+++ llvm/trunk/test/MC/AsmParser/labels.s Mon Aug 31 03:09:09 2009
@@ -23,10 +23,10 @@
// CHECK: addl $"b$c", %eax
addl "b$c", %eax
-// CHECK: set "a 0", 11
+// CHECK: "a 0" = 11
.set "a 0", 11
-// CHECK: .long 11
+// CHECK: .long "a 0"
.long "a 0"
// XXCHCK: .section "a 1,a 2"
@@ -44,7 +44,7 @@
// CHECK: .comm "a 6",1
.comm "a 6", 1
-// CHECK: .zerofill __DATA,__bss,"a 7",1
+// CHECK: .zerofill __DATA,__bss,"a 7",1,0
.lcomm "a 7", 1
// FIXME: We don't bother to support .lsym.
@@ -52,7 +52,7 @@
// CHECX: .lsym "a 8",1
// .lsym "a 8", 1
-// CHECK: set "a 9", a - b
+// CHECK: "a 9" = a - b
.set "a 9", a - b
// CHECK: .long "a 9"
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Mon Aug 31 03:09:09 2009
@@ -431,7 +431,7 @@
// identifier '=' ... -> assignment statement
Lexer.Lex();
- return ParseAssignment(IDVal, false);
+ return ParseAssignment(IDVal);
default: // Normal instruction or directive.
break;
@@ -708,7 +708,7 @@
return false;
}
-bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
+bool AsmParser::ParseAssignment(const StringRef &Name) {
// FIXME: Use better location, we should use proper tokens.
SMLoc EqualLoc = Lexer.getLoc();
@@ -737,7 +737,7 @@
return Error(EqualLoc, "symbol has already been defined");
// Do the assignment.
- Out.EmitAssignment(Sym, Value, IsDotSet);
+ Out.EmitAssignment(Sym, Value);
return false;
}
@@ -769,7 +769,7 @@
return TokError("unexpected token in '.set'");
Lexer.Lex();
- return ParseAssignment(Name, true);
+ return ParseAssignment(Name);
}
/// ParseDirectiveSection:
Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=80577&r1=80576&r2=80577&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Mon Aug 31 03:09:09 2009
@@ -94,7 +94,7 @@
SMLoc DirectiveLoc);
void EatToEndOfStatement();
- bool ParseAssignment(const StringRef &Name, bool IsDotSet);
+ bool ParseAssignment(const StringRef &Name);
bool ParsePrimaryExpr(const MCExpr *&Res);
bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res);
More information about the llvm-commits
mailing list