MC-ize the stub printing in ARM.
[oota-llvm.git] / lib / Target / TargetData.cpp
index b99056134f951d45a703c85e2584443c4db44b3e..9a168087aedcc53514ca92331c666c05fb0c29db 100644 (file)
@@ -318,20 +318,27 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
 namespace {
 
 class StructLayoutMap : public AbstractTypeUser {
-public:
   typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
-private:
   LayoutInfoTy LayoutInfo;
 
+  void RemoveEntry(LayoutInfoTy::iterator I, bool WasAbstract) {
+    I->second->~StructLayout();
+    free(I->second);
+    if (WasAbstract)
+      I->first->removeAbstractTypeUser(this);
+    LayoutInfo.erase(I);
+  }
+  
+  
   /// refineAbstractType - The callback method invoked when an abstract type is
   /// resolved to another type.  An object must override this method to update
   /// its internal state to reference NewType instead of OldType.
   ///
   virtual void refineAbstractType(const DerivedType *OldTy,
                                   const Type *) {
-    assert(LayoutInfo.find(cast<const StructType>(OldTy)) != LayoutInfo.end() &&
-           "Abstract value not in local map!");
-    InvalidateEntry(cast<const StructType>(OldTy));
+    LayoutInfoTy::iterator I = LayoutInfo.find(cast<const StructType>(OldTy));
+    assert(I != LayoutInfo.end() && "Using type but not in map?");
+    RemoveEntry(I, true);
   }
 
   /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware
@@ -340,9 +347,9 @@ private:
   /// This method notifies ATU's when this occurs for a type.
   ///
   virtual void typeBecameConcrete(const DerivedType *AbsTy) {
-    assert(LayoutInfo.find(cast<const StructType>(AbsTy)) != LayoutInfo.end() &&
-           "Abstract value not in local map!");
-    InvalidateEntry(cast<const StructType>(AbsTy));
+    LayoutInfoTy::iterator I = LayoutInfo.find(cast<const StructType>(AbsTy));
+    assert(I != LayoutInfo.end() && "Using type but not in map?");
+    RemoveEntry(I, true);
   }
 
 public:
@@ -353,7 +360,7 @@ public:
       const Type *Key = I->first;
       StructLayout *Value = I->second;
 
-      if (Key && Key->isAbstract())
+      if (Key->isAbstract())
         Key->removeAbstractTypeUser(this);
 
       Value->~StructLayout();
@@ -364,13 +371,7 @@ public:
   void InvalidateEntry(const StructType *Ty) {
     LayoutInfoTy::iterator I = LayoutInfo.find(Ty);
     if (I == LayoutInfo.end()) return;
-  
-    I->second->~StructLayout();
-    free(I->second);
-    LayoutInfo.erase(I);
-
-    if (Ty->isAbstract())
-      Ty->removeAbstractTypeUser(this);
+    RemoveEntry(I, Ty->isAbstract());
   }
 
   StructLayout *&operator[](const StructType *STy) {
@@ -419,9 +420,8 @@ const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
 /// avoid a dangling pointer in this cache.
 void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
   if (!LayoutMap) return;  // No cache.
-
-  StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);
-  STM->InvalidateEntry(Ty);
+  
+  static_cast<StructLayoutMap*>(LayoutMap)->InvalidateEntry(Ty);
 }
 
 std::string TargetData::getStringRepresentation() const {
@@ -545,6 +545,13 @@ unsigned char TargetData::getABITypeAlignment(const Type *Ty) const {
   return getAlignment(Ty, true);
 }
 
+/// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for
+/// an integer type of the specified bitwidth.
+unsigned char TargetData::getABIIntegerTypeAlignment(unsigned BitWidth) const {
+  return getAlignmentInfo(INTEGER_ALIGN, BitWidth, true, 0);
+}
+
+
 unsigned char TargetData::getCallFrameTypeAlignment(const Type *Ty) const {
   for (unsigned i = 0, e = Alignments.size(); i != e; ++i)
     if (Alignments[i].AlignType == STACK_ALIGN)
@@ -573,7 +580,7 @@ const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const {
 uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices,
                                       unsigned NumIndices) const {
   const Type *Ty = ptrTy;
-  assert(isa<PointerType>(Ty) && "Illegal argument for getIndexedOffset()");
+  assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
   uint64_t Result = 0;
 
   generic_gep_type_iterator<Value* const*>