Fix preselection/lowerswitches bug
[oota-llvm.git] / lib / Target / TargetData.cpp
index 8aa1851a181cf75e49e5a966d6a137922e1f400b..a377fd0d7f945b3a830d41af41fc9078ce6549f7 100644 (file)
@@ -1,4 +1,11 @@
 //===-- TargetData.cpp - Data size & alignment routines --------------------==//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file defines target properties related to datatype size/offset/alignment
 // information.  It uses lazy annotations to cache information about how 
@@ -15,7 +22,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Constants.h"
 
-// Handle the Pass registration stuff neccesary to use TargetData's.
+// Handle the Pass registration stuff necessary to use TargetData's.
 namespace {
   // Register the default SparcV9 implementation...
   RegisterPass<TargetData> X("targetdata", "Target Data Layout");
@@ -45,7 +52,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD)
     getTypeInfo(Ty, &TD, TySize, A);
     TyAlign = A;
 
-    // Add padding if neccesary to make the data element aligned properly...
+    // Add padding if necessary to make the data element aligned properly...
     if (StructSize % TyAlign != 0)
       StructSize = (StructSize/TyAlign + 1) * TyAlign;   // Add padding...
 
@@ -69,10 +76,10 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
                                      void *D) {
   const TargetData &TD = *(const TargetData*)D;
   assert(AID == TD.AID && "Target data annotation ID mismatch!");
-  const Type *Ty = cast<const Type>((const Value *)T);
+  const Type *Ty = cast<Type>((const Value *)T);
   assert(isa<StructType>(Ty) && 
         "Can only create StructLayout annotation on structs!");
-  return new StructLayout((const StructType *)Ty, TD);
+  return new StructLayout(cast<StructType>(Ty), TD);
 }
 
 //===----------------------------------------------------------------------===//
@@ -112,8 +119,8 @@ TargetData::TargetData(const std::string &ToolName, const Module *M)
   : AID(AnnotationManager::getID("TargetData::" + ToolName)) {
   AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this);
 
-  LittleEndian     = M->isLittleEndian();
-  PointerSize      = M->has32BitPointers() ? 4 : 8;
+  LittleEndian     = M->getEndianness() != Module::BigEndian;
+  PointerSize      = M->getPointerSize() != Module::Pointer64 ? 4 : 8;
   PointerAlignment = PointerSize;
   DoubleAlignment  = PointerSize;
   FloatAlignment   = 4;