diff --git a/gen/abi-ppc64.cpp b/gen/abi-ppc64.cpp new file mode 100644 index 00000000..16e641fa --- /dev/null +++ b/gen/abi-ppc64.cpp @@ -0,0 +1,59 @@ +//===-- abi-x86-64.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// The PowerOpen 64bit ABI can be found here: +// http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html +// +//===----------------------------------------------------------------------===// + +#include "gen/abi.h" +#include "gen/irstate.h" +#include "gen/tollvm.h" +#include "gen/llvmhelpers.h" +#include "gen/dvalue.h" + +struct PPC64TargetABI : TargetABI { + + void newFunctionType(TypeFunction* tf) + { + } + + bool returnInArg(TypeFunction* tf) + { +#if DMDV2 + if (tf->isref) + return false; +#endif + // Return structs and static arrays on the stack. The latter is needed + // because otherwise LLVM tries to actually return the array in a number + // of physical registers, which leads, depending on the target, to + // either horrendous codegen or backend crashes. + Type* rt = tf->next->toBasetype(); + return (rt->ty == Tstruct || rt->ty == Tsarray); + } + + bool passByVal(Type* t) + { + return t->toBasetype()->ty == Tstruct; + } + + void doneWithFunctionType() + { + } + + void rewriteFunctionType(TypeFunction* tf) + { + } +}; + +// The public getter for abi.cpp +TargetABI* getPPC64TargetABI() +{ + return new PPC64TargetABI(); +} \ No newline at end of file diff --git a/gen/abi-ppc64.h b/gen/abi-ppc64.h new file mode 100644 index 00000000..de4e989a --- /dev/null +++ b/gen/abi-ppc64.h @@ -0,0 +1,23 @@ +//===-- gen/abi-x86-64.h - x86_64 ABI description ---------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// The ABI implementation used for 64 bit PowerPC targets. +// +//===----------------------------------------------------------------------===// + +#ifndef __LDC_GEN_ABI_PPC64_H__ +#define __LDC_GEN_ABI_PPC64_H__ + +#include "gen/abi.h" + + +TargetABI* getPPC64TargetABI(); + + +#endif diff --git a/gen/abi.cpp b/gen/abi.cpp index 64850688..fb286bf2 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -20,6 +20,7 @@ #include "gen/logger.h" #include "gen/dvalue.h" #include "gen/abi-generic.h" +#include "gen/abi-ppc64.h" #include "gen/abi-x86.h" #include "gen/abi-x86-64.h" #include "ir/irfunction.h" @@ -74,6 +75,8 @@ TargetABI * TargetABI::getTarget() return getX86TargetABI(); case ARCHx86_64: return getX86_64TargetABI(); + case ARCHppc_64: + return getPPC64TargetABI(); default: Logger::cout() << "WARNING: Unknown ABI, guessing...\n"; return new UnknownTargetABI;