I cannot find a libgcc function for this builtin. Therefor expanding it to a noop...
authorAndrew Lenharth <andrewl@lenharth.org>
Sat, 16 Feb 2008 14:46:26 +0000 (14:46 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Sat, 16 Feb 2008 14:46:26 +0000 (14:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47213 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CellSPU/SPUISelLowering.cpp
lib/Target/IA64/IA64ISelLowering.cpp
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/Sparc/SparcISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.cpp

index 0d6a47c01366954a712434cb814c1970a52410b9..9355e4871fe4dc38b2e25f242f3f8121c5f95e0a 100644 (file)
@@ -1135,11 +1135,21 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
 
   case ISD::MEMBARRIER: {
     assert(Node->getNumOperands() == 6 && "Invalid MemBarrier node!");
-    SDOperand Ops[6];
-    Ops[0] = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
-    for (int x = 1; x < 6; ++x)
-      Ops[x] = PromoteOp(Node->getOperand(x));
-    Result = DAG.UpdateNodeOperands(Result, &Ops[0], 6);
+    switch (TLI.getOperationAction(ISD::MEMBARRIER, MVT::Other)) {
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Legal: {
+      SDOperand Ops[6];
+      Ops[0] = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+      for (int x = 1; x < 6; ++x)
+        Ops[x] = PromoteOp(Node->getOperand(x));
+      Result = DAG.UpdateNodeOperands(Result, &Ops[0], 6);
+      break;
+    }
+    case TargetLowering::Expand:
+      //There is no libgcc call for this op
+      Result = Node->getOperand(0);  // Noop
+    break;
+    }
     break;
   }
 
index 98165a27c54bde00ef730f9e8a8f2414cb1d05e2..d1538f32c8e5224963b16a290c91d756bb1ffb67 100644 (file)
@@ -210,6 +210,7 @@ ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
   setOperationAction(ISD::STACKSAVE,          MVT::Other, Expand); 
   setOperationAction(ISD::STACKRESTORE,       MVT::Other, Expand);
   setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32  , Expand);
+  setOperationAction(ISD::MEMBARRIER        , MVT::Other, Expand);
 
   if (!Subtarget->hasV6Ops()) {
     setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand);
index d434eb9786df8c7f081839a256a813e186073908..334f6fe54f9cb75edc82f37e2c455561e20a4c5a 100644 (file)
@@ -2459,6 +2459,7 @@ void CWriter::lowerIntrinsics(Function &F) {
         if (Function *F = CI->getCalledFunction())
           switch (F->getIntrinsicID()) {
           case Intrinsic::not_intrinsic:
+          case Intrinsic::memory_barrier:
           case Intrinsic::vastart:
           case Intrinsic::vacopy:
           case Intrinsic::vaend:
@@ -2544,6 +2545,9 @@ void CWriter::visitCallInst(CallInst &I) {
         WroteCallee = true;
         break;
       }
+      case Intrinsic::memory_barrier:
+        Out << "0; __sync_syncronize()";
+        return;
       case Intrinsic::vastart:
         Out << "0; ";
 
index bfdb9e8ac8f9725fbca1c1de69093612138902b5..23c860ab754646c5ee9f491122e98268328c2e40 100644 (file)
@@ -181,7 +181,8 @@ SPUTargetLowering::SPUTargetLowering(SPUTargetMachine &TM)
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);
   setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
-  
+  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
+
   // PowerPC has no SREM/UREM instructions
   setOperationAction(ISD::SREM, MVT::i32, Expand);
   setOperationAction(ISD::UREM, MVT::i32, Expand);
index 6b9cf1592bb5cc3004b60b723049001220e16267..85db947477d966f55270d496599b021724ed082e 100644 (file)
@@ -69,7 +69,8 @@ IA64TargetLowering::IA64TargetLowering(TargetMachine &TM)
       setOperationAction(ISD::MEMMOVE          , MVT::Other, Expand);
       setOperationAction(ISD::MEMSET           , MVT::Other, Expand);
       setOperationAction(ISD::MEMCPY           , MVT::Other, Expand);
-      
+      setOperationAction(ISD::MEMBARRIER       , MVT::Other, Expand);
+
       setOperationAction(ISD::SINT_TO_FP       , MVT::i1   , Promote);
       setOperationAction(ISD::UINT_TO_FP       , MVT::i1   , Promote);
 
index fa2f72c4eba413ff714931b06d01a32096c64c28..ed76621131b9261173912202b9ada031e4f9012d 100644 (file)
@@ -84,6 +84,7 @@ MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM)
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);
   setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
+  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
 
   setOperationAction(ISD::CTPOP, MVT::i32, Expand);
   setOperationAction(ISD::CTTZ , MVT::i32, Expand);
index 5ebc4c0c4259cb3fb03699bea28a64217989dc39..aa7396fc90e93f9aefc0215f310bbf407b65f1ca 100644 (file)
@@ -81,7 +81,8 @@ PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM)
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);
   setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
-  
+  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
+
   // PowerPC has no SREM/UREM instructions
   setOperationAction(ISD::SREM, MVT::i32, Expand);
   setOperationAction(ISD::UREM, MVT::i32, Expand);
index 8dd81b76d3bcb808d30d81519d3325531dcca3c8..faa3d3bbd97f78e3252af307712ef2193b73610d 100644 (file)
@@ -195,7 +195,8 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);
   setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
-  
+  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
+
   setOperationAction(ISD::FSIN , MVT::f64, Expand);
   setOperationAction(ISD::FCOS , MVT::f64, Expand);
   setOperationAction(ISD::FREM , MVT::f64, Expand);
index 8ec8a5a46f5aa7281045e27ebf60114eba584e9f..3e1f9428c912600a3ff493d7e86aeb91014ffd95 100644 (file)
@@ -281,6 +281,10 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
   setOperationAction(ISD::MEMSET          , MVT::Other, Custom);
   setOperationAction(ISD::MEMCPY          , MVT::Other, Custom);
 
+  if (!Subtarget->hasSSE2())
+    setOperationAction(ISD::MEMBARRIER    , MVT::Other, Expand);
+
+
   // Use the default ISD::LOCATION, ISD::DECLARE expansion.
   setOperationAction(ISD::LOCATION, MVT::Other, Expand);
   // FIXME - use subtarget debug flags