mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
Slightly revise iOS additions
This commit is contained in:
parent
d3970c35ff
commit
f1fb9d50fd
3 changed files with 30 additions and 30 deletions
|
@ -817,7 +817,6 @@ void registerPredefinedTargetVersions() {
|
|||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
VersionCondition::addPredefinedGlobalIdent("CppRuntime_Clang");
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
if (triple.getEnvironment() == llvm::Triple::Android) {
|
||||
VersionCondition::addPredefinedGlobalIdent("Android");
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//
|
||||
// The Procedure Call Standard can be found here:
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
|
||||
// https://github.com/ARM-software/software-standards/blob/master/abi/aapcs64/aapcs64.rst
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
@ -20,7 +21,7 @@
|
|||
#include "gen/abi-generic.h"
|
||||
|
||||
/**
|
||||
* The AACPS64 uses a special native va_list type:
|
||||
* The AAPCS64 uses a special native va_list type:
|
||||
*
|
||||
* typedef struct __va_list {
|
||||
* void *__stack; // next stack param
|
||||
|
@ -38,20 +39,16 @@
|
|||
*/
|
||||
struct AArch64TargetABI : TargetABI {
|
||||
private:
|
||||
const bool isDarwin;
|
||||
IndirectByvalRewrite byvalRewrite;
|
||||
HFAToArray hfaToArray;
|
||||
CompositeToArray64 compositeToArray64;
|
||||
IntegerRewrite integerRewrite;
|
||||
|
||||
bool isVaList(Type *t) {
|
||||
if (global.params.targetTriple->isOSDarwin())
|
||||
{
|
||||
return t->ty == Tpointer &&
|
||||
static_cast<TypePointer*>(t)->next->ty == Tchar;
|
||||
}
|
||||
else
|
||||
return t->ty == Tstruct && strcmp(t->toPrettyChars(true),
|
||||
"ldc.internal.vararg.std.__va_list") == 0;
|
||||
bool isAAPCS64VaList(Type *t) {
|
||||
return !isDarwin && t->ty == Tstruct &&
|
||||
strcmp(t->toPrettyChars(true),
|
||||
"ldc.internal.vararg.std.__va_list") == 0;
|
||||
}
|
||||
|
||||
bool passIndirectlyByValue(Type *t) {
|
||||
|
@ -61,6 +58,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
AArch64TargetABI() : isDarwin(global.params.targetTriple->isOSDarwin()) {}
|
||||
|
||||
bool returnInArg(TypeFunction *tf, bool) override {
|
||||
if (tf->isref) {
|
||||
return false;
|
||||
|
@ -95,7 +94,7 @@ public:
|
|||
if (t->ty != Tstruct && t->ty != Tsarray)
|
||||
return;
|
||||
|
||||
if (!isReturnVal && isVaList(t)) {
|
||||
if (!isReturnVal && isAAPCS64VaList(t)) {
|
||||
// compiler magic: pass va_list args implicitly by reference
|
||||
arg.byref = true;
|
||||
arg.ltype = arg.ltype->getPointerTo();
|
||||
|
@ -121,15 +120,14 @@ public:
|
|||
}
|
||||
|
||||
Type *vaListType() override {
|
||||
if (global.params.targetTriple->isOSDarwin())
|
||||
return Type::tchar->pointerTo();
|
||||
else {
|
||||
// We need to pass the actual va_list type for correct mangling. Simply
|
||||
// using TypeIdentifier here is a bit wonky but works, as long as the name
|
||||
// is actually available in the scope (this is what DMD does, so if a better
|
||||
// solution is found there, this should be adapted).
|
||||
return createTypeIdentifier(Loc(), Identifier::idPool("__va_list"));
|
||||
}
|
||||
if (isDarwin)
|
||||
return TargetABI::vaListType(); // char*
|
||||
|
||||
// We need to pass the actual va_list type for correct mangling. Simply
|
||||
// using TypeIdentifier here is a bit wonky but works, as long as the name
|
||||
// is actually available in the scope (this is what DMD does, so if a better
|
||||
// solution is found there, this should be adapted).
|
||||
return createTypeIdentifier(Loc(), Identifier::idPool("__va_list"));
|
||||
}
|
||||
|
||||
const char *objcMsgSendFunc(Type *ret, IrFuncTy &fty) override {
|
||||
|
|
|
@ -48,24 +48,27 @@ LLType *IrTypeBasic::getComplexType(llvm::LLVMContext &ctx, LLType *type) {
|
|||
|
||||
namespace {
|
||||
llvm::Type *getReal80Type(llvm::LLVMContext &ctx) {
|
||||
llvm::Triple::ArchType const a = global.params.targetTriple->getArch();
|
||||
bool const anyX86 = (a == llvm::Triple::x86) || (a == llvm::Triple::x86_64);
|
||||
bool const anyAarch64 =
|
||||
const auto &triple = *global.params.targetTriple;
|
||||
const auto a = triple.getArch();
|
||||
const bool anyX86 = (a == llvm::Triple::x86) || (a == llvm::Triple::x86_64);
|
||||
const bool anyAarch64 =
|
||||
(a == llvm::Triple::aarch64) || (a == llvm::Triple::aarch64_be);
|
||||
bool const isAndroid =
|
||||
global.params.targetTriple->getEnvironment() == llvm::Triple::Android;
|
||||
const bool isAndroid = triple.getEnvironment() == llvm::Triple::Android;
|
||||
|
||||
// only x86 has 80bit float - but no support with MS C Runtime!
|
||||
if (anyX86 && !global.params.targetTriple->isWindowsMSVCEnvironment() &&
|
||||
!isAndroid) {
|
||||
// Only x86 has 80-bit extended precision.
|
||||
// MSVC and Android/x86 use double precision, Android/x64 quadruple.
|
||||
if (anyX86 && !triple.isWindowsMSVCEnvironment() && !isAndroid) {
|
||||
return llvm::Type::getX86_FP80Ty(ctx);
|
||||
}
|
||||
|
||||
if ((anyAarch64 && !global.params.targetTriple->isOSDarwin()) ||
|
||||
// AArch64 targets except Darwin (64-bit) use 128-bit quadruple precision.
|
||||
// FIXME: PowerPC, SystemZ, ...
|
||||
if ((anyAarch64 && !triple.isOSDarwin()) ||
|
||||
(isAndroid && a == llvm::Triple::x86_64)) {
|
||||
return llvm::Type::getFP128Ty(ctx);
|
||||
}
|
||||
|
||||
// 64-bit double precision for all other targets.
|
||||
return llvm::Type::getDoubleTy(ctx);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue