llvm.org GIT mirror llvm / 61f3193
Fix yet another unseen regression caused by r223113 r223113 added support for ARM modified immediate assembly syntax. Which assumes all immediate operands are prefixed with a '#'. This assumption is wrong as per the ARMARM - which recommends that all '#' characters be treated optional. The current patch fixes this regression and adds a test case. A follow-up patch will expand the test coverage to other instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223381 91177308-0d34-0410-b5e6-96231b3b80d8 Asiri Rathnayake 5 years ago
3 changed file(s) with 34 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
44174417 MCAsmLexer &Lexer = getLexer();
44184418 int64_t Imm1, Imm2;
44194419
4420 if ((Parser.getTok().isNot(AsmToken::Hash) &&
4421 Parser.getTok().isNot(AsmToken::Dollar))
4422 || Lexer.peekTok().is(AsmToken::Colon))
4420 SMLoc S = Parser.getTok().getLoc();
4421
4422 // 1) A mod_imm operand can appear in the place of a register name:
4423 // add r0, #mod_imm
4424 // add r0, r0, #mod_imm
4425 // to correctly handle the latter, we bail out as soon as we see an
4426 // identifier.
4427 //
4428 // 2) Similarly, we do not want to parse into complex operands:
4429 // mov r0, #mod_imm
4430 // mov r0, :lower16:(_foo)
4431 if (Parser.getTok().is(AsmToken::Identifier) ||
4432 Parser.getTok().is(AsmToken::Colon))
44234433 return MatchOperand_NoMatch;
44244434
4425 SMLoc S = Parser.getTok().getLoc();
4426
4427 // Eat the hash (or dollar)
4428 Parser.Lex();
4435 // Hash (dollar) is optional as per the ARMARM
4436 if (Parser.getTok().is(AsmToken::Hash) ||
4437 Parser.getTok().is(AsmToken::Dollar)) {
4438 // Avoid parsing into complex operands (#:)
4439 if (Lexer.peekTok().is(AsmToken::Colon))
4440 return MatchOperand_NoMatch;
4441
4442 // Eat the hash (dollar)
4443 Parser.Lex();
4444 }
44294445
44304446 SMLoc Sx1, Ex1;
44314447 Sx1 = Parser.getTok().getLoc();
44824498 return MatchOperand_ParseFail;
44834499 }
44844500
4485 if (Lexer.peekTok().isNot(AsmToken::Hash) &&
4486 Lexer.peekTok().isNot(AsmToken::Dollar)) {
4487 Error(Lexer.peekTok().getLoc(), "immediate operand expected");
4488 return MatchOperand_ParseFail;
4489 }
4490
44914501 // Eat the comma
44924502 Parser.Lex();
44934503
44954505 SMLoc Sx2, Ex2;
44964506 Sx2 = Parser.getTok().getLoc();
44974507
4498 // Eat the hash (or dollar)
4499 Parser.Lex();
4508 // Eat the optional hash (dollar)
4509 if (Parser.getTok().is(AsmToken::Hash) ||
4510 Parser.getTok().is(AsmToken::Dollar))
4511 Parser.Lex();
45004512
45014513 const MCExpr *Imm2Exp;
45024514 if (getParser().parseExpression(Imm2Exp, Ex2)) {
1515 @ ADC (immediate)
1616 @------------------------------------------------------------------------------
1717 adc r1, r2, #0xf
18 adc r1, r2, $0xf
19 adc r1, r2, 0xf
20 adc r1, r2, 15
1821 adc r7, r8, #42, #2
1922 adc r7, r8, #-2147483638
2023 adc r7, r8, #40, #2
3235 adcseq r1, r2, #0xf00
3336 adceq r1, r2, #0xf00
3437
38 @ CHECK: adc r1, r2, #15 @ encoding: [0x0f,0x10,0xa2,0xe2]
39 @ CHECK: adc r1, r2, #15 @ encoding: [0x0f,0x10,0xa2,0xe2]
40 @ CHECK: adc r1, r2, #15 @ encoding: [0x0f,0x10,0xa2,0xe2]
3541 @ CHECK: adc r1, r2, #15 @ encoding: [0x0f,0x10,0xa2,0xe2]
3642 @ CHECK: adc r7, r8, #-2147483638 @ encoding: [0x2a,0x71,0xa8,0xe2]
3743 @ CHECK: adc r7, r8, #-2147483638 @ encoding: [0x2a,0x71,0xa8,0xe2]
33 .text
44 bar:
55 mov r0, =0x101
6 @ CHECK: error: unexpected token in operand
6 @ CHECK: error: unknown token in expression
77 @ CHECK: mov r0, =0x101
88 @ CHECK: ^
99