From 05d8b71424316ad7b014adbbb316f78c5bd46861 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 18 Jan 2011 05:34:24 +0000 Subject: [PATCH] McARM: Unify ParseMemory() successfull return. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123740 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 64 ++++++++--------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 08f3a90d1cf..c2e8442026b 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -720,17 +720,19 @@ ParseMemory(SmallVectorImpl &Operands) { bool OffsetIsReg = false; bool Negative = false; bool Writeback = false; + ARMOperand *WBOp = 0; + int OffsetRegNum = -1; + bool OffsetRegShifted = false; + enum ShiftType ShiftType = Lsl; + const MCExpr *ShiftAmount = 0; + const MCExpr *Offset = 0; // First look for preindexed address forms, that is after the "[Rn" we now // have to see if the next token is a comma. if (Tok.is(AsmToken::Comma)) { Preindexed = true; Parser.Lex(); // Eat comma token. - int OffsetRegNum; - bool OffsetRegShifted; - enum ShiftType ShiftType; - const MCExpr *ShiftAmount = 0; - const MCExpr *Offset = 0; + if (ParseMemoryOffsetReg(Negative, OffsetRegShifted, ShiftType, ShiftAmount, Offset, OffsetIsReg, OffsetRegNum, E)) return true; @@ -743,29 +745,12 @@ ParseMemory(SmallVectorImpl &Operands) { Parser.Lex(); // Eat right bracket token. const AsmToken &ExclaimTok = Parser.getTok(); - ARMOperand *WBOp = 0; if (ExclaimTok.is(AsmToken::Exclaim)) { WBOp = ARMOperand::CreateToken(ExclaimTok.getString(), ExclaimTok.getLoc()); Writeback = true; Parser.Lex(); // Eat exclaim token } - - // Force Offset to exist if used. - if (!OffsetIsReg) { - if (!Offset) - Offset = MCConstantExpr::Create(0, getContext()); - } - - Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset, - OffsetRegNum, OffsetRegShifted, - ShiftType, ShiftAmount, Preindexed, - Postindexed, Negative, Writeback, - S, E)); - if (WBOp) - Operands.push_back(WBOp); - - return false; } else { // The "[Rn" we have so far was not followed by a comma. @@ -774,12 +759,6 @@ ParseMemory(SmallVectorImpl &Operands) { E = Tok.getLoc(); Parser.Lex(); // Eat right bracket token. - int OffsetRegNum = -1; - bool OffsetRegShifted = false; - enum ShiftType ShiftType = Lsl; - const MCExpr *ShiftAmount = 0; - const MCExpr *Offset = 0; - const AsmToken &NextTok = Parser.getTok(); if (NextTok.isNot(AsmToken::EndOfStatement)) { @@ -798,20 +777,23 @@ ParseMemory(SmallVectorImpl &Operands) { E)) return true; } - - // Force Offset to exist if used. - if (!OffsetIsReg) { - if (!Offset) - Offset = MCConstantExpr::Create(0, getContext()); - } - - Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset, - OffsetRegNum, OffsetRegShifted, - ShiftType, ShiftAmount, Preindexed, - Postindexed, Negative, Writeback, - S, E)); - return false; } + + // Force Offset to exist if used. + if (!OffsetIsReg) { + if (!Offset) + Offset = MCConstantExpr::Create(0, getContext()); + } + + Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset, + OffsetRegNum, OffsetRegShifted, + ShiftType, ShiftAmount, Preindexed, + Postindexed, Negative, Writeback, + S, E)); + if (WBOp) + Operands.push_back(WBOp); + + return false; } /// Parse the offset of a memory operand after we have seen "[Rn," or "[Rn],"