[LLVMdev] Implementing llvm.memory.barrier on PowerPC

Gary Benson gbenson at redhat.com
Tue Aug 19 07:18:53 PDT 2008


Hi all,

I'm trying to implement llvm.memory.barrier on PowerPC.  I've modelled
my patch (attached) on the implementation in X86, but when I try and
compile my test file (also attached) with llc I get the error "Cannot
yet select: 0x10fa4ad0: ch = MemBarrier 0x10fa4828, 0x10fa4c68,
0x10fa4be0, 0x10fa4be0, 0x10fa4be0, 0x10fa4be0".  This presumably
means my "membarrier" pattern isn't being found... but why?

Thanks in advance,
Gary

--
http://gbenson.net/
-------------- next part --------------
Index: include/llvm/IntrinsicsPowerPC.td
===================================================================
--- include/llvm/IntrinsicsPowerPC.td	(revision 54985)
+++ include/llvm/IntrinsicsPowerPC.td	(working copy)
@@ -26,6 +26,9 @@
   def int_ppc_dcbtst: Intrinsic<[llvm_void_ty, llvm_ptr_ty], [IntrWriteMem]>;
   def int_ppc_dcbz  : Intrinsic<[llvm_void_ty, llvm_ptr_ty], [IntrWriteMem]>;
   def int_ppc_dcbzl : Intrinsic<[llvm_void_ty, llvm_ptr_ty], [IntrWriteMem]>;
+
+  // sync instruction
+  def int_ppc_sync : Intrinsic<[llvm_void_ty], [IntrWriteMem]>;
 }
 
 
Index: lib/Target/PowerPC/PPCInstrInfo.td
===================================================================
--- lib/Target/PowerPC/PPCInstrInfo.td	(revision 54985)
+++ lib/Target/PowerPC/PPCInstrInfo.td	(working copy)
@@ -773,6 +773,10 @@
                      [(store F8RC:$frS, xaddr:$dst)]>;
 }
 
+let isBarrier = 1 in
+def SYNC : XForm_24<31, 598, (outs), (ins),
+                    "sync", LdStSync,
+                    [(int_ppc_sync)]>;
 
 //===----------------------------------------------------------------------===//
 // PPC32 Arithmetic Instructions.
@@ -1357,5 +1361,13 @@
 def : Pat<(extloadf32 xaddr:$src),
           (FMRSD (LFSX xaddr:$src))>;
 
+// Memory barriers
+def : Pat<(membarrier (i8 imm:$ll),
+                      (i8 imm:$ls),
+                      (i8 imm:$sl),
+                      (i8 imm:$ss),
+                      (i8 imm:$device)),
+           (SYNC)>;
+
 include "PPCInstrAltivec.td"
 include "PPCInstr64Bit.td"
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp	(revision 54985)
+++ lib/Target/PowerPC/PPCISelLowering.cpp	(working copy)
@@ -78,9 +78,6 @@
   // from FP_ROUND:  that rounds to nearest, this rounds to zero.
   setOperationAction(ISD::FP_ROUND_INREG, MVT::ppcf128, Custom);
 
-  // PowerPC has no intrinsics for these particular operations
-  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
-
   // PowerPC has no SREM/UREM instructions
   setOperationAction(ISD::SREM, MVT::i32, Expand);
   setOperationAction(ISD::UREM, MVT::i32, Expand);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.bc
Type: application/octet-stream
Size: 236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080819/95229c58/attachment.obj>


More information about the llvm-dev mailing list