PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/JIT/PyTypeBuilder.cc

http://unladen-swallow.googlecode.com/
C++ | 19 lines | 16 code | 3 blank | 0 comment | 1 complexity | c6e2ded74e91f513a5f79bac59297cdb MD5 | raw file
 1#include "JIT/PyTypeBuilder.h"
 2
 3#include "JIT/global_llvm_data.h"
 4
 5#include "llvm/ExecutionEngine/ExecutionEngine.h"
 6#include "llvm/Target/TargetData.h"
 7
 8unsigned int
 9_PyTypeBuilder_GetFieldIndexFromOffset(
10    const llvm::StructType *type, size_t offset)
11{
12    const llvm::TargetData *target_data =
13        PyGlobalLlvmData::Get()->getExecutionEngine()->getTargetData();
14    const llvm::StructLayout *layout = target_data->getStructLayout(type);
15    unsigned int index = layout->getElementContainingOffset(offset);
16    assert(layout->getElementOffset(index) == offset &&
17           "offset must be at start of element");
18    return index;
19}