LCOV - code coverage report
Current view: top level - lib/Target - Target.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 54 16.7 %
Date: 2018-10-20 13:21:21 Functions: 3 24 12.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- Target.cpp --------------------------------------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file implements the common infrastructure (including C bindings) for
      11             : // libLLVMTarget.a, which implements target information.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm-c/Target.h"
      16             : #include "llvm-c/Initialization.h"
      17             : #include "llvm/Analysis/TargetLibraryInfo.h"
      18             : #include "llvm/IR/DataLayout.h"
      19             : #include "llvm/IR/LLVMContext.h"
      20             : #include "llvm/IR/LegacyPassManager.h"
      21             : #include "llvm/IR/Value.h"
      22             : #include "llvm/InitializePasses.h"
      23             : #include <cstring>
      24             : 
      25             : using namespace llvm;
      26             : 
      27             : // Avoid including "llvm-c/Core.h" for compile time, fwd-declare this instead.
      28             : extern "C" LLVMContextRef LLVMGetGlobalContext(void);
      29             : 
      30             : inline TargetLibraryInfoImpl *unwrap(LLVMTargetLibraryInfoRef P) {
      31             :   return reinterpret_cast<TargetLibraryInfoImpl*>(P);
      32             : }
      33             : 
      34             : inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfoImpl *P) {
      35             :   TargetLibraryInfoImpl *X = const_cast<TargetLibraryInfoImpl*>(P);
      36             :   return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
      37             : }
      38             : 
      39       10756 : void llvm::initializeTarget(PassRegistry &Registry) {
      40       10756 :   initializeTargetLibraryInfoWrapperPassPass(Registry);
      41       10756 :   initializeTargetTransformInfoWrapperPassPass(Registry);
      42       10756 : }
      43             : 
      44           0 : void LLVMInitializeTarget(LLVMPassRegistryRef R) {
      45           0 :   initializeTarget(*unwrap(R));
      46           0 : }
      47             : 
      48           5 : LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M) {
      49           5 :   return wrap(&unwrap(M)->getDataLayout());
      50             : }
      51             : 
      52           5 : void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL) {
      53           5 :   unwrap(M)->setDataLayout(*unwrap(DL));
      54           5 : }
      55             : 
      56           0 : LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
      57           0 :   return wrap(new DataLayout(StringRep));
      58             : }
      59             : 
      60           0 : void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
      61           0 :   delete unwrap(TD);
      62           0 : }
      63             : 
      64           0 : void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
      65             :                               LLVMPassManagerRef PM) {
      66           0 :   unwrap(PM)->add(new TargetLibraryInfoWrapperPass(*unwrap(TLI)));
      67           0 : }
      68             : 
      69           0 : char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD) {
      70             :   std::string StringRep = unwrap(TD)->getStringRepresentation();
      71           0 :   return strdup(StringRep.c_str());
      72             : }
      73             : 
      74           0 : LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) {
      75           0 :   return unwrap(TD)->isLittleEndian() ? LLVMLittleEndian : LLVMBigEndian;
      76             : }
      77             : 
      78           0 : unsigned LLVMPointerSize(LLVMTargetDataRef TD) {
      79           0 :   return unwrap(TD)->getPointerSize(0);
      80             : }
      81             : 
      82           0 : unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
      83           0 :   return unwrap(TD)->getPointerSize(AS);
      84             : }
      85             : 
      86           0 : LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
      87           0 :   return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext())));
      88             : }
      89             : 
      90           0 : LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
      91           0 :   return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext()), AS));
      92             : }
      93             : 
      94           0 : LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD) {
      95           0 :   return wrap(unwrap(TD)->getIntPtrType(*unwrap(C)));
      96             : }
      97             : 
      98           0 : LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS) {
      99           0 :   return wrap(unwrap(TD)->getIntPtrType(*unwrap(C), AS));
     100             : }
     101             : 
     102           0 : unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     103           0 :   return unwrap(TD)->getTypeSizeInBits(unwrap(Ty));
     104             : }
     105             : 
     106           0 : unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     107           0 :   return unwrap(TD)->getTypeStoreSize(unwrap(Ty));
     108             : }
     109             : 
     110           0 : unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     111           0 :   return unwrap(TD)->getTypeAllocSize(unwrap(Ty));
     112             : }
     113             : 
     114           0 : unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     115           0 :   return unwrap(TD)->getABITypeAlignment(unwrap(Ty));
     116             : }
     117             : 
     118           0 : unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     119           0 :   return unwrap(TD)->getABITypeAlignment(unwrap(Ty));
     120             : }
     121             : 
     122           0 : unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
     123           0 :   return unwrap(TD)->getPrefTypeAlignment(unwrap(Ty));
     124             : }
     125             : 
     126           0 : unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
     127             :                                         LLVMValueRef GlobalVar) {
     128           0 :   return unwrap(TD)->getPreferredAlignment(unwrap<GlobalVariable>(GlobalVar));
     129             : }
     130             : 
     131           0 : unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
     132             :                              unsigned long long Offset) {
     133             :   StructType *STy = unwrap<StructType>(StructTy);
     134           0 :   return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset);
     135             : }
     136             : 
     137           0 : unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
     138             :                                        unsigned Element) {
     139             :   StructType *STy = unwrap<StructType>(StructTy);
     140           0 :   return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element);
     141             : }

Generated by: LCOV version 1.13