Skip to content

Commit a9e4f91

Browse files
committed
[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
1 parent 055770d commit a9e4f91

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
363363
O << "0, ";
364364
printOperand(MI, OpNo, O);
365365
return false;
366+
case 'I':
367+
// Write 'i' if an integer constant, otherwise nothing. Used to print
368+
// addi vs add, etc.
369+
if (MI->getOperand(OpNo).isImm())
370+
O << "i";
371+
return false;
366372
case 'U': // Print 'u' for update form.
367373
case 'X': // Print 'x' for indexed form.
368374
// FIXME: Currently for PowerPC memory operands are always loaded
Lines changed: 19 additions & 0 deletions
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)