[llvm-commits] [llvm] r80484 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCNullStreamer.cpp test/MC/AsmParser/directive_lsym.s tools/llvm-mc/AsmParser.cpp
Daniel Dunbar
daniel at zuster.org
Sat Aug 29 23:17:16 PDT 2009
Author: ddunbar
Date: Sun Aug 30 01:17:16 2009
New Revision: 80484
URL: http://llvm.org/viewvc/llvm-project?rev=80484&view=rev
Log:
llvm-mc: MCStreamer cleanups. - Remove EmitLocalSymbol, this is unsupported for now.
- Switch Emit{CommonSymbol,Zerofill} to take alignment in bytes (for consistency).
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_lsym.s
llvm/trunk/tools/llvm-mc/AsmParser.cpp
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Sun Aug 30 01:17:16 2009
@@ -31,7 +31,7 @@
/// MCStreamer - Streaming machine code generation interface. This interface
/// is intended to provide a programatic interface that is very similar to the
/// level that an assembler .s file provides. It has callbacks to emit bytes,
- /// "emit directives", etc. The implementation of this interface retains
+ /// handle directives, etc. The implementation of this interface retains
/// state to know what the current section is etc.
///
/// There are multiple implementations of this interface: one for writing out
@@ -73,6 +73,7 @@
/// CurSection - This is the current section code is being emitted to, it is
/// kept up to date by SwitchSection.
const MCSection *CurSection;
+
public:
virtual ~MCStreamer();
@@ -80,17 +81,16 @@
/// @name Symbol & Section Management
/// @{
+
+ /// getCurrentSection - Return the current seciton that the streamer is
+ /// emitting code to.
+ const MCSection *getCurrentSection() const { return CurSection; }
/// SwitchSection - Set the current section where code is being emitted to
/// @param Section. This is required to update CurSection.
///
/// This corresponds to assembler directives like .section, .text, etc.
virtual void SwitchSection(const MCSection *Section) = 0;
-
-
- /// getCurrentSection - Return the current seciton that the streamer is
- /// emitting code to.
- const MCSection *getCurrentSection() const { return CurSection; }
/// EmitLabel - Emit a label for @param Symbol into the current section.
///
@@ -100,9 +100,6 @@
/// @param Symbol - The symbol to emit. A given symbol should only be
/// emitted as a label once, and symbols emitted as a label should never be
/// used in an assignment.
- //
- // FIXME: What to do about the current section? Should we get rid of the
- // symbol section in the constructor and initialize it here?
virtual void EmitLabel(MCSymbol *Symbol) = 0;
/// EmitAssemblerFlag - Note in the output the specified @param Flag
@@ -126,11 +123,6 @@
bool MakeAbsolute = false) = 0;
/// EmitSymbolAttribute - Add the given @param Attribute to @param Symbol.
- //
- // FIXME: This doesn't make much sense, could we just have attributes be on
- // the symbol and make the printer smart enough to add the right symbols?
- // This should work as long as the order of attributes in the file doesn't
- // matter.
virtual void EmitSymbolAttribute(MCSymbol *Symbol,
SymbolAttr Attribute) = 0;
@@ -140,37 +132,30 @@
/// @param DescValue - The value to set into the n_desc field.
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
- /// EmitLocalSymbol - Emit a local symbol of @param Value to @param Symbol.
- ///
- /// @param Symbol - The local symbol being created.
- /// @param Value - The value for the symbol.
- virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) = 0;
-
- /// EmitCommonSymbol - Emit a common or local common symbol of @param Size
- /// with the @param Pow2Alignment if non-zero.
+ /// EmitCommonSymbol - Emit a common or local common symbol.
///
/// @param Symbol - The common symbol to emit.
/// @param Size - The size of the common symbol.
- /// @param Pow2Alignment - The alignment of the common symbol if non-zero.
+ /// @param ByteAlignment - The alignment of the symbol if
+ /// non-zero. This must be a power of 2 on some targets.
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment) = 0;
+ unsigned ByteAlignment) = 0;
- /// EmitZerofill - Emit a the zerofill section and possiblity a symbol, if
- /// @param Symbol is non-NULL, for @param Size and with the @param
- /// Pow2Alignment if non-zero.
+ /// EmitZerofill - Emit a the zerofill section and an option symbol.
///
/// @param Section - The zerofill section to create and or to put the symbol
/// @param Symbol - The zerofill symbol to emit, if non-NULL.
/// @param Size - The size of the zerofill symbol.
- /// @param Pow2Alignment - The alignment of the zerofill symbol if non-zero.
+ /// @param ByteAlignment - The alignment of the zerofill symbol if
+ /// non-zero. This must be a power of 2 on some targets.
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
- unsigned Size = 0,unsigned Pow2Alignment = 0) = 0;
+ unsigned Size = 0,unsigned ByteAlignment = 0) = 0;
/// @}
/// @name Generating Data
/// @{
- /// EmitBytes - Emit the bytes in @param Data into the output.
+ /// EmitBytes - Emit the bytes in \arg Data into the output.
///
/// This is used to implement assembler directives such as .byte, .ascii,
/// etc.
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sun Aug 30 01:17:16 2009
@@ -53,13 +53,11 @@
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
- virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value);
-
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment);
+ unsigned ByteAlignment);
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
- unsigned Size = 0, unsigned Pow2Alignment = 0);
+ unsigned Size = 0, unsigned ByteAlignment = 0);
virtual void EmitBytes(const StringRef &Data);
@@ -173,21 +171,17 @@
OS << ".desc" << ' ' << Symbol << ',' << DescValue << '\n';
}
-void MCAsmStreamer::EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {
- OS << ".lsym" << ' ' << Symbol << ',' << Value << '\n';
-}
-
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment) {
+ unsigned ByteAlignment) {
OS << ".comm";
OS << ' ' << Symbol << ',' << Size;
- if (Pow2Alignment != 0)
- OS << ',' << Pow2Alignment;
+ if (ByteAlignment != 0)
+ OS << ',' << Log2_32(ByteAlignment);
OS << '\n';
}
void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
- unsigned Size, unsigned Pow2Alignment) {
+ unsigned Size, unsigned ByteAlignment) {
// Note: a .zerofill directive does not switch sections.
OS << ".zerofill ";
@@ -197,8 +191,8 @@
if (Symbol != NULL) {
OS << ',' << Symbol << ',' << Size;
- if (Pow2Alignment != 0)
- OS << ',' << Pow2Alignment;
+ if (ByteAlignment != 0)
+ OS << ',' << Log2_32(ByteAlignment);
}
OS << '\n';
}
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sun Aug 30 01:17:16 2009
@@ -111,13 +111,11 @@
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
- virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value);
-
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment);
+ unsigned ByteAlignment);
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
- unsigned Size = 0, unsigned Pow2Alignment = 0);
+ unsigned Size = 0, unsigned ByteAlignment = 0);
virtual void EmitBytes(const StringRef &Data);
@@ -266,24 +264,18 @@
getSymbolData(*Symbol).setFlags(DescValue & SF_DescFlagsMask);
}
-void MCMachOStreamer::EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {
- // FIXME: Implement?
- llvm_report_error("unsupported '.lsym' directive");
-}
-
void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment) {
+ unsigned ByteAlignment) {
// FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
MCSymbolData &SD = getSymbolData(*Symbol);
SD.setExternal(true);
- SD.setCommon(Size, 1 << Pow2Alignment);
+ SD.setCommon(Size, ByteAlignment);
}
void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
- unsigned Size, unsigned Pow2Alignment) {
- unsigned ByteAlignment = 1 << Pow2Alignment;
+ unsigned Size, unsigned ByteAlignment) {
MCSectionData &SectData = getSectionData(*Section);
// The symbol may not be present, which only creates the section.
@@ -296,7 +288,7 @@
MCSymbolData &SD = getSymbolData(*Symbol);
- MCFragment *F = new MCZeroFillFragment(Size, 1 << Pow2Alignment, &SectData);
+ MCFragment *F = new MCZeroFillFragment(Size, ByteAlignment, &SectData);
SD.setFragment(F);
Symbol->setSection(*Section);
Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCNullStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCNullStreamer.cpp Sun Aug 30 01:17:16 2009
@@ -41,13 +41,11 @@
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
- virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {}
-
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
- unsigned Pow2Alignment) {}
+ unsigned ByteAlignment) {}
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
- unsigned Size = 0, unsigned Pow2Alignment = 0) {}
+ unsigned Size = 0, unsigned ByteAlignment = 0) {}
virtual void EmitBytes(const StringRef &Data) {}
Modified: llvm/trunk/test/MC/AsmParser/directive_lsym.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_lsym.s?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_lsym.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_lsym.s Sun Aug 30 01:17:16 2009
@@ -1,5 +1,10 @@
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# FIXME: This is currently unsupported. If it turns out no one uses it, we
+# should just rip it out.
+
+# XFAIL: *
+
# CHECK: TEST0:
# CHECK: .lsym bar,foo
# CHECK: .lsym baz,3
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=80484&r1=80483&r2=80484&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Sun Aug 30 01:17:16 2009
@@ -1257,15 +1257,17 @@
if (!Sym->isUndefined())
return Error(IDLoc, "invalid symbol redefinition");
+ // '.lcomm' is equivalent to '.zerofill'.
// Create the Symbol as a common or local common with Size and Pow2Alignment
- if (IsLocal)
+ if (IsLocal) {
Out.EmitZerofill(getMachOSection("__DATA", "__bss",
MCSectionMachO::S_ZEROFILL, 0,
SectionKind()),
- Sym, Size, Pow2Alignment);
- else
- Out.EmitCommonSymbol(Sym, Size, Pow2Alignment);
+ Sym, Size, 1 << Pow2Alignment);
+ return false;
+ }
+ Out.EmitCommonSymbol(Sym, Size, 1 << Pow2Alignment);
return false;
}
@@ -1355,7 +1357,7 @@
Out.EmitZerofill(getMachOSection(Segment, Section,
MCSectionMachO::S_ZEROFILL, 0,
SectionKind()),
- Sym, Size, Pow2Alignment);
+ Sym, Size, 1 << Pow2Alignment);
return false;
}
@@ -1426,10 +1428,11 @@
Lexer.Lex();
- // Create the Sym with the value of the Expr
- Out.EmitLocalSymbol(Sym, Expr);
-
- return false;
+ // We don't currently support this directive.
+ //
+ // FIXME: Diagnostic location!
+ (void) Sym;
+ return TokError("directive '.lsym' is unsupported");
}
/// ParseDirectiveInclude
More information about the llvm-commits
mailing list