[ms-inline asm] Remove brackets from around a symbol reference in the target
[oota-llvm.git] / lib / Target / X86 / AsmParser / X86AsmParser.cpp
index f587d36232c10ce5f2f673a985badeddca24e710..aaf571ae9d30a9f14631eb9eb25abf04cfa28502 100644 (file)
@@ -1140,6 +1140,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
       if (getLexer().isNot(AsmToken::RBrac))
         return ErrorOperand(Tok.getLoc(), "Expected ']' token!");
 
+      if (isParsingInlineAsm()) {
+        // Remove the '[' and ']' from the IR string.
+        InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1));
+        InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Tok.getLoc(), 1));
+      }
       unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
       StringRef SymName(IdentStart.getPointer(), Len);
       Parser.Lex(); // Eat ']'
@@ -1211,6 +1216,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
       Parser.Lex(); // Consume the token.
     }
   }
+  if (isParsingInlineAsm() && Disp && isa<MCSymbolRefExpr>(Disp)) {
+    // Remove the '[' and ']' from the IR string.
+    InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1));
+    InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, End, 1));
+  }
 
   if (!Disp)
     Disp = MCConstantExpr::Create(SM.getDisp(), getContext());