mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
43148d2e6e
interfaces which could be extracted from it, and must be provided on construction, to a chained analysis group. The end goal here is that TTI works much like AA -- there is a baseline "no-op" and target independent pass which is in the group, and each target can expose a target-specific pass in the group. These passes will naturally chain allowing each target-specific pass to delegate to the generic pass as needed. In particular, this will allow a much simpler interface for passes that would like to use TTI -- they can have a hard dependency on TTI and it will just be satisfied by the stub implementation when that is all that is available. This patch is a WIP however. In particular, the "stub" pass is actually the one and only pass, and everything there is implemented by delegating to the target-provided interfaces. As a consequence the tools still have to explicitly construct the pass. Switching targets to provide custom passes and sinking the stub behavior into the NoTTI pass is the next step. llvm-svn: 171621
117 lines
3.8 KiB
C++
117 lines
3.8 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/IR/DataLayout.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/InitializePasses.h"
|
|
#include "llvm/PassManager.h"
|
|
#include "llvm/Target/TargetLibraryInfo.h"
|
|
#include <cstring>
|
|
|
|
using namespace llvm;
|
|
|
|
void llvm::initializeTarget(PassRegistry &Registry) {
|
|
initializeDataLayoutPass(Registry);
|
|
initializeTargetLibraryInfoPass(Registry);
|
|
}
|
|
|
|
void LLVMInitializeTarget(LLVMPassRegistryRef R) {
|
|
initializeTarget(*unwrap(R));
|
|
}
|
|
|
|
LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
|
|
return wrap(new DataLayout(StringRep));
|
|
}
|
|
|
|
void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) {
|
|
unwrap(PM)->add(new DataLayout(*unwrap(TD)));
|
|
}
|
|
|
|
void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
|
|
LLVMPassManagerRef PM) {
|
|
unwrap(PM)->add(new TargetLibraryInfo(*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(getGlobalContext()));
|
|
}
|
|
|
|
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
|
|
return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), 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)->getCallFrameTypeAlignment(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);
|
|
}
|
|
|
|
void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
|
|
delete unwrap(TD);
|
|
}
|