MC: Parse .org directives.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74218 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 2595518..2b697a6 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -324,6 +324,8 @@
       return ParseDirectiveValue(8);
     if (!strcmp(IDVal, ".fill"))
       return ParseDirectiveFill();
+    if (!strcmp(IDVal, ".org"))
+      return ParseDirectiveOrg();
     if (!strcmp(IDVal, ".space"))
       return ParseDirectiveSpace();
 
@@ -332,7 +334,6 @@
     return false;
   }
 
-
   MCInst Inst;
   if (ParseX86InstOperands(Inst))
     return true;
@@ -558,3 +559,31 @@
 
   return false;
 }
+
+/// ParseDirectiveOrg
+///  ::= .org expression [ , expression ]
+bool AsmParser::ParseDirectiveOrg() {
+  int64_t Offset;
+  if (ParseExpression(Offset))
+    return true;
+
+  // Parse optional fill expression.
+  int64_t FillExpr = 0;
+  if (Lexer.isNot(asmtok::EndOfStatement)) {
+    if (Lexer.isNot(asmtok::Comma))
+      return TokError("unexpected token in '.org' directive");
+    Lexer.Lex();
+    
+    if (ParseExpression(FillExpr))
+      return true;
+
+    if (Lexer.isNot(asmtok::EndOfStatement))
+      return TokError("unexpected token in '.org' directive");
+  }
+
+  Lexer.Lex();
+  
+  Out.EmitValueToOffset(MCValue::get(Offset), FillExpr);
+
+  return false;
+}