Use X86AddrNumOperands instead of magic constant one
[oota-llvm.git] / lib / Target / TargetData.cpp
index 213bd5f31ffd6cdf2a67ed5e9c80851feeabde2f..29004dad2841983935bb820378ce78e3aaeb3494 100644 (file)
@@ -51,14 +51,14 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) {
     unsigned TyAlign = ST->isPacked() ? 1 : TD.getABITypeAlignment(Ty);
 
     // Add padding if necessary to align the data element properly.
-    if (StructSize & TyAlign-1)
+    if ((StructSize & (TyAlign-1)) != 0)
       StructSize = TargetData::RoundUpAlignment(StructSize, TyAlign);
 
     // Keep track of maximum alignment constraint.
     StructAlignment = std::max(TyAlign, StructAlignment);
 
     MemberOffsets[i] = StructSize;
-    StructSize += TD.getABITypeSize(Ty); // Consume space for this data item
+    StructSize += TD.getTypePaddedSize(Ty); // Consume space for this data item
   }
 
   // Empty structures have alignment of 1 byte.
@@ -66,7 +66,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) {
 
   // Add padding to the end of the struct so that it could be put in an array
   // and all array elements would be aligned correctly.
-  if (StructSize & (StructAlignment-1) != 0)
+  if ((StructSize & (StructAlignment-1)) != 0)
     StructSize = TargetData::RoundUpAlignment(StructSize, StructAlignment);
 }
 
@@ -176,11 +176,11 @@ void TargetData::init(const std::string &TargetDescription) {
   PointerPrefAlign = PointerABIAlign;
 
   // Default alignments
-  setAlignment(INTEGER_ALIGN,   1,  1, 1);   // Bool
-  setAlignment(INTEGER_ALIGN,   1,  1, 8);   // Byte
-  setAlignment(INTEGER_ALIGN,   2,  2, 16);  // short
-  setAlignment(INTEGER_ALIGN,   4,  4, 32);  // int
-  setAlignment(INTEGER_ALIGN,   4,  8, 64);  // long
+  setAlignment(INTEGER_ALIGN,   1,  1, 1);   // i1
+  setAlignment(INTEGER_ALIGN,   1,  1, 8);   // i8
+  setAlignment(INTEGER_ALIGN,   2,  2, 16);  // i16
+  setAlignment(INTEGER_ALIGN,   4,  4, 32);  // i32
+  setAlignment(INTEGER_ALIGN,   4,  8, 64);  // i64
   setAlignment(FLOAT_ALIGN,     4,  4, 32);  // float
   setAlignment(FLOAT_ALIGN,     8,  8, 64);  // double
   setAlignment(VECTOR_ALIGN,    8,  8, 64);  // v2i32
@@ -302,14 +302,14 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
       BestMatchIdx = LargestInt;
     } else {
       assert(AlignType == VECTOR_ALIGN && "Unknown alignment type!");
-      
+
       // If we didn't find a vector size that is smaller or equal to this type,
       // then we will end up scalarizing this to its element type.  Just return
       // the alignment of the element.
       return getAlignment(cast<VectorType>(Ty)->getElementType(), ABIInfo);
-    }    
+    }
   }
-    
+
   // Since we got a "best match" index, just return it.
   return ABIInfo ? Alignments[BestMatchIdx].ABIAlign
                  : Alignments[BestMatchIdx].PrefAlign;
@@ -425,7 +425,7 @@ uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
     return getPointerSizeInBits();
   case Type::ArrayTyID: {
     const ArrayType *ATy = cast<ArrayType>(Ty);
-    return getABITypeSizeInBits(ATy->getElementType())*ATy->getNumElements();
+    return getTypePaddedSizeInBits(ATy->getElementType())*ATy->getNumElements();
   }
   case Type::StructTyID:
     // Get the layout annotation... which is lazily created on demand.
@@ -475,12 +475,12 @@ unsigned char TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const {
             : getPointerPrefAlignment());
   case Type::ArrayTyID:
     return getAlignment(cast<ArrayType>(Ty)->getElementType(), abi_or_pref);
-    
+
   case Type::StructTyID: {
     // Packed structure types always have an ABI alignment of one.
     if (cast<StructType>(Ty)->isPacked() && abi_or_pref)
       return 1;
-    
+
     // Get the layout annotation... which is lazily created on demand.
     const StructLayout *Layout = getStructLayout(cast<StructType>(Ty));
     unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref, Ty);
@@ -568,7 +568,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices,
 
       // Get the array index and the size of each array element.
       int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue();
-      Result += arrayIdx * (int64_t)getABITypeSize(Ty);
+      Result += arrayIdx * (int64_t)getTypePaddedSize(Ty);
     }
   }