From d677b310e8bad449816c85263a77e1532be7cac9 Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Thu, 9 Jan 2014 07:50:34 +0000 Subject: Revert r198819 - "Remove dead code." llvm-svn: 198854 --- llvm/lib/IR/Module.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'llvm/lib/IR/Module.cpp') diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 996c5b6..f938a92 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -60,6 +60,51 @@ Module::~Module() { delete static_cast *>(NamedMDSymTab); } +/// Target endian information. +Module::Endianness Module::getEndianness() const { + StringRef temp = DataLayout; + Module::Endianness ret = BigEndian; + + while (!temp.empty()) { + std::pair 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 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. -- cgit v1.1