mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
eb66b33867
I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
142 lines
4.7 KiB
C++
142 lines
4.7 KiB
C++
//===-- Target.cpp --------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the common infrastructure (including C bindings) for
|
|
// libLLVMTarget.a, which implements target information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm-c/Target.h"
|
|
#include "llvm-c/Initialization.h"
|
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
|
#include "llvm/IR/DataLayout.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/LegacyPassManager.h"
|
|
#include "llvm/IR/Value.h"
|
|
#include "llvm/InitializePasses.h"
|
|
#include <cstring>
|
|
|
|
using namespace llvm;
|
|
|
|
// Avoid including "llvm-c/Core.h" for compile time, fwd-declare this instead.
|
|
extern "C" LLVMContextRef LLVMGetGlobalContext(void);
|
|
|
|
inline TargetLibraryInfoImpl *unwrap(LLVMTargetLibraryInfoRef P) {
|
|
return reinterpret_cast<TargetLibraryInfoImpl*>(P);
|
|
}
|
|
|
|
inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfoImpl *P) {
|
|
TargetLibraryInfoImpl *X = const_cast<TargetLibraryInfoImpl*>(P);
|
|
return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
|
|
}
|
|
|
|
void llvm::initializeTarget(PassRegistry &Registry) {
|
|
initializeTargetLibraryInfoWrapperPassPass(Registry);
|
|
initializeTargetTransformInfoWrapperPassPass(Registry);
|
|
}
|
|
|
|
void LLVMInitializeTarget(LLVMPassRegistryRef R) {
|
|
initializeTarget(*unwrap(R));
|
|
}
|
|
|
|
LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M) {
|
|
return wrap(&unwrap(M)->getDataLayout());
|
|
}
|
|
|
|
void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL) {
|
|
unwrap(M)->setDataLayout(*unwrap(DL));
|
|
}
|
|
|
|
LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
|
|
return wrap(new DataLayout(StringRep));
|
|
}
|
|
|
|
void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
|
|
delete unwrap(TD);
|
|
}
|
|
|
|
void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
|
|
LLVMPassManagerRef PM) {
|
|
unwrap(PM)->add(new TargetLibraryInfoWrapperPass(*unwrap(TLI)));
|
|
}
|
|
|
|
char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD) {
|
|
std::string StringRep = unwrap(TD)->getStringRepresentation();
|
|
return strdup(StringRep.c_str());
|
|
}
|
|
|
|
LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD) {
|
|
return unwrap(TD)->isLittleEndian() ? LLVMLittleEndian : LLVMBigEndian;
|
|
}
|
|
|
|
unsigned LLVMPointerSize(LLVMTargetDataRef TD) {
|
|
return unwrap(TD)->getPointerSize(0);
|
|
}
|
|
|
|
unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
|
|
return unwrap(TD)->getPointerSize(AS);
|
|
}
|
|
|
|
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
|
|
return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext())));
|
|
}
|
|
|
|
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
|
|
return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext()), AS));
|
|
}
|
|
|
|
LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD) {
|
|
return wrap(unwrap(TD)->getIntPtrType(*unwrap(C)));
|
|
}
|
|
|
|
LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS) {
|
|
return wrap(unwrap(TD)->getIntPtrType(*unwrap(C), AS));
|
|
}
|
|
|
|
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getTypeSizeInBits(unwrap(Ty));
|
|
}
|
|
|
|
unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getTypeStoreSize(unwrap(Ty));
|
|
}
|
|
|
|
unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getTypeAllocSize(unwrap(Ty));
|
|
}
|
|
|
|
unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getABITypeAlignment(unwrap(Ty));
|
|
}
|
|
|
|
unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getABITypeAlignment(unwrap(Ty));
|
|
}
|
|
|
|
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
|
|
return unwrap(TD)->getPrefTypeAlignment(unwrap(Ty));
|
|
}
|
|
|
|
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
|
|
LLVMValueRef GlobalVar) {
|
|
return unwrap(TD)->getPreferredAlignment(unwrap<GlobalVariable>(GlobalVar));
|
|
}
|
|
|
|
unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
|
|
unsigned long long Offset) {
|
|
StructType *STy = unwrap<StructType>(StructTy);
|
|
return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset);
|
|
}
|
|
|
|
unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
|
|
unsigned Element) {
|
|
StructType *STy = unwrap<StructType>(StructTy);
|
|
return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element);
|
|
}
|