add llvm-mc support for parsing the .subsections_via_symbols directive.
authorKevin Enderby <enderby@apple.com>
Mon, 13 Jul 2009 21:03:15 +0000 (21:03 +0000)
committerKevin Enderby <enderby@apple.com>
Mon, 13 Jul 2009 21:03:15 +0000 (21:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75500 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCStreamer.h
lib/MC/MCAsmStreamer.cpp
test/MC/AsmParser/directive_subsections_via_symbols.s [new file with mode: 0644]
tools/llvm-mc/AsmParser.cpp
tools/llvm-mc/AsmParser.h

index e0c50ebb72bcdcbd53f3d8fc9a5a911b4b4f439e..dc185aecfdf3361f00abaab00831e847491ae1b2 100644 (file)
@@ -89,6 +89,11 @@ namespace llvm {
     // symbol section in the constructor and initialize it here?
     virtual void EmitLabel(MCSymbol *Symbol) = 0;
 
+    /// SubsectionsViaSymbols - Note in the output that the conventions used in
+    /// in the assembly file allows the bytes of a section to be divided up at
+    /// the boundaries of the symbols by a link editor for processing as atoms.
+    virtual void SubsectionsViaSymbols(void) = 0;
+
     /// EmitAssignment - Emit an assignment of @param Value to @param Symbol.
     ///
     /// This corresponds to an assembler statement such as:
index 172ae9ec958b8a687ab37977c3553054bd020774..c0a334adc9e527fe6791bb2a803ba7411db95950 100644 (file)
@@ -38,6 +38,8 @@ namespace {
 
     virtual void EmitLabel(MCSymbol *Symbol);
 
+    virtual void SubsectionsViaSymbols(void);
+
     virtual void EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
                                 bool MakeAbsolute = false);
 
@@ -117,6 +119,10 @@ void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
   Symbol->setExternal(false);
 }
 
+void MCAsmStreamer::SubsectionsViaSymbols(void) {
+  OS << ".subsections_via_symbols\n";
+}
+
 void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
                                    bool MakeAbsolute) {
   assert(!Symbol->getSection() && "Cannot assign to a label!");
diff --git a/test/MC/AsmParser/directive_subsections_via_symbols.s b/test/MC/AsmParser/directive_subsections_via_symbols.s
new file mode 100644 (file)
index 0000000..826b7f1
--- /dev/null
@@ -0,0 +1,6 @@
+# RUN: llvm-mc %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: .subsections_via_symbols
+TEST0:  
+       .subsections_via_symbols
index a2cdea4c4dc03af5eb7c582007a377dabbedd2a9..fe9d4f3352ffc9c6dc1964c4ea49a629ab44cf78 100644 (file)
@@ -527,6 +527,9 @@ bool AsmParser::ParseStatement() {
     if (!strcmp(IDVal, ".zerofill"))
       return ParseDirectiveDarwinZerofill();
 
+    if (!strcmp(IDVal, ".subsections_via_symbols"))
+      return ParseDirectiveDarwinSubsectionsViaSymbols();
+
     Warning(IDLoc, "ignoring directive for now");
     EatToEndOfStatement();
     return false;
@@ -1052,3 +1055,16 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
 
   return false;
 }
+
+/// ParseDirectiveDarwinSubsectionsViaSymbols
+///  ::= .subsections_via_symbols
+bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
+  if (Lexer.isNot(asmtok::EndOfStatement))
+    return TokError("unexpected token in '.subsections_via_symbols' directive");
+  
+  Lexer.Lex();
+
+  Out.SubsectionsViaSymbols();
+
+  return false;
+}
index 620ac19c98668a313ff0e6257e8ad95734fd6cc1..fcdd064977cd823e911ae58c2d1ded6d70fa3dd1 100644 (file)
@@ -112,6 +112,9 @@ private:
 
   bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
   bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"
+
+  // Darwin specific ".subsections_via_symbols"
+  bool ParseDirectiveDarwinSubsectionsViaSymbols();
 };
 
 } // end namespace llvm