summaryrefslogtreecommitdiff
path: root/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2006-05-12 07:01:44 +0000
committerOwen Anderson <resistor@mac.com>2006-05-12 07:01:44 +0000
commit2577c22131fbcf58cefdad63114c3e14a9d00c26 (patch)
treef9cc38292ab99e33520ce93cb18d188050347593 /lib/Target/TargetData.cpp
parent07000c6f01d8f57170f2d4c77a86d934bdc5c696 (diff)
downloadllvm-2577c22131fbcf58cefdad63114c3e14a9d00c26.tar.gz
llvm-2577c22131fbcf58cefdad63114c3e14a9d00c26.tar.bz2
llvm-2577c22131fbcf58cefdad63114c3e14a9d00c26.tar.xz
Add a method to generate a string representation from a TargetData.
This continues the work on PR 761. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 14ce6e89de..f7c0d7800b 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -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 @@ TargetData::~TargetData() {
}
}
+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*>,