Use the default lowering of ISD::DYNAMIC_STACKALLOC, delete now dead code.
authorChris Lattner <sabre@nondot.org>
Sun, 15 Jan 2006 09:00:21 +0000 (09:00 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 15 Jan 2006 09:00:21 +0000 (09:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelPattern.cpp

index 7789a1b8b2b7d0c8010ccb684e5ceb57796fa210..5d5a344243c004eed4fb5512d45131a3f2a9a452 100644 (file)
@@ -700,46 +700,6 @@ SDOperand X86DAGToDAGISel::Select(SDOperand N) {
                                       Base, Scale, Index, Disp, Chain);
       return Chain;
     }
-
-    case ISD::DYNAMIC_STACKALLOC: {
-      SDOperand Chain = N.getOperand(0);
-      SDOperand Size  = N.getOperand(1);
-      SDOperand Align = N.getOperand(2);
-
-      // FIXME: We are currently ignoring the requested alignment for handling
-      // greater than the stack alignment.  This will need to be revisited at
-      // some point.
-      if (!isa<ConstantSDNode>(Align) ||
-          cast<ConstantSDNode>(Align)->getValue() != 0) {
-        std::cerr << "Cannot allocate stack object with greater alignment than"
-                  << " the stack alignment yet!";
-        abort();
-      }
-
-      // FIXME: This produces crappy code. Lots of unnecessary MOV32rr to and
-      // from ESP.
-      SDOperand InFlag;
-      SDOperand SPVal = CurDAG->getCopyFromReg(Chain, X86::ESP, MVT::i32, InFlag);
-      Chain  = SPVal.getValue(1);
-      InFlag = SPVal.getValue(2);
-
-      SDOperand Result = Select(CurDAG->getNode(X86ISD::SUB_FLAG, MVT::i32,
-                                                SPVal, Size, InFlag));
-      InFlag = Result.getValue(1);
-
-      // Force the result back into ESP.
-      Chain  = CurDAG->getCopyToReg(Chain,
-                                    CurDAG->getRegister(X86::ESP, MVT::i32),
-                                    Result, InFlag);
-      InFlag = Chain.getValue(1);
-
-      // Copy the result back from ESP.
-      Result = CurDAG->getCopyFromReg(Chain, X86::ESP, MVT::i32, InFlag);
-
-      CodeGenMap[N.getValue(0)] = Result;
-      CodeGenMap[N.getValue(1)] = Result.getValue(1);
-      return Result.getValue(N.ResNo);
-    }
   }
 
   return SelectCode(N);
index a749380b864bae141598a520449160381f469000..22194aa1de93cfd2485a31c9e66d5a3e5381a795 100644 (file)
@@ -162,9 +162,10 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
   setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand);
   setOperationAction(ISD::DEBUG_LABEL, MVT::Other, Expand);
 
-  // Not implemented yet.
-  setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); 
-  setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
+  // Expand to the default code.
+  setOperationAction(ISD::STACKSAVE,          MVT::Other, Expand); 
+  setOperationAction(ISD::STACKRESTORE,       MVT::Other, Expand);
+  setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32  , Expand);
 
   if (X86ScalarSSE) {
     // Set up the FP register classes.
index 678e1829affdfac5d66c4b17cedb3a4175e702ec..1ec33722039d6079ed89303927b4708d36667ca0 100644 (file)
@@ -2386,46 +2386,6 @@ unsigned ISel::SelectExpr(SDOperand N) {
     return Result;
   }
 
-  case ISD::DYNAMIC_STACKALLOC:
-    // Generate both result values.
-    if (Result != 1)
-      ExprMap[N.getValue(1)] = 1;   // Generate the token
-    else
-      Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
-
-    // FIXME: We are currently ignoring the requested alignment for handling
-    // greater than the stack alignment.  This will need to be revisited at some
-    // point.  Align = N.getOperand(2);
-
-    if (!isa<ConstantSDNode>(N.getOperand(2)) ||
-        cast<ConstantSDNode>(N.getOperand(2))->getValue() != 0) {
-      std::cerr << "Cannot allocate stack object with greater alignment than"
-                << " the stack alignment yet!";
-      abort();
-    }
-
-    if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
-      Select(N.getOperand(0));
-      BuildMI(BB, X86::SUB32ri, 2, X86::ESP).addReg(X86::ESP)
-        .addImm(CN->getValue());
-    } else {
-      if (getRegPressure(N.getOperand(0)) > getRegPressure(N.getOperand(1))) {
-        Select(N.getOperand(0));
-        Tmp1 = SelectExpr(N.getOperand(1));
-      } else {
-        Tmp1 = SelectExpr(N.getOperand(1));
-        Select(N.getOperand(0));
-      }
-
-      // Subtract size from stack pointer, thereby allocating some space.
-      BuildMI(BB, X86::SUB32rr, 2, X86::ESP).addReg(X86::ESP).addReg(Tmp1);
-    }
-
-    // Put a pointer to the space into the result register, by copying the stack
-    // pointer.
-    BuildMI(BB, X86::MOV32rr, 1, Result).addReg(X86::ESP);
-    return Result;
-
   case X86ISD::TAILCALL:
   case X86ISD::CALL: {
     // The chain for this call is now lowered.
@@ -3295,7 +3255,6 @@ void ISel::Select(SDOperand N) {
   case ISD::EXTLOAD:
   case ISD::SEXTLOAD:
   case ISD::ZEXTLOAD:
-  case ISD::DYNAMIC_STACKALLOC:
   case X86ISD::TAILCALL:
   case X86ISD::CALL:
     ExprMap.erase(N);