summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2014-01-09 07:50:34 +0000
committerNadav Rotem <nrotem@apple.com>2014-01-09 07:50:34 +0000
commit7b651ce261483d9360c2ac6a4879806ef2826c31 (patch)
treecfe6fee533e09068db6d33b88af2204fe901a077 /lib/IR
parent0ee9bc789499c7725ace1b6973c3fe5d4e8cae67 (diff)
downloadllvm-7b651ce261483d9360c2ac6a4879806ef2826c31.tar.gz
llvm-7b651ce261483d9360c2ac6a4879806ef2826c31.tar.bz2
llvm-7b651ce261483d9360c2ac6a4879806ef2826c31.tar.xz
Revert r198819 - "Remove dead code."
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198854 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Module.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp
index 996c5b67a4..f938a92741 100644
--- a/lib/IR/Module.cpp
+++ b/lib/IR/Module.cpp
@@ -60,6 +60,51 @@ Module::~Module() {
delete static_cast<StringMap<NamedMDNode *> *>(NamedMDSymTab);
}
+/// Target endian information.
+Module::Endianness Module::getEndianness() const {
+ StringRef temp = DataLayout;
+ Module::Endianness ret = BigEndian;
+
+ while (!temp.empty()) {
+ std::pair<StringRef, StringRef> P = getToken(temp, "-");
+
+ StringRef token = P.first;
+ temp = P.second;
+
+ if (token[0] == 'e') {
+ ret = LittleEndian;
+ } else if (token[0] == 'E') {
+ ret = BigEndian;
+ }
+ }
+
+ return ret;
+}
+
+/// Target Pointer Size information.
+Module::PointerSize Module::getPointerSize() const {
+ StringRef temp = DataLayout;
+ Module::PointerSize ret = Pointer64;
+
+ while (!temp.empty()) {
+ std::pair<StringRef, StringRef> TmpP = getToken(temp, "-");
+ temp = TmpP.second;
+ TmpP = getToken(TmpP.first, ":");
+ StringRef token = TmpP.second, signalToken = TmpP.first;
+
+ if (signalToken[0] == 'p') {
+ int size = 0;
+ getToken(token, ":").first.getAsInteger(10, size);
+ if (size == 32)
+ ret = Pointer32;
+ else if (size == 64)
+ ret = Pointer64;
+ }
+ }
+
+ return ret;
+}
+
/// getNamedValue - Return the first global value in the module with
/// the specified name, of arbitrary type. This method returns null
/// if a global with the specified name is not found.