diff --git a/README.md b/README.md index e6fc98513c..c5be3ec1a0 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Supported Platforms Avian can currently target the following platforms: - * Linux (i386, x86_64, ARM, and 32-bit PowerPC) + * Linux (i386, x86_64, and ARM) * Windows (i386 and x86_64) * Mac OS X (i386 and x86_64) * Apple iOS (i386 and ARM) @@ -86,7 +86,7 @@ certain flags described below, all of which are optional. $ make \ platform={linux,windows,darwin,freebsd} \ - arch={i386,x86_64,powerpc,arm} \ + arch={i386,x86_64,arm} \ process={compile,interpret} \ mode={debug,debug-fast,fast,small} \ lzma= \ diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index d0c16b0466..452f5b32fb 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -701,9 +701,6 @@ extern "C" JNIEXPORT jobjectArray JNICALL #elif defined ARCH_x86_64 e->SetObjectArrayElement(array, index++, e->NewStringUTF("os.arch=x86_64")); -#elif defined ARCH_powerpc - e->SetObjectArrayElement(array, index++, e->NewStringUTF("os.arch=ppc")); - #elif defined ARCH_arm e->SetObjectArrayElement(array, index++, e->NewStringUTF("os.arch=arm")); diff --git a/classpath/jni-util.h b/classpath/jni-util.h index 3830ccea1a..951aa43fc0 100644 --- a/classpath/jni-util.h +++ b/classpath/jni-util.h @@ -67,8 +67,6 @@ typedef unsigned __int64 uint64_t; # define ARCH_x86_32 # elif defined __x86_64__ # define ARCH_x86_64 -# elif (defined __POWERPC__) || (defined __powerpc__) -# define ARCH_powerpc # elif defined __arm__ # define ARCH_arm # endif diff --git a/include/avian/codegen/assembler.h b/include/avian/codegen/assembler.h index 7fc2ca0f3f..49a7664d6d 100644 --- a/include/avian/codegen/assembler.h +++ b/include/avian/codegen/assembler.h @@ -41,7 +41,7 @@ const bool TailCalls = true; const bool TailCalls = false; #endif -#if (defined AVIAN_USE_FRAME_POINTER) || (defined ARCH_powerpc) +#ifdef AVIAN_USE_FRAME_POINTER const bool UseFramePointer = true; #else const bool UseFramePointer = false; diff --git a/include/avian/codegen/targets.h b/include/avian/codegen/targets.h index 11b8976313..9e8eb8a335 100644 --- a/include/avian/codegen/targets.h +++ b/include/avian/codegen/targets.h @@ -24,7 +24,6 @@ Architecture* makeArchitectureNative(vm::System* system, bool useNativeFeatures) Architecture* makeArchitectureX86(vm::System* system, bool useNativeFeatures); Architecture* makeArchitectureArm(vm::System* system, bool useNativeFeatures); -Architecture* makeArchitecturePowerpc(vm::System* system, bool useNativeFeatures); } // namespace codegen } // namespace avian diff --git a/include/avian/tools/object-writer/tools.h b/include/avian/tools/object-writer/tools.h index 34058f1970..1785a0c5a8 100644 --- a/include/avian/tools/object-writer/tools.h +++ b/include/avian/tools/object-writer/tools.h @@ -114,7 +114,6 @@ public: enum Architecture { x86 = AVIAN_ARCH_X86, x86_64 = AVIAN_ARCH_X86_64, - PowerPC = AVIAN_ARCH_POWERPC, Arm = AVIAN_ARCH_ARM, UnknownArch = AVIAN_ARCH_UNKNOWN }; @@ -132,10 +131,6 @@ public: inline bool operator == (const PlatformInfo& other) { return format == other.format && arch == other.arch; } - - inline bool isLittleEndian() { - return arch != PowerPC; - } }; class Platform { diff --git a/makefile b/makefile index 932a2d03e4..c16e4cbaa8 100755 --- a/makefile +++ b/makefile @@ -7,12 +7,7 @@ build-arch := $(shell uname -m \ | sed 's/^i.86$$/i386/' \ | sed 's/^x86pc$$/i386/' \ | sed 's/amd64/x86_64/' \ - | sed 's/^arm.*$$/arm/' \ - | sed 's/ppc/powerpc/') - -ifeq (Power,$(filter Power,$(build-arch))) - build-arch = powerpc -endif + | sed 's/^arm.*$$/arm/') build-platform := \ $(shell uname -s | tr [:upper:] [:lower:] \ @@ -428,35 +423,10 @@ codeimage-symbols = _binary_codeimage_bin_start:_binary_codeimage_bin_end developer-dir := $(shell if test -d /Developer/Platforms/$(target).platform/Developer/SDKs; then echo /Developer; \ else echo /Applications/Xcode.app/Contents/Developer; fi) -ifeq ($(build-arch),powerpc) - ifneq ($(arch),$(build-arch)) - bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN - endif -endif - ifeq ($(arch),i386) pointer-size = 4 endif -ifeq ($(arch),powerpc) - asm = powerpc - pointer-size = 4 - - ifneq ($(arch),$(build-arch)) - bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN - endif - - ifneq ($(platform),darwin) - ifneq ($(arch),$(build-arch)) - cxx = powerpc-linux-gnu-g++ - cc = powerpc-linux-gnu-gcc - ar = powerpc-linux-gnu-ar - ranlib = powerpc-linux-gnu-ranlib - strip = powerpc-linux-gnu-strip - endif - endif -endif - ifeq ($(arch),arm) asm = arm pointer-size = 4 @@ -709,13 +679,6 @@ ifeq ($(platform),darwin) lflags += $(flags) endif - ifeq ($(arch),powerpc) - classpath-extra-cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION} - cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION} - asmflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION} - lflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION} - endif - ifeq ($(arch),i386) classpath-extra-cflags += \ -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} @@ -1153,12 +1116,9 @@ x86-assembler-sources = $(wildcard $(src)/codegen/target/x86/*.cpp) arm-assembler-sources = $(wildcard $(src)/codegen/target/arm/*.cpp) -powerpc-assembler-sources = $(wildcard $(src)/codegen/target/powerpc/*.cpp) - all-assembler-sources = \ $(x86-assembler-sources) \ - $(arm-assembler-sources) \ - $(powerpc-assembler-sources) + $(arm-assembler-sources) native-assembler-sources = $($(target-asm)-assembler-sources) @@ -1424,10 +1384,6 @@ ifeq ($(target-arch),x86_64) cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86_64 endif -ifeq ($(target-arch),powerpc) - cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_POWERPC -endif - ifeq ($(target-arch),arm) cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_ARM endif diff --git a/src/avian/arch.h b/src/avian/arch.h index d6380c18fa..0cb12f9142 100644 --- a/src/avian/arch.h +++ b/src/avian/arch.h @@ -41,8 +41,6 @@ compileTimeMemoryBarrier() #if (defined ARCH_x86_32) || (defined ARCH_x86_64) # include "x86.h" -#elif defined ARCH_powerpc -# include "powerpc.h" #elif defined ARCH_arm # include "arm.h" #else diff --git a/src/avian/common.h b/src/avian/common.h index c7c1e32c9f..cd70124464 100644 --- a/src/avian/common.h +++ b/src/avian/common.h @@ -28,10 +28,6 @@ #include "float.h" #include -#ifdef powerpc -# undef powerpc -#endif - #ifdef linux # undef linux #endif @@ -126,8 +122,6 @@ typedef intptr_t intptr_alias_t; # define ARCH_x86_32 # elif defined __x86_64__ # define ARCH_x86_64 -# elif (defined __POWERPC__) || (defined __powerpc__) -# define ARCH_powerpc # elif defined __arm__ # define ARCH_arm # else @@ -151,7 +145,7 @@ typedef intptr_t __attribute__((__may_alias__)) intptr_alias_t; # define PATH_SEPARATOR ':' #endif // not PLATFORM_WINDOWS -#if (defined ARCH_x86_32) || (defined ARCH_powerpc) || (defined ARCH_arm) +#if (defined ARCH_x86_32) || (defined ARCH_arm) # define LD "ld" # if (defined _MSC_VER) || ((defined __MINGW32__) && __GNUC__ >= 4) # define LLD "I64d" diff --git a/src/avian/environment.h b/src/avian/environment.h index 218603e00e..147b866d87 100644 --- a/src/avian/environment.h +++ b/src/avian/environment.h @@ -28,7 +28,6 @@ #define AVIAN_ARCH_X86 (1 << 8) #define AVIAN_ARCH_X86_64 (2 << 8) #define AVIAN_ARCH_ARM (3 << 8) -#define AVIAN_ARCH_POWERPC (4 << 8) #endif diff --git a/src/avian/machine.h b/src/avian/machine.h index 935f0eade3..807dbb14bc 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -184,10 +184,6 @@ struct JavaVMVTable { void* reserved1; void* reserved2; -#if (! TARGET_RT_MAC_CFM) && defined(__ppc__) - void* cfm_vectors[4]; -#endif - jint (JNICALL *DestroyJavaVM) (JavaVM*); @@ -207,10 +203,6 @@ struct JavaVMVTable { jint (JNICALL *AttachCurrentThreadAsDaemon) (JavaVM*, JNIEnv**, void*); - -#if TARGET_RT_MAC_CFM && defined(__ppc__) - void* real_functions[5]; -#endif }; struct JNIEnvVTable { @@ -219,10 +211,6 @@ struct JNIEnvVTable { void* reserved2; void* reserved3; -#if (! TARGET_RT_MAC_CFM) && defined(__ppc__) - void* cfm_vectors[225]; -#endif - jint (JNICALL *GetVersion) (JNIEnv*); @@ -1139,9 +1127,6 @@ struct JNIEnvVTable { (JNICALL *GetDirectBufferCapacity) (JNIEnv*, jobject); -#if TARGET_RT_MAC_CFM && defined(__ppc__) - void* real_functions[228]; -#endif }; inline void diff --git a/src/avian/powerpc.h b/src/avian/powerpc.h deleted file mode 100644 index 2b55e81bbb..0000000000 --- a/src/avian/powerpc.h +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef POWERPC_H -#define POWERPC_H - -#include "avian/types.h" -#include "avian/common.h" - -#ifdef __APPLE__ -# include "mach/mach_types.h" -# include "mach/ppc/thread_act.h" -# include "mach/ppc/thread_status.h" - -# define THREAD_STATE PPC_THREAD_STATE -# define THREAD_STATE_TYPE ppc_thread_state_t -# define THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT - -# if __DARWIN_UNIX03 && defined(_STRUCT_PPC_EXCEPTION_STATE) -# define FIELD(x) __##x -# else -# define FIELD(x) x -# endif - -# define THREAD_STATE_IP(state) ((state).FIELD(srr0)) -# define THREAD_STATE_STACK(state) ((state).FIELD(r1)) -# define THREAD_STATE_THREAD(state) ((state).FIELD(r13)) -# define THREAD_STATE_LINK(state) ((state).FIELD(lr)) - -# define IP_REGISTER(context) \ - THREAD_STATE_IP(context->uc_mcontext->FIELD(ss)) -# define STACK_REGISTER(context) \ - THREAD_STATE_STACK(context->uc_mcontext->FIELD(ss)) -# define THREAD_REGISTER(context) \ - THREAD_STATE_THREAD(context->uc_mcontext->FIELD(ss)) -# define LINK_REGISTER(context) \ - THREAD_STATE_LINK(context->uc_mcontext->FIELD(ss)) - -#define VA_LIST(x) (&(x)) - -#else // not __APPLE__ -# define IP_REGISTER(context) (context->uc_mcontext.regs->gpr[32]) -# define STACK_REGISTER(context) (context->uc_mcontext.regs->gpr[1]) -# define THREAD_REGISTER(context) (context->uc_mcontext.regs->gpr[13]) -# define LINK_REGISTER(context) (context->uc_mcontext.regs->gpr[36]) - -#define VA_LIST(x) (x) - -#endif // not __APPLE__ - -extern "C" uint64_t -vmNativeCall(void* function, unsigned stackTotal, void* memoryTable, - unsigned memoryCount, unsigned memoryBase, - void* gprTable, void* fprTable, unsigned returnType); - -namespace vm { - -inline void -trap() -{ - asm("trap"); -} - -inline void -memoryBarrier() -{ - __asm__ __volatile__("sync": : :"memory"); -} - -inline void -storeStoreMemoryBarrier() -{ - memoryBarrier(); -} - -inline void -storeLoadMemoryBarrier() -{ - memoryBarrier(); -} - -inline void -loadMemoryBarrier() -{ - memoryBarrier(); -} - -inline void -syncInstructionCache(const void* start, unsigned size) -{ - const unsigned CacheLineSize = 32; - const uintptr_t Mask = ~(CacheLineSize - 1); - - uintptr_t cacheLineStart = reinterpret_cast(start) & Mask; - uintptr_t cacheLineEnd - = (reinterpret_cast(start) + size + CacheLineSize - 1) & Mask; - - for (uintptr_t p = cacheLineStart; p < cacheLineEnd; p += CacheLineSize) { - __asm__ __volatile__("dcbf 0, %0" : : "r" (p)); - } - - __asm__ __volatile__("sync"); - - for (uintptr_t p = cacheLineStart; p < cacheLineEnd; p += CacheLineSize) { - __asm__ __volatile__("icbi 0, %0" : : "r" (p)); - } - - __asm__ __volatile__("isync"); -} - -#ifdef USE_ATOMIC_OPERATIONS -inline bool -atomicCompareAndSwap32(uint32_t* p, uint32_t old, uint32_t new_) -{ -#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1) - return __sync_bool_compare_and_swap(p, old, new_); -#else // not GCC >= 4.1 - bool result; - - __asm__ __volatile__(" sync\n" - "1:\n" - " lwarx %0,0,%2\n" - " cmpw %0,%3\n" - " bne- 2f\n" - " stwcx. %4,0,%2\n" - " bne- 1b\n" - " isync \n" - "2:\n" - " xor %0,%0,%3\n" - " cntlzw %0,%0\n" - " srwi %0,%0,5\n" - : "=&r"(result), "+m"(*p) - : "r"(p), "r"(old), "r"(new_) - : "cc", "memory"); - - return result; -#endif // not GCC >= 4.1 -} - -inline bool -atomicCompareAndSwap(uintptr_t* p, uintptr_t old, uintptr_t new_) -{ - return atomicCompareAndSwap32(reinterpret_cast(p), old, new_); -} -#endif // USE_ATOMIC_OPERATIONS - -inline uint64_t -dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, - unsigned argumentCount, unsigned argumentsSize, - unsigned returnType) -{ -#ifdef __APPLE__ -# define SKIP(var, count) var += count; -# define ALIGN(var) - const unsigned LinkageArea = 24; - const unsigned FprCount = 13; -#else -# define SKIP(var, count) -# define ALIGN(var) if (var & 1) ++var; - const unsigned LinkageArea = 8; - const unsigned FprCount = 8; -#endif - - const unsigned GprCount = 8; - uintptr_t gprTable[GprCount]; - unsigned gprIndex = 0; - - uint64_t fprTable[FprCount]; - unsigned fprIndex = 0; - - uintptr_t stack[argumentsSize / BytesPerWord]; - unsigned stackSkip = 0; - unsigned stackIndex = 0; - - unsigned ai = 0; - for (unsigned ati = 0; ati < argumentCount; ++ ati) { - switch (argumentTypes[ati]) { - case FLOAT_TYPE: { - if (fprIndex < FprCount) { - double d = bitsToFloat(arguments[ai]); - memcpy(fprTable + fprIndex, &d, 8); - ++ fprIndex; - SKIP(gprIndex, 1); - SKIP(stackSkip, 1); - } else { - stack[stackIndex++] = arguments[ai]; - } - ++ ai; - } break; - - case DOUBLE_TYPE: { - if (fprIndex + 1 <= FprCount) { - memcpy(fprTable + fprIndex, arguments + ai, 8); - ++ fprIndex; - SKIP(gprIndex, 8 / BytesPerWord); - SKIP(stackSkip, 8 / BytesPerWord); - } else { - ALIGN(stackIndex); - memcpy(stack + stackIndex, arguments + ai, 8); - stackIndex += 8 / BytesPerWord; - } - ai += 8 / BytesPerWord; - } break; - - case INT64_TYPE: { - if (gprIndex + (8 / BytesPerWord) <= GprCount) { - ALIGN(gprIndex); - memcpy(gprTable + gprIndex, arguments + ai, 8); - gprIndex += 8 / BytesPerWord; - SKIP(stackSkip, 8 / BytesPerWord); - } else { - ALIGN(stackIndex); - memcpy(stack + stackIndex, arguments + ai, 8); - stackIndex += 8 / BytesPerWord; - } - ai += 8 / BytesPerWord; - } break; - - default: { - if (gprIndex < GprCount) { - gprTable[gprIndex++] = arguments[ai]; - SKIP(stackSkip, 1); - } else { - stack[stackIndex++] = arguments[ai]; - } - ++ ai; - } break; - } - } - - return vmNativeCall - (function, - (((1 + stackSkip + stackIndex) * BytesPerWord) + LinkageArea + 15) & -16, - stack, stackIndex * BytesPerWord, - LinkageArea + (stackSkip * BytesPerWord), - (gprIndex ? gprTable : 0), - (fprIndex ? fprTable : 0), returnType); -} - -} // namespace vm - -#endif//POWERPC_H diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index 59b2095dff..d8bb1fc460 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -2227,11 +2227,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL Avian_java_nio_ByteOrder_isLittleEndian (Thread*, object, uintptr_t*) { -#ifdef ARCH_powerpc - return false; -#else return true; -#endif } extern "C" AVIAN_EXPORT int64_t JNICALL @@ -2432,8 +2428,6 @@ Avian_libcore_io_Posix_uname(Thread* t, object, uintptr_t*) object arch = makeString(t, "x86"); #elif defined ARCH_x86_64 object arch = makeString(t, "x86_64"); -#elif defined ARCH_powerpc - object arch = makeString(t, "ppc"); #elif defined ARCH_arm object arch = makeString(t, "arm"); #else diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index b53a646aa1..7f35b8a7b3 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -2986,8 +2986,6 @@ jvmInitProperties(Thread* t, uintptr_t* arguments) local::setProperty(t, method, *properties, "os.arch", "x86"); #elif defined ARCH_x86_64 local::setProperty(t, method, *properties, "os.arch", "x86_64"); -#elif defined ARCH_powerpc - local::setProperty(t, method, *properties, "os.arch", "ppc"); #elif defined ARCH_arm local::setProperty(t, method, *properties, "os.arch", "arm"); #else diff --git a/src/codegen/target/powerpc/assembler.cpp b/src/codegen/target/powerpc/assembler.cpp deleted file mode 100644 index 5b0edd07aa..0000000000 --- a/src/codegen/target/powerpc/assembler.cpp +++ /dev/null @@ -1,1010 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include -#include -#include - -#include "avian/alloc-vector.h" -#include - -#include "encode.h" -#include "context.h" -#include "fixup.h" -#include "block.h" -#include "operations.h" -#include "multimethod.h" -#include "../multimethod.h" - -using namespace vm; -using namespace avian::util; - -namespace avian { -namespace codegen { -namespace powerpc { - -inline int unha16(int32_t high, int32_t low) { - return ((high - ((low & 0x8000) ? 1 : 0)) << 16) | low; -} - -const RegisterFile MyRegisterFile(0xFFFFFFFF, 0); - -#ifdef __APPLE__ -const unsigned FrameFooterSize = 6; -const unsigned ReturnAddressOffset = 2; -const unsigned AlignArguments = false; -#else -const unsigned FrameFooterSize = 2; -const unsigned ReturnAddressOffset = 1; -const unsigned AlignArguments = true; -#endif - -const unsigned StackAlignmentInBytes = 16; -const unsigned StackAlignmentInWords -= StackAlignmentInBytes / TargetBytesPerWord; - -const int StackRegister = 1; -const int ThreadRegister = 13; - -const bool DebugJumps = false; - -class JumpOffset; - -unsigned padding(MyBlock*, unsigned); - -bool bounded(int right, int left, int32_t v); - -class Task; -class ConstantPoolEntry; - -bool -needJump(MyBlock* b) -{ - return b->next or (not bounded(2, 16, b->size)); -} - -unsigned -padding(MyBlock* b, unsigned offset) -{ - unsigned total = 0; - for (JumpEvent* e = b->jumpEventHead; e; e = e->next) { - if (e->offset <= offset) { - for (JumpOffset* o = e->jumpOffsetHead; o; o = o->next) { - total += TargetBytesPerWord; - } - - if (needJump(b)) { - total += TargetBytesPerWord; - } - } else { - break; - } - } - - return total; -} - -void -resolve(MyBlock* b) -{ - Context* c = b->context; - - for (JumpEvent** e = &(b->jumpEventHead); *e;) { - for (JumpOffset** o = &((*e)->jumpOffsetHead); *o;) { - if ((*o)->task->promise->resolved() - and (*o)->task->instructionOffset->resolved()) - { - int32_t v = reinterpret_cast((*o)->task->promise->value()) - - (c->result + (*o)->task->instructionOffset->value()); - - if (bounded(2, 16, v)) { - // this conditional jump needs no indirection -- a direct - // jump will suffice - *o = (*o)->next; - continue; - } - } - - o = &((*o)->next); - } - - if ((*e)->jumpOffsetHead == 0) { - *e = (*e)->next; - } else { - e = &((*e)->next); - } - } - - if (b->jumpOffsetHead) { - if (c->jumpOffsetTail) { - c->jumpOffsetTail->next = b->jumpOffsetHead; - } else { - c->jumpOffsetHead = b->jumpOffsetHead; - } - c->jumpOffsetTail = b->jumpOffsetTail; - } - - if (c->jumpOffsetHead) { - bool append; - if (b->next == 0 or b->next->jumpEventHead) { - append = true; - } else { - int32_t v = (b->start + b->size + b->next->size + TargetBytesPerWord) - - (c->jumpOffsetHead->offset + c->jumpOffsetHead->block->start); - - append = not bounded(2, 16, v); - - if (DebugJumps) { - fprintf(stderr, - "current %p %d %d next %p %d %d\n", - b, b->start, b->size, b->next, b->start + b->size, - b->next->size); - fprintf(stderr, - "offset %p %d is of distance %d to next block; append? %d\n", - c->jumpOffsetHead, c->jumpOffsetHead->offset, v, append); - } - } - - if (append) { -#ifndef NDEBUG - int32_t v = (b->start + b->size) - - (c->jumpOffsetHead->offset + c->jumpOffsetHead->block->start); - - expect(c, bounded(2, 16, v)); -#endif // not NDEBUG - - appendJumpEvent(c, b, b->size, c->jumpOffsetHead, c->jumpOffsetTail); - - if (DebugJumps) { - for (JumpOffset* o = c->jumpOffsetHead; o; o = o->next) { - fprintf(stderr, - "include %p %d in jump event %p at offset %d in block %p\n", - o, o->offset, b->jumpEventTail, b->size, b); - } - } - - c->jumpOffsetHead = 0; - c->jumpOffsetTail = 0; - } - } -} - -// BEGIN OPERATION COMPILERS - -using namespace isa; - -// END OPERATION COMPILERS - -unsigned -argumentFootprint(unsigned footprint) -{ - return max(pad(footprint, StackAlignmentInWords), StackAlignmentInWords); -} - -void -nextFrame(ArchitectureContext* c UNUSED, int32_t* start, unsigned size, - unsigned footprint, void* link, bool, - int targetParameterFootprint, void** ip, void** stack) -{ - assert(c, *ip >= start); - assert(c, *ip <= start + (size / BytesPerWord)); - - int32_t* instruction = static_cast(*ip); - - if ((*start >> 26) == 32) { - // skip stack overflow check - start += 3; - } - - if (instruction <= start + 2 - or *instruction == lwz(0, 1, 8) - or *instruction == mtlr(0) - or *instruction == blr()) - { - *ip = link; - return; - } - - unsigned offset = footprint; - - if (TailCalls and targetParameterFootprint >= 0) { - if (argumentFootprint(targetParameterFootprint) > StackAlignmentInWords) { - offset += argumentFootprint(targetParameterFootprint) - - StackAlignmentInWords; - } - - // check for post-non-tail-call stack adjustment of the form "lwzx - // r0,0(r1); stwu r0,offset(r1)": - if (instruction < start + (size / BytesPerWord) - 1 - and (static_cast(instruction[1]) >> 16) == 0x9401) - { - offset += static_cast(instruction[1]) / BytesPerWord; - } else if ((static_cast(*instruction) >> 16) == 0x9401) { - offset += static_cast(*instruction) / BytesPerWord; - } - - // todo: check for and handle tail calls - } - - *ip = static_cast(*stack)[offset + ReturnAddressOffset]; - *stack = static_cast(*stack) + offset; -} - -class MyArchitecture: public Architecture { - public: - MyArchitecture(System* system): c(system), referenceCount(0) { - populateTables(&c); - } - - virtual unsigned floatRegisterSize() { - return 0; - } - - virtual const RegisterFile* registerFile() { - return &MyRegisterFile; - } - - virtual int scratch() { - return 31; - } - - virtual int stack() { - return StackRegister; - } - - virtual int thread() { - return ThreadRegister; - } - - virtual int returnLow() { - return 4; - } - - virtual int returnHigh() { - return (TargetBytesPerWord == 4 ? 3 : lir::NoRegister); - } - - virtual int virtualCallTarget() { - return 4; - } - - virtual int virtualCallIndex() { - return 3; - } - - virtual bool bigEndian() { - return true; - } - - virtual uintptr_t maximumImmediateJump() { - return 0x1FFFFFF; - } - - virtual bool reserved(int register_) { - switch (register_) { - case 0: // r0 has special meaning in addi and other instructions - case StackRegister: - case ThreadRegister: -#ifndef __APPLE__ - // r2 is reserved for system uses on SYSV - case 2: -#endif - return true; - - default: - return false; - } - } - - virtual unsigned frameFootprint(unsigned footprint) { - return max(footprint, StackAlignmentInWords); - } - - virtual unsigned argumentFootprint(unsigned footprint) { - return powerpc::argumentFootprint(footprint); - } - - virtual bool argumentAlignment() { - return AlignArguments; - } - - virtual bool argumentRegisterAlignment() { - return true; - } - - virtual unsigned argumentRegisterCount() { - return 8; - } - - virtual int argumentRegister(unsigned index) { - assert(&c, index < argumentRegisterCount()); - - return index + 3; - } - - virtual bool hasLinkRegister() { - return true; - } - - virtual unsigned stackAlignmentInWords() { - return StackAlignmentInWords; - } - - virtual bool matchCall(void* returnAddress, void* target) { - uint32_t* instruction = static_cast(returnAddress) - 1; - - return *instruction == static_cast - (bl(static_cast(target) - - reinterpret_cast(instruction))); - } - - virtual void updateCall(lir::UnaryOperation op UNUSED, - void* returnAddress, - void* newTarget) - { - switch (op) { - case lir::Call: - case lir::Jump: - case lir::AlignedCall: - case lir::AlignedJump: { - updateOffset(c.s, static_cast(returnAddress) - 4, false, - reinterpret_cast(newTarget), 0); - } break; - - case lir::LongCall: - case lir::LongJump: { - updateImmediate - (c.s, static_cast(returnAddress) - 12, - reinterpret_cast(newTarget), TargetBytesPerWord, false); - } break; - - case lir::AlignedLongCall: - case lir::AlignedLongJump: { - uint32_t* p = static_cast(returnAddress) - 4; - *reinterpret_cast(unha16(p[0] & 0xFFFF, p[1] & 0xFFFF)) - = newTarget; - } break; - - default: abort(&c); - } - } - - virtual unsigned constantCallSize() { - return 4; - } - - virtual void setConstant(void* dst, uint64_t constant) { - updateImmediate(c.s, dst, constant, TargetBytesPerWord, false); - } - - virtual unsigned alignFrameSize(unsigned sizeInWords) { - const unsigned alignment = StackAlignmentInWords; - return (ceilingDivide(sizeInWords + FrameFooterSize, alignment) * alignment); - } - - virtual void nextFrame(void* start, unsigned size, unsigned footprint, - void* link, bool mostRecent, - int targetParameterFootprint, void** ip, - void** stack) - { - powerpc::nextFrame(&c, static_cast(start), size, footprint, link, - mostRecent, targetParameterFootprint, ip, stack); - } - - virtual void* frameIp(void* stack) { - return stack ? static_cast(stack)[ReturnAddressOffset] : 0; - } - - virtual unsigned frameHeaderSize() { - return 0; - } - - virtual unsigned frameReturnAddressSize() { - return 0; - } - - virtual unsigned frameFooterSize() { - return FrameFooterSize; - } - - virtual int returnAddressOffset() { - return ReturnAddressOffset; - } - - virtual int framePointerOffset() { - return 0; - } - - virtual bool alwaysCondensed(lir::BinaryOperation) { - return false; - } - - virtual bool alwaysCondensed(lir::TernaryOperation) { - return false; - } - - virtual void plan - (lir::UnaryOperation, - unsigned, OperandMask& aMask, - bool* thunk) - { - aMask.typeMask = (1 << lir::RegisterOperand) | (1 << lir::ConstantOperand); - aMask.registerMask = ~static_cast(0); - *thunk = false; - } - - virtual void planSource - (lir::BinaryOperation op, - unsigned, OperandMask& aMask, - unsigned, bool* thunk) - { - aMask.typeMask = ~0; - aMask.registerMask = ~static_cast(0); - - *thunk = false; - - switch (op) { - case lir::Negate: - aMask.typeMask = (1 << lir::RegisterOperand); - break; - - case lir::Absolute: - case lir::FloatAbsolute: - case lir::FloatSquareRoot: - case lir::FloatNegate: - case lir::Float2Float: - case lir::Float2Int: - case lir::Int2Float: - *thunk = true; - break; - - default: - break; - } - } - - virtual void planDestination - (lir::BinaryOperation op, - unsigned, const OperandMask& aMask UNUSED, - unsigned, OperandMask& bMask) - { - bMask.typeMask = (1 << lir::RegisterOperand) | (1 << lir::MemoryOperand); - bMask.registerMask = ~static_cast(0); - - switch (op) { - case lir::Negate: - bMask.typeMask = (1 << lir::RegisterOperand); - break; - - default: - break; - } - } - - virtual void planMove - (unsigned, OperandMask& srcMask, - OperandMask& tmpMask, - const OperandMask& dstMask) - { - srcMask.typeMask = ~0; - srcMask.registerMask = ~static_cast(0); - - tmpMask.typeMask = 0; - tmpMask.registerMask = 0; - - if (dstMask.typeMask & (1 << lir::MemoryOperand)) { - // can't move directly from memory or constant to memory - srcMask.typeMask = 1 << lir::RegisterOperand; - tmpMask.typeMask = 1 << lir::RegisterOperand; - tmpMask.registerMask = ~static_cast(0); - } - } - - virtual void planSource - (lir::TernaryOperation op, - unsigned aSize, OperandMask& aMask, - unsigned, OperandMask& bMask, - unsigned, bool* thunk) - { - aMask.typeMask = (1 << lir::RegisterOperand) | (1 << lir::ConstantOperand); - aMask.registerMask = ~static_cast(0); - - bMask.typeMask = (1 << lir::RegisterOperand); - bMask.registerMask = ~static_cast(0); - - *thunk = false; - - switch (op) { - case lir::Add: - case lir::Subtract: - if (aSize == 8) { - aMask.typeMask = bMask.typeMask = (1 << lir::RegisterOperand); - } - break; - - case lir::Multiply: - aMask.typeMask = bMask.typeMask = (1 << lir::RegisterOperand); - break; - - case lir::Divide: - case lir::Remainder: - // todo: we shouldn't need to defer to thunks for integers which - // are smaller than or equal to tne native word size, but - // PowerPC doesn't generate traps for divide by zero, so we'd - // need to do the checks ourselves. Using an inline check - // should be faster than calling an out-of-line thunk, but the - // thunk is easier, so they's what we do for now. - if (true) {//if (TargetBytesPerWord == 4 and aSize == 8) { - *thunk = true; - } else { - aMask.typeMask = (1 << lir::RegisterOperand); - } - break; - - case lir::FloatAdd: - case lir::FloatSubtract: - case lir::FloatMultiply: - case lir::FloatDivide: - case lir::FloatRemainder: - case lir::JumpIfFloatEqual: - case lir::JumpIfFloatNotEqual: - case lir::JumpIfFloatLess: - case lir::JumpIfFloatGreater: - case lir::JumpIfFloatLessOrEqual: - case lir::JumpIfFloatGreaterOrEqual: - case lir::JumpIfFloatLessOrUnordered: - case lir::JumpIfFloatGreaterOrUnordered: - case lir::JumpIfFloatLessOrEqualOrUnordered: - case lir::JumpIfFloatGreaterOrEqualOrUnordered: - *thunk = true; - break; - - default: - break; - } - } - - virtual void planDestination - (lir::TernaryOperation op, - unsigned, const OperandMask& aMask UNUSED, - unsigned, const OperandMask& bMask UNUSED, - unsigned, OperandMask& cMask) - { - if (isBranch(op)) { - cMask.typeMask = (1 << lir::ConstantOperand); - cMask.registerMask = 0; - } else { - cMask.typeMask = (1 << lir::RegisterOperand); - cMask.registerMask = ~static_cast(0); - } - } - - virtual Assembler* makeAssembler(util::Allocator* allocator, Zone* zone); - - virtual void acquire() { - ++ referenceCount; - } - - virtual void release() { - if (-- referenceCount == 0) { - c.s->free(this); - } - } - - ArchitectureContext c; - unsigned referenceCount; -}; - -class MyAssembler: public Assembler { - public: - MyAssembler(System* s, util::Allocator* a, Zone* zone, MyArchitecture* arch) - : c(s, a, zone), arch_(arch) - { } - - virtual void setClient(Client* client) { - assert(&c, c.client == 0); - c.client = client; - } - - virtual Architecture* arch() { - return arch_; - } - - virtual void checkStackOverflow(uintptr_t handler, - unsigned stackLimitOffsetFromThread) - { - lir::Register stack(StackRegister); - lir::Memory stackLimit(ThreadRegister, stackLimitOffsetFromThread); - lir::Constant handlerConstant - (new(c.zone) ResolvedPromise(handler)); - branchRM(&c, lir::JumpIfGreaterOrEqual, TargetBytesPerWord, &stack, &stackLimit, - &handlerConstant); - } - - virtual void saveFrame(unsigned stackOffset, unsigned) { - lir::Register returnAddress(0); - emit(&c, mflr(returnAddress.low)); - - lir::Memory returnAddressDst - (StackRegister, ReturnAddressOffset * TargetBytesPerWord); - moveRM(&c, TargetBytesPerWord, &returnAddress, TargetBytesPerWord, - &returnAddressDst); - - lir::Register stack(StackRegister); - lir::Memory stackDst(ThreadRegister, stackOffset); - moveRM(&c, TargetBytesPerWord, &stack, TargetBytesPerWord, &stackDst); - } - - virtual void pushFrame(unsigned argumentCount, ...) { - struct { - unsigned size; - lir::OperandType type; - lir::Operand* operand; - } arguments[argumentCount]; - - va_list a; va_start(a, argumentCount); - unsigned footprint = 0; - for (unsigned i = 0; i < argumentCount; ++i) { - arguments[i].size = va_arg(a, unsigned); - arguments[i].type = static_cast(va_arg(a, int)); - arguments[i].operand = va_arg(a, lir::Operand*); - footprint += ceilingDivide(arguments[i].size, TargetBytesPerWord); - } - va_end(a); - - allocateFrame(arch_->alignFrameSize(footprint)); - - unsigned offset = 0; - for (unsigned i = 0; i < argumentCount; ++i) { - if (i < arch_->argumentRegisterCount()) { - lir::Register dst(arch_->argumentRegister(i)); - - apply(lir::Move, - OperandInfo(arguments[i].size, arguments[i].type, arguments[i].operand), - OperandInfo(pad(arguments[i].size, TargetBytesPerWord), lir::RegisterOperand, - &dst)); - - offset += ceilingDivide(arguments[i].size, TargetBytesPerWord); - } else { - lir::Memory dst - (ThreadRegister, (offset + FrameFooterSize) * TargetBytesPerWord); - - apply(lir::Move, - OperandInfo(arguments[i].size, arguments[i].type, arguments[i].operand), - OperandInfo(pad(arguments[i].size, TargetBytesPerWord), lir::MemoryOperand, &dst)); - - offset += ceilingDivide(arguments[i].size, TargetBytesPerWord); - } - } - } - - virtual void allocateFrame(unsigned footprint) { - lir::Register returnAddress(0); - emit(&c, mflr(returnAddress.low)); - - lir::Memory returnAddressDst - (StackRegister, ReturnAddressOffset * TargetBytesPerWord); - moveRM(&c, TargetBytesPerWord, &returnAddress, TargetBytesPerWord, - &returnAddressDst); - - lir::Register stack(StackRegister); - lir::Memory stackDst(StackRegister, -footprint * TargetBytesPerWord); - moveAndUpdateRM - (&c, TargetBytesPerWord, &stack, TargetBytesPerWord, &stackDst); - } - - virtual void adjustFrame(unsigned difference) { - lir::Register nextStack(0); - lir::Memory stackSrc(StackRegister, 0); - moveMR(&c, TargetBytesPerWord, &stackSrc, TargetBytesPerWord, &nextStack); - - lir::Memory stackDst(StackRegister, -difference * TargetBytesPerWord); - moveAndUpdateRM - (&c, TargetBytesPerWord, &nextStack, TargetBytesPerWord, &stackDst); - } - - virtual void popFrame(unsigned) { - lir::Register stack(StackRegister); - lir::Memory stackSrc(StackRegister, 0); - moveMR(&c, TargetBytesPerWord, &stackSrc, TargetBytesPerWord, &stack); - - lir::Register returnAddress(0); - lir::Memory returnAddressSrc - (StackRegister, ReturnAddressOffset * TargetBytesPerWord); - moveMR(&c, TargetBytesPerWord, &returnAddressSrc, TargetBytesPerWord, - &returnAddress); - - emit(&c, mtlr(returnAddress.low)); - } - - virtual void popFrameForTailCall(unsigned footprint, - int offset, - int returnAddressSurrogate, - int framePointerSurrogate) - { - if (TailCalls) { - if (offset) { - lir::Register tmp(0); - lir::Memory returnAddressSrc - (StackRegister, (ReturnAddressOffset + footprint) - * TargetBytesPerWord); - moveMR(&c, TargetBytesPerWord, &returnAddressSrc, TargetBytesPerWord, - &tmp); - - emit(&c, mtlr(tmp.low)); - - lir::Memory stackSrc(StackRegister, footprint * TargetBytesPerWord); - moveMR(&c, TargetBytesPerWord, &stackSrc, TargetBytesPerWord, &tmp); - - lir::Memory stackDst - (StackRegister, (footprint - offset) * TargetBytesPerWord); - moveAndUpdateRM - (&c, TargetBytesPerWord, &tmp, TargetBytesPerWord, &stackDst); - - if (returnAddressSurrogate != lir::NoRegister) { - assert(&c, offset > 0); - - lir::Register ras(returnAddressSurrogate); - lir::Memory dst - (StackRegister, (ReturnAddressOffset + offset) - * TargetBytesPerWord); - moveRM(&c, TargetBytesPerWord, &ras, TargetBytesPerWord, &dst); - } - - if (framePointerSurrogate != lir::NoRegister) { - assert(&c, offset > 0); - - lir::Register fps(framePointerSurrogate); - lir::Memory dst(StackRegister, offset * TargetBytesPerWord); - moveRM(&c, TargetBytesPerWord, &fps, TargetBytesPerWord, &dst); - } - } else { - popFrame(footprint); - } - } else { - abort(&c); - } - } - - virtual void popFrameAndPopArgumentsAndReturn(unsigned frameFootprint, - unsigned argumentFootprint) - { - popFrame(frameFootprint); - - assert(&c, argumentFootprint >= StackAlignmentInWords); - assert(&c, (argumentFootprint % StackAlignmentInWords) == 0); - - if (TailCalls and argumentFootprint > StackAlignmentInWords) { - lir::Register tmp(0); - lir::Memory stackSrc(StackRegister, 0); - moveMR(&c, TargetBytesPerWord, &stackSrc, TargetBytesPerWord, &tmp); - - lir::Memory stackDst(StackRegister, - (argumentFootprint - StackAlignmentInWords) - * TargetBytesPerWord); - moveAndUpdateRM - (&c, TargetBytesPerWord, &tmp, TargetBytesPerWord, &stackDst); - } - - return_(&c); - } - - virtual void popFrameAndUpdateStackAndReturn(unsigned frameFootprint, - unsigned stackOffsetFromThread) - { - popFrame(frameFootprint); - - lir::Register tmp1(0); - lir::Memory stackSrc(StackRegister, 0); - moveMR(&c, TargetBytesPerWord, &stackSrc, TargetBytesPerWord, &tmp1); - - lir::Register tmp2(5); - lir::Memory newStackSrc(ThreadRegister, stackOffsetFromThread); - moveMR(&c, TargetBytesPerWord, &newStackSrc, TargetBytesPerWord, &tmp2); - - lir::Register stack(StackRegister); - subR(&c, TargetBytesPerWord, &stack, &tmp2, &tmp2); - - lir::Memory stackDst(StackRegister, 0, tmp2.low); - moveAndUpdateRM - (&c, TargetBytesPerWord, &tmp1, TargetBytesPerWord, &stackDst); - - return_(&c); - } - - virtual void apply(lir::Operation op) { - arch_->c.operations[op](&c); - } - - virtual void apply(lir::UnaryOperation op, OperandInfo a) - { - arch_->c.unaryOperations[Multimethod::index(op, a.type)] - (&c, a.size, a.operand); - } - - virtual void apply(lir::BinaryOperation op, OperandInfo a, OperandInfo b) - { - arch_->c.binaryOperations[index(&(arch_->c), op, a.type, b.type)] - (&c, a.size, a.operand, b.size, b.operand); - } - - virtual void apply(lir::TernaryOperation op, OperandInfo a, OperandInfo b, OperandInfo c) - { - if (isBranch(op)) { - assert(&this->c, a.size == b.size); - assert(&this->c, c.size == TargetBytesPerWord); - assert(&this->c, c.type == lir::ConstantOperand); - - arch_->c.branchOperations[branchIndex(&(arch_->c), a.type, b.type)] - (&this->c, op, a.size, a.operand, b.operand, c.operand); - } else { - assert(&this->c, b.size == c.size); - assert(&this->c, b.type == lir::RegisterOperand); - assert(&this->c, c.type == lir::RegisterOperand); - - arch_->c.ternaryOperations[index(&(arch_->c), op, a.type)] - (&this->c, b.size, a.operand, b.operand, c.operand); - } - } - - virtual void setDestination(uint8_t* dst) { - c.result = dst; - } - - virtual void write() { - uint8_t* dst = c.result; - unsigned dstOffset = 0; - for (MyBlock* b = c.firstBlock; b; b = b->next) { - if (DebugJumps) { - fprintf(stderr, "write block %p\n", b); - } - - unsigned blockOffset = 0; - for (JumpEvent* e = b->jumpEventHead; e; e = e->next) { - unsigned size = e->offset - blockOffset; - memcpy(dst + dstOffset, - c.code.data.begin() + b->offset + blockOffset, - size); - blockOffset = e->offset; - dstOffset += size; - - unsigned jumpTableSize = 0; - for (JumpOffset* o = e->jumpOffsetHead; o; o = o->next) { - if (DebugJumps) { - fprintf(stderr, "visit offset %p %d in block %p\n", - o, o->offset, b); - } - - uint8_t* address = dst + dstOffset + jumpTableSize; - - if (needJump(b)) { - address += TargetBytesPerWord; - } - - o->task->jumpAddress = address; - - jumpTableSize += TargetBytesPerWord; - } - - assert(&c, jumpTableSize); - - bool jump = needJump(b); - if (jump) { - write4(dst + dstOffset, isa::b(jumpTableSize + TargetBytesPerWord)); - } - - dstOffset += jumpTableSize + (jump ? TargetBytesPerWord : 0); - } - - unsigned size = b->size - blockOffset; - - memcpy( - dst + dstOffset, c.code.data.begin() + b->offset + blockOffset, size); - - dstOffset += size; - } - - unsigned index = dstOffset; - assert(&c, index % TargetBytesPerWord == 0); - for (ConstantPoolEntry* e = c.constantPool; e; e = e->next) { - e->address = dst + index; - index += TargetBytesPerWord; - } - - for (Task* t = c.tasks; t; t = t->next) { - t->run(&c); - } - - for (ConstantPoolEntry* e = c.constantPool; e; e = e->next) { - *static_cast(e->address) = e->constant->value(); -// fprintf(stderr, "constant %p at %p\n", reinterpret_cast(e->constant->value()), e->address); - } - } - - virtual Promise* offset(bool) { - return powerpc::offsetPromise(&c); - } - - virtual Block* endBlock(bool startNew) { - MyBlock* b = c.lastBlock; - b->size = c.code.length() - b->offset; - if (startNew) { - c.lastBlock = new(c.zone) MyBlock(&c, c.code.length()); - } else { - c.lastBlock = 0; - } - return b; - } - - virtual void endEvent() { - MyBlock* b = c.lastBlock; - unsigned thisEventOffset = c.code.length() - b->offset; - if (b->jumpOffsetHead) { - int32_t v = (thisEventOffset + TargetBytesPerWord) - - b->jumpOffsetHead->offset; - - if (v > 0 and not bounded(2, 16, v)) { - appendJumpEvent - (&c, b, b->lastEventOffset, b->jumpOffsetHead, - b->lastJumpOffsetTail); - - if (DebugJumps) { - for (JumpOffset* o = b->jumpOffsetHead; - o != b->lastJumpOffsetTail->next; o = o->next) - { - fprintf(stderr, - "in endEvent, include %p %d in jump event %p " - "at offset %d in block %p\n", - o, o->offset, b->jumpEventTail, b->lastEventOffset, b); - } - } - - b->jumpOffsetHead = b->lastJumpOffsetTail->next; - b->lastJumpOffsetTail->next = 0; - if (b->jumpOffsetHead == 0) { - b->jumpOffsetTail = 0; - } - } - } - b->lastEventOffset = thisEventOffset; - b->lastJumpOffsetTail = b->jumpOffsetTail; - } - - virtual unsigned length() { - return c.code.length(); - } - - virtual unsigned footerSize() { - return c.constantPoolCount * TargetBytesPerWord; - } - - virtual void dispose() { - c.code.dispose(); - } - - Context c; - MyArchitecture* arch_; -}; - -Assembler* MyArchitecture::makeAssembler(util::Allocator* allocator, Zone* zone) -{ - return new(zone) MyAssembler(this->c.s, allocator, zone, this); -} - -} // namespace powerpc - -Architecture* -makeArchitecturePowerpc(System* system, bool) -{ - return new (allocate(system, sizeof(powerpc::MyArchitecture))) powerpc::MyArchitecture(system); -} - -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/block.cpp b/src/codegen/target/powerpc/block.cpp deleted file mode 100644 index 7179616def..0000000000 --- a/src/codegen/target/powerpc/block.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "context.h" -#include "block.h" -#include "avian/common.h" - -namespace avian { -namespace codegen { -namespace powerpc { - -void resolve(MyBlock*); - -unsigned padding(MyBlock*, unsigned); - -MyBlock::MyBlock(Context* context, unsigned offset): - context(context), next(0), jumpOffsetHead(0), jumpOffsetTail(0), - lastJumpOffsetTail(0), jumpEventHead(0), jumpEventTail(0), - lastEventOffset(0), offset(offset), start(~0), size(0), resolved(false) -{ } - -unsigned MyBlock::resolve(unsigned start, Assembler::Block* next) { - this->start = start; - this->next = static_cast(next); - - powerpc::resolve(this); - - this->resolved = true; - - return start + size + padding(this, size); -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/block.h b/src/codegen/target/powerpc/block.h deleted file mode 100644 index 10c5909620..0000000000 --- a/src/codegen/target/powerpc/block.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_BLOCK_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_BLOCK_H - -namespace avian { -namespace codegen { -namespace powerpc { - -class JumpEvent; - -class MyBlock: public Assembler::Block { - public: - MyBlock(Context* context, unsigned offset); - - virtual unsigned resolve(unsigned start, Assembler::Block* next); - - Context* context; - MyBlock* next; - JumpOffset* jumpOffsetHead; - JumpOffset* jumpOffsetTail; - JumpOffset* lastJumpOffsetTail; - JumpEvent* jumpEventHead; - JumpEvent* jumpEventTail; - unsigned lastEventOffset; - unsigned offset; - unsigned start; - unsigned size; - bool resolved; -}; - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_BLOCK_H diff --git a/src/codegen/target/powerpc/context.cpp b/src/codegen/target/powerpc/context.cpp deleted file mode 100644 index acfcea2c03..0000000000 --- a/src/codegen/target/powerpc/context.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "context.h" -#include "block.h" -#include "avian/common.h" - -namespace avian { -namespace codegen { -namespace powerpc { - -Context::Context(vm::System* s, util::Allocator* a, vm::Zone* zone) - : s(s), - zone(zone), - client(0), - code(s, a, 1024), - tasks(0), - result(0), - firstBlock(new (zone) MyBlock(this, 0)), - lastBlock(firstBlock), - jumpOffsetHead(0), - jumpOffsetTail(0), - constantPool(0), - constantPoolCount(0) -{ -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/context.h b/src/codegen/target/powerpc/context.h deleted file mode 100644 index 325e6d09c5..0000000000 --- a/src/codegen/target/powerpc/context.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_CONTEXT_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_CONTEXT_H - -#include -#include "avian/alloc-vector.h" - -#ifdef powerpc -#undef powerpc -#endif - -namespace vm { -class System; -class Zone; -} // namespace vm - - -namespace avian { - -namespace util { -class Allocator; -} - -namespace codegen { -namespace powerpc { - -class Task; -class JumpOffset; -class ConstantPoolEntry; -class MyBlock; - -class Context { - public: - Context(vm::System* s, util::Allocator* a, vm::Zone* zone); - - vm::System* s; - vm::Zone* zone; - Assembler::Client* client; - vm::Vector code; - Task* tasks; - uint8_t* result; - MyBlock* firstBlock; - MyBlock* lastBlock; - JumpOffset* jumpOffsetHead; - JumpOffset* jumpOffsetTail; - ConstantPoolEntry* constantPool; - unsigned constantPoolCount; -}; - -typedef void (*OperationType)(Context*); - -typedef void (*UnaryOperationType)(Context*, unsigned, lir::Operand*); - -typedef void (*BinaryOperationType) -(Context*, unsigned, lir::Operand*, unsigned, lir::Operand*); - -typedef void (*TernaryOperationType) -(Context*, unsigned, lir::Operand*, lir::Operand*, - lir::Operand*); - -typedef void (*BranchOperationType) -(Context*, lir::TernaryOperation, unsigned, lir::Operand*, - lir::Operand*, lir::Operand*); - -class ArchitectureContext { - public: - ArchitectureContext(vm::System* s): s(s) { } - - vm::System* s; - OperationType operations[lir::OperationCount]; - UnaryOperationType unaryOperations[lir::UnaryOperationCount - * lir::OperandTypeCount]; - BinaryOperationType binaryOperations - [lir::BinaryOperationCount * lir::OperandTypeCount * lir::OperandTypeCount]; - TernaryOperationType ternaryOperations - [lir::NonBranchTernaryOperationCount * lir::OperandTypeCount]; - BranchOperationType branchOperations - [lir::BranchOperationCount * lir::OperandTypeCount * lir::OperandTypeCount]; -}; - -inline avian::util::Aborter* getAborter(Context* con) { - return con->s; -} - -inline avian::util::Aborter* getAborter(ArchitectureContext* con) { - return con->s; -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_CONTEXT_H diff --git a/src/codegen/target/powerpc/encode.h b/src/codegen/target/powerpc/encode.h deleted file mode 100644 index 1fe17ae265..0000000000 --- a/src/codegen/target/powerpc/encode.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_ENCODE_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_ENCODE_H - -#ifdef powerpc -#undef powerpc -#endif - -namespace avian { -namespace codegen { -namespace powerpc { - -namespace isa { -// INSTRUCTION FORMATS -inline int D(int op, int rt, int ra, int d) { return op<<26|rt<<21|ra<<16|(d & 0xFFFF); } -// inline int DS(int op, int rt, int ra, int ds, int xo) { return op<<26|rt<<21|ra<<16|ds<<2|xo; } -inline int I(int op, int li, int aa, int lk) { return op<<26|(li & 0x3FFFFFC)|aa<<1|lk; } -inline int B(int op, int bo, int bi, int bd, int aa, int lk) { return op<<26|bo<<21|bi<<16|(bd & 0xFFFC)|aa<<1|lk; } -// inline int SC(int op, int lev) { return op<<26|lev<<5|2; } -inline int X(int op, int rt, int ra, int rb, int xo, int rc) { return op<<26|rt<<21|ra<<16|rb<<11|xo<<1|rc; } -inline int XL(int op, int bt, int ba, int bb, int xo, int lk) { return op<<26|bt<<21|ba<<16|bb<<11|xo<<1|lk; } -inline int XFX(int op, int rt, int spr, int xo) { return op<<26|rt<<21|((spr >> 5) | ((spr << 5) & 0x3E0))<<11|xo<<1; } -// inline int XFL(int op, int flm, int frb, int xo, int rc) { return op<<26|flm<<17|frb<<11|xo<<1|rc; } -// inline int XS(int op, int rs, int ra, int sh, int xo, int sh2, int rc) { return op<<26|rs<<21|ra<<16|sh<<11|xo<<2|sh2<<1|rc; } -inline int XO(int op, int rt, int ra, int rb, int oe, int xo, int rc) { return op<<26|rt<<21|ra<<16|rb<<11|oe<<10|xo<<1|rc; } -// inline int A(int op, int frt, int fra, int frb, int frc, int xo, int rc) { return op<<26|frt<<21|fra<<16|frb<<11|frc<<6|xo<<1|rc; } -inline int M(int op, int rs, int ra, int rb, int mb, int me, int rc) { return op<<26|rs<<21|ra<<16|rb<<11|mb<<6|me<<1|rc; } -// inline int MD(int op, int rs, int ra, int sh, int mb, int xo, int sh2, int rc) { return op<<26|rs<<21|ra<<16|sh<<11|mb<<5|xo<<2|sh2<<1|rc; } -// inline int MDS(int op, int rs, int ra, int rb, int mb, int xo, int rc) { return op<<26|rs<<21|ra<<16|rb<<11|mb<<5|xo<<1|rc; } -// INSTRUCTIONS -inline int lbz(int rt, int ra, int i) { return D(34, rt, ra, i); } -inline int lbzx(int rt, int ra, int rb) { return X(31, rt, ra, rb, 87, 0); } -inline int lha(int rt, int ra, int i) { return D(42, rt, ra, i); } -inline int lhax(int rt, int ra, int rb) { return X(31, rt, ra, rb, 343, 0); } -// inline int lhz(int rt, int ra, int i) { return D(40, rt, ra, i); } -inline int lhzx(int rt, int ra, int rb) { return X(31, rt, ra, rb, 279, 0); } -inline int lwz(int rt, int ra, int i) { return D(32, rt, ra, i); } -inline int lwzx(int rt, int ra, int rb) { return X(31, rt, ra, rb, 23, 0); } -inline int stb(int rs, int ra, int i) { return D(38, rs, ra, i); } -inline int stbx(int rs, int ra, int rb) { return X(31, rs, ra, rb, 215, 0); } -inline int sth(int rs, int ra, int i) { return D(44, rs, ra, i); } -inline int sthx(int rs, int ra, int rb) { return X(31, rs, ra, rb, 407, 0); } -inline int stw(int rs, int ra, int i) { return D(36, rs, ra, i); } -inline int stwu(int rs, int ra, int i) { return D(37, rs, ra, i); } -inline int stwux(int rs, int ra, int rb) { return X(31, rs, ra, rb, 183, 0); } -inline int stwx(int rs, int ra, int rb) { return X(31, rs, ra, rb, 151, 0); } -inline int add(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 266, 0); } -inline int addc(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 10, 0); } -inline int adde(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 138, 0); } -inline int addi(int rt, int ra, int i) { return D(14, rt, ra, i); } -inline int addic(int rt, int ra, int i) { return D(12, rt, ra, i); } -inline int addis(int rt, int ra, int i) { return D(15, rt, ra, i); } -inline int subf(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 40, 0); } -inline int subfc(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 8, 0); } -inline int subfe(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 136, 0); } -inline int subfic(int rt, int ra, int i) { return D(8, rt, ra, i); } -inline int subfze(int rt, int ra) { return XO(31, rt, ra, 0, 0, 200, 0); } -inline int mullw(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 235, 0); } -// inline int mulhw(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 75, 0); } -inline int mulhwu(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 11, 0); } -// inline int mulli(int rt, int ra, int i) { return D(7, rt, ra, i); } -inline int divw(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 491, 0); } -// inline int divwu(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 459, 0); } -// inline int divd(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 489, 0); } -// inline int divdu(int rt, int ra, int rb) { return XO(31, rt, ra, rb, 0, 457, 0); } -inline int neg(int rt, int ra) { return XO(31, rt, ra, 0, 0, 104, 0); } -inline int and_(int rt, int ra, int rb) { return X(31, ra, rt, rb, 28, 0); } -inline int andi(int rt, int ra, int i) { return D(28, ra, rt, i); } -inline int andis(int rt, int ra, int i) { return D(29, ra, rt, i); } -inline int or_(int rt, int ra, int rb) { return X(31, ra, rt, rb, 444, 0); } -inline int ori(int rt, int ra, int i) { return D(24, rt, ra, i); } -inline int xor_(int rt, int ra, int rb) { return X(31, ra, rt, rb, 316, 0); } -inline int oris(int rt, int ra, int i) { return D(25, rt, ra, i); } -inline int xori(int rt, int ra, int i) { return D(26, rt, ra, i); } -inline int xoris(int rt, int ra, int i) { return D(27, rt, ra, i); } -inline int rlwinm(int rt, int ra, int i, int mb, int me) { return M(21, ra, rt, i, mb, me, 0); } -inline int rlwimi(int rt, int ra, int i, int mb, int me) { return M(20, ra, rt, i, mb, me, 0); } -inline int slw(int rt, int ra, int sh) { return X(31, ra, rt, sh, 24, 0); } -// inline int sld(int rt, int ra, int rb) { return X(31, ra, rt, rb, 27, 0); } -inline int srw(int rt, int ra, int sh) { return X(31, ra, rt, sh, 536, 0); } -inline int sraw(int rt, int ra, int sh) { return X(31, ra, rt, sh, 792, 0); } -inline int srawi(int rt, int ra, int sh) { return X(31, ra, rt, sh, 824, 0); } -inline int extsb(int rt, int rs) { return X(31, rs, rt, 0, 954, 0); } -inline int extsh(int rt, int rs) { return X(31, rs, rt, 0, 922, 0); } -inline int mfspr(int rt, int spr) { return XFX(31, rt, spr, 339); } -inline int mtspr(int spr, int rs) { return XFX(31, rs, spr, 467); } -inline int b(int i) { return I(18, i, 0, 0); } -inline int bl(int i) { return I(18, i, 0, 1); } -inline int bcctr(int bo, int bi, int lk) { return XL(19, bo, bi, 0, 528, lk); } -inline int bclr(int bo, int bi, int lk) { return XL(19, bo, bi, 0, 16, lk); } -inline int bc(int bo, int bi, int bd, int lk) { return B(16, bo, bi, bd, 0, lk); } -inline int cmp(int bf, int ra, int rb) { return X(31, bf << 2, ra, rb, 0, 0); } -inline int cmpl(int bf, int ra, int rb) { return X(31, bf << 2, ra, rb, 32, 0); } -inline int cmpi(int bf, int ra, int i) { return D(11, bf << 2, ra, i); } -inline int cmpli(int bf, int ra, int i) { return D(10, bf << 2, ra, i); } -inline int sync(int L) { return X(31, L, 0, 0, 598, 0); } -// PSEUDO-INSTRUCTIONS -inline int li(int rt, int i) { return addi(rt, 0, i); } -inline int lis(int rt, int i) { return addis(rt, 0, i); } -inline int slwi(int rt, int ra, int i) { return rlwinm(rt, ra, i, 0, 31-i); } -inline int srwi(int rt, int ra, int i) { return rlwinm(rt, ra, 32-i, i, 31); } -// inline int sub(int rt, int ra, int rb) { return subf(rt, rb, ra); } -// inline int subc(int rt, int ra, int rb) { return subfc(rt, rb, ra); } -// inline int subi(int rt, int ra, int i) { return addi(rt, ra, -i); } -// inline int subis(int rt, int ra, int i) { return addis(rt, ra, -i); } -inline int mr(int rt, int ra) { return or_(rt, ra, ra); } -inline int mflr(int rx) { return mfspr(rx, 8); } -inline int mtlr(int rx) { return mtspr(8, rx); } -inline int mtctr(int rd) { return mtspr(9, rd); } -inline int bctr() { return bcctr(20, 0, 0); } -inline int bctrl() { return bcctr(20, 0, 1); } -inline int blr() { return bclr(20, 0, 0); } -inline int blt(int i) { return bc(12, 0, i, 0); } -inline int bgt(int i) { return bc(12, 1, i, 0); } -inline int bge(int i) { return bc(4, 0, i, 0); } -inline int ble(int i) { return bc(4, 1, i, 0); } -inline int beq(int i) { return bc(12, 2, i, 0); } -inline int bne(int i) { return bc(4, 2, i, 0); } -inline int cmpw(int ra, int rb) { return cmp(0, ra, rb); } -inline int cmplw(int ra, int rb) { return cmpl(0, ra, rb); } -inline int cmpwi(int ra, int i) { return cmpi(0, ra, i); } -inline int cmplwi(int ra, int i) { return cmpli(0, ra, i); } -inline int trap() { return 0x7fe00008; } // todo: macro-ify - -} // namespace isa - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_ENCODE_H - diff --git a/src/codegen/target/powerpc/fixup.cpp b/src/codegen/target/powerpc/fixup.cpp deleted file mode 100644 index a430133cf7..0000000000 --- a/src/codegen/target/powerpc/fixup.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "context.h" -#include "block.h" -#include "fixup.h" -#include "encode.h" - -namespace avian { -namespace codegen { -namespace powerpc { - -using namespace isa; -using namespace util; - -unsigned padding(MyBlock*, unsigned); - -int ha16(int32_t i); - -bool bounded(int right, int left, int32_t v) { - return ((v << left) >> left) == v and ((v >> right) << right) == v; -} - -OffsetPromise::OffsetPromise(Context* c, MyBlock* block, unsigned offset): - c(c), block(block), offset(offset) -{ } - -bool OffsetPromise::resolved() { - return block->resolved; -} - -int64_t OffsetPromise::value() { - assert(c, resolved()); - - unsigned o = offset - block->offset; - return block->start + padding(block, o) + o; -} - -Promise* offsetPromise(Context* c) { - return new(c->zone) OffsetPromise(c, c->lastBlock, c->code.length()); -} - -void* updateOffset(vm::System* s, uint8_t* instruction, bool conditional, int64_t value, - void* jumpAddress) -{ - int32_t v = reinterpret_cast(value) - instruction; - - int32_t mask; - if (conditional) { - if (not bounded(2, 16, v)) { - *static_cast(jumpAddress) = isa::b(0); - updateOffset(s, static_cast(jumpAddress), false, value, 0); - - v = static_cast(jumpAddress) - instruction; - - expect(s, bounded(2, 16, v)); - } - mask = 0xFFFC; - } else { - expect(s, bounded(2, 6, v)); - mask = 0x3FFFFFC; - } - - int32_t* p = reinterpret_cast(instruction); - *p = vm::targetV4((v & mask) | ((~mask) & vm::targetV4(*p))); - - return instruction + 4; -} - -OffsetListener::OffsetListener(vm::System* s, uint8_t* instruction, bool conditional, - void* jumpAddress): - s(s), - instruction(instruction), - jumpAddress(jumpAddress), - conditional(conditional) -{ } - -bool OffsetListener::resolve(int64_t value, void** location) { - void* p = updateOffset(s, instruction, conditional, value, jumpAddress); - if (location) *location = p; - return false; -} - -OffsetTask::OffsetTask(Task* next, Promise* promise, Promise* instructionOffset, - bool conditional): - Task(next), - promise(promise), - instructionOffset(instructionOffset), - jumpAddress(0), - conditional(conditional) -{ } - -void OffsetTask::run(Context* c) { - if (promise->resolved()) { - updateOffset - (c->s, c->result + instructionOffset->value(), conditional, - promise->value(), jumpAddress); - } else { - new (promise->listen(sizeof(OffsetListener))) - OffsetListener(c->s, c->result + instructionOffset->value(), - conditional, jumpAddress); - } -} - -JumpOffset::JumpOffset(MyBlock* block, OffsetTask* task, unsigned offset): - block(block), task(task), next(0), offset(offset) -{ } - -JumpEvent::JumpEvent(JumpOffset* jumpOffsetHead, JumpOffset* jumpOffsetTail, - unsigned offset): - jumpOffsetHead(jumpOffsetHead), jumpOffsetTail(jumpOffsetTail), next(0), - offset(offset) -{ } - -void appendOffsetTask(Context* c, Promise* promise, Promise* instructionOffset, - bool conditional) -{ - OffsetTask* task = new(c->zone) OffsetTask(c->tasks, promise, instructionOffset, conditional); - - c->tasks = task; - - if (conditional) { - JumpOffset* offset = - new(c->zone) JumpOffset(c->lastBlock, task, c->code.length() - c->lastBlock->offset); - - if (c->lastBlock->jumpOffsetTail) { - c->lastBlock->jumpOffsetTail->next = offset; - } else { - c->lastBlock->jumpOffsetHead = offset; - } - c->lastBlock->jumpOffsetTail = offset; - } -} - -void appendJumpEvent(Context* c, MyBlock* b, unsigned offset, JumpOffset* head, - JumpOffset* tail) -{ - JumpEvent* e = new(c->zone) JumpEvent - (head, tail, offset); - - if (b->jumpEventTail) { - b->jumpEventTail->next = e; - } else { - b->jumpEventHead = e; - } - b->jumpEventTail = e; -} - -ShiftMaskPromise* shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask) { - return new (c->zone) ShiftMaskPromise(base, shift, mask); -} - -void -updateImmediate(vm::System* s, void* dst, int32_t src, unsigned size, bool address) -{ - switch (size) { - case 4: { - int32_t* p = static_cast(dst); - int r = (vm::targetV4(p[1]) >> 21) & 31; - - if (address) { - p[0] = vm::targetV4(lis(r, ha16(src))); - p[1] |= vm::targetV4(src & 0xFFFF); - } else { - p[0] = vm::targetV4(lis(r, src >> 16)); - p[1] = vm::targetV4(ori(r, r, src)); - } - } break; - - default: abort(s); - } -} - -ImmediateListener::ImmediateListener(vm::System* s, void* dst, unsigned size, unsigned offset, - bool address): - s(s), dst(dst), size(size), offset(offset), address(address) -{ } - -bool ImmediateListener::resolve(int64_t value, void** location) { - updateImmediate(s, dst, value, size, address); - if (location) *location = static_cast(dst) + offset; - return false; -} - -ImmediateTask::ImmediateTask(Task* next, Promise* promise, Promise* offset, unsigned size, - unsigned promiseOffset, bool address): - Task(next), - promise(promise), - offset(offset), - size(size), - promiseOffset(promiseOffset), - address(address) -{ } - -void ImmediateTask::run(Context* c) { - if (promise->resolved()) { - updateImmediate - (c->s, c->result + offset->value(), promise->value(), size, address); - } else { - new (promise->listen(sizeof(ImmediateListener))) ImmediateListener - (c->s, c->result + offset->value(), size, promiseOffset, address); - } -} - -void -appendImmediateTask(Context* c, Promise* promise, Promise* offset, - unsigned size, unsigned promiseOffset, bool address) -{ - c->tasks = new(c->zone) ImmediateTask(c->tasks, promise, offset, size, promiseOffset, address); -} - -ConstantPoolEntry::ConstantPoolEntry(Context* c, Promise* constant): - c(c), constant(constant), next(c->constantPool), address(0) -{ - c->constantPool = this; - ++ c->constantPoolCount; -} - -int64_t ConstantPoolEntry::value() { - assert(c, resolved()); - - return reinterpret_cast(address); -} - -bool ConstantPoolEntry::resolved() { - return address != 0; -} - -ConstantPoolEntry* appendConstantPoolEntry(Context* c, Promise* constant) { - return new (c->zone) ConstantPoolEntry(c, constant); -} - - -} // namespace powerpc -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/fixup.h b/src/codegen/target/powerpc/fixup.h deleted file mode 100644 index 27778bb1fc..0000000000 --- a/src/codegen/target/powerpc/fixup.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_FIXUP_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_FIXUP_H - -namespace avian { -namespace codegen { -namespace powerpc { - - -class Task { - public: - Task(Task* next): next(next) { } - - virtual void run(Context* c) = 0; - - Task* next; -}; - -class OffsetPromise: public Promise { - public: - OffsetPromise(Context* c, MyBlock* block, unsigned offset); - - virtual bool resolved(); - - virtual int64_t value(); - - Context* c; - MyBlock* block; - unsigned offset; -}; - -Promise* offsetPromise(Context* c); - -void* -updateOffset(vm::System* s, uint8_t* instruction, bool conditional, int64_t value, - void* jumpAddress); - -class OffsetListener: public Promise::Listener { - public: - OffsetListener(vm::System* s, uint8_t* instruction, bool conditional, - void* jumpAddress); - - virtual bool resolve(int64_t value, void** location); - - vm::System* s; - uint8_t* instruction; - void* jumpAddress; - bool conditional; -}; - -class OffsetTask: public Task { - public: - OffsetTask(Task* next, Promise* promise, Promise* instructionOffset, - bool conditional); - - virtual void run(Context* c); - - Promise* promise; - Promise* instructionOffset; - void* jumpAddress; - bool conditional; -}; - -class JumpOffset { - public: - JumpOffset(MyBlock* block, OffsetTask* task, unsigned offset); - - MyBlock* block; - OffsetTask* task; - JumpOffset* next; - unsigned offset; -}; - -class JumpEvent { - public: - JumpEvent(JumpOffset* jumpOffsetHead, JumpOffset* jumpOffsetTail, - unsigned offset); - - JumpOffset* jumpOffsetHead; - JumpOffset* jumpOffsetTail; - JumpEvent* next; - unsigned offset; -}; - -void appendOffsetTask(Context* c, Promise* promise, Promise* instructionOffset, - bool conditional); - -void appendJumpEvent(Context* c, MyBlock* b, unsigned offset, JumpOffset* head, - JumpOffset* tail); - -ShiftMaskPromise* shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask); - -void updateImmediate(vm::System* s, void* dst, int32_t src, unsigned size, bool address); - -class ImmediateListener: public Promise::Listener { - public: - ImmediateListener(vm::System* s, void* dst, unsigned size, unsigned offset, - bool address); - - virtual bool resolve(int64_t value, void** location); - - vm::System* s; - void* dst; - unsigned size; - unsigned offset; - bool address; -}; - -class ImmediateTask: public Task { - public: - ImmediateTask(Task* next, Promise* promise, Promise* offset, unsigned size, - unsigned promiseOffset, bool address); - - virtual void run(Context* c); - - Promise* promise; - Promise* offset; - unsigned size; - unsigned promiseOffset; - bool address; -}; - -void -appendImmediateTask(Context* c, Promise* promise, Promise* offset, - unsigned size, unsigned promiseOffset, bool address); - -class ConstantPoolEntry: public Promise { - public: - ConstantPoolEntry(Context* c, Promise* constant); - - virtual int64_t value(); - - virtual bool resolved(); - - Context* c; - Promise* constant; - ConstantPoolEntry* next; - void* address; -}; - -ConstantPoolEntry* appendConstantPoolEntry(Context* c, Promise* constant); - -inline int ha16(int32_t i) { - return ((i >> 16) + ((i & 0x8000) ? 1 : 0)) & 0xffff; -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_FIXUP_H diff --git a/src/codegen/target/powerpc/multimethod.cpp b/src/codegen/target/powerpc/multimethod.cpp deleted file mode 100644 index b8214ac62c..0000000000 --- a/src/codegen/target/powerpc/multimethod.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "context.h" -#include "block.h" -#include "avian/common.h" -#include "operations.h" - -#include "multimethod.h" -#include "../multimethod.h" - -namespace avian { -namespace codegen { -namespace powerpc { - -using namespace util; - -unsigned index(ArchitectureContext*, - lir::BinaryOperation operation, - lir::OperandType operand1, - lir::OperandType operand2) -{ - return operation - + (lir::BinaryOperationCount * operand1) - + (lir::BinaryOperationCount * lir::OperandTypeCount * operand2); -} - -unsigned index(ArchitectureContext* c UNUSED, - lir::TernaryOperation operation, - lir::OperandType operand1) -{ - assert(c, not isBranch(operation)); - - return operation + (lir::NonBranchTernaryOperationCount * operand1); -} - -unsigned branchIndex(ArchitectureContext* c UNUSED, lir::OperandType operand1, - lir::OperandType operand2) -{ - return operand1 + (lir::OperandTypeCount * operand2); -} - -void populateTables(ArchitectureContext* c) { - const lir::OperandType C = lir::ConstantOperand; - const lir::OperandType A = lir::AddressOperand; - const lir::OperandType R = lir::RegisterOperand; - const lir::OperandType M = lir::MemoryOperand; - - OperationType* zo = c->operations; - UnaryOperationType* uo = c->unaryOperations; - BinaryOperationType* bo = c->binaryOperations; - TernaryOperationType* to = c->ternaryOperations; - BranchOperationType* bro = c->branchOperations; - - zo[lir::Return] = return_; - zo[lir::LoadBarrier] = memoryBarrier; - zo[lir::StoreStoreBarrier] = memoryBarrier; - zo[lir::StoreLoadBarrier] = memoryBarrier; - zo[lir::Trap] = trap; - - uo[Multimethod::index(lir::LongCall, C)] = CAST1(longCallC); - - uo[Multimethod::index(lir::AlignedLongCall, C)] = CAST1(alignedLongCallC); - - uo[Multimethod::index(lir::LongJump, C)] = CAST1(longJumpC); - - uo[Multimethod::index(lir::AlignedLongJump, C)] = CAST1(alignedLongJumpC); - - uo[Multimethod::index(lir::Jump, R)] = CAST1(jumpR); - uo[Multimethod::index(lir::Jump, C)] = CAST1(jumpC); - - uo[Multimethod::index(lir::AlignedJump, R)] = CAST1(jumpR); - uo[Multimethod::index(lir::AlignedJump, C)] = CAST1(jumpC); - - uo[Multimethod::index(lir::Call, C)] = CAST1(callC); - uo[Multimethod::index(lir::Call, R)] = CAST1(callR); - - uo[Multimethod::index(lir::AlignedCall, C)] = CAST1(callC); - uo[Multimethod::index(lir::AlignedCall, R)] = CAST1(callR); - - bo[index(c, lir::Move, R, R)] = CAST2(moveRR); - bo[index(c, lir::Move, C, R)] = CAST2(moveCR); - bo[index(c, lir::Move, C, M)] = CAST2(moveCM); - bo[index(c, lir::Move, M, R)] = CAST2(moveMR); - bo[index(c, lir::Move, R, M)] = CAST2(moveRM); - bo[index(c, lir::Move, A, R)] = CAST2(moveAR); - - bo[index(c, lir::MoveZ, R, R)] = CAST2(moveZRR); - bo[index(c, lir::MoveZ, M, R)] = CAST2(moveZMR); - bo[index(c, lir::MoveZ, C, R)] = CAST2(moveCR); - - bo[index(c, lir::Negate, R, R)] = CAST2(negateRR); - - to[index(c, lir::Add, R)] = CAST3(addR); - to[index(c, lir::Add, C)] = CAST3(addC); - - to[index(c, lir::Subtract, R)] = CAST3(subR); - to[index(c, lir::Subtract, C)] = CAST3(subC); - - to[index(c, lir::Multiply, R)] = CAST3(multiplyR); - - to[index(c, lir::Divide, R)] = CAST3(divideR); - - to[index(c, lir::Remainder, R)] = CAST3(remainderR); - - to[index(c, lir::ShiftLeft, R)] = CAST3(shiftLeftR); - to[index(c, lir::ShiftLeft, C)] = CAST3(shiftLeftC); - - to[index(c, lir::ShiftRight, R)] = CAST3(shiftRightR); - to[index(c, lir::ShiftRight, C)] = CAST3(shiftRightC); - - to[index(c, lir::UnsignedShiftRight, R)] = CAST3(unsignedShiftRightR); - to[index(c, lir::UnsignedShiftRight, C)] = CAST3(unsignedShiftRightC); - - to[index(c, lir::And, C)] = CAST3(andC); - to[index(c, lir::And, R)] = CAST3(andR); - - to[index(c, lir::Or, C)] = CAST3(orC); - to[index(c, lir::Or, R)] = CAST3(orR); - - to[index(c, lir::Xor, C)] = CAST3(xorC); - to[index(c, lir::Xor, R)] = CAST3(xorR); - - bro[branchIndex(c, R, R)] = CAST_BRANCH(branchRR); - bro[branchIndex(c, C, R)] = CAST_BRANCH(branchCR); - bro[branchIndex(c, C, M)] = CAST_BRANCH(branchCM); - bro[branchIndex(c, R, M)] = CAST_BRANCH(branchRM); -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/multimethod.h b/src/codegen/target/powerpc/multimethod.h deleted file mode 100644 index 12bf1448e2..0000000000 --- a/src/codegen/target/powerpc/multimethod.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_MULTIMETHOD_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_MULTIMETHOD_H - -#define CAST1(x) reinterpret_cast(x) -#define CAST2(x) reinterpret_cast(x) -#define CAST3(x) reinterpret_cast(x) -#define CAST_BRANCH(x) reinterpret_cast(x) - -namespace avian { -namespace codegen { -namespace powerpc { - -unsigned index(ArchitectureContext*, - lir::BinaryOperation operation, - lir::OperandType operand1, - lir::OperandType operand2); - -unsigned index(ArchitectureContext* c UNUSED, - lir::TernaryOperation operation, - lir::OperandType operand1); - -unsigned branchIndex(ArchitectureContext* c UNUSED, lir::OperandType operand1, - lir::OperandType operand2); - -void populateTables(ArchitectureContext* c); - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_MULTIMETHOD_H diff --git a/src/codegen/target/powerpc/operations.cpp b/src/codegen/target/powerpc/operations.cpp deleted file mode 100644 index c439091eb3..0000000000 --- a/src/codegen/target/powerpc/operations.cpp +++ /dev/null @@ -1,1100 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "context.h" -#include "block.h" -#include "avian/common.h" -#include "encode.h" -#include "operations.h" -#include "fixup.h" -#include "multimethod.h" - -using namespace vm; - -namespace avian { -namespace codegen { -namespace powerpc { - -using namespace isa; -using namespace util; - -const int64_t MASK_LO32 = 0x0ffffffff; -const int MASK_LO16 = 0x0ffff; -const int MASK_LO8 = 0x0ff; -// inline int lo32(int64_t i) { return (int)(i & MASK_LO32); } -// inline int hi32(int64_t i) { return lo32(i >> 32); } -inline int lo16(int64_t i) { return (int)(i & MASK_LO16); } -inline int hi16(int64_t i) { return lo16(i >> 16); } -// inline int lo8(int64_t i) { return (int)(i & MASK_LO8); } -// inline int hi8(int64_t i) { return lo8(i >> 8); } - -inline int carry16(target_intptr_t v) { - return static_cast(v) < 0 ? 1 : 0; -} - -void andC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst); - -void shiftLeftR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - if(size == 8) { - lir::Register Tmp(newTemp(con), newTemp(con)); lir::Register* tmp = &Tmp; - emit(con, subfic(tmp->high, a->low, 32)); - emit(con, slw(t->high, b->high, a->low)); - emit(con, srw(tmp->low, b->low, tmp->high)); - emit(con, or_(t->high, t->high, tmp->low)); - emit(con, addi(tmp->high, a->low, -32)); - emit(con, slw(tmp->low, b->low, tmp->high)); - emit(con, or_(t->high, t->high, tmp->low)); - emit(con, slw(t->low, b->low, a->low)); - freeTemp(con, tmp->high); freeTemp(con, tmp->low); - } else { - emit(con, slw(t->low, b->low, a->low)); - } -} - -void moveRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize, lir::Register* dst); - -void shiftLeftC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t) { - int sh = getValue(a); - if (size == 8) { - sh &= 0x3F; - if (sh) { - if (sh < 32) { - emit(con, rlwinm(t->high,b->high,sh,0,31-sh)); - emit(con, rlwimi(t->high,b->low,sh,32-sh,31)); - emit(con, slwi(t->low, b->low, sh)); - } else { - emit(con, rlwinm(t->high,b->low,sh-32,0,63-sh)); - emit(con, li(t->low,0)); - } - } else { - moveRR(con, size, b, size, t); - } - } else { - emit(con, slwi(t->low, b->low, sh & 0x1F)); - } -} - -void shiftRightR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - if(size == 8) { - lir::Register Tmp(newTemp(con), newTemp(con)); lir::Register* tmp = &Tmp; - emit(con, subfic(tmp->high, a->low, 32)); - emit(con, srw(t->low, b->low, a->low)); - emit(con, slw(tmp->low, b->high, tmp->high)); - emit(con, or_(t->low, t->low, tmp->low)); - emit(con, addic(tmp->high, a->low, -32)); - emit(con, sraw(tmp->low, b->high, tmp->high)); - emit(con, ble(8)); - emit(con, ori(t->low, tmp->low, 0)); - emit(con, sraw(t->high, b->high, a->low)); - freeTemp(con, tmp->high); freeTemp(con, tmp->low); - } else { - emit(con, sraw(t->low, b->low, a->low)); - } -} - -void shiftRightC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t) { - int sh = getValue(a); - if(size == 8) { - sh &= 0x3F; - if (sh) { - if (sh < 32) { - emit(con, rlwinm(t->low,b->low,32-sh,sh,31)); - emit(con, rlwimi(t->low,b->high,32-sh,0,sh-1)); - emit(con, srawi(t->high,b->high,sh)); - } else { - emit(con, srawi(t->high,b->high,31)); - emit(con, srawi(t->low,b->high,sh-32)); - } - } else { - moveRR(con, size, b, size, t); - } - } else { - emit(con, srawi(t->low, b->low, sh & 0x1F)); - } -} - -void unsignedShiftRightR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - emit(con, srw(t->low, b->low, a->low)); - if(size == 8) { - lir::Register Tmp(newTemp(con), newTemp(con)); lir::Register* tmp = &Tmp; - emit(con, subfic(tmp->high, a->low, 32)); - emit(con, slw(tmp->low, b->high, tmp->high)); - emit(con, or_(t->low, t->low, tmp->low)); - emit(con, addi(tmp->high, a->low, -32)); - emit(con, srw(tmp->low, b->high, tmp->high)); - emit(con, or_(t->low, t->low, tmp->low)); - emit(con, srw(t->high, b->high, a->low)); - freeTemp(con, tmp->high); freeTemp(con, tmp->low); - } -} - -void unsignedShiftRightC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t) { - int sh = getValue(a); - if (size == 8) { - if (sh & 0x3F) { - if (sh == 32) { - lir::Register high(b->high); - moveRR(con, 4, &high, 4, t); - emit(con, li(t->high,0)); - } else if (sh < 32) { - emit(con, srwi(t->low, b->low, sh)); - emit(con, rlwimi(t->low,b->high,32-sh,0,sh-1)); - emit(con, rlwinm(t->high,b->high,32-sh,sh,31)); - } else { - emit(con, rlwinm(t->low,b->high,64-sh,sh-32,31)); - emit(con, li(t->high,0)); - } - } else { - moveRR(con, size, b, size, t); - } - } else { - if (sh & 0x1F) { - emit(con, srwi(t->low, b->low, sh & 0x1F)); - } else { - moveRR(con, size, b, size, t); - } - } -} - -void jumpR(Context* c, unsigned size UNUSED, lir::Register* target) { - assert(c, size == TargetBytesPerWord); - - emit(c, mtctr(target->low)); - emit(c, bctr()); -} - -void swapRR(Context* c, unsigned aSize, lir::Register* a, - unsigned bSize, lir::Register* b) { - assert(c, aSize == TargetBytesPerWord); - assert(c, bSize == TargetBytesPerWord); - - lir::Register tmp(c->client->acquireTemporary()); - moveRR(c, aSize, a, bSize, &tmp); - moveRR(c, bSize, b, aSize, a); - moveRR(c, bSize, &tmp, bSize, b); - c->client->releaseTemporary(tmp.low); -} - -void moveRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize, lir::Register* dst) { - switch (srcSize) { - case 1: - emit(c, extsb(dst->low, src->low)); - break; - - case 2: - emit(c, extsh(dst->low, src->low)); - break; - - case 4: - case 8: - if (srcSize == 4 and dstSize == 8) { - moveRR(c, 4, src, 4, dst); - emit(c, srawi(dst->high, src->low, 31)); - } else if (srcSize == 8 and dstSize == 8) { - lir::Register srcHigh(src->high); - lir::Register dstHigh(dst->high); - - if (src->high == dst->low) { - if (src->low == dst->high) { - swapRR(c, 4, src, 4, dst); - } else { - moveRR(c, 4, &srcHigh, 4, &dstHigh); - moveRR(c, 4, src, 4, dst); - } - } else { - moveRR(c, 4, src, 4, dst); - moveRR(c, 4, &srcHigh, 4, &dstHigh); - } - } else if (src->low != dst->low) { - emit(c, mr(dst->low, src->low)); - } - break; - - default: abort(c); - } -} - -void moveZRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned, lir::Register* dst) { - switch (srcSize) { - case 2: - emit(c, andi(dst->low, src->low, 0xFFFF)); - break; - - default: abort(c); - } -} - -void moveCR2(Context* c, unsigned, lir::Constant* src, - unsigned dstSize, lir::Register* dst, unsigned promiseOffset) { - if (dstSize <= 4) { - if (src->value->resolved()) { - int32_t v = src->value->value(); - if (fitsInInt16(v)) { - emit(c, li(dst->low, v)); - } else { - emit(c, lis(dst->low, v >> 16)); - emit(c, ori(dst->low, dst->low, v)); - } - } else { - appendImmediateTask - (c, src->value, offsetPromise(c), TargetBytesPerWord, promiseOffset, false); - emit(c, lis(dst->low, 0)); - emit(c, ori(dst->low, dst->low, 0)); - } - } else { - abort(c); // todo - } -} - -void moveCR(Context* c, unsigned srcSize, lir::Constant* src, - unsigned dstSize, lir::Register* dst) { - moveCR2(c, srcSize, src, dstSize, dst, 0); -} - -void addR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - if(size == 8) { - emit(con, addc(t->low, a->low, b->low)); - emit(con, adde(t->high, a->high, b->high)); - } else { - emit(con, add(t->low, a->low, b->low)); - } -} - -void addC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t) { - assert(con, size == TargetBytesPerWord); - - int32_t i = getValue(a); - if(i) { - emit(con, addi(t->low, b->low, lo16(i))); - if(not fitsInInt16(i)) - emit(con, addis(t->low, t->low, hi16(i) + carry16(i))); - } else { - moveRR(con, size, b, size, t); - } -} - -void subR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - if(size == 8) { - emit(con, subfc(t->low, a->low, b->low)); - emit(con, subfe(t->high, a->high, b->high)); - } else { - emit(con, subf(t->low, a->low, b->low)); - } -} - -void subC(Context* c, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t) { - assert(c, size == TargetBytesPerWord); - - ResolvedPromise promise(- a->value->value()); - lir::Constant constant(&promise); - addC(c, size, &constant, b, t); -} - -void multiplyR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - if(size == 8) { - bool useTemporaries = b->low == t->low; - int tmpLow; - int tmpHigh; - if (useTemporaries) { - tmpLow = con->client->acquireTemporary(); - tmpHigh = con->client->acquireTemporary(); - } else { - tmpLow = t->low; - tmpHigh = t->high; - } - - emit(con, mullw(tmpHigh, a->high, b->low)); - emit(con, mullw(tmpLow, a->low, b->high)); - emit(con, add(t->high, tmpHigh, tmpLow)); - emit(con, mulhwu(tmpLow, a->low, b->low)); - emit(con, add(t->high, t->high, tmpLow)); - emit(con, mullw(t->low, a->low, b->low)); - - if (useTemporaries) { - con->client->releaseTemporary(tmpLow); - con->client->releaseTemporary(tmpHigh); - } - } else { - emit(con, mullw(t->low, a->low, b->low)); - } -} - -void divideR(Context* con, unsigned size UNUSED, lir::Register* a, lir::Register* b, lir::Register* t) { - assert(con, size == 4); - emit(con, divw(t->low, b->low, a->low)); -} - -void remainderR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t) { - bool useTemporary = b->low == t->low; - lir::Register tmp(t->low); - if (useTemporary) { - tmp.low = con->client->acquireTemporary(); - } - - divideR(con, size, a, b, &tmp); - multiplyR(con, size, a, &tmp, &tmp); - subR(con, size, &tmp, b, t); - - if (useTemporary) { - con->client->releaseTemporary(tmp.low); - } -} - -int -normalize(Context* c, int offset, int index, unsigned scale, - bool* preserveIndex, bool* release) { - if (offset != 0 or scale != 1) { - lir::Register normalizedIndex - (*preserveIndex ? c->client->acquireTemporary() : index); - - if (*preserveIndex) { - *release = true; - *preserveIndex = false; - } else { - *release = false; - } - - int scaled; - - if (scale != 1) { - lir::Register unscaledIndex(index); - - ResolvedPromise scalePromise(log(scale)); - lir::Constant scaleConstant(&scalePromise); - - shiftLeftC(c, TargetBytesPerWord, &scaleConstant, - &unscaledIndex, &normalizedIndex); - - scaled = normalizedIndex.low; - } else { - scaled = index; - } - - if (offset != 0) { - lir::Register untranslatedIndex(scaled); - - ResolvedPromise offsetPromise(offset); - lir::Constant offsetConstant(&offsetPromise); - - addC(c, TargetBytesPerWord, &offsetConstant, - &untranslatedIndex, &normalizedIndex); - } - - return normalizedIndex.low; - } else { - *release = false; - return index; - } -} - -void store(Context* c, unsigned size, lir::Register* src, - int base, int offset, int index, unsigned scale, bool preserveIndex) { - if (index != lir::NoRegister) { - bool release; - int normalized = normalize - (c, offset, index, scale, &preserveIndex, &release); - - switch (size) { - case 1: - emit(c, stbx(src->low, base, normalized)); - break; - - case 2: - emit(c, sthx(src->low, base, normalized)); - break; - - case 4: - emit(c, stwx(src->low, base, normalized)); - break; - - case 8: { - lir::Register srcHigh(src->high); - store(c, 4, &srcHigh, base, 0, normalized, 1, preserveIndex); - store(c, 4, src, base, 4, normalized, 1, preserveIndex); - } break; - - default: abort(c); - } - - if (release) c->client->releaseTemporary(normalized); - } else { - switch (size) { - case 1: - emit(c, stb(src->low, base, offset)); - break; - - case 2: - emit(c, sth(src->low, base, offset)); - break; - - case 4: - emit(c, stw(src->low, base, offset)); - break; - - case 8: { - lir::Register srcHigh(src->high); - store(c, 4, &srcHigh, base, offset, lir::NoRegister, 1, false); - store(c, 4, src, base, offset + 4, lir::NoRegister, 1, false); - } break; - - default: abort(c); - } - } -} - -void moveRM(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize UNUSED, lir::Memory* dst) { - assert(c, srcSize == dstSize); - - store(c, srcSize, src, dst->base, dst->offset, dst->index, dst->scale, true); -} - -void moveAndUpdateRM(Context* c, unsigned srcSize UNUSED, lir::Register* src, - unsigned dstSize UNUSED, lir::Memory* dst) { - assert(c, srcSize == TargetBytesPerWord); - assert(c, dstSize == TargetBytesPerWord); - - if (dst->index == lir::NoRegister) { - emit(c, stwu(src->low, dst->base, dst->offset)); - } else { - assert(c, dst->offset == 0); - assert(c, dst->scale == 1); - - emit(c, stwux(src->low, dst->base, dst->index)); - } -} - -void load(Context* c, unsigned srcSize, int base, int offset, int index, - unsigned scale, unsigned dstSize, lir::Register* dst, - bool preserveIndex, bool signExtend) { - if (index != lir::NoRegister) { - bool release; - int normalized = normalize - (c, offset, index, scale, &preserveIndex, &release); - - switch (srcSize) { - case 1: - emit(c, lbzx(dst->low, base, normalized)); - if (signExtend) { - emit(c, extsb(dst->low, dst->low)); - } - break; - - case 2: - if (signExtend) { - emit(c, lhax(dst->low, base, normalized)); - } else { - emit(c, lhzx(dst->low, base, normalized)); - } - break; - - case 4: - case 8: { - if (srcSize == 4 and dstSize == 8) { - load(c, 4, base, 0, normalized, 1, 4, dst, preserveIndex, false); - moveRR(c, 4, dst, 8, dst); - } else if (srcSize == 8 and dstSize == 8) { - lir::Register dstHigh(dst->high); - load(c, 4, base, 0, normalized, 1, 4, &dstHigh, preserveIndex, false); - load(c, 4, base, 4, normalized, 1, 4, dst, preserveIndex, false); - } else { - emit(c, lwzx(dst->low, base, normalized)); - } - } break; - - default: abort(c); - } - - if (release) c->client->releaseTemporary(normalized); - } else { - switch (srcSize) { - case 1: - emit(c, lbz(dst->low, base, offset)); - if (signExtend) { - emit(c, extsb(dst->low, dst->low)); - } - break; - - case 2: - if (signExtend) { - emit(c, lha(dst->low, base, offset)); - } else { - emit(c, lha(dst->low, base, offset)); - } - break; - - case 4: - emit(c, lwz(dst->low, base, offset)); - break; - - case 8: { - if (dstSize == 8) { - lir::Register dstHigh(dst->high); - load(c, 4, base, offset, lir::NoRegister, 1, 4, &dstHigh, false, false); - load(c, 4, base, offset + 4, lir::NoRegister, 1, 4, dst, false, false); - } else { - emit(c, lwzx(dst->low, base, offset)); - } - } break; - - default: abort(c); - } - } -} - -void moveMR(Context* c, unsigned srcSize, lir::Memory* src, - unsigned dstSize, lir::Register* dst) { - load(c, srcSize, src->base, src->offset, src->index, src->scale, - dstSize, dst, true, true); -} - -void moveZMR(Context* c, unsigned srcSize, lir::Memory* src, - unsigned dstSize, lir::Register* dst) { - load(c, srcSize, src->base, src->offset, src->index, src->scale, - dstSize, dst, true, false); -} - -void andR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst) { - if (size == 8) { - lir::Register ah(a->high); - lir::Register bh(b->high); - lir::Register dh(dst->high); - - andR(c, 4, a, b, dst); - andR(c, 4, &ah, &bh, &dh); - } else { - emit(c, and_(dst->low, a->low, b->low)); - } -} - -void andC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst) { - int64_t v = a->value->value(); - - if (size == 8) { - ResolvedPromise high((v >> 32) & 0xFFFFFFFF); - lir::Constant ah(&high); - - ResolvedPromise low(v & 0xFFFFFFFF); - lir::Constant al(&low); - - lir::Register bh(b->high); - lir::Register dh(dst->high); - - andC(c, 4, &al, b, dst); - andC(c, 4, &ah, &bh, &dh); - } else { - // bitmasks of the form regex 0*1*0* can be handled in a single - // rlwinm instruction, hence the following: - - uint32_t v32 = static_cast(v); - unsigned state = 0; - unsigned start = 0; - unsigned end = 31; - for (unsigned i = 0; i < 32; ++i) { - unsigned bit = (v32 >> i) & 1; - switch (state) { - case 0: - if (bit) { - start = i; - state = 1; - } - break; - - case 1: - if (bit == 0) { - end = i - 1; - state = 2; - } - break; - - case 2: - if (bit) { - // not in 0*1*0* form. We can only use andi(s) if either - // the topmost or bottommost 16 bits are zero. - - if ((v32 >> 16) == 0) { - emit(c, andi(dst->low, b->low, v32)); - } else if ((v32 & 0xFFFF) == 0) { - emit(c, andis(dst->low, b->low, v32 >> 16)); - } else { - bool useTemporary = b->low == dst->low; - lir::Register tmp(dst->low); - if (useTemporary) { - tmp.low = c->client->acquireTemporary(); - } - - moveCR(c, 4, a, 4, &tmp); - andR(c, 4, b, &tmp, dst); - - if (useTemporary) { - c->client->releaseTemporary(tmp.low); - } - } - return; - } - break; - } - } - - if (state) { - if (start != 0 or end != 31) { - emit(c, rlwinm(dst->low, b->low, 0, 31 - end, 31 - start)); - } else { - moveRR(c, 4, b, 4, dst); - } - } else { - emit(c, li(dst->low, 0)); - } - } -} - -void orR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst) { - if (size == 8) { - lir::Register ah(a->high); - lir::Register bh(b->high); - lir::Register dh(dst->high); - - orR(c, 4, a, b, dst); - orR(c, 4, &ah, &bh, &dh); - } else { - emit(c, or_(dst->low, a->low, b->low)); - } -} - -void orC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst) { - int64_t v = a->value->value(); - - if (size == 8) { - ResolvedPromise high((v >> 32) & 0xFFFFFFFF); - lir::Constant ah(&high); - - ResolvedPromise low(v & 0xFFFFFFFF); - lir::Constant al(&low); - - lir::Register bh(b->high); - lir::Register dh(dst->high); - - orC(c, 4, &al, b, dst); - orC(c, 4, &ah, &bh, &dh); - } else { - emit(c, ori(b->low, dst->low, v)); - if (v >> 16) { - emit(c, oris(dst->low, dst->low, v >> 16)); - } - } -} - -void xorR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst) { - if (size == 8) { - lir::Register ah(a->high); - lir::Register bh(b->high); - lir::Register dh(dst->high); - - xorR(c, 4, a, b, dst); - xorR(c, 4, &ah, &bh, &dh); - } else { - emit(c, xor_(dst->low, a->low, b->low)); - } -} - -void xorC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst) { - uint64_t v = a->value->value(); - - if (size == 8) { - ResolvedPromise high((v >> 32) & 0xFFFFFFFF); - lir::Constant ah(&high); - - ResolvedPromise low(v & 0xFFFFFFFF); - lir::Constant al(&low); - - lir::Register bh(b->high); - lir::Register dh(dst->high); - - xorC(c, 4, &al, b, dst); - xorC(c, 4, &ah, &bh, &dh); - } else { - if (v >> 16) { - emit(c, xoris(b->low, dst->low, v >> 16)); - emit(c, xori(dst->low, dst->low, v)); - } else { - emit(c, xori(b->low, dst->low, v)); - } - } -} - -void moveAR2(Context* c, unsigned srcSize UNUSED, lir::Address* src, - unsigned dstSize, lir::Register* dst, unsigned promiseOffset) { - assert(c, srcSize == 4 and dstSize == 4); - - lir::Memory memory(dst->low, 0, -1, 0); - - appendImmediateTask - (c, src->address, offsetPromise(c), TargetBytesPerWord, promiseOffset, true); - - emit(c, lis(dst->low, 0)); - moveMR(c, dstSize, &memory, dstSize, dst); -} - -void moveAR(Context* c, unsigned srcSize, lir::Address* src, - unsigned dstSize, lir::Register* dst) { - moveAR2(c, srcSize, src, dstSize, dst, 0); -} - -void compareRR(Context* c, unsigned aSize UNUSED, lir::Register* a, - unsigned bSize UNUSED, lir::Register* b) { - assert(c, aSize == 4 and bSize == 4); - - emit(c, cmpw(b->low, a->low)); -} - -void compareCR(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Register* b) { - assert(c, aSize == 4 and bSize == 4); - - if (a->value->resolved() and fitsInInt16(a->value->value())) { - emit(c, cmpwi(b->low, a->value->value())); - } else { - lir::Register tmp(c->client->acquireTemporary()); - moveCR(c, aSize, a, bSize, &tmp); - compareRR(c, bSize, &tmp, bSize, b); - c->client->releaseTemporary(tmp.low); - } -} - -void compareCM(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Memory* b) { - assert(c, aSize == 4 and bSize == 4); - - lir::Register tmp(c->client->acquireTemporary()); - moveMR(c, bSize, b, bSize, &tmp); - compareCR(c, aSize, a, bSize, &tmp); - c->client->releaseTemporary(tmp.low); -} - -void compareRM(Context* c, unsigned aSize, lir::Register* a, - unsigned bSize, lir::Memory* b) { - assert(c, aSize == 4 and bSize == 4); - - lir::Register tmp(c->client->acquireTemporary()); - moveMR(c, bSize, b, bSize, &tmp); - compareRR(c, aSize, a, bSize, &tmp); - c->client->releaseTemporary(tmp.low); -} - -void compareUnsignedRR(Context* c, unsigned aSize UNUSED, lir::Register* a, - unsigned bSize UNUSED, lir::Register* b) { - assert(c, aSize == 4 and bSize == 4); - - emit(c, cmplw(b->low, a->low)); -} - -void compareUnsignedCR(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Register* b) { - assert(c, aSize == 4 and bSize == 4); - - if (a->value->resolved() and (a->value->value() >> 16) == 0) { - emit(c, cmplwi(b->low, a->value->value())); - } else { - lir::Register tmp(c->client->acquireTemporary()); - moveCR(c, aSize, a, bSize, &tmp); - compareUnsignedRR(c, bSize, &tmp, bSize, b); - c->client->releaseTemporary(tmp.low); - } -} - -int32_t -branch(Context* c, lir::TernaryOperation op) { - switch (op) { - case lir::JumpIfEqual: - return beq(0); - - case lir::JumpIfNotEqual: - return bne(0); - - case lir::JumpIfLess: - return blt(0); - - case lir::JumpIfGreater: - return bgt(0); - - case lir::JumpIfLessOrEqual: - return ble(0); - - case lir::JumpIfGreaterOrEqual: - return bge(0); - - default: - abort(c); - } -} - -void conditional(Context* c, int32_t branch, lir::Constant* target) { - appendOffsetTask(c, target->value, offsetPromise(c), true); - emit(c, branch); -} - -void branch(Context* c, lir::TernaryOperation op, lir::Constant* target) { - conditional(c, branch(c, op), target); -} - -void branchLong(Context* c, lir::TernaryOperation op, lir::Operand* al, - lir::Operand* ah, lir::Operand* bl, - lir::Operand* bh, lir::Constant* target, - BinaryOperationType compareSigned, - BinaryOperationType compareUnsigned) { - compareSigned(c, 4, ah, 4, bh); - - unsigned next = 0; - - switch (op) { - case lir::JumpIfEqual: - next = c->code.length(); - emit(c, bne(0)); - - compareSigned(c, 4, al, 4, bl); - conditional(c, beq(0), target); - break; - - case lir::JumpIfNotEqual: - conditional(c, bne(0), target); - - compareSigned(c, 4, al, 4, bl); - conditional(c, bne(0), target); - break; - - case lir::JumpIfLess: - conditional(c, blt(0), target); - - next = c->code.length(); - emit(c, bgt(0)); - - compareUnsigned(c, 4, al, 4, bl); - conditional(c, blt(0), target); - break; - - case lir::JumpIfGreater: - conditional(c, bgt(0), target); - - next = c->code.length(); - emit(c, blt(0)); - - compareUnsigned(c, 4, al, 4, bl); - conditional(c, bgt(0), target); - break; - - case lir::JumpIfLessOrEqual: - conditional(c, blt(0), target); - - next = c->code.length(); - emit(c, bgt(0)); - - compareUnsigned(c, 4, al, 4, bl); - conditional(c, ble(0), target); - break; - - case lir::JumpIfGreaterOrEqual: - conditional(c, bgt(0), target); - - next = c->code.length(); - emit(c, blt(0)); - - compareUnsigned(c, 4, al, 4, bl); - conditional(c, bge(0), target); - break; - - default: - abort(c); - } - - if (next) { - updateOffset( - c->s, - c->code.data.begin() + next, - true, - reinterpret_cast(c->code.data.begin() + c->code.length()), - 0); - } -} - -void branchRR(Context* c, lir::TernaryOperation op, unsigned size, - lir::Register* a, lir::Register* b, - lir::Constant* target) { - if (size > TargetBytesPerWord) { - lir::Register ah(a->high); - lir::Register bh(b->high); - - branchLong(c, op, a, &ah, b, &bh, target, CAST2(compareRR), - CAST2(compareUnsignedRR)); - } else { - compareRR(c, size, a, size, b); - branch(c, op, target); - } -} - -void branchCR(Context* c, lir::TernaryOperation op, unsigned size, - lir::Constant* a, lir::Register* b, - lir::Constant* target) { - if (size > TargetBytesPerWord) { - int64_t v = a->value->value(); - - ResolvedPromise low(v & ~static_cast(0)); - lir::Constant al(&low); - - ResolvedPromise high((v >> 32) & ~static_cast(0)); - lir::Constant ah(&high); - - lir::Register bh(b->high); - - branchLong(c, op, &al, &ah, b, &bh, target, CAST2(compareCR), - CAST2(compareUnsignedCR)); - } else { - compareCR(c, size, a, size, b); - branch(c, op, target); - } -} - -void branchRM(Context* c, lir::TernaryOperation op, unsigned size, - lir::Register* a, lir::Memory* b, - lir::Constant* target) { - assert(c, size <= TargetBytesPerWord); - - compareRM(c, size, a, size, b); - branch(c, op, target); -} - -void branchCM(Context* c, lir::TernaryOperation op, unsigned size, - lir::Constant* a, lir::Memory* b, - lir::Constant* target) { - assert(c, size <= TargetBytesPerWord); - - compareCM(c, size, a, size, b); - branch(c, op, target); -} - -void moveCM(Context* c, unsigned srcSize, lir::Constant* src, - unsigned dstSize, lir::Memory* dst) { - switch (dstSize) { - case 8: { - lir::Constant srcHigh - (shiftMaskPromise(c, src->value, 32, 0xFFFFFFFF)); - lir::Constant srcLow - (shiftMaskPromise(c, src->value, 0, 0xFFFFFFFF)); - - lir::Memory dstLow - (dst->base, dst->offset + 4, dst->index, dst->scale); - - moveCM(c, 4, &srcLow, 4, &dstLow); - moveCM(c, 4, &srcHigh, 4, dst); - } break; - - default: - lir::Register tmp(c->client->acquireTemporary()); - moveCR(c, srcSize, src, dstSize, &tmp); - moveRM(c, dstSize, &tmp, dstSize, dst); - c->client->releaseTemporary(tmp.low); - } -} - -void negateRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize UNUSED, lir::Register* dst) { - assert(c, srcSize == dstSize); - - if (srcSize == 8) { - lir::Register dstHigh(dst->high); - - emit(c, subfic(dst->low, src->low, 0)); - emit(c, subfze(dst->high, src->high)); - } else { - emit(c, neg(dst->low, src->low)); - } -} - -void callR(Context* c, unsigned size UNUSED, lir::Register* target) { - assert(c, size == TargetBytesPerWord); - - emit(c, mtctr(target->low)); - emit(c, bctrl()); -} - -void callC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - appendOffsetTask(c, target->value, offsetPromise(c), false); - emit(c, bl(0)); -} - -void longCallC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - lir::Register tmp(0); - moveCR2(c, TargetBytesPerWord, target, TargetBytesPerWord, &tmp, 12); - callR(c, TargetBytesPerWord, &tmp); -} - -void alignedLongCallC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - lir::Register tmp(c->client->acquireTemporary()); - lir::Address address(appendConstantPoolEntry(c, target->value)); - moveAR2(c, TargetBytesPerWord, &address, TargetBytesPerWord, &tmp, 12); - callR(c, TargetBytesPerWord, &tmp); - c->client->releaseTemporary(tmp.low); -} - -void longJumpC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - lir::Register tmp(0); - moveCR2(c, TargetBytesPerWord, target, TargetBytesPerWord, &tmp, 12); - jumpR(c, TargetBytesPerWord, &tmp); -} - -void alignedLongJumpC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - lir::Register tmp(c->client->acquireTemporary()); - lir::Address address(appendConstantPoolEntry(c, target->value)); - moveAR2(c, TargetBytesPerWord, &address, TargetBytesPerWord, &tmp, 12); - jumpR(c, TargetBytesPerWord, &tmp); - c->client->releaseTemporary(tmp.low); -} - -void jumpC(Context* c, unsigned size UNUSED, lir::Constant* target) { - assert(c, size == TargetBytesPerWord); - - appendOffsetTask(c, target->value, offsetPromise(c), false); - emit(c, b(0)); -} - -void return_(Context* c) { - emit(c, blr()); -} - -void trap(Context* c) { - emit(c, isa::trap()); -} - -void memoryBarrier(Context* c) { - emit(c, sync(0)); -} - -} // namespace powerpc -} // namespace codegen -} // namespace avian diff --git a/src/codegen/target/powerpc/operations.h b/src/codegen/target/powerpc/operations.h deleted file mode 100644 index 53e1af515b..0000000000 --- a/src/codegen/target/powerpc/operations.h +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_OPERATIONS_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_OPERATIONS_H - -#include "context.h" - -namespace avian { -namespace codegen { -namespace powerpc { - -inline void emit(Context* con, int code) { con->code.append4(vm::targetV4(code)); } -inline int newTemp(Context* con) { return con->client->acquireTemporary(); } -inline void freeTemp(Context* con, int r) { con->client->releaseTemporary(r); } -inline int64_t getValue(lir::Constant* c) { return c->value->value(); } - -void andC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst); - -void shiftLeftR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void moveRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize, lir::Register* dst); - -void shiftLeftC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t); - -void shiftRightR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void shiftRightC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t); - -void unsignedShiftRightR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void unsignedShiftRightC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t); - -void jumpR(Context* c, unsigned size UNUSED, lir::Register* target); - -void swapRR(Context* c, unsigned aSize, lir::Register* a, - unsigned bSize, lir::Register* b); - -void moveRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize, lir::Register* dst); - -void moveZRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned, lir::Register* dst); - -void moveCR2(Context* c, unsigned, lir::Constant* src, - unsigned dstSize, lir::Register* dst, unsigned promiseOffset); - -void moveCR(Context* c, unsigned srcSize, lir::Constant* src, - unsigned dstSize, lir::Register* dst); - -void addR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void addC(Context* con, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t); - -void subR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void subC(Context* c, unsigned size, lir::Constant* a, lir::Register* b, lir::Register* t); - -void multiplyR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -void divideR(Context* con, unsigned size UNUSED, lir::Register* a, lir::Register* b, lir::Register* t); - -void remainderR(Context* con, unsigned size, lir::Register* a, lir::Register* b, lir::Register* t); - -int -normalize(Context* c, int offset, int index, unsigned scale, - bool* preserveIndex, bool* release); - -void store(Context* c, unsigned size, lir::Register* src, - int base, int offset, int index, unsigned scale, bool preserveIndex); - -void moveRM(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize UNUSED, lir::Memory* dst); - -void moveAndUpdateRM(Context* c, unsigned srcSize UNUSED, lir::Register* src, - unsigned dstSize UNUSED, lir::Memory* dst); - -void load(Context* c, unsigned srcSize, int base, int offset, int index, - unsigned scale, unsigned dstSize, lir::Register* dst, - bool preserveIndex, bool signExtend); - -void moveMR(Context* c, unsigned srcSize, lir::Memory* src, - unsigned dstSize, lir::Register* dst); - -void moveZMR(Context* c, unsigned srcSize, lir::Memory* src, - unsigned dstSize, lir::Register* dst); - -void andR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst); - -void andC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst); - -void orR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst); - -void orC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst); - -void xorR(Context* c, unsigned size, lir::Register* a, - lir::Register* b, lir::Register* dst); - -void xorC(Context* c, unsigned size, lir::Constant* a, - lir::Register* b, lir::Register* dst); - -void moveAR2(Context* c, unsigned srcSize UNUSED, lir::Address* src, - unsigned dstSize, lir::Register* dst, unsigned promiseOffset); - -void moveAR(Context* c, unsigned srcSize, lir::Address* src, - unsigned dstSize, lir::Register* dst); - -void compareRR(Context* c, unsigned aSize UNUSED, lir::Register* a, - unsigned bSize UNUSED, lir::Register* b); - -void compareCR(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Register* b); - -void compareCM(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Memory* b); - -void compareRM(Context* c, unsigned aSize, lir::Register* a, - unsigned bSize, lir::Memory* b); - -void compareUnsignedRR(Context* c, unsigned aSize UNUSED, lir::Register* a, - unsigned bSize UNUSED, lir::Register* b); - -void compareUnsignedCR(Context* c, unsigned aSize, lir::Constant* a, - unsigned bSize, lir::Register* b); - -int32_t branch(Context* c, lir::TernaryOperation op); - -void conditional(Context* c, int32_t branch, lir::Constant* target); - -void branch(Context* c, lir::TernaryOperation op, lir::Constant* target); - -void branchLong(Context* c, lir::TernaryOperation op, lir::Operand* al, - lir::Operand* ah, lir::Operand* bl, - lir::Operand* bh, lir::Constant* target, - BinaryOperationType compareSigned, - BinaryOperationType compareUnsigned); - -void branchRR(Context* c, lir::TernaryOperation op, unsigned size, - lir::Register* a, lir::Register* b, - lir::Constant* target); - -void branchCR(Context* c, lir::TernaryOperation op, unsigned size, - lir::Constant* a, lir::Register* b, - lir::Constant* target); - -void branchRM(Context* c, lir::TernaryOperation op, unsigned size, - lir::Register* a, lir::Memory* b, - lir::Constant* target); - -void branchCM(Context* c, lir::TernaryOperation op, unsigned size, - lir::Constant* a, lir::Memory* b, - lir::Constant* target); - -void moveCM(Context* c, unsigned srcSize, lir::Constant* src, - unsigned dstSize, lir::Memory* dst); - -void negateRR(Context* c, unsigned srcSize, lir::Register* src, - unsigned dstSize UNUSED, lir::Register* dst); - -void callR(Context* c, unsigned size UNUSED, lir::Register* target); - -void callC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void longCallC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void alignedLongCallC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void longJumpC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void alignedLongJumpC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void jumpC(Context* c, unsigned size UNUSED, lir::Constant* target); - -void return_(Context* c); - -void trap(Context* c); - -void memoryBarrier(Context* c); - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_OPERATIONS_H diff --git a/src/codegen/target/powerpc/registers.h b/src/codegen/target/powerpc/registers.h deleted file mode 100644 index 098066518f..0000000000 --- a/src/codegen/target/powerpc/registers.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#ifndef AVIAN_CODEGEN_ASSEMBLER_POWERPC_REGISTERS_H -#define AVIAN_CODEGEN_ASSEMBLER_POWERPC_REGISTERS_H - -namespace avian { -namespace codegen { -namespace powerpc { - - -} // namespace powerpc -} // namespace codegen -} // namespace avian - -#endif // AVIAN_CODEGEN_ASSEMBLER_POWERPC_REGISTERS_H diff --git a/src/codegen/targets.cpp b/src/codegen/targets.cpp index 2fe5881f45..b4aaa99a51 100644 --- a/src/codegen/targets.cpp +++ b/src/codegen/targets.cpp @@ -29,8 +29,6 @@ Architecture* makeArchitectureNative(vm::System* system, bool useNativeFeatures return makeArchitectureX86(system, useNativeFeatures); #elif AVIAN_TARGET_ARCH == AVIAN_ARCH_ARM return makeArchitectureArm(system, useNativeFeatures); -#elif AVIAN_TARGET_ARCH == AVIAN_ARCH_POWERPC - return makeArchitecturePowerpc(system, useNativeFeatures); #else #error "Unsupported codegen target" #endif diff --git a/src/compile-powerpc.S b/src/compile-powerpc.S deleted file mode 100644 index 7797dc7237..0000000000 --- a/src/compile-powerpc.S +++ /dev/null @@ -1,295 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "avian/types.h" -#include "avian/target-fields.h" - -.text - -#define BYTES_PER_WORD 4 - -#ifdef __APPLE__ -# define GLOBAL(x) _##x -# define LOCAL(x) L##x -# define LINKAGE_AREA 6 -# define RETURN_ADDRESS_OFFSET 8 -#else -# define GLOBAL(x) x -# define LOCAL(x) .L##x -# define LINKAGE_AREA 2 -# define RETURN_ADDRESS_OFFSET 4 -# include "powerpc-regs.S" -#endif - -#define ARGUMENT_BASE BYTES_PER_WORD * LINKAGE_AREA - -#define CONTINUATION_NEXT 4 -#define CONTINUATION_ADDRESS 16 -#define CONTINUATION_RETURN_ADDRESS_OFFSET 20 -#define CONTINUATION_FRAME_POINTER_OFFSET 24 -#define CONTINUATION_LENGTH 28 -#define CONTINUATION_BODY 32 - -.globl GLOBAL(vmInvoke) -GLOBAL(vmInvoke): - // save return address - mflr r0 - stw r0,RETURN_ADDRESS_OFFSET(r1) - - // r3: thread - // r4: function - // r5: arguments - // r6: argumentFootprint - // r7: frameSize - // r8: returnType - - // r9: temporary - - // allocate stack space, adding room for callee-saved registers and - // return type - subfic r9,r7,-80 - stwux r1,r1,r9 - - // save callee-saved registers - add r9,r7,r1 - - stw r13,0(r9) - stw r14,4(r9) - stw r15,8(r9) - stw r16,12(r9) - stw r17,16(r9) - stw r18,20(r9) - stw r19,24(r9) - stw r20,28(r9) - stw r21,32(r9) - stw r22,36(r9) - stw r23,40(r9) - stw r24,44(r9) - stw r25,48(r9) - stw r26,52(r9) - stw r27,56(r9) - stw r28,60(r9) - stw r29,64(r9) - stw r30,68(r9) - stw r31,72(r9) - - // save return type - stw r8,76(r9) - - // we use r13 to hold the thread pointer, by convention - mr r13,r3 - - // copy arguments into place - li r16,0 - addi r18,r1,ARGUMENT_BASE - b LOCAL(vmInvoke_argumentTest) - -LOCAL(vmInvoke_argumentLoop): - lwzx r17,r16,r5 - stwx r17,r16,r18 - addi r16,r16,BYTES_PER_WORD - -LOCAL(vmInvoke_argumentTest): - cmplw r16,r6 - blt LOCAL(vmInvoke_argumentLoop) - - // load and call function address - mtctr r4 - bctrl - -.globl GLOBAL(vmInvoke_returnAddress) -GLOBAL(vmInvoke_returnAddress): - // restore stack pointer - lwz r1,0(r1) - - // clear MyThread::stack to avoid confusing another thread calling - // java.lang.Thread.getStackTrace on this one. See - // MyProcess::getStackTrace in compile.cpp for details on how we get - // a reliable stack trace from a thread that might be interrupted at - // any point in its execution. - li r5,0 - stw r5,TARGET_THREAD_STACK(r13) - -.globl GLOBAL(vmInvoke_safeStack) -GLOBAL(vmInvoke_safeStack): - -#ifdef AVIAN_CONTINUATIONS - // call the next continuation, if any - lwz r5,TARGET_THREAD_CONTINUATION(r13) - cmplwi r5,0 - beq LOCAL(vmInvoke_exit) - - lwz r6,CONTINUATION_LENGTH(r5) - slwi r6,r6,2 - subfic r7,r6,-80 - stwux r1,r1,r7 - - addi r7,r5,CONTINUATION_BODY - - li r8,0 - addi r10,r1,ARGUMENT_BASE - b LOCAL(vmInvoke_continuationTest) - -LOCAL(vmInvoke_continuationLoop): - lwzx r9,r7,r8 - stwx r9,r10,r8 - addi r8,r8,4 - -LOCAL(vmInvoke_continuationTest): - cmplw r8,r6 - ble LOCAL(vmInvoke_continuationLoop) - - lwz r7,CONTINUATION_RETURN_ADDRESS_OFFSET(r5) - bl LOCAL(vmInvoke_getPC) - -LOCAL(vmInvoke_getPC): - mflr r10 -#ifdef __APPLE__ - la r10,lo16(GLOBAL(vmInvoke_returnAddress)-LOCAL(vmInvoke_getPC))(r10) -#else - lwz r10,LOCAL(vmInvoke_returnAddress_address)-LOCAL(vmInvoke_getPC)(r10) -#endif - stwx r10,r1,r7 - - lwz r7,CONTINUATION_FRAME_POINTER_OFFSET(r5) - lwz r8,0(r1) - add r7,r7,r1 - stw r8,0(r7) - stw r7,0(r1) - - lwz r7,CONTINUATION_NEXT(r5) - stw r7,TARGET_THREAD_CONTINUATION(r13) - - // call the continuation unless we're handling an exception - lwz r7,TARGET_THREAD_EXCEPTION(r13) - cmpwi r7,0 - bne LOCAL(vmInvoke_handleException) - lwz r7,CONTINUATION_ADDRESS(r5) - mtctr r7 - bctr - -LOCAL(vmInvoke_handleException): - // we're handling an exception - call the exception handler instead - li r8,0 - stw r8,TARGET_THREAD_EXCEPTION(r13) - lwz r8,TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT(r13) - lwz r9,0(r1) - subfic r8,r8,0 - stwux r9,r1,r8 - lwz r8,TARGET_THREAD_EXCEPTIONOFFSET(r13) - stwx r7,r1,r8 - - lwz r7,TARGET_THREAD_EXCEPTIONHANDLER(r13) - mtctr r7 - bctr - -LOCAL(vmInvoke_exit): -#endif // AVIAN_CONTINUATIONS - - // restore callee-saved registers - subi r9,r1,80 - - lwz r13,0(r9) - lwz r14,4(r9) - lwz r15,8(r9) - lwz r16,12(r9) - lwz r17,16(r9) - lwz r18,20(r9) - lwz r19,24(r9) - lwz r20,28(r9) - lwz r21,32(r9) - lwz r22,36(r9) - lwz r23,40(r9) - lwz r24,44(r9) - lwz r25,48(r9) - lwz r26,52(r9) - lwz r27,56(r9) - lwz r28,60(r9) - lwz r29,64(r9) - lwz r30,68(r9) - lwz r31,72(r9) - - // handle return value based on expected type - lwz r8,76(r9) - -LOCAL(vmInvoke_return): - // load return address - lwz r0,RETURN_ADDRESS_OFFSET(r1) - mtlr r0 - - // return - blr - -#ifndef __APPLE__ -LOCAL(vmInvoke_returnAddress_address): - .long GLOBAL(vmInvoke_returnAddress) -#endif - -.globl GLOBAL(vmJumpAndInvoke) -GLOBAL(vmJumpAndInvoke): -#ifdef AVIAN_CONTINUATIONS - // r3: thread - // r4: address - // r5: stack - // r6: argumentFootprint - // r7: arguments - // r8: frameSize - - // restore (pseudo)-stack pointer (we don't want to touch the real - // stack pointer, since we haven't copied the arguments yet) - lwz r5,0(r5) - - // make everything between r1 and r5 one big stack frame while we - // shuffle things around - stw r5,0(r1) - - // allocate new frame, adding room for callee-saved registers - subfic r10,r8,-80 - stwux r5,r5,r10 - - mr r13,r3 - - // copy arguments into place - li r8,0 - addi r11,r5,ARGUMENT_BASE - b LOCAL(vmJumpAndInvoke_argumentTest) - -LOCAL(vmJumpAndInvoke_argumentLoop): - lwzx r12,r7,r8 - stwx r12,r11,r8 - addi r8,r8,4 - -LOCAL(vmJumpAndInvoke_argumentTest): - cmplw r8,r6 - ble LOCAL(vmJumpAndInvoke_argumentLoop) - - // the arguments have been copied, so we can set the real stack - // pointer now - mr r1,r5 - - // set return address to vmInvoke_returnAddress - bl LOCAL(vmJumpAndInvoke_getPC) - -LOCAL(vmJumpAndInvoke_getPC): - mflr r10 -#ifdef __APPLE__ - la r10,lo16(GLOBAL(vmInvoke_returnAddress)-LOCAL(vmJumpAndInvoke_getPC))(r10) -#else - lwz r10,LOCAL(vmInvoke_returnAddress_address)-LOCAL(vmJumpAndInvoke_getPC)(r10) -#endif - mtlr r10 - - mtctr r4 - bctr -#else // not AVIAN_CONTINUATIONS - // vmJumpAndInvoke should only be called when continuations are - // enabled - trap -#endif // not AVIAN_CONTINUATIONS diff --git a/src/compile.cpp b/src/compile.cpp index 4703db05e7..66c9e26899 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -8981,10 +8981,10 @@ class MyProcessor: public Processor { } else if (isThunk(t, ip) or isVirtualThunk(t, ip)) { // we caught the thread in a thunk where the stack register // indicates the most recent Java frame on the stack - + // On e.g. x86, the return address will have already been // pushed onto the stack, in which case we use getIp to - // retrieve it. On e.g. PowerPC and ARM, it will be in the + // retrieve it. On e.g. ARM, it will be in the // link register. Note that we can't just check if the link // argument is null here, since we use ecx/rcx as a // pseudo-link register on x86 for the purpose of tail diff --git a/src/powerpc.S b/src/powerpc.S deleted file mode 100644 index fe4d90796a..0000000000 --- a/src/powerpc.S +++ /dev/null @@ -1,259 +0,0 @@ -/* Copyright (c) 2008-2014, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -#include "avian/types.h" - -.text - -#define BYTES_PER_WORD 4 -#define GPR_COUNT 8 - -#ifdef __APPLE__ -# define GLOBAL(x) _##x -# define LOCAL(x) L##x -# define LINKAGE_AREA 6 -# define MEMORY_BASE BYTES_PER_WORD * (LINKAGE_AREA + GPR_COUNT) -# define RETURN_ADDRESS_OFFSET 8 -#else -# define GLOBAL(x) x -# define LOCAL(x) .L##x -# define LINKAGE_AREA 2 -# define MEMORY_BASE BYTES_PER_WORD * LINKAGE_AREA -# define RETURN_ADDRESS_OFFSET 4 -# include "powerpc-regs.S" -#endif - -.globl GLOBAL(vmNativeCall) -GLOBAL(vmNativeCall): - // save return address - mflr r0 - stw r0,RETURN_ADDRESS_OFFSET(r1) - - // r3 aka r13: function - // r4 : stackTotal - // r5 : memoryTable - // r6 : memoryCount - // r7 : memoryBase - // r8 : gprTable - // r9 : fprTable - // r10 aka r14: returnType - - // r15 : stack frame size - // r16 : temporary - // r17 : temporary - // r18 : temporary - - // allocate stack space, adding room for callee-saved registers and - // scratch space for copying a FP return value into GPRs - subfic r11,r4,-48 - stwux r1,r1,r11 - - // save callee-saved registers used for local variables - add r11,r4,r1 - - // save registers used for local variables - stw r13,0(r11) - stw r14,4(r11) - stw r15,8(r11) - stw r16,12(r11) - stw r17,16(r11) - stw r18,20(r11) - stw r19,24(r11) - - // remember where we saved the local variables - mr r19,r11 - - // save our argument registers so we can clobber them - mr r13,r3 - mr r14,r10 - - li r16,0 - b LOCAL(test) - -LOCAL(loop): - lwzx r17,r16,r5 - add r18,r16,r7 - stwx r17,r18,r1 - addi r16,r16,BYTES_PER_WORD - -LOCAL(test): - cmplw r16,r6 - blt LOCAL(loop) - - // do we need to load the floating point registers? - cmpwi r9,0 - beq LOCAL(gpr) - - // yes, we do - lfd f1,0(r9) - lfd f2,8(r9) - lfd f3,16(r9) - lfd f4,24(r9) - lfd f5,32(r9) - lfd f6,40(r9) - lfd f7,48(r9) - lfd f8,56(r9) -#ifdef __APPLE__ - lfd f9,64(r9) - lfd f10,72(r9) - lfd f11,80(r9) - lfd f12,88(r9) - lfd f13,96(r9) -#endif - -LOCAL(gpr): - // do we need to load the general-purpose registers? - cmpwi r8,0 - beq LOCAL(call) - - // yes, we do - mr r16,r8 - lwz r3,0(r16) - lwz r4,4(r16) - lwz r5,8(r16) - lwz r6,12(r16) - lwz r7,16(r16) - lwz r8,20(r16) - lwz r9,24(r16) - lwz r10,28(r16) - -LOCAL(call): - // load and call function address - mtctr r13 - bctrl - - // handle return value based on expected type - cmpwi r14,VOID_TYPE - bne LOCAL(float) - b LOCAL(exit) - -LOCAL(float): - cmpwi r14,FLOAT_TYPE - bne LOCAL(double) - stfs f1,32(r19) - lwz r4,32(r19) - b LOCAL(exit) -LOCAL(double): - cmpwi r14,DOUBLE_TYPE - bne LOCAL(int64) - stfd f1,32(r19) - lwz r3,32(r19) - lwz r4,36(r19) - b LOCAL(exit) -LOCAL(int64): - cmpwi r14,INT64_TYPE - beq LOCAL(exit) - mr r4,r3 - b LOCAL(exit) - -LOCAL(copy): - // move floating point return value to GPRs via memory - stfd f1,32(r19) - lwz r3,32(r19) - lwz r4,36(r19) - b LOCAL(exit) - -LOCAL(exit): - // restore callee-saved registers used for local variables - lwz r13,0(r19) - lwz r14,4(r19) - lwz r15,8(r19) - lwz r16,12(r19) - lwz r17,16(r19) - lwz r18,20(r19) - lwz r19,24(r19) - - // restore stack pointer - lwz r1,0(r1) - - // load return address - lwz r0,RETURN_ADDRESS_OFFSET(r1) - mtlr r0 - - // return - blr - -.globl GLOBAL(vmJump) -GLOBAL(vmJump): - mtlr r3 - mr r1,r5 - mr r13,r6 - mr r4,r7 - mr r3,r8 - blr - -#define CHECKPOINT_THREAD 4 -#define CHECKPOINT_STACK 24 - -.globl GLOBAL(vmRun) -GLOBAL(vmRun): - // r3: function - // r4: arguments - // r5: checkpoint - - mflr r0 - stw r0,RETURN_ADDRESS_OFFSET(r1) - - stwu r1,-(MEMORY_BASE+88)(r1) - - stw r13,MEMORY_BASE+0(r1) - stw r14,MEMORY_BASE+4(r1) - stw r15,MEMORY_BASE+8(r1) - stw r16,MEMORY_BASE+12(r1) - stw r17,MEMORY_BASE+16(r1) - stw r18,MEMORY_BASE+20(r1) - stw r19,MEMORY_BASE+24(r1) - stw r20,MEMORY_BASE+28(r1) - stw r21,MEMORY_BASE+32(r1) - stw r22,MEMORY_BASE+36(r1) - stw r23,MEMORY_BASE+40(r1) - stw r24,MEMORY_BASE+44(r1) - stw r25,MEMORY_BASE+48(r1) - stw r26,MEMORY_BASE+52(r1) - stw r27,MEMORY_BASE+56(r1) - stw r28,MEMORY_BASE+60(r1) - stw r29,MEMORY_BASE+64(r1) - stw r30,MEMORY_BASE+68(r1) - stw r31,MEMORY_BASE+72(r1) - - stw r1,CHECKPOINT_STACK(r5) - - mr r6,r3 - lwz r3,CHECKPOINT_THREAD(r5) - - mtctr r6 - bctrl - -.globl GLOBAL(vmRun_returnAddress) -GLOBAL(vmRun_returnAddress): - lwz r13,MEMORY_BASE+0(r1) - lwz r14,MEMORY_BASE+4(r1) - lwz r15,MEMORY_BASE+8(r1) - lwz r16,MEMORY_BASE+12(r1) - lwz r17,MEMORY_BASE+16(r1) - lwz r18,MEMORY_BASE+20(r1) - lwz r19,MEMORY_BASE+24(r1) - lwz r20,MEMORY_BASE+28(r1) - lwz r21,MEMORY_BASE+32(r1) - lwz r22,MEMORY_BASE+36(r1) - lwz r23,MEMORY_BASE+40(r1) - lwz r24,MEMORY_BASE+44(r1) - lwz r25,MEMORY_BASE+48(r1) - lwz r26,MEMORY_BASE+52(r1) - lwz r27,MEMORY_BASE+56(r1) - lwz r28,MEMORY_BASE+60(r1) - lwz r29,MEMORY_BASE+64(r1) - lwz r30,MEMORY_BASE+68(r1) - lwz r31,MEMORY_BASE+72(r1) - - lwz r1,0(r1) - lwz r0,RETURN_ADDRESS_OFFSET(r1) - mtlr r0 - blr diff --git a/src/tools/bootimage-generator/main.cpp b/src/tools/bootimage-generator/main.cpp index 7eb68ce7fe..62b840a256 100644 --- a/src/tools/bootimage-generator/main.cpp +++ b/src/tools/bootimage-generator/main.cpp @@ -1907,9 +1907,9 @@ main(int ac, const char** av) // todo: currently, the compiler cannot compile code with jumps or // calls spanning more than the maximum size of an immediate value - // in a branch instruction for the target architecture (~32MB on - // PowerPC and ARM). When that limitation is removed, we'll be able - // to specify a capacity as large as we like here: + // in a branch instruction for the target architecture (~32MB on ARM). + // When that limitation is removed, we'll be able to specify a + // capacity as large as we like here: #if (AVIAN_TARGET_ARCH == AVIAN_ARCH_X86_64) \ || (AVIAN_TARGET_ARCH == AVIAN_ARCH_X86) const unsigned CodeCapacity = 128 * 1024 * 1024; diff --git a/src/tools/object-writer/elf.cpp b/src/tools/object-writer/elf.cpp index 110c8e153f..6f39d48fc9 100644 --- a/src/tools/object-writer/elf.cpp +++ b/src/tools/object-writer/elf.cpp @@ -49,7 +49,6 @@ #define EM_386 3 #define EM_X86_64 62 #define EM_ARM 40 -#define EM_PPC 20 #define SHT_PROGBITS 1 #define SHT_SYMTAB 2 @@ -130,8 +129,6 @@ unsigned getElfPlatform(PlatformInfo::Architecture arch) { return EM_386; case PlatformInfo::Arm: return EM_ARM; - case PlatformInfo::PowerPC: - return EM_PPC; default: return ~0; } @@ -375,7 +372,6 @@ public: ElfPlatform elfX86Platform(PlatformInfo::x86); ElfPlatform elfArmPlatform(PlatformInfo::Arm); -ElfPlatform elfPowerPCPlatform(PlatformInfo::PowerPC); ElfPlatform elfX86_64Platform(PlatformInfo::x86_64); } // namespace diff --git a/src/tools/object-writer/mach-o.cpp b/src/tools/object-writer/mach-o.cpp index 88976ab120..89dec28e25 100644 --- a/src/tools/object-writer/mach-o.cpp +++ b/src/tools/object-writer/mach-o.cpp @@ -32,13 +32,11 @@ #define CPU_TYPE_I386 7 #define CPU_TYPE_X86_64 (CPU_TYPE_I386 | CPU_ARCH_ABI64) -#define CPU_TYPE_POWERPC 18 #define CPU_TYPE_ARM 12 #define CPU_SUBTYPE_I386_ALL 3 #define CPU_SUBTYPE_X86_64_ALL CPU_SUBTYPE_I386_ALL -#define CPU_SUBTYPE_POWERPC_ALL 0 -#define CPU_SUBTYPE_ARM_V7 9 +#define CPU_SUBTYPE_ARM_V7 9 namespace { @@ -153,10 +151,6 @@ public: cpuType = CPU_TYPE_I386; cpuSubType = CPU_SUBTYPE_I386_ALL; break; - case PlatformInfo::PowerPC: - cpuType = CPU_TYPE_POWERPC; - cpuSubType = CPU_SUBTYPE_POWERPC_ALL; - break; case PlatformInfo::Arm: cpuType = CPU_TYPE_ARM; cpuSubType = CPU_SUBTYPE_ARM_V7; @@ -293,7 +287,6 @@ public: MachOPlatform darwinx86Platform(PlatformInfo::x86); MachOPlatform darwinArmPlatform(PlatformInfo::Arm); -MachOPlatform darwinPowerPCPlatform(PlatformInfo::PowerPC); MachOPlatform darwinx86_64Platform(PlatformInfo::x86_64); } // namespace diff --git a/src/tools/object-writer/tools.cpp b/src/tools/object-writer/tools.cpp index c6d418a2db..7d0137d19c 100644 --- a/src/tools/object-writer/tools.cpp +++ b/src/tools/object-writer/tools.cpp @@ -108,8 +108,6 @@ PlatformInfo::Architecture PlatformInfo::archFromString(const char* arch) { return x86; } else if(strcmp(arch, "x86_64") == 0) { return x86_64; - } else if(strcmp(arch, "powerpc") == 0) { - return PowerPC; } else if(strcmp(arch, "arm") == 0) { return Arm; } else {