llvm.org GIT mirror llvm / 05d8b71
McARM: Unify ParseMemory() successfull return. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123740 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 9 years ago
1 changed file(s) with 24 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
719719 bool OffsetIsReg = false;
720720 bool Negative = false;
721721 bool Writeback = false;
722 ARMOperand *WBOp = 0;
723 int OffsetRegNum = -1;
724 bool OffsetRegShifted = false;
725 enum ShiftType ShiftType = Lsl;
726 const MCExpr *ShiftAmount = 0;
727 const MCExpr *Offset = 0;
722728
723729 // First look for preindexed address forms, that is after the "[Rn" we now
724730 // have to see if the next token is a comma.
725731 if (Tok.is(AsmToken::Comma)) {
726732 Preindexed = true;
727733 Parser.Lex(); // Eat comma token.
728 int OffsetRegNum;
729 bool OffsetRegShifted;
730 enum ShiftType ShiftType;
731 const MCExpr *ShiftAmount = 0;
732 const MCExpr *Offset = 0;
734
733735 if (ParseMemoryOffsetReg(Negative, OffsetRegShifted, ShiftType, ShiftAmount,
734736 Offset, OffsetIsReg, OffsetRegNum, E))
735737 return true;
742744 Parser.Lex(); // Eat right bracket token.
743745
744746 const AsmToken &ExclaimTok = Parser.getTok();
745 ARMOperand *WBOp = 0;
746747 if (ExclaimTok.is(AsmToken::Exclaim)) {
747748 WBOp = ARMOperand::CreateToken(ExclaimTok.getString(),
748749 ExclaimTok.getLoc());
749750 Writeback = true;
750751 Parser.Lex(); // Eat exclaim token
751752 }
752
753 // Force Offset to exist if used.
754 if (!OffsetIsReg) {
755 if (!Offset)
756 Offset = MCConstantExpr::Create(0, getContext());
757 }
758
759 Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset,
760 OffsetRegNum, OffsetRegShifted,
761 ShiftType, ShiftAmount, Preindexed,
762 Postindexed, Negative, Writeback,
763 S, E));
764 if (WBOp)
765 Operands.push_back(WBOp);
766
767 return false;
768753 } else {
769754 // The "[Rn" we have so far was not followed by a comma.
770755
773758 E = Tok.getLoc();
774759 Parser.Lex(); // Eat right bracket token.
775760
776 int OffsetRegNum = -1;
777 bool OffsetRegShifted = false;
778 enum ShiftType ShiftType = Lsl;
779 const MCExpr *ShiftAmount = 0;
780 const MCExpr *Offset = 0;
781
782761 const AsmToken &NextTok = Parser.getTok();
783762
784763 if (NextTok.isNot(AsmToken::EndOfStatement)) {
797776 E))
798777 return true;
799778 }
800
801 // Force Offset to exist if used.
802 if (!OffsetIsReg) {
803 if (!Offset)
804 Offset = MCConstantExpr::Create(0, getContext());
805 }
806
807 Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset,
808 OffsetRegNum, OffsetRegShifted,
809 ShiftType, ShiftAmount, Preindexed,
810 Postindexed, Negative, Writeback,
811 S, E));
812 return false;
813 }
779 }
780
781 // Force Offset to exist if used.
782 if (!OffsetIsReg) {
783 if (!Offset)
784 Offset = MCConstantExpr::Create(0, getContext());
785 }
786
787 Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset,
788 OffsetRegNum, OffsetRegShifted,
789 ShiftType, ShiftAmount, Preindexed,
790 Postindexed, Negative, Writeback,
791 S, E));
792 if (WBOp)
793 Operands.push_back(WBOp);
794
795 return false;
814796 }
815797
816798 /// Parse the offset of a memory operand after we have seen "[Rn," or "[Rn],"