[llvm-commits] CVS: llvm/lib/Target/TargetData.cpp

Owen Anderson resistor at mac.com
Fri May 12 00:01:57 PDT 2006



Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.63 -> 1.64
---
Log message:

Add a method to generate a string representation from a TargetData.

This continues the work on PR 761: http://llvm.cs.uiuc.edu/PR761 .


---
Diffs of the changes:  (+21 -0)

 TargetData.cpp |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+)


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.63 llvm/lib/Target/TargetData.cpp:1.64
--- llvm/lib/Target/TargetData.cpp:1.63	Fri May 12 01:06:55 2006
+++ llvm/lib/Target/TargetData.cpp	Fri May 12 02:01:44 2006
@@ -25,6 +25,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include <algorithm>
 #include <cstdlib>
+#include <sstream>
 using namespace llvm;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
@@ -218,6 +219,26 @@
   }
 }
 
+std::string TargetData::getStringRepresentation() const {
+  std::stringstream repr;
+  
+  if (LittleEndian)
+    repr << "e";
+  else
+    repr << "E";
+  
+  repr << "-p:" << (PointerSize * 8) << ":" << (PointerAlignment * 8);
+  repr << "-d:64:" << (DoubleAlignment * 8);
+  repr << "-f:32:" << (FloatAlignment * 8);
+  repr << "-l:64:" << (LongAlignment * 8);
+  repr << "-i:32:" << (IntAlignment * 8);
+  repr << "-s:16:" << (ShortAlignment * 8);
+  repr << "-b:8:" << (ByteAlignment * 8);
+  repr << "-B:8:" << (BoolAlignment * 8);
+  
+  return repr.str();
+}
+
 const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
   if (Layouts == 0)
     Layouts = new std::map<std::pair<const TargetData*,const StructType*>,






More information about the llvm-commits mailing list