diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
commit | 3ebe59c892051375623fea55e977ff559fdb3323 (patch) | |
tree | 57c29e90762855b6aacd9a7341a1db0bcf526be1 /lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp | |
parent | 7aa1c321f00d29fdc84e9a03080853aa25dd06fc (diff) |
Change SMRange to be half-open (exclusive end) instead of closed (inclusive)
This is necessary not only for representing empty ranges, but for handling
multibyte characters in the input. (If the end pointer in a range refers to
a multibyte character, should it point to the beginning or the end of the
character in a char array?) Some of the code in the asm parsers was already
assuming this anyway.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp')
-rw-r--r-- | lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp b/lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp index 69bbc57bea..2ab163e091 100644 --- a/lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp +++ b/lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp @@ -35,7 +35,8 @@ class MBlazeAsmParser : public MCTargetAsmParser { bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); } MBlazeOperand *ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &Operands); - MBlazeOperand *ParseRegister(unsigned &RegNo); + MBlazeOperand *ParseRegister(); + MBlazeOperand *ParseRegister(SMLoc &StartLoc, SMLoc &EndLoc); MBlazeOperand *ParseImmediate(); MBlazeOperand *ParseFsl(); MBlazeOperand* ParseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands); @@ -383,23 +384,31 @@ ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &Operands) { bool MBlazeAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) { - return (ParseRegister(RegNo) == 0); + MBlazeOperand *Reg = ParseRegister(StartLoc, EndLoc); + if (!Reg) + return true; + RegNo = Reg->getReg(); + return false; } -MBlazeOperand *MBlazeAsmParser::ParseRegister(unsigned &RegNo) { - SMLoc S = Parser.getTok().getLoc(); - SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1); +MBlazeOperand *MBlazeAsmParser::ParseRegister() { + SMLoc S, E; + return ParseRegister(S, E); +} - switch (getLexer().getKind()) { - default: return 0; - case AsmToken::Identifier: - RegNo = MatchRegisterName(getLexer().getTok().getIdentifier()); - if (RegNo == 0) - return 0; +MBlazeOperand *MBlazeAsmParser::ParseRegister(SMLoc &StartLoc, SMLoc &EndLoc) { + StartLoc = Parser.getTok().getLoc(); + EndLoc = Parser.getTok().getEndLoc(); - getLexer().Lex(); - return MBlazeOperand::CreateReg(RegNo, S, E); - } + if (getLexer().getKind() != AsmToken::Identifier) + return 0; + + unsigned RegNo = MatchRegisterName(getLexer().getTok().getIdentifier()); + if (RegNo == 0) + return 0; + + getLexer().Lex(); + return MBlazeOperand::CreateReg(RegNo, StartLoc, EndLoc); } static unsigned MatchFslRegister(StringRef String) { @@ -415,7 +424,7 @@ static unsigned MatchFslRegister(StringRef String) { MBlazeOperand *MBlazeAsmParser::ParseFsl() { SMLoc S = Parser.getTok().getLoc(); - SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1); + SMLoc E = Parser.getTok().getEndLoc(); switch (getLexer().getKind()) { default: return 0; @@ -432,7 +441,7 @@ MBlazeOperand *MBlazeAsmParser::ParseFsl() { MBlazeOperand *MBlazeAsmParser::ParseImmediate() { SMLoc S = Parser.getTok().getLoc(); - SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1); + SMLoc E = Parser.getTok().getEndLoc(); const MCExpr *EVal; switch (getLexer().getKind()) { @@ -454,8 +463,7 @@ ParseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands) { MBlazeOperand *Op; // Attempt to parse the next token as a register name - unsigned RegNo; - Op = ParseRegister(RegNo); + Op = ParseRegister(); // Attempt to parse the next token as an FSL immediate if (!Op) |