/// @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.
///
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
+ virtual void EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value);
+
virtual void EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
unsigned Pow2Alignment, bool IsLocal);
OS << ".desc" << ' ' << Symbol->getName() << ',' << DescValue << '\n';
}
+void MCAsmStreamer::EmitLocalSymbol(MCSymbol *Symbol, const MCValue &Value) {
+ OS << ".lsym" << ' ' << Symbol->getName() << ',' << Value << '\n';
+}
+
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
unsigned Pow2Alignment, bool IsLocal) {
if (IsLocal)
--- /dev/null
+# RUN: llvm-mc %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: .lsym bar,foo
+# CHECK: .lsym baz,3
+TEST0:
+ .lsym bar, foo
+ .lsym baz, 2+1
return ParseDirectiveDarwinZerofill();
if (!strcmp(IDVal, ".desc"))
return ParseDirectiveDarwinSymbolDesc();
+ if (!strcmp(IDVal, ".lsym"))
+ return ParseDirectiveDarwinLsym();
if (!strcmp(IDVal, ".subsections_via_symbols"))
return ParseDirectiveDarwinSubsectionsViaSymbols();
return false;
}
+
+/// ParseDirectiveLsym
+/// ::= .lsym identifier , expression
+bool AsmParser::ParseDirectiveDarwinLsym() {
+ if (Lexer.isNot(asmtok::Identifier))
+ return TokError("expected identifier in directive");
+
+ // handle the identifier as the key symbol.
+ SMLoc IDLoc = Lexer.getLoc();
+ MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
+ Lexer.Lex();
+
+ if (Lexer.isNot(asmtok::Comma))
+ return TokError("unexpected token in '.lsym' directive");
+ Lexer.Lex();
+
+ MCValue Expr;
+ if (ParseRelocatableExpression(Expr))
+ return true;
+
+ if (Lexer.isNot(asmtok::EndOfStatement))
+ return TokError("unexpected token in '.lsym' directive");
+
+ Lexer.Lex();
+
+ // Create the Sym with the value of the Expr
+ Out.EmitLocalSymbol(Sym, Expr);
+
+ return false;
+}
/// accepts a single symbol (which should be a label or an external).
bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr);
bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
+ bool ParseDirectiveDarwinLsym(); // Darwin specific ".lsym"
bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"