Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSP430] Emulate [at]rd in destination position as 0(rd) #33

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,11 @@ bool MSP430AsmParser::ParseOperand(OperandVector &Operands) {
getLexer().Lex(); // Eat '+'
return false;
}
Operands.push_back(MSP430Operand::CreateIndReg(RegNo, StartLoc, EndLoc));
if (Operands.size() > 1) // Emulate @rd in destination position as 0(rd)
Operands.push_back(MSP430Operand::CreateMem(RegNo,
Copy link
Contributor

@asl asl Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we (in separate patch) recognize memoperand with zero offset in the asmprinter and print as @Reg instead of 0(Reg)? Could be a bit better for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll take a look. Thanks!

MCConstantExpr::create(0, getContext()), StartLoc, EndLoc));
else
Operands.push_back(MSP430Operand::CreateIndReg(RegNo, StartLoc, EndLoc));
return false;
}
case AsmToken::Hash:
Expand Down
2 changes: 2 additions & 0 deletions src/llvm/test/MC/MSP430/addrmode.s
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ foo:
mov #42, 12(r15)
mov #42, &disp
mov disp, disp+2
mov r7, @r15

; CHECK: mov #42, r15 ; encoding: [0x3f,0x40,0x2a,0x00]
; CHECK: mov #42, 12(r15) ; encoding: [0xbf,0x40,0x2a,0x00,0x0c,0x00]
; CHECK: mov #42, &disp ; encoding: [0xb2,0x40,0x2a,0x00,A,A]
; CHECK: mov disp, disp+2 ; encoding: [0x90,0x40,A,A,B,B]
; CHECK: mov r7, 0(r15) ; encoding: [0x8f,0x47,0x00,0x00]

add r7, r8
add 6(r7), r8
Expand Down
1 change: 0 additions & 1 deletion src/llvm/test/MC/MSP430/invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ foo:
mov r7 ; CHECK: :[[@LINE]]:3: error: too few operands for instruction

;; invalid destination addressing modes
mov r7, @r15 ; CHECK: :[[@LINE]]:14: error: invalid operand for instruction
mov r7, @r15+ ; CHECK: :[[@LINE]]:14: error: invalid operand for instruction
mov r7, #0 ; CHECK: :[[@LINE]]:14: error: invalid operand for instruction
mov r7, #123 ; CHECK: :[[@LINE]]:14: error: invalid operand for instruction
Expand Down