LLVM API Documentation

Target.cpp

Go to the documentation of this file.
00001 //===-- Target.cpp --------------------------------------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the C bindings for libLLVMTarget.a, which implements
00011 // target information.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "llvm-c/Target.h"
00016 #include "llvm/PassManager.h"
00017 #include "llvm/Target/TargetData.h"
00018 #include <cstring>
00019 
00020 using namespace llvm;
00021 
00022 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
00023   return wrap(new TargetData(StringRep));
00024 }
00025 
00026 void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) {
00027   unwrap(PM)->add(new TargetData(*unwrap(TD)));
00028 }
00029 
00030 char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD) {
00031   std::string StringRep = unwrap(TD)->getStringRepresentation();
00032   return strdup(StringRep.c_str());
00033 }
00034 
00035 LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) {
00036   return unwrap(TD)->isLittleEndian();
00037 }
00038 
00039 unsigned LLVMPointerSize(LLVMTargetDataRef TD) {
00040   return unwrap(TD)->getPointerSize();
00041 }
00042 
00043 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
00044   return wrap(unwrap(TD)->getIntPtrType());
00045 }
00046 
00047 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00048   return unwrap(TD)->getTypeSizeInBits(unwrap(Ty));
00049 }
00050 
00051 unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00052   return unwrap(TD)->getTypeStoreSize(unwrap(Ty));
00053 }
00054 
00055 unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00056   return unwrap(TD)->getABITypeSize(unwrap(Ty));
00057 }
00058 
00059 unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00060   return unwrap(TD)->getABITypeAlignment(unwrap(Ty));
00061 }
00062 
00063 unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00064   return unwrap(TD)->getCallFrameTypeAlignment(unwrap(Ty));
00065 }
00066 
00067 unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
00068   return unwrap(TD)->getPrefTypeAlignment(unwrap(Ty));
00069 }
00070 
00071 unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
00072                                         LLVMValueRef GlobalVar) {
00073   return unwrap(TD)->getPreferredAlignment(unwrap<GlobalVariable>(GlobalVar));
00074 }
00075 
00076 unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
00077                              unsigned long long Offset) {
00078   const StructType *STy = unwrap<StructType>(StructTy);
00079   return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset);
00080 }
00081 
00082 unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
00083                                        unsigned Element) {
00084   const StructType *STy = unwrap<StructType>(StructTy);
00085   return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element);
00086 }
00087 
00088 void LLVMInvalidateStructLayout(LLVMTargetDataRef TD, LLVMTypeRef StructTy) {
00089   unwrap(TD)->InvalidateStructLayoutInfo(unwrap<StructType>(StructTy));
00090 }
00091 
00092 void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
00093   delete unwrap(TD);
00094 }



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.