[llvm-commits] [llvm] r53366 - in /llvm/branches/Apple/Gaz: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Bill Wendling isanbard at gmail.com
Wed Jul 9 14:33:25 PDT 2008


Author: void
Date: Wed Jul  9 16:33:24 2008
New Revision: 53366

URL: http://llvm.org/viewvc/llvm-project?rev=53366&view=rev
Log:
Pulling r53361 into Gaz:

Move the IsVolatile and SVOffset fields into the MemSDNode base
class, and store IsVolatile and Alignment in a more compact form.
This makes AtomicSDNode slightly larger, but it shrinks LoadSDNode
and StoreSDNode, which are much more common and are the largest of
the SDNode subclasses. Also, this lets the isVolatile() and
getAlignment() accessors be non-virtual.


Modified:
    llvm/branches/Apple/Gaz/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/branches/Apple/Gaz/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/branches/Apple/Gaz/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Gaz/include/llvm/CodeGen/SelectionDAGNodes.h?rev=53366&r1=53365&r2=53366&view=diff

==============================================================================
--- llvm/branches/Apple/Gaz/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/branches/Apple/Gaz/include/llvm/CodeGen/SelectionDAGNodes.h Wed Jul  9 16:33:24 2008
@@ -1440,23 +1440,25 @@
   //! SrcValue - Memory location for alias analysis.
   const Value *SrcValue;
 
-  //! Alignment - Alignment of memory location in bytes.
-  unsigned Alignment;
+  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
+  int SVOffset;
+
+  /// Flags - the low bit indicates whether this is a volatile reference;
+  /// the remainder is a log2 encoding of the alignment in bytes.
+  unsigned Flags;
 
 public:
-  MemSDNode(unsigned Opc, SDVTList VTs, const Value *srcValue,
-            unsigned alignment)
-    : SDNode(Opc, VTs), SrcValue(srcValue), Alignment(alignment) {}
-  
-  virtual ~MemSDNode() {}
+  MemSDNode(unsigned Opc, SDVTList VTs,
+            const Value *srcValue, int SVOff,
+            unsigned alignment, bool isvolatile);
 
   /// Returns alignment and volatility of the memory access
-  unsigned getAlignment() const { return Alignment; }
-  virtual bool isVolatile() const = 0;
+  unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
+  bool isVolatile() const { return Flags & 1; }
   
   /// Returns the SrcValue and offset that describes the location of the access
   const Value *getSrcValue() const { return SrcValue; }
-  virtual int getSrcValueOffset() const = 0;
+  int getSrcValueOffset() const { return SVOffset; }
   
   /// getMemOperand - Return a MachineMemOperand object describing the memory
   /// reference performed by operation.
@@ -1499,7 +1501,8 @@
   AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 
                SDOperand Cmp, SDOperand Swp, const Value* SrcVal,
                unsigned Align=0)
-    : MemSDNode(Opc, VTL, SrcVal, Align) {
+    : MemSDNode(Opc, VTL, SrcVal, /*SVOffset=*/0,
+                Align, /*isVolatile=*/true) {
     Ops[0] = Chain;
     Ops[1] = Ptr;
     Ops[2] = Swp;
@@ -1508,7 +1511,8 @@
   }
   AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 
                SDOperand Val, const Value* SrcVal, unsigned Align=0)
-    : MemSDNode(Opc, VTL, SrcVal, Align) {
+    : MemSDNode(Opc, VTL, SrcVal, /*SVOffset=*/0,
+                Align, /*isVolatile=*/true) {
     Ops[0] = Chain;
     Ops[1] = Ptr;
     Ops[2] = Val;
@@ -1521,10 +1525,6 @@
 
   bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_CMP_SWAP; }
 
-  // Implementation for MemSDNode
-  virtual int getSrcValueOffset() const { return 0; }
-  virtual bool isVolatile() const { return true; }   
-  
   /// getMemOperand - Return a MachineMemOperand object describing the memory
   /// reference performed by this atomic load/store.
   virtual MachineMemOperand getMemOperand() const;
@@ -2055,12 +2055,6 @@
   // MemoryVT - VT of in-memory value.
   MVT MemoryVT;
 
-  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
-  int SVOffset;
-
-  //! IsVolatile - True if the load/store is volatile.
-  bool IsVolatile;
-
 protected:
   //! Operand array for load and store
   /*!
@@ -2073,8 +2067,7 @@
   LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned numOperands,
                SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
                const Value *SV, int SVO, unsigned Align, bool Vol)
-    : MemSDNode(NodeTy, VTs, SV, Align), AddrMode(AM), MemoryVT(VT),
-      SVOffset(SVO), IsVolatile(Vol) {
+    : MemSDNode(NodeTy, VTs, SV, SVO, Align, Vol), AddrMode(AM), MemoryVT(VT) {
     for (unsigned i = 0; i != numOperands; ++i)
       Ops[i] = Operands[i];
     InitOperands(Ops, numOperands);
@@ -2101,10 +2094,6 @@
   /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
   bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; }
 
-  // Implementation for MemSDNode
-  virtual int getSrcValueOffset() const { return SVOffset; }
-  virtual bool isVolatile() const { return IsVolatile; }  
-  
   /// getMemOperand - Return a MachineMemOperand object describing the memory
   /// reference performed by this load or store.
   virtual MachineMemOperand getMemOperand() const;

Modified: llvm/branches/Apple/Gaz/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Gaz/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=53366&r1=53365&r2=53366&view=diff

==============================================================================
--- llvm/branches/Apple/Gaz/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/branches/Apple/Gaz/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Jul  9 16:33:24 2008
@@ -4331,6 +4331,17 @@
   TheGlobal = const_cast<GlobalValue*>(GA);
 }
 
+MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs,
+                     const Value *srcValue, int SVO,
+                     unsigned alignment, bool vol)
+ : SDNode(Opc, VTs), SrcValue(srcValue), SVOffset(SVO),
+   Flags(vol | ((Log2_32(alignment) + 1) << 1)) {
+
+  assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
+  assert(getAlignment() == alignment && "Alignment representation error!");
+  assert(isVolatile() == vol && "Volatile representation error!");
+}
+
 /// getMemOperand - Return a MachineMemOperand object describing the memory
 /// reference performed by this atomic.
 MachineMemOperand AtomicSDNode::getMemOperand() const {





More information about the llvm-commits mailing list