Added the LAR (load segment access rights)
[llvm/avr.git] / include / llvm-c / Target.h
blob43388512e8756685cf2e95969cf71d48a5aa81dc
1 /*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*\
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 header declares the C interface to libLLVMTarget.a, which *|
11 |* implements target information. *|
12 |* *|
13 |* Many exotic languages can interoperate with C code but have a harder time *|
14 |* with C++ due to name mangling. So in addition to C, this interface enables *|
15 |* tools written in such languages. *|
16 |* *|
17 \*===----------------------------------------------------------------------===*/
19 #ifndef LLVM_C_TARGET_H
20 #define LLVM_C_TARGET_H
22 #include "llvm-c/Core.h"
23 #include "llvm/Config/config.h"
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
29 enum { LLVMBigEndian, LLVMLittleEndian };
30 typedef int LLVMByteOrdering;
32 typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
33 typedef struct LLVMStructLayout *LLVMStructLayoutRef;
35 /* Declare all of the target-initialization functions that are available. */
36 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
37 #include "llvm/Config/Targets.def"
39 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
40 #include "llvm/Config/Targets.def"
42 /** LLVMInitializeAllTargetInfos - The main program should call this function if
43 it wants access to all available targets that LLVM is configured to
44 support. */
45 static inline void LLVMInitializeAllTargetInfos() {
46 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
47 #include "llvm/Config/Targets.def"
50 /** LLVMInitializeAllTargets - The main program should call this function if it
51 wants to link in all available targets that LLVM is configured to
52 support. */
53 static inline void LLVMInitializeAllTargets() {
54 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
55 #include "llvm/Config/Targets.def"
58 /** LLVMInitializeNativeTarget - The main program should call this function to
59 initialize the native target corresponding to the host. This is useful
60 for JIT applications to ensure that the target gets linked in correctly. */
61 static inline int LLVMInitializeNativeTarget() {
62 /* If we have a native target, initialize it to ensure it is linked in. */
63 #ifdef LLVM_NATIVE_ARCH
64 #define DoInit2(TARG) \
65 LLVMInitialize ## TARG ## Info (); \
66 LLVMInitialize ## TARG ()
67 #define DoInit(T) DoInit2(T)
68 DoInit(LLVM_NATIVE_ARCH);
69 return 0;
70 #undef DoInit
71 #undef DoInit2
72 #else
73 return 1;
74 #endif
77 /*===-- Target Data -------------------------------------------------------===*/
79 /** Creates target data from a target layout string.
80 See the constructor llvm::TargetData::TargetData. */
81 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
83 /** Adds target data information to a pass manager. This does not take ownership
84 of the target data.
85 See the method llvm::PassManagerBase::add. */
86 void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef);
88 /** Converts target data to a target layout string. The string must be disposed
89 with LLVMDisposeMessage.
90 See the constructor llvm::TargetData::TargetData. */
91 char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef);
93 /** Returns the byte order of a target, either LLVMBigEndian or
94 LLVMLittleEndian.
95 See the method llvm::TargetData::isLittleEndian. */
96 LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef);
98 /** Returns the pointer size in bytes for a target.
99 See the method llvm::TargetData::getPointerSize. */
100 unsigned LLVMPointerSize(LLVMTargetDataRef);
102 /** Returns the integer type that is the same size as a pointer on a target.
103 See the method llvm::TargetData::getIntPtrType. */
104 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef);
106 /** Computes the size of a type in bytes for a target.
107 See the method llvm::TargetData::getTypeSizeInBits. */
108 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef);
110 /** Computes the storage size of a type in bytes for a target.
111 See the method llvm::TargetData::getTypeStoreSize. */
112 unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef);
114 /** Computes the ABI size of a type in bytes for a target.
115 See the method llvm::TargetData::getTypeAllocSize. */
116 unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef);
118 /** Computes the ABI alignment of a type in bytes for a target.
119 See the method llvm::TargetData::getTypeABISize. */
120 unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
122 /** Computes the call frame alignment of a type in bytes for a target.
123 See the method llvm::TargetData::getTypeABISize. */
124 unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
126 /** Computes the preferred alignment of a type in bytes for a target.
127 See the method llvm::TargetData::getTypeABISize. */
128 unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
130 /** Computes the preferred alignment of a global variable in bytes for a target.
131 See the method llvm::TargetData::getPreferredAlignment. */
132 unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef,
133 LLVMValueRef GlobalVar);
135 /** Computes the structure element that contains the byte offset for a target.
136 See the method llvm::StructLayout::getElementContainingOffset. */
137 unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy,
138 unsigned long long Offset);
140 /** Computes the byte offset of the indexed struct element for a target.
141 See the method llvm::StructLayout::getElementContainingOffset. */
142 unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy,
143 unsigned Element);
145 /** Struct layouts are speculatively cached. If a TargetDataRef is alive when
146 types are being refined and removed, this method must be called whenever a
147 struct type is removed to avoid a dangling pointer in this cache.
148 See the method llvm::TargetData::InvalidateStructLayoutInfo. */
149 void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy);
151 /** Deallocates a TargetData.
152 See the destructor llvm::TargetData::~TargetData. */
153 void LLVMDisposeTargetData(LLVMTargetDataRef);
156 #ifdef __cplusplus
159 namespace llvm {
160 class TargetData;
162 inline TargetData *unwrap(LLVMTargetDataRef P) {
163 return reinterpret_cast<TargetData*>(P);
166 inline LLVMTargetDataRef wrap(const TargetData *P) {
167 return reinterpret_cast<LLVMTargetDataRef>(const_cast<TargetData*>(P));
171 #endif /* defined(__cplusplus) */
173 #endif