mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
33cc3f81c1
During the years there have been some attempts at figuring out how to align byval arguments. A look at the commit log suggests that they were * Use the ABI alignment. * When that was not sufficient for x86-64, I added the 's' specification to DataLayout. * When that was not sufficient Evan added the virtual getByValTypeAlignment. * When even that was not sufficient, we just got the FE to add the alignment to the byval. This patch is just a simple cleanup that removes my first attempt at fixing the problem. I also added an AArch64 implementation of getByValTypeAlignment to make sure this patch is a nop. I also left the 's' parsing for backward compatibility. I will send a short email to llvmdev about the change for anyone maintaining an out of tree target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198287 91177308-0d34-0410-b5e6-96231b3b80d8
143 lines
4.6 KiB
C++
143 lines
4.6 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/IR/Value.h"
|
|
#include "llvm/InitializePasses.h"
|
|
#include "llvm/PassManager.h"
|
|
#include "llvm/Target/TargetLibraryInfo.h"
|
|
#include <cstring>
|
|
|
|
using namespace llvm;
|
|
|
|
inline DataLayout *unwrap(LLVMTargetDataRef P) {
|
|
return reinterpret_cast<DataLayout*>(P);
|
|
}
|
|
|
|
inline LLVMTargetDataRef wrap(const DataLayout *P) {
|
|
return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
|
|
}
|
|
|
|
inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
|
|
return reinterpret_cast<TargetLibraryInfo*>(P);
|
|
}
|
|
|
|
inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
|
|
TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
|
|
return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void LLVMDisposeTargetData(LLVMTargetDataRef TD) {
|
|
delete unwrap(TD);
|
|
}
|