[llvm-branch-commits] [llvm-branch] r73891 - in /llvm/branches/Apple/Bender: include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp

Bill Wendling isanbard at gmail.com
Mon Jun 22 11:05:52 PDT 2009


Author: void
Date: Mon Jun 22 13:05:52 2009
New Revision: 73891

URL: http://llvm.org/viewvc/llvm-project?rev=73891&view=rev
Log:
Apply patch to fix "structure assignment drops address space qualifier on the
llvm side".

Modified:
    llvm/branches/Apple/Bender/include/llvm/IntrinsicInst.h
    llvm/branches/Apple/Bender/include/llvm/Intrinsics.td
    llvm/branches/Apple/Bender/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp

Modified: llvm/branches/Apple/Bender/include/llvm/IntrinsicInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender/include/llvm/IntrinsicInst.h?rev=73891&r1=73890&r2=73891&view=diff

==============================================================================
--- llvm/branches/Apple/Bender/include/llvm/IntrinsicInst.h (original)
+++ llvm/branches/Apple/Bender/include/llvm/IntrinsicInst.h Mon Jun 22 13:05:52 2009
@@ -214,6 +214,7 @@
       case Intrinsic::memcpy:
       case Intrinsic::memmove:
       case Intrinsic::memset:
+      case Intrinsic::memcpyany:
         return true;
       default: return false;
       }
@@ -268,6 +269,7 @@
     static inline bool classof(const MemTransferInst *) { return true; }
     static inline bool classof(const IntrinsicInst *I) {
       return I->getIntrinsicID() == Intrinsic::memcpy ||
+             I->getIntrinsicID() == Intrinsic::memcpyany ||
              I->getIntrinsicID() == Intrinsic::memmove;
     }
     static inline bool classof(const Value *V) {

Modified: llvm/branches/Apple/Bender/include/llvm/Intrinsics.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender/include/llvm/Intrinsics.td?rev=73891&r1=73890&r2=73891&view=diff

==============================================================================
--- llvm/branches/Apple/Bender/include/llvm/Intrinsics.td (original)
+++ llvm/branches/Apple/Bender/include/llvm/Intrinsics.td Mon Jun 22 13:05:52 2009
@@ -215,6 +215,7 @@
                              [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty,
                               llvm_i32_ty],
                             [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;
+
 def int_memmove : Intrinsic<[llvm_void_ty],
                             [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty,
                              llvm_i32_ty],
@@ -224,6 +225,18 @@
                              llvm_i32_ty],
                             [IntrWriteArgMem, NoCapture<0>]>;
 
+// This version is used to support a memcpy that allows different address
+// spaces for the source and destination to allow OpenCL to copy structures.
+// We make it only a member of MemIntrinsic for now since we don't want it
+// to participate with the normal memcpy optimizations.
+// FIXME: fold this version with memcpy and add a volatile bit and check all
+//        memcpy optimizations.
+def int_memcpyany : Intrinsic<[llvm_void_ty],
+                             [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
+                              llvm_i32_ty],
+                             [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;
+
+
 // These functions do not actually read memory, but they are sensitive to the
 // rounding mode.  This needs to be modelled separately; in the meantime
 // declaring them as reading memory is conservatively correct.

Modified: llvm/branches/Apple/Bender/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=73891&r1=73890&r2=73891&view=diff

==============================================================================
--- llvm/branches/Apple/Bender/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/branches/Apple/Bender/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Jun 22 13:05:52 2009
@@ -3867,6 +3867,24 @@
                               I.getOperand(1), 0, I.getOperand(2), 0));
     return 0;
   }
+  case Intrinsic::memcpyany: {
+    // Default is to lower memcpyany that allows multiple address spaces for
+    // OpenCL to either generating an inline memcpy or to standard memcpy
+    // function.  We assert for address spaces < 256 since we only support
+    // user defined address spaces.
+    assert(cast<PointerType>(I.getOperand(1)->getType())->getAddressSpace()
+           < 256 &&
+           cast<PointerType>(I.getOperand(2)->getType())->getAddressSpace()
+           < 256 &&
+           "Unknown address space");
+    SDValue Op1 = getValue(I.getOperand(1));
+    SDValue Op2 = getValue(I.getOperand(2));
+    SDValue Op3 = getValue(I.getOperand(3));
+    unsigned Align = cast<ConstantInt>(I.getOperand(4))->getZExtValue();
+    DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false,
+                              I.getOperand(1), 0, I.getOperand(2), 0));
+    return 0;
+  }
   case Intrinsic::memset: {
     SDValue Op1 = getValue(I.getOperand(1));
     SDValue Op2 = getValue(I.getOperand(2));





More information about the llvm-branch-commits mailing list