Skip to content

Commit f78f530

Browse files
tbaederrtstellar
authored andcommitted
[llvm][PPC] Add missing case for 'I' asm memory operands
From https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers: I: Print the letter ‘i’ if the operand is an integer constant, otherwise nothing. Used to print ‘addi’ vs ‘add’ instructions. Differential Revision: https://reviews.llvm.org/D103968 (cherry picked from commit a9e4f91)
1 parent c7d7ace commit f78f530

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
321321
O << "0, ";
322322
printOperand(MI, OpNo, O);
323323
return false;
324+
case 'I':
325+
// Write 'i' if an integer constant, otherwise nothing. Used to print
326+
// addi vs add, etc.
327+
if (MI->getOperand(OpNo).isImm())
328+
O << "i";
329+
return false;
324330
case 'U': // Print 'u' for update form.
325331
case 'X': // Print 'x' for indexed form.
326332
// FIXME: Currently for PowerPC memory operands are always loaded
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-- | FileCheck %s
3+
; https://bugs.llvm.org/show_bug.cgi?id=50608
4+
5+
define dso_local signext i32 @main(i32 signext %argc, i8** %argv) {
6+
; CHECK-LABEL: main:
7+
; CHECK: # %bb.0: # %entry
8+
; CHECK-NEXT: stw 3, -4(1)
9+
; CHECK-NEXT: li 3, 0
10+
; CHECK-NEXT: addi 4, 1, -4
11+
; CHECK-NEXT: #APP
12+
; CHECK-NEXT: .ascii "-1@0(4)"
13+
; CHECK-NEXT: .byte 0
14+
; CHECK-NEXT: #NO_APP
15+
; CHECK-NEXT: blr
16+
entry:
17+
call void asm sideeffect " .asciz \22${0:n}@${1:I}$1\22 ", "n,nZr"(i32 1, i32 %argc)
18+
ret i32 0
19+
}

0 commit comments

Comments
 (0)