Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 647ece5

Browse files
committed
[MSP430] Fix absolute addressing mode printing in AsmPrinter
Align checks for absolute addressing mode with its current implementation (SR is used as a base register). This fixes https://bugs.llvm.org/show_bug.cgi?id=39993 Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D56785 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352178 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4792786 commit 647ece5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/Target/MSP430/MSP430AsmPrinter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int OpNum,
113113
// Print displacement first
114114

115115
// Imm here is in fact global address - print extra modifier.
116-
if (Disp.isImm() && !Base.getReg())
116+
if (Disp.isImm() && Base.getReg() == MSP430::SR)
117117
O << '&';
118118
printOperand(MI, OpNum+1, O, "nohash");
119119

120120
// Print register base field
121-
if (Base.getReg()) {
121+
if (Base.getReg() != MSP430::SR && Base.getReg() != MSP430::PC) {
122122
O << '(';
123123
printOperand(MI, OpNum, O);
124124
O << ')';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llc < %s | FileCheck %s
2+
3+
; Check that absolute addressing mode is represented in a way
4+
; defined in MSP430 EABI and not as indexed addressing mode form.
5+
; See PR39993 for details.
6+
7+
target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-n8:16"
8+
target triple = "msp430-elf"
9+
10+
define void @f() {
11+
entry:
12+
; CHECK: mov r1, &256
13+
call void asm sideeffect "mov r1, $0", "*m"(i8* inttoptr (i16 256 to i8*))
14+
ret void
15+
}

0 commit comments

Comments
 (0)