diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-02 17:22:24 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-02 17:22:24 +0000 |
commit | 3ff57094a7d176a759ddb1e1668489d89064f56c (patch) | |
tree | 27726bf327a50d838d365cc73ff14d45192d0661 /lib/MC/MCParser/AsmParser.cpp | |
parent | 8bc9ef77b7e9910fbeb40725dfa49d793158db51 (diff) |
Add support for expressions in .sleb/.uleb directives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118023 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 8aaee95eda..877bae9e1c 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -261,8 +261,6 @@ public: bool ParseDirectiveMacro(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveEndMacro(StringRef, SMLoc DirectiveLoc); - void ParseUleb128(uint64_t Value); - void ParseSleb128(int64_t Value); bool ParseDirectiveLEB128(StringRef, SMLoc); }; @@ -2178,44 +2176,22 @@ bool GenericAsmParser::ParseDirectiveEndMacro(StringRef Directive, "no current macro definition"); } -void GenericAsmParser::ParseUleb128(uint64_t Value) { - const uint64_t Mask = (1 << 7) - 1; - do { - unsigned Byte = Value & Mask; - Value >>= 7; - if (Value) // Not the last one - Byte |= (1 << 7); - getStreamer().EmitIntValue(Byte, 1, DEFAULT_ADDRSPACE); - } while (Value); -} +bool GenericAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) { + getParser().CheckForValidSection(); -void GenericAsmParser::ParseSleb128(int64_t Value) { - const int64_t Mask = (1 << 7) - 1; - for(;;) { - unsigned Byte = Value & Mask; - Value >>= 7; - bool Done = ((Value == 0 && (Byte & 0x40) == 0) || - (Value == -1 && (Byte & 0x40) != 0)); - if (!Done) - Byte |= (1 << 7); - getStreamer().EmitIntValue(Byte, 1, DEFAULT_ADDRSPACE); - if (Done) - break; - } -} + const MCExpr *Value; -bool GenericAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) { - int64_t Value; - if (getParser().ParseAbsoluteExpression(Value)) + if (getParser().ParseExpression(Value)) return true; if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in directive"); if (DirName[1] == 's') - ParseSleb128(Value); + getStreamer().EmitSLEB128Value(Value); else - ParseUleb128(Value); + getStreamer().EmitULEB128Value(Value); + return false; } |