Deleted Added
sdiff udiff text old ( 224145 ) new ( 226633 )
full compact
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/InitializePasses.h"
18#include "llvm/PassManager.h"
19#include "llvm/Target/TargetData.h"
20#include "llvm/LLVMContext.h"
21#include <cstring>
22
23using namespace llvm;
24
25void llvm::initializeTarget(PassRegistry &Registry) {
26 initializeTargetDataPass(Registry);
27 initializeTargetLibraryInfoPass(Registry);

--- 6 unchanged lines hidden (view full) ---

34LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
35 return wrap(new TargetData(StringRep));
36}
37
38void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) {
39 unwrap(PM)->add(new TargetData(*unwrap(TD)));
40}
41
42char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD) {
43 std::string StringRep = unwrap(TD)->getStringRepresentation();
44 return strdup(StringRep.c_str());
45}
46
47LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) {
48 return unwrap(TD)->isLittleEndian() ? LLVMLittleEndian : LLVMBigEndian;
49}

--- 32 unchanged lines hidden (view full) ---

82
83unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
84 LLVMValueRef GlobalVar) {
85 return unwrap(TD)->getPreferredAlignment(unwrap<GlobalVariable>(GlobalVar));
86}
87
88unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
89 unsigned long long Offset) {
90 const StructType *STy = unwrap<StructType>(StructTy);
91 return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset);
92}
93
94unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
95 unsigned Element) {
96 const StructType *STy = unwrap<StructType>(StructTy);
97 return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element);
98}
99
100void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
101 delete unwrap(TD);
102}