Hi Bill,<br><div><br></div><div>Thanks for looking into this. As we chatted about on IRC I don't think this is the right way to deal with them at the moment. It may be hard (or impossible) currently for llvm to generate these kinds of memory operands for inline asm, but with some work I think it'll be possible. I think you're working up some additional testcases now and we can have those as the code to include here.</div><div><br></div><div>As a note, when you're using a testcase that's just derived straight from C code it's nice to paste it in the testcase. Also, the comments for the operands don't seem to match what's right below them - perhaps a FIXME even or something? :)</div><div><br></div><div>Thanks!</div><div><br></div><div>-eric</div><br><div class="gmail_quote">On Thu Sep 11 2014 at 1:23:06 PM Bill Schmidt <<a href="mailto:wschmidt@linux.vnet.ibm.com">wschmidt@linux.vnet.ibm.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: wschmidt<br>
Date: Thu Sep 11 15:10:03 2014<br>
New Revision: 217622<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217622&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=217622&view=rev</a><br>
Log:<br>
[PATCH, PowerPC] Accept 'U' and 'X' constraints in inline asm<br>
<br>
Inline asm may specify 'U' and 'X' constraints to print a 'u' for an<br>
update-form memory reference, or an 'x' for an indexed-form memory<br>
reference.  However, these are really only useful in GCC internal code<br>
generation.  In inline asm the operand of the memory constraint is<br>
typically just a register containing the address, so 'U' and 'X' make<br>
no sense.<br>
<br>
This patch quietly accepts 'U' and 'X' in inline asm patterns, but<br>
otherwise does nothing.  If we ever unexpectedly see a non-register,<br>
we'll assert and sort it out afterwards.<br>
<br>
I've added a new test for these constraints; the test case should be<br>
used for other asm-constraints changes down the road.<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/<u></u>PowerPC/asm-constraints.ll<br>
Modified:<br>
    llvm/trunk/lib/Target/PowerPC/<u></u>PPCAsmPrinter.cpp<br>
<br>
Modified: llvm/trunk/lib/Target/PowerPC/<u></u>PPCAsmPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=217622&r1=217621&r2=217622&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/Target/<u></u>PowerPC/PPCAsmPrinter.cpp?rev=<u></u>217622&r1=217621&r2=217622&<u></u>view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/Target/PowerPC/<u></u>PPCAsmPrinter.cpp (original)<br>
+++ llvm/trunk/lib/Target/PowerPC/<u></u>PPCAsmPrinter.cpp Thu Sep 11 15:10:03 2014<br>
@@ -275,6 +275,16 @@ bool PPCAsmPrinter::<u></u>PrintAsmMemoryOperan<br>
         printOperand(MI, OpNo, O);<br>
         return false;<br>
       }<br>
+    case 'U': // Print 'u' for update form.<br>
+    case 'X': // Print 'x' for indexed form.<br>
+      {<br>
+       // Memory constraints should always produce an MO_Register,<br>
+       // so we never get an update or indexed form.  (In GCC, these<br>
+       // are useful in internal code gen; not so much in inline asm.)<br>
+       // So tolerate these but don't output anything.<br>
+       assert(MI->getOperand(OpNo).<u></u>isReg());<br>
+       return false;<br>
+      }<br>
     }<br>
   }<br>
<br>
<br>
Added: llvm/trunk/test/CodeGen/<u></u>PowerPC/asm-constraints.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/asm-constraints.ll?rev=217622&view=auto" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/test/<u></u>CodeGen/PowerPC/asm-<u></u>constraints.ll?rev=217622&<u></u>view=auto</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/test/CodeGen/<u></u>PowerPC/asm-constraints.ll (added)<br>
+++ llvm/trunk/test/CodeGen/<u></u>PowerPC/asm-constraints.ll Thu Sep 11 15:10:03 2014<br>
@@ -0,0 +1,32 @@<br>
+; RUN llc < %s -mcpu=pwr8 | FileCheck %s<br>
+<br>
+target datalayout = "e-m:e-i64:64-n32:64"<br>
+target triple = "powerpc64le-unknown-linux-<u></u>gnu"<br>
+<br>
+; Function Attrs: nounwind<br>
+; Check that we accept 'U' and 'X' constraints.<br>
+define void @foo(i32 signext %result, i8* %addr) #0 {<br>
+entry:<br>
+  %result.addr = alloca i32, align 4<br>
+  %addr.addr = alloca i8*, align 8<br>
+  store i32 %result, i32* %result.addr, align 4<br>
+  store i8* %addr, i8** %addr.addr, align 8<br>
+  %0 = load i8** %addr.addr, align 8<br>
+  %1 = call i32 asm sideeffect "ld${1:U}${1:X} $0,$1\0Acmpw $0,$0\0Abne- 1f\0A1: isync\0A", "=r,*m,~{memory},~{cr0}"(i8* %0) #1, !srcloc !1<br>
+  store i32 %1, i32* %result.addr, align 4<br>
+  ret void<br>
+}<br>
+<br>
+; CHECK-LABEL: @foo<br>
+; CHECK: ld [[REG:[0-9]+]],0(4)<br>
+; CHECK-NEXT: cmpw [[REG]],[[REG]]<br>
+; CHECK-NEXT: bne- 1f<br>
+; CHECK-NEXT: 1: isync<br>
+<br>
+attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-<u></u>leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"=<u></u>"8" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
+attributes #1 = { nounwind }<br>
+<br>
+!llvm.ident = !{!0}<br>
+<br>
+!0 = metadata !{metadata !"clang version 3.6.0 (trunk 217557)"}<br>
+!1 = metadata !{i32 67, i32 91, i32 110, i32 126}<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote></div>