diff options
Diffstat (limited to 'llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 25 | 
1 files changed, 20 insertions, 5 deletions
| diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 29ecc182d31..401894e75e1 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -15,6 +15,7 @@  #include "llvm/MC/MCParser/MCAsmLexer.h"  #include "llvm/MC/MCParser/MCAsmParser.h"  #include "llvm/MC/MCParser/MCParsedAsmOperand.h" +#include "llvm/MC/MCAsmInfo.h"  #include "llvm/MC/MCContext.h"  #include "llvm/MC/MCStreamer.h"  #include "llvm/MC/MCExpr.h" @@ -2099,15 +2100,29 @@ bool ARMAsmParser::ParseDirectiveThumb(SMLoc L) {  /// ParseDirectiveThumbFunc  ///  ::= .thumbfunc symbol_name  bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) { -  const AsmToken &Tok = Parser.getTok(); -  if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) -    return Error(L, "unexpected token in .thumb_func directive"); -  StringRef Name = Tok.getString(); -  Parser.Lex(); // Consume the identifier token. +  const MCAsmInfo &MAI = getParser().getStreamer().getContext().getAsmInfo(); +  bool isMachO = MAI.hasSubsectionsViaSymbols(); +  StringRef Name; + +  // Darwin asm has function name after .thumb_func direction +  // ELF doesn't +  if (isMachO) { +    const AsmToken &Tok = Parser.getTok(); +    if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) +      return Error(L, "unexpected token in .thumb_func directive"); +    Name = Tok.getString(); +    Parser.Lex(); // Consume the identifier token. +  } +    if (getLexer().isNot(AsmToken::EndOfStatement))      return Error(L, "unexpected token in directive");    Parser.Lex(); +  // FIXME: assuming function name will be the line following .thumb_func +  if (!isMachO) { +    Name = Parser.getTok().getString(); +  } +    // Mark symbol as a thumb symbol.    MCSymbol *Func = getParser().getContext().GetOrCreateSymbol(Name);    getParser().getStreamer().EmitThumbFunc(Func); | 

