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