├── AVMPI ├── float4Support.cpp └── float4Support.h ├── CMakeLists.txt ├── LICENSE ├── README.md ├── docs ├── README.md ├── details.md ├── nanjit-opcodes.md └── overview.md ├── nanojit ├── Allocator.cpp ├── Allocator.h ├── Assembler.cpp ├── Assembler.h ├── CodeAlloc.cpp ├── CodeAlloc.h ├── Containers.cpp ├── Containers.h ├── Fragmento.cpp ├── Fragmento.h ├── LIR.cpp ├── LIR.h ├── LIRopcode.tbl ├── Native.h ├── NativeARM.cpp ├── NativeARM.h ├── NativeCommon.h ├── NativeMIPS.cpp ├── NativeMIPS.h ├── NativePPC.cpp ├── NativePPC.h ├── NativeSH4-auto-generated.h ├── NativeSH4.cpp ├── NativeSH4.h ├── NativeSparc.cpp ├── NativeSparc.h ├── NativeThumb2.cpp ├── NativeThumb2.h ├── NativeX64.cpp ├── NativeX64.h ├── Nativei386.cpp ├── Nativei386.h ├── RegAlloc.cpp ├── RegAlloc.h ├── manifest.mk ├── nanojit.h ├── njconfig.cpp ├── njconfig.h └── njcpudetect.h ├── nanojitextra ├── nanojitextra.cpp ├── nanojitextra.h └── spi.cpp ├── samples └── example1.cpp ├── utils └── nanojit-lirasm │ ├── Makefile.in │ ├── README │ ├── VMPI.nj │ ├── VMPI.cpp │ ├── VMPI.h │ ├── avmplus.cpp │ └── avmplus.h │ ├── autoconf │ ├── config.guess │ ├── config.sub │ └── install-sh │ ├── config.h.in │ ├── configure.in │ └── lirasm │ ├── LInsClasses.tbl │ ├── lirasm.cpp │ ├── testlirc.sh │ └── tests │ ├── 32-bit │ ├── float │ │ ├── livef.in │ │ └── livef.out │ ├── lived.in │ ├── lived.out │ ├── many_params.in │ └── many_params.out │ ├── 64-bit │ ├── dasq.in │ ├── dasq.out │ ├── float │ │ ├── livef.in │ │ └── livef.out │ ├── lived.in │ ├── lived.out │ ├── qasd.in │ ├── qasd.out │ ├── shq.in │ └── shq.out │ ├── add.in │ ├── add.out │ ├── addd.in │ ├── addd.out │ ├── addjovi.in │ ├── addjovi.out │ ├── addjovi_ovf.in │ ├── addjovi_ovf.out │ ├── addsub.in │ ├── addsub.out │ ├── backjump.in │ ├── backjump.out │ ├── bigendian │ ├── fuzz-527178.in │ ├── fuzz-527178.out │ ├── ldc2i.in │ ├── ldc2i.out │ ├── lds2i.in │ ├── lds2i.out │ ├── lduc2ui.in │ ├── lduc2ui.out │ ├── ldus2ui.in │ └── ldus2ui.out │ ├── bug596923.in │ ├── bug596923.out │ ├── bug643969.in │ ├── bug643969.out │ ├── call1.in │ ├── call1.out │ ├── call2.in │ ├── call2.out │ ├── calld1.in │ ├── calld1.out │ ├── callid1.in │ ├── callid1.out │ ├── callid2.in │ ├── callid2.out │ ├── callid3.in │ ├── callid3.out │ ├── callv.in │ ├── callv.out │ ├── cmov.in │ ├── cmov.out │ ├── cmovd.in │ ├── cmovd.out │ ├── cond_eqd.in │ ├── cond_eqd.out │ ├── cond_eqi.in │ ├── cond_eqi.out │ ├── cond_ged.in │ ├── cond_ged.out │ ├── cond_gei.in │ ├── cond_gei.out │ ├── cond_geui.in │ ├── cond_geui.out │ ├── cond_gtd.in │ ├── cond_gtd.out │ ├── cond_gti.in │ ├── cond_gti.out │ ├── cond_gtui.in │ ├── cond_gtui.out │ ├── cond_led.in │ ├── cond_led.out │ ├── cond_lei.in │ ├── cond_lei.out │ ├── cond_leui.in │ ├── cond_leui.out │ ├── cond_ltd.in │ ├── cond_ltd.out │ ├── cond_lti.in │ ├── cond_lti.out │ ├── cond_ltui.in │ ├── cond_ltui.out │ ├── divd.in │ ├── divd.out │ ├── float │ ├── addf.in │ ├── addf.out │ ├── addf4.in │ ├── addf4.out │ ├── call2f.in │ ├── call2f.out │ ├── callf1.in │ ├── callf1.out │ ├── callf4_1.in │ ├── callf4_1.out │ ├── callf4_2.in │ ├── callf4_2.out │ ├── callif1.in │ ├── callif1.out │ ├── callif2.in │ ├── callif2.out │ ├── callif3.in │ ├── callif3.out │ ├── callif4_1.in │ ├── callif4_1.out │ ├── callif4_2.in │ ├── callif4_2.out │ ├── callif4_3.in │ ├── callif4_3.out │ ├── cmovf.in │ ├── cmovf.out │ ├── cmovf4.in │ ├── cmovf4.out │ ├── divf.in │ ├── divf.out │ ├── divf4.in │ ├── divf4.out │ ├── fnegf.in │ ├── fnegf.out │ ├── fnegf4.in │ ├── fnegf4.out │ ├── fpu1-598151-flt.in │ ├── fpu1-598151-flt.out │ ├── fpu2-598151-flt.in │ ├── fpu2-598151-flt.out │ ├── mulf.in │ ├── mulf.out │ ├── mulf4.in │ ├── mulf4.out │ ├── multfrag2f.in │ ├── multfrag2f.out │ ├── multfrag2f4.in │ ├── multfrag2f4.out │ ├── subf.in │ ├── subf.out │ ├── subf4.in │ └── subf4.out │ ├── float_double.in │ ├── float_double.out │ ├── floatingpoint.in │ ├── floatingpoint.out │ ├── fneg.in │ ├── fneg.out │ ├── fpu1-598151.in │ ├── fpu1-598151.out │ ├── fpu2-598151.in │ ├── fpu2-598151.out │ ├── hardfloat │ ├── d2i.in │ ├── d2i.out │ ├── f2i.in │ ├── f2i.out │ ├── i2d.in │ ├── i2d.out │ ├── ui2d.in │ └── ui2d.out │ ├── largeframe.in │ ├── largeframe.out │ ├── littleendian │ ├── fuzz-527178.in │ ├── fuzz-527178.out │ ├── ldc2i.in │ ├── ldc2i.out │ ├── lds2i.in │ ├── lds2i.out │ ├── lduc2ui.in │ ├── lduc2ui.out │ ├── ldus2ui.in │ └── ldus2ui.out │ ├── loadstore.in │ ├── loadstore.out │ ├── mul_xxx.in │ ├── mul_xxx.out │ ├── mul_xxy.in │ ├── mul_xxy.out │ ├── mul_xyy.in │ ├── mul_xyy.out │ ├── mul_xyz.in │ ├── mul_xyz.out │ ├── muld.in │ ├── muld.out │ ├── muljovi.in │ ├── muljovi.out │ ├── muljovi_ovf.in │ ├── muljovi_ovf.out │ ├── muljovi_xxx.in │ ├── muljovi_xxx.out │ ├── muljovi_xxy.in │ ├── muljovi_xxy.out │ ├── muljovi_xyy.in │ ├── muljovi_xyy.out │ ├── muljovi_xyz.in │ ├── muljovi_xyz.out │ ├── mulov_xxx.in │ ├── mulov_xxx.out │ ├── mulov_xxy.in │ ├── mulov_xxy.out │ ├── mulov_xyy.in │ ├── mulov_xyy.out │ ├── mulov_xyz.in │ ├── mulov_xyz.out │ ├── multfrag1.in │ ├── multfrag1.out │ ├── multfrag2.in │ ├── multfrag2.out │ ├── multfrag3.in │ ├── multfrag3.out │ ├── negnot.in │ ├── negnot.out │ ├── negnotq.in │ ├── negnotq.out │ ├── random.out │ ├── shi.in │ ├── shi.out │ ├── softfloat │ ├── dhi2i.in │ ├── dhi2i.out │ ├── dlo2i.in │ ├── dlo2i.out │ ├── ii2d.in │ └── ii2d.out │ ├── std2f.in │ ├── std2f.out │ ├── subd.in │ ├── subd.out │ ├── subjovi.in │ ├── subjovi.out │ ├── subjovi_ovf.in │ └── subjovi_ovf.out └── vprof ├── manifest.mk ├── readme.txt ├── testVprofMT.c ├── vprof.cpp └── vprof.h /AVMPI/float4Support.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "avmplus.h" 8 | #include "float4Support.h" 9 | 10 | #ifdef VMCFG_GENERIC_FLOAT4 11 | namespace avmplus 12 | { 13 | /* Note: This file must be compiled with NEON turned on even for targets that don't have NEON, in order for the adapters to work. 14 | But VMCFG_NEON may be undefined, indicating that we don't want fast intrinsic implementation */ 15 | #ifdef VMCFG_FLOAT 16 | #ifdef VMCFG_ARM 17 | #include 18 | #define float4_ret_t float32x4_t 19 | #elif defined VMCFG_SSE2 20 | #include 21 | #define float4_ret_t __m128 22 | #else 23 | #error Unsupported platform in float4Support.cpp 24 | #endif 25 | #else 26 | 27 | #endif 28 | 29 | typedef union { 30 | float4_ret_t f4_jit; 31 | float4_t f4; 32 | } rvtype; 33 | 34 | // Alignment is buggy in MSVC, do it by hand. 35 | #define DECLARE_ALIGNED_FLOAT4_PTR(v) \ 36 | float locals[8]; \ 37 | uintptr_t lptr = (uintptr_t)(&locals[0]);\ 38 | rvtype *v = reinterpret_cast((lptr + 0xf) & ~0xf); 39 | 40 | float4_ret_t verifyEnterVECR_adapter_impl(avmplus::MethodEnv* env, int32_t argc, uint32_t* ap){ 41 | DECLARE_ALIGNED_FLOAT4_PTR(retval); 42 | retval->f4 = avmplus::BaseExecMgr::verifyEnterVECR(env, argc, ap); 43 | return retval->f4_jit; 44 | } 45 | 46 | float4_t thunkEnterVECR_adapter_impl(void* thunk_p, MethodEnv* env, int32_t argc, uint32_t* argv){ 47 | typedef float4_ret_t (*VecrThunk)(avmplus::MethodEnv* env, int32_t argc, uint32_t* argv); 48 | DECLARE_ALIGNED_FLOAT4_PTR(retval); 49 | if( thunk_p) // prevent ARM GCC from doing CSE, it crashes otherwise 50 | retval->f4_jit = ((VecrThunk) thunk_p)(env, argc, argv); 51 | return retval->f4; 52 | } 53 | #ifdef DEBUGGER 54 | float4_ret_t debugEnterVECR_adapter_impl(avmplus::MethodEnv* env, int32_t argc, uint32_t* ap){ 55 | DECLARE_ALIGNED_FLOAT4_PTR(retval); 56 | retval->f4 = avmplus::BaseExecMgr::debugEnterExitWrapperV(env, argc, ap); 57 | return retval->f4_jit; 58 | } 59 | const VecrMethodProc debugEnterVECR_adapter = (VecrMethodProc) debugEnterVECR_adapter_impl; 60 | #endif 61 | 62 | const VecrMethodProc verifyEnterVECR_adapter = (VecrMethodProc) verifyEnterVECR_adapter_impl; 63 | const VecrThunkProc thunkEnterVECR_adapter = thunkEnterVECR_adapter_impl; 64 | 65 | } 66 | #endif 67 | // TODO: leave these for "#if !defined(VMCFG_NEON) && !defined(VMCFG_SSE2)", add hardware-accellerated versions for NEON and SSE2 68 | float4_t f4_add(const float4_t& x1, const float4_t& x2) 69 | { 70 | float4_t retval = { x1.x + x2.x, x1.y + x2.y, x1.z + x2.z, x1.w + x2.w }; 71 | return retval; 72 | } 73 | 74 | float4_t f4_sub(const float4_t& x1, const float4_t& x2) 75 | { 76 | float4_t retval = { x1.x - x2.x, x1.y - x2.y, x1.z - x2.z, x1.w - x2.w }; 77 | return retval; 78 | } 79 | 80 | float4_t f4_mul(const float4_t& x1, const float4_t& x2) 81 | { 82 | float4_t retval = { x1.x * x2.x, x1.y * x2.y, x1.z * x2.z, x1.w * x2.w }; 83 | return retval; 84 | } 85 | 86 | float4_t f4_div(const float4_t& x1, const float4_t& x2) 87 | { 88 | float4_t retval = { x1.x / x2.x, x1.y / x2.y, x1.z / x2.z, x1.w / x2.w }; 89 | return retval; 90 | } 91 | -------------------------------------------------------------------------------- /AVMPI/float4Support.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | 8 | #ifndef __float4Support__ 9 | #define __float4Support__ 10 | 11 | #include 12 | 13 | #if defined(VMCFG_GENERIC_FLOAT4) || !defined(VMCFG_FLOAT) 14 | /** 15 | * Float4 support, no intrinsics 16 | */ 17 | typedef 18 | struct float4_t { 19 | float x, y, z, w; 20 | } float4_t; 21 | 22 | 23 | /* These may be hardware-accelerated and slighly imprecise (e.g. in handling of denormal numbers) 24 | The implementation stays in .cpp so it can be done in the same way that the CodegenLIR.cpp does it */ 25 | float4_t f4_add(const float4_t& x1, const float4_t& x2); 26 | float4_t f4_sub(const float4_t& x1, const float4_t& x2); 27 | float4_t f4_mul(const float4_t& x1, const float4_t& x2); 28 | float4_t f4_div(const float4_t& x1, const float4_t& x2); 29 | 30 | 31 | REALLY_INLINE int32_t f4_eq_i(const float4_t& x1, const float4_t& x2) 32 | { 33 | return (x1.x == x2.x) && (x1.y == x2.y) && (x1.z == x2.z) && (x1.w == x2.w); 34 | } 35 | 36 | // in hardware: vdupq_n_f32/ _mm_set_ps1 37 | REALLY_INLINE float4_t f4_setall(float v) 38 | { 39 | float4_t retval = {v, v, v, v}; 40 | return retval; 41 | } 42 | 43 | // in hardware: vdupq_n_f32, or _mm_sqrt_ps 44 | REALLY_INLINE float4_t f4_sqrt(const float4_t& v) 45 | { 46 | float4_t retval = { sqrtf(v.x), sqrtf(v.y), sqrtf(v.z), sqrtf(v.w)}; 47 | return retval; 48 | } 49 | 50 | REALLY_INLINE float f4_x(const float4_t& v) { return v.x; } 51 | REALLY_INLINE float f4_y(const float4_t& v) { return v.y; } 52 | REALLY_INLINE float f4_z(const float4_t& v) { return v.z; } 53 | REALLY_INLINE float f4_w(const float4_t& v) { return v.w; } 54 | 55 | 56 | /** 57 | * Float4 support through intrinsics starts below 58 | */ 59 | 60 | 61 | #else // not VMCFG_GENERIC_FLOAT4 62 | #define verifyEnterVECR_adapter verifyEnterVECR 63 | #define debugEnterVECR_adapter debugEnterExitWrapperV 64 | #define thunkEnterVECR_adapter(thunk, env, argc, argv) ((VecrMethodProc)thunk)(env,argc,argv) 65 | 66 | #if defined VMCFG_SSE2 67 | #include 68 | 69 | typedef __m128 float4_t; 70 | 71 | #define f4_add _mm_add_ps 72 | #define f4_sub _mm_sub_ps 73 | #define f4_mul _mm_mul_ps 74 | #define f4_div _mm_div_ps 75 | #define f4_setall _mm_set_ps1 76 | #define f4_sqrt _mm_sqrt_ps 77 | 78 | REALLY_INLINE int32_t f4_eq_i(float4_t a, float4_t b) 79 | { 80 | return (_mm_movemask_epi8(_mm_castps_si128(_mm_cmpneq_ps(a, b))) == 0); 81 | } 82 | 83 | REALLY_INLINE float f4_x(float4_t v) { return _mm_cvtss_f32(v); } 84 | REALLY_INLINE float f4_y(float4_t v) { return _mm_cvtss_f32(_mm_shuffle_ps(v, v, 0x55)); } 85 | REALLY_INLINE float f4_z(float4_t v) { return _mm_cvtss_f32(_mm_shuffle_ps(v, v, 0xAA)); } 86 | REALLY_INLINE float f4_w(float4_t v) { return _mm_cvtss_f32(_mm_shuffle_ps(v, v, 0xFF)); } 87 | 88 | #elif defined VMCFG_NEON // FIXME: nobody defines VMCFG_NEON currently... this should change. 89 | #include 90 | 91 | typedef float32x4_t float4_t; 92 | 93 | #define f4_add vaddq_f32 94 | #define f4_sub vsubq_f32 95 | #define f4_mul vmulq_f32 96 | #define f4_sqrt vsqrtq_f32 97 | #define f4_setall vdupq_n_f32 98 | 99 | REALLY_INLINE int32_t f4_eq_i(float4_t a, float4_t b) 100 | { 101 | uint32x2_t res = vreinterpret_u32_u16(vmovn_u32(vceqq_f32(a, b))); 102 | return vget_lane_u32(res, 0) == 0xffffffff && vget_lane_u32(res, 1) == 0xffffffff; 103 | } 104 | 105 | REALLY_INLINE float f4_x(float4_t v) { return vgetq_lane_f32(v, 0); } 106 | REALLY_INLINE float f4_y(float4_t v) { return vgetq_lane_f32(v, 1); } 107 | REALLY_INLINE float f4_z(float4_t v) { return vgetq_lane_f32(v, 2); } 108 | REALLY_INLINE float f4_w(float4_t v) { return vgetq_lane_f32(v, 3); } 109 | 110 | REALLY_INLINE float4_t f4_div(float4_t a, float4_t b) 111 | { 112 | float4_t result = { f4_x(a) / f4_x(b), f4_y(a) / f4_y(b), f4_z(a) / f4_z(b), f4_w(a) / f4_w(b) }; 113 | return result; 114 | } 115 | #else 116 | #error Hardware-accellerated float4 support not implemented for the current system! The generic mode should have been activated. 117 | #endif 118 | 119 | #endif // VMCFG_GENERIC_FLOAT4 120 | #endif // __float4Support__ 121 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(nanojitextra) 3 | 4 | enable_language(CXX) 5 | enable_language(C) 6 | 7 | message(STATUS "OS type is ${CMAKE_SYSTEM_NAME}") 8 | message(STATUS "System processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}") 9 | message(STATUS "Build type is ${CMAKE_BUILD_TYPE}") 10 | 11 | if(CMAKE_SYSTEM_NAME STREQUAL Linux) 12 | add_definitions ( 13 | -DAVMPLUS_UNIX=1 14 | -DAVMPLUS_LINUX=1 15 | ) 16 | set(EXTRA_LIBS dl) 17 | elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) 18 | add_definitions ( 19 | -DAVMPLUS_UNIX=1 20 | ) 21 | elseif(CMAKE_SYSTEM_NAME STREQUAL Windows) 22 | add_definitions ( 23 | -DAVMPLUS_WIN32=1 24 | ) 25 | else() 26 | message(FATAL_ERROR "The build only supports Windows, Mac OSX and Linux currently") 27 | endif() 28 | 29 | string(TOUPPER ${CMAKE_HOST_SYSTEM_PROCESSOR} UPPERCASE_CMAKE_HOST_SYSTEM_PROCESSOR) 30 | 31 | if(UPPERCASE_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL X86_64 OR UPPERCASE_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL AMD64) 32 | add_definitions( 33 | -DAVMPLUS_64BIT=1 34 | -DAVMPLUS_AMD64=1 35 | -DVMCFG_SSE2=1 36 | ) 37 | set (NANOJIT_ARCH X64) 38 | elseif(UPPERCASE_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL I686) 39 | add_definitions( 40 | -DAVMPLUS_IA32 41 | -DVMCFG_SSE2=1 42 | ) 43 | set (NANOJIT_ARCH i386) 44 | else() 45 | message(FATAL_ERROR "The build only supports AMD64 and I386 currently") 46 | endif() 47 | 48 | add_definitions ( 49 | -DFEATURE_NANOJIT=1 50 | ) 51 | 52 | if (CMAKE_BUILD_TYPE) 53 | string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE) 54 | 55 | if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) 56 | add_definitions( 57 | -D_DEBUG=1 58 | -DDEBUG=1 59 | -DAVMPLUS_VERBOSE=1 60 | ) 61 | endif() 62 | else() 63 | message(FATAL_ERROR "Unknown build type! Set CMAKE_BUILD_TYPE to DEBUG, CHECKED, RELEASE, or RELWITHDEBINFO!") 64 | endif() 65 | 66 | if (MSVC) 67 | set(LIBRARY_TYPE STATIC) 68 | else() 69 | set(LIBRARY_TYPE SHARED) 70 | endif() 71 | 72 | if (UNIX AND NOT APPLE) 73 | # -fsanitize=bounds -fsanitize=alignment -fsanitize=object-size 74 | # set(SANITIZER_FLAGS "-fsanitize=address") 75 | set(CMAKE_C_FLAGS "${SANITIZER_FLAGS} -fno-omit-frame-pointer -std=c99 -O2 -g -Wall -Wno-comment ${CXX_OPTIONS}") 76 | set(CMAKE_C_FLAGS_DEBUG "${SANITIZER_FLAGS} -fno-omit-frame-pointer -std=c99 -O0 -g3 -Wall -Wno-comment ${CXX_OPTIONS}") 77 | set(CMAKE_C_FLAGS_RELEASE "-std=c99 -O3 -Wall -Wno-comment ${CXX_OPTIONS}") 78 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${SANITIZER_FLAGS} -std=c99 -O1 -g3 -Wall ${CXX_OPTIONS}") 79 | set(CMAKE_CXX_FLAGS "${SANITIZER_FLAGS} -fno-omit-frame-pointer -O0 -g3 -Wall -Wno-narrowing -Wno-sign-compare -std=c++11 -fno-exceptions ${CXX_OPTIONS}") 80 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -Wno-narrowing -Wno-sign-compare -std=c++11 -fno-exceptions ${CXX_OPTIONS}") 81 | set(CMAKE_CXX_FLAGS_DEBUG "${SANITIZER_FLAGS} -fno-omit-frame-pointer -O0 -g3 -Wall -Wno-narrowing -Wno-sign-compare -std=c++11 -fno-exceptions ${CXX_OPTIONS}") 82 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${SANITIZER_FLAGS} -O1 -g3 -Wall -Wno-narrowing -Wno-sign-compare -std=c++11 -fno-exceptions ${CXX_OPTIONS}") 83 | endif () 84 | 85 | include_directories( 86 | ${CMAKE_CURRENT_SOURCE_DIR} 87 | utils/nanojit-lirasm/VMPI.nj 88 | nanojit 89 | nanojitextra 90 | ) 91 | 92 | set (NATIVE_SRC 93 | nanojit/Native${NANOJIT_ARCH}.cpp 94 | ) 95 | set (LIB_SRCS 96 | nanojit/Allocator.cpp 97 | nanojit/Assembler.cpp 98 | nanojit/CodeAlloc.cpp 99 | nanojit/Containers.cpp 100 | nanojit/Fragmento.cpp 101 | nanojit/LIR.cpp 102 | nanojit/njconfig.cpp 103 | nanojit/RegAlloc.cpp 104 | utils/nanojit-lirasm/VMPI.nj/VMPI.cpp 105 | utils/nanojit-lirasm/VMPI.nj/avmplus.cpp 106 | vprof/vprof.cpp 107 | AVMPI/float4Support.cpp 108 | ) 109 | set (LIB_HEADERS 110 | nanojit/Allocator.h 111 | nanojit/Assembler.h 112 | nanojit/CodeAlloc.h 113 | nanojit/Containers.h 114 | nanojit/Fragmento.h 115 | nanojit/LIR.h 116 | nanojit/nanojit.h 117 | nanojit/Native.h 118 | nanojit/Native${NANOJIT_ARCH}.h 119 | nanojit/njconfig.h 120 | nanojit/RegAlloc.h 121 | ) 122 | 123 | set (EXT_SRCS 124 | nanojitextra/spi.cpp 125 | nanojitextra/nanojitextra.cpp) 126 | 127 | set (LIRASM_SRCS utils/nanojit-lirasm/lirasm/lirasm.cpp) 128 | 129 | set (NANOJITEXTRA_HEADERS nanojitextra/nanojitextra.h) 130 | 131 | add_library(nanojit ${LIBRARY_TYPE} ${LIB_SRCS} ${NATIVE_SRC} ${LIB_HEADERS}) 132 | target_link_libraries(nanojit ${EXTRA_LIBS}) 133 | if(APPLE) 134 | set_target_properties(nanojit PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") 135 | endif() 136 | 137 | add_library(nanojitextra ${LIBRARY_TYPE} ${LIB_SRCS} ${NATIVE_SRC} ${EXT_SRCS} ${NANOJITEXTRA_HEADERS} ${LIB_HEADERS}) 138 | target_link_libraries(nanojitextra ${EXTRA_LIBS}) 139 | 140 | add_executable(lirasm ${LIRASM_SRCS}) 141 | target_link_libraries(lirasm nanojit) 142 | 143 | add_executable(example1 samples/example1.cpp) 144 | target_link_libraries(example1 nanojitextra) 145 | 146 | install(FILES ${NANOJITEXTRA_HEADERS} 147 | DESTINATION include/nanojit) 148 | install(TARGETS nanojitextra lirasm 149 | RUNTIME DESTINATION bin 150 | ARCHIVE DESTINATION lib 151 | LIBRARY DESTINATION lib) 152 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Nanojit 2 | 3 | ## Docs 4 | 5 | * [Overview](./overview.md) 6 | * [LIR Opcodes](./nanjit-opcodes.md) 7 | * [NanoJIT Notes](./details.md) 8 | -------------------------------------------------------------------------------- /docs/details.md: -------------------------------------------------------------------------------- 1 | # Some random titbits 2 | 3 | ## Function parameters 4 | 5 | ### JIT Functions can only take integer/pointer arguments 6 | At least on X64 a limitation in NanoJIT is that JIT compiled functions can only take a limited number of arguments. On Win64 the limit is upto 4 integer or pointer arguments. On UNIX platforms it is 6 arguments, again only integer or pointer values. These 7 | limitations arise as the current implementation only looks at the first 4/6 registers for arguments as per the X64 ABI. 8 | 9 | A JIT function should be able to return a double or float though - but this is something that is yet to be verified. 10 | 11 | ### External C functions can only take upto 8 arguments 12 | External C functions called from JIT code can only take upto 8 arguments, although in this case it it possible to 13 | to pass double or float values. Return values can also be double or float. 14 | 15 | ### All parameters are fixed size 16 | The LIR writer does not allow specifying whether a parameter is 32-bit or 64-bit. Apparently the size is set automatically based 17 | on machine architecture. See mozilla [bug 541232](https://bugzilla.mozilla.org/show_bug.cgi?id=541232). 18 | 19 | This limitation means that for a JITed function, parameters are always the architecture word size, i.e. 64-bit on 64-bit platforms, and 32-bit on 32-bit platforms. Also as described above, a JIT compiled function can only accept integer or pointer arguments therefore if you need to pass double values, just pass a pointer to a struct that contains the arguments. Of course Nanojit does not understand structs so you need to call the relevant memory load/store operations. 20 | 21 | ### Liveness requirements 22 | I found it necessary to copy function parameters to the stack, as the parameter value appears to not be preserved across jumps. 23 | 24 | Update: I understand from Edwin Smith (original Nanojit architect) that the reason why a parameter may be getting clobberred is because: 25 | 26 | > The register allocator computes virtual register liveness as it runs, while it 27 | is scanning LIR bottom-up. If the parameter register is being reused, it's 28 | because the register allocator thinks it's available. Since it's running bottom 29 | up, it will see the uses of a register before the definition, if the register is 30 | being used at all. 31 | 32 | > Loops are tricky. If a virtual register is being defined before the loop entry 33 | point, and used inside a loop, then it's live range must cover the whole loop. 34 | the frontend compiler must insert LIR_live at the loop jumps (back edges) 35 | to extend the live range. see LIR_livei, livep, etc.. 36 | 37 | ## Jumps and Labels 38 | The instruction set requires setting labels as jump targets. There is no concept of basic blocks as in LLVM, but a basic block can be simulated by having a sequence of code with a label at the beginning and a jump at the end. 39 | 40 | As far as I can see the code generation always inserts the next instruction into the current position within the LIR buffer, so that the way labels and jumps need to be handled is like this: 41 | 42 | * When you need to insert a jump, initially set jump target to NULL. This is okay. But keep track in a memory structure the logical target (e.g. the label name) for that jump target. 43 | * Assign labels to the start of each basic block as you generate code for each basic block - these will become jump targets. Maintain a map of labels names to instructions. 44 | * After code generation is completed go back through the list of jumps you created in step 1, and set the targets to the labels which are now in place. You use the map created in step 2 to locate the label instructions. 45 | 46 | -------------------------------------------------------------------------------- /docs/overview.md: -------------------------------------------------------------------------------- 1 | # nanojit Overview 2 | 3 | ## Acknowledgment 4 | 5 | This document is based upon the [Mozilla article](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/Tracing_JIT). 6 | 7 | ## LIR 8 | The nanojit/LIR.cpp and nanojit/LIR.h files define the intermediate representation LIR, which is used as input to nanojit. LIR is a conventional three-address, linear code. It is similar to SSA but not exactly so as it lacks phi nodes. A single instruction of LIR is called a LIns, short for "LIR instruction". The LIns values are inserted into a LIR buffer, itself contained within a logical fragment, and the nanojit compilation pipeline and Assembler transforms the LIns values into NIns values (i.e. machine code). 9 | 10 | ## Fragment 11 | A Fragment represents a chunk of code. A fragment can be made a function by giving it a LIR_start and appropriate return instructions, but it need not always be a function, i.e., it can be a fragment of a function. 12 | 13 | ## Assembler 14 | The nanojit/Assembler.cpp and nanojit/Assembler.h files define the class Assembler, which transforms LIns values into NIns values. In other words, an Assembler transforms LIR code into native code. An Assembler is also able to modify existing fragments of native code, by rewriting native jump instructions to jump to new locations. In this way the Assembler can "patch together" multiple fragments, so that program control can flow from one fragment into another, or back out of generated code and into the interpreter. 15 | An Assembler reads or writes native code. Therefore an Assembler contains several machine-specific methods which are implemented in the accompanying nanojit/Native*.* files. 16 | An Assembler runs in a single pass over its input, transforming one LIns value to zero or more NIns values. It is important to keep in mind that this pass runs backwards from the last LIns in the input LIR code to the first, generating native code in reverse. Running backwards sometimes makes the logic difficult to follow, but it is an essential factor in maintaining the Assembler's high speed and small size. 17 | 18 | ## RegAlloc 19 | Nanojit's register allocator. This is a local register allocator, meaning that it does not allocate registers across basic blocks. It is correspondingly very simple: register allocation is done immediately, step-by-step as code is being generated. A running tally is kept of assignments between registers and LIR operands, and any time a new LIR operand is required in a register a new one is assigned from the list of free registers. When all registers are in use, the least-often-used register currently in use is spilled. 20 | 21 | ## Native 22 | The files Nativei386.h, Nativei386.cpp, NativeARM.h, NativeARM.cpp, etc. each define architecture-specific methods within the Assembler class. Only one architecture-specific variant is included into any given build of the Assembler; the architecture is selected and fixed when the build is configured. 23 | The architecture-specific methods found in these files are the only functions within nanojit or TraceMonkey that emit raw bytes of machine-code into memory. 24 | -------------------------------------------------------------------------------- /nanojit/Allocator.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "nanojit.h" 8 | 9 | #ifdef FEATURE_NANOJIT 10 | 11 | namespace nanojit 12 | { 13 | Allocator::Allocator() 14 | : current_chunk(NULL) 15 | , current_top(NULL) 16 | , current_limit(NULL) 17 | { } 18 | 19 | Allocator::~Allocator() 20 | { 21 | reset(); 22 | } 23 | 24 | void Allocator::reset() 25 | { 26 | Chunk *c = current_chunk; 27 | while (c) { 28 | Chunk *prev = c->prev; 29 | freeChunk(c); 30 | c = prev; 31 | } 32 | current_chunk = NULL; 33 | current_top = NULL; 34 | current_limit = NULL; 35 | postReset(); 36 | } 37 | 38 | char* Allocator::allocSlow(size_t nbytes, size_t align_mask) 39 | { 40 | // We don't know how much padding will be needed for alignment 41 | // until the new chunk is allocated and we know its address, 42 | // thus we assume the worst here. 43 | fill(nbytes + align_mask); 44 | char* p = (char*)(((uintptr_t)current_top + align_mask) & ~align_mask); 45 | NanoAssert(p + nbytes <= current_limit); 46 | current_top = p + nbytes; 47 | return p; 48 | } 49 | 50 | void Allocator::fill(size_t nbytes) 51 | { 52 | if (nbytes < MIN_CHUNK_SZB) 53 | nbytes = MIN_CHUNK_SZB; 54 | size_t chunkbytes = sizeof(Chunk) + nbytes - sizeof(int64_t); 55 | void* mem = allocChunk(chunkbytes); 56 | NanoAssert(mem); 57 | Chunk* chunk = (Chunk*) mem; 58 | chunk->prev = current_chunk; 59 | chunk->size = chunkbytes; 60 | current_chunk = chunk; 61 | current_top = (char*)chunk->data; 62 | current_limit = (char*)mem + chunkbytes; 63 | } 64 | 65 | size_t Allocator::getBytesAllocated(size_t(*my_malloc_usable_size)(void *)) 66 | { 67 | size_t n = 0; 68 | Chunk *c = current_chunk; 69 | while (c) { 70 | size_t usable = my_malloc_usable_size(c); 71 | n += usable ? usable : c->size; 72 | c = c->prev; 73 | } 74 | return n; 75 | } 76 | } 77 | 78 | #endif // FEATURE_NANOJIT 79 | -------------------------------------------------------------------------------- /nanojit/Allocator.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #ifndef __nanojit_Allocator__ 8 | #define __nanojit_Allocator__ 9 | 10 | namespace nanojit 11 | { 12 | /** 13 | * Allocator is a bump-pointer allocator with an SPI for getting more 14 | * memory from embedder-implemented allocator, such as malloc()/free(). 15 | * 16 | * alloc() never returns NULL. The implementation of allocChunk() 17 | * is expected to perform a longjmp or exception when an allocation can't 18 | * proceed. 19 | */ 20 | class Allocator { 21 | public: 22 | Allocator(); 23 | ~Allocator(); 24 | 25 | // Usable space in the minimum chunk size; there are also a few bytes 26 | // used for administration. 27 | static const size_t MIN_CHUNK_SZB = 2000; 28 | 29 | void reset(); 30 | 31 | /** alloc memory, never return null. */ 32 | void* alloc(size_t nbytes, size_t align = 8) { 33 | const size_t align_mask = align - 1; 34 | NanoAssert((align & align_mask) == 0); // check alignment is power of 2 35 | char* p = (char*)(((uintptr_t)current_top + align_mask) & ~align_mask); 36 | if (p + nbytes <= current_limit) { 37 | current_top = p + nbytes; 38 | } else { 39 | p = allocSlow(nbytes, align_mask); 40 | NanoAssert(p); 41 | } 42 | return (void*)p; 43 | } 44 | 45 | size_t getBytesAllocated(size_t(*my_malloc_usable_size)(void *)); 46 | 47 | protected: 48 | char* allocSlow(size_t nbytes, size_t align_mask); 49 | void fill(size_t minbytes); 50 | 51 | class Chunk { 52 | public: 53 | Chunk* prev; 54 | size_t size; 55 | int64_t data[1]; // int64_t forces 8-byte alignment. 56 | }; 57 | 58 | Chunk* current_chunk; 59 | char* current_top; 60 | char* current_limit; 61 | 62 | // allocator SPI 63 | 64 | /** allocate another block from a host provided allocator */ 65 | void* allocChunk(size_t nbytes); 66 | 67 | /** free back to the same allocator */ 68 | void freeChunk(void*); 69 | 70 | /** hook for post-reset action. */ 71 | void postReset(); 72 | }; 73 | } 74 | 75 | // _MSC_VER >= 1900 supports C++11 where "alignof" is defined 76 | #if !defined(_MSC_VER) || (_MSC_VER < 1900) 77 | // function for computing type alignment 78 | template 79 | inline size_t alignof1() { 80 | struct Wrapper { char c; T t; private: Wrapper() {} }; 81 | return sizeof(Wrapper) - sizeof(T); 82 | } 83 | #endif 84 | 85 | /** global new overload enabling this pattern: new (allocator, align) T(...) */ 86 | inline void* operator new(size_t size, nanojit::Allocator &a, size_t align) { 87 | return a.alloc(size, align); 88 | } 89 | 90 | inline void* operator new(size_t size, nanojit::Allocator *a, size_t align) { 91 | return a->alloc(size, align); 92 | } 93 | 94 | /** global new overload enabling this pattern: new (allocator) T(...) */ 95 | inline void* operator new(size_t size, nanojit::Allocator &a) { 96 | return a.alloc(size); 97 | } 98 | inline void* operator new(size_t size, nanojit::Allocator *a) { 99 | return a->alloc(size); 100 | } 101 | 102 | /** global new[] overload enabling this pattern: new (allocator) T[] */ 103 | inline void* operator new[](size_t size, nanojit::Allocator& a) { 104 | return a.alloc(size); 105 | } 106 | inline void* operator new[](size_t size, nanojit::Allocator* a) { 107 | return a->alloc(size); 108 | } 109 | 110 | /** global new[] overload enabling this pattern: new (allocator,align) T[] */ 111 | inline void* operator new[](size_t size, nanojit::Allocator& a, size_t align) { 112 | return a.alloc(size, align); 113 | } 114 | inline void* operator new[](size_t size, nanojit::Allocator* a, size_t align) { 115 | return a->alloc(size, align); 116 | } 117 | 118 | #endif // __nanojit_Allocator__ 119 | -------------------------------------------------------------------------------- /nanojit/Containers.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "nanojit.h" 8 | 9 | #ifdef FEATURE_NANOJIT 10 | 11 | namespace nanojit 12 | { 13 | BitSet::BitSet(Allocator& allocator, int nbits) 14 | : allocator(allocator) 15 | , cap((nbits+63)>>6) 16 | { 17 | resetAndAlloc(); 18 | } 19 | 20 | void BitSet::resetAndAlloc() 21 | { 22 | bits = (int64_t*)allocator.alloc(cap * sizeof(int64_t)); 23 | reset(); 24 | } 25 | 26 | void BitSet::reset() 27 | { 28 | for (int i=0, n=cap; i < n; i++) 29 | bits[i] = 0; 30 | } 31 | 32 | bool BitSet::setFrom(BitSet& other) 33 | { 34 | int c = other.cap; 35 | if (c > cap) 36 | grow(c); 37 | int64_t *bits = this->bits; 38 | int64_t *otherbits = other.bits; 39 | int64_t newbits = 0; 40 | for (int i=0; i < c; i++) { 41 | int64_t b = bits[i]; 42 | int64_t b2 = otherbits[i]; 43 | newbits |= b2 & ~b; // bits in b2 that are not in b 44 | bits[i] = b|b2; 45 | } 46 | return newbits != 0; 47 | } 48 | 49 | /** keep doubling the bitset length until w fits */ 50 | void BitSet::grow(int w) 51 | { 52 | int cap2 = cap; 53 | do { 54 | cap2 <<= 1; 55 | } while (w >= cap2); 56 | int64_t *bits2 = (int64_t*) allocator.alloc(cap2 * sizeof(int64_t)); 57 | int j=0; 58 | for (; j < cap; j++) 59 | bits2[j] = bits[j]; 60 | for (; j < cap2; j++) 61 | bits2[j] = 0; 62 | cap = cap2; 63 | bits = bits2; 64 | } 65 | } 66 | 67 | #endif // FEATURE_NANOJIT 68 | -------------------------------------------------------------------------------- /nanojit/Fragmento.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "nanojit.h" 8 | 9 | namespace nanojit 10 | { 11 | #ifdef FEATURE_NANOJIT 12 | 13 | using namespace avmplus; 14 | 15 | // 16 | // Fragment 17 | // 18 | Fragment::Fragment(const void* _ip 19 | verbose_only(, uint32_t profFragID)) 20 | : 21 | lirbuf(NULL), 22 | lastIns(NULL), 23 | ip(_ip), 24 | recordAttempts(0), 25 | fragEntry(NULL), 26 | verbose_only( loopLabel(NULL), ) 27 | verbose_only( profFragID(profFragID), ) 28 | verbose_only( profCount(0), ) 29 | verbose_only( nStaticExits(0), ) 30 | verbose_only( nCodeBytes(0), ) 31 | verbose_only( nExitBytes(0), ) 32 | verbose_only( guardNumberer(1), ) 33 | verbose_only( guardsForFrag(NULL), ) 34 | _code(NULL), 35 | _hits(0) 36 | { 37 | // when frag profiling is enabled, profFragID should be >= 1, 38 | // else it should be zero. However, there's no way to assert 39 | // that here since there's no way to determine whether frag 40 | // profiling is enabled. 41 | } 42 | #endif /* FEATURE_NANOJIT */ 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /nanojit/Fragmento.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | 8 | #ifndef __nanojit_Fragmento__ 9 | #define __nanojit_Fragmento__ 10 | 11 | namespace nanojit 12 | { 13 | struct GuardRecord; 14 | 15 | /** 16 | * Fragments are linear sequences of native code that have a single entry 17 | * point at the start of the fragment and may have one or more exit points 18 | * 19 | * It may turn out that that this arrangement causes too much traffic 20 | * between d and i-caches and that we need to carve up the structure differently. 21 | */ 22 | class Fragment 23 | { 24 | public: 25 | Fragment(const void* 26 | verbose_only(, uint32_t profFragID)); 27 | //### FIXME 28 | #ifdef NANOJIT_THUMB2 29 | NIns* code() { return (NIns*)((uintptr_t)_code | 0x1); } 30 | #else 31 | NIns* code() { return _code; } 32 | #endif 33 | void setCode(NIns* codee) { _code = codee; } 34 | int32_t& hits() { return _hits; } 35 | 36 | LirBuffer* lirbuf; 37 | LIns* lastIns; 38 | 39 | const void* ip; 40 | uint32_t recordAttempts; 41 | NIns* fragEntry; 42 | 43 | // for fragment entry and exit profiling. See detailed 44 | // how-to-use comment below. 45 | verbose_only( LIns* loopLabel; ) // where's the loop top? 46 | verbose_only( uint32_t profFragID; ) 47 | verbose_only( uint32_t profCount; ) 48 | verbose_only( uint32_t nStaticExits; ) 49 | verbose_only( size_t nCodeBytes; ) 50 | verbose_only( size_t nExitBytes; ) 51 | verbose_only( uint32_t guardNumberer; ) 52 | verbose_only( GuardRecord* guardsForFrag; ) 53 | 54 | private: 55 | NIns* _code; // ptr to start of code 56 | int32_t _hits; 57 | }; 58 | } 59 | 60 | /* 61 | * How to use fragment profiling 62 | * 63 | * Fragprofiling adds code to count how many times each fragment is 64 | * entered, and how many times each guard (exit) is taken. Using this 65 | * it's possible to easily find which fragments are hot, which ones 66 | * typically exit early, etc. The fragprofiler also gathers some 67 | * simple static info: for each fragment, the number of code bytes, 68 | * number of exit-block bytes, and number of guards (exits). 69 | * 70 | * Fragments and guards are given unique IDs (FragID, GuardID) which 71 | * are shown in debug printouts, so as to facilitate navigating from 72 | * the accumulated statistics to the associated bits of code. 73 | * GuardIDs are issued automatically, but FragIDs you must supply when 74 | * calling Fragment::Fragment. Supply values >= 1, and supply a 75 | * different value for each new fragment (doesn't matter what, they 76 | * just have to be unique and >= 1); else 77 | * js_FragProfiling_FragFinalizer will assert. 78 | * 79 | * How to use/embed: 80 | * 81 | * - use a debug build (one with NJ_VERBOSE). Without it, none of 82 | * this code is compiled in. 83 | * 84 | * - set LC_FragProfile in the lcbits of the LogControl* object handed 85 | * to Nanojit 86 | * 87 | * When enabled, Fragment::profCount is incremented every time the 88 | * fragment is entered, and GuardRecord::profCount is incremented 89 | * every time that guard exits. However, NJ has no way to know where 90 | * the fragment entry/loopback point is. So you must set 91 | * Fragment::loopLabel before running the assembler, so as to indicate 92 | * where the fragment-entry counter increment should be placed. If 93 | * the fragment does not naturally have a loop label then you will 94 | * need to artificially add one. 95 | * 96 | * It is the embedder's problem to fish out, collate and present the 97 | * accumulated stats at the end of the Fragment's lifetime. A 98 | * Fragment contains stats indicating its entry count and static code 99 | * sizes. It also has a ::guardsForFrag field, which is a linked list 100 | * of GuardRecords, and by traversing them you can get hold of the 101 | * exit counts. 102 | */ 103 | 104 | #endif // __nanojit_Fragmento__ 105 | -------------------------------------------------------------------------------- /nanojit/Native.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | 8 | #ifndef __nanojit_Native__ 9 | #define __nanojit_Native__ 10 | 11 | // define PEDANTIC=1 to ignore specialized forms, force general forms 12 | // for everything, far branches, extra page-linking, etc. This will 13 | // flush out many corner cases. 14 | 15 | #define PEDANTIC 0 16 | #if PEDANTIC 17 | # define UNLESS_PEDANTIC(...) 18 | # define IF_PEDANTIC(...) __VA_ARGS__ 19 | #else 20 | # define UNLESS_PEDANTIC(...) __VA_ARGS__ 21 | # define IF_PEDANTIC(...) 22 | #endif 23 | 24 | #ifdef NANOJIT_IA32 25 | #include "Nativei386.h" 26 | #elif defined(NANOJIT_THUMB2) 27 | #include "NativeThumb2.h" 28 | #elif defined(NANOJIT_ARM) 29 | #include "NativeARM.h" 30 | #elif defined(NANOJIT_PPC) 31 | #include "NativePPC.h" 32 | #elif defined(NANOJIT_SPARC) 33 | #include "NativeSparc.h" 34 | #elif defined(NANOJIT_X64) 35 | #include "NativeX64.h" 36 | #elif defined(NANOJIT_SH4) 37 | #include "NativeSH4.h" 38 | #elif defined(NANOJIT_MIPS) 39 | #include "NativeMIPS.h" 40 | #else 41 | #error "unknown nanojit architecture" 42 | #endif 43 | 44 | #ifndef NJ_USES_IMMD_POOL 45 | # define NJ_USES_IMMD_POOL 0 46 | #endif 47 | 48 | #ifndef NJ_USES_IMMF4_POOL 49 | # define NJ_USES_IMMF4_POOL 0 50 | #endif 51 | 52 | #ifndef NJ_JTBL_SUPPORTED 53 | # define NJ_JTBL_SUPPORTED 0 54 | #endif 55 | 56 | #ifndef NJ_EXPANDED_LOADSTORE_SUPPORTED 57 | # define NJ_EXPANDED_LOADSTORE_SUPPORTED 0 58 | #endif 59 | 60 | #ifndef NJ_F2I_SUPPORTED 61 | # define NJ_F2I_SUPPORTED 0 62 | #endif 63 | 64 | #ifndef NJ_SOFTFLOAT_SUPPORTED 65 | # define NJ_SOFTFLOAT_SUPPORTED 0 66 | #endif 67 | 68 | #ifndef NJ_DIVI_SUPPORTED 69 | # define NJ_DIVI_SUPPORTED 0 70 | #endif 71 | 72 | #if NJ_SOFTFLOAT_SUPPORTED 73 | #define CASESF(x) case x 74 | #else 75 | #define CASESF(x) 76 | #endif 77 | 78 | namespace nanojit { 79 | 80 | class Fragment; 81 | struct SideExit; 82 | 83 | struct GuardRecord 84 | { 85 | void* jmp; 86 | GuardRecord* next; 87 | SideExit* exit; 88 | // profiling stuff 89 | verbose_only( uint32_t profCount; ) 90 | verbose_only( uint32_t profGuardID; ) 91 | verbose_only( GuardRecord* nextInFrag; ) 92 | }; 93 | 94 | struct SideExit 95 | { 96 | GuardRecord* guards; 97 | Fragment* from; 98 | Fragment* target; 99 | 100 | void addGuard(GuardRecord* gr) 101 | { 102 | NanoAssert(gr->next == NULL); 103 | NanoAssert(guards != gr); 104 | gr->next = guards; 105 | guards = gr; 106 | } 107 | }; 108 | } 109 | 110 | #define isSPorFP(r) ( (r)==SP || (r)==FP ) 111 | 112 | #if defined(NJ_VERBOSE) 113 | inline char cvaltoa(unsigned char u) { 114 | return u<10 ? u+'0' : u+'a'-10; 115 | } 116 | 117 | inline char* appendHexVals(char* str, char* valFrom, char* valTo) { 118 | NanoAssert(valFrom <= valTo); 119 | str += VMPI_strlen(str); 120 | for(char* ch = valFrom; ch < valTo; ch++) { 121 | unsigned char u = (unsigned char)*ch; 122 | *str++ = cvaltoa(u >> 4); 123 | *str++ = cvaltoa(u & 0xf); 124 | *str++ = ' '; 125 | } 126 | *str = '\0'; 127 | return str; 128 | } 129 | 130 | inline char* padTo(char* str, int n, char c=' ') { 131 | char* start = str + VMPI_strlen(str); 132 | char* end = &str[n]; 133 | while(start < end) 134 | *start++ = c; 135 | *end = '\0'; 136 | return end; 137 | } 138 | 139 | // Used for printing native instructions. Like Assembler::outputf(), 140 | // but only outputs if LC_Native is set. Also prepends the output 141 | // with the address of the current native instruction. 142 | #define asm_output(...) do { \ 143 | if (_logc->lcbits & LC_Native) { \ 144 | maybe_disassemble(); \ 145 | outline[0]='\0'; \ 146 | VMPI_sprintf(outline, "%p ", _nIns); \ 147 | if (_logc->lcbits & LC_Bytes) { \ 148 | appendHexVals(outline, (char*)_nIns, (char*)_nInsAfter); \ 149 | padTo(outline, 3*15); \ 150 | } \ 151 | VMPI_sprintf(outline + VMPI_strlen(outline), ##__VA_ARGS__); \ 152 | output(); \ 153 | _nInsAfter = _nIns; \ 154 | } \ 155 | } while (0) /* no semi */ 156 | #define gpn(r) regNames[(REGNUM(r))] 157 | #else 158 | #define asm_output(...) 159 | #define gpn(r) 160 | #endif /* NJ_VERBOSE */ 161 | 162 | #endif // __nanojit_Native__ 163 | -------------------------------------------------------------------------------- /nanojit/NativeCommon.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #ifndef __nanojit_NativeCommon__ 8 | #define __nanojit_NativeCommon__ 9 | 10 | namespace nanojit 11 | { 12 | // In debug builds, Register is defined as a non-integer type to avoid 13 | // possible mix-ups with RegisterMask and integer offsets. In non-debug 14 | // builds, it's defined as an integer just in case some compilers fail to 15 | // optimize single-element structs in the obvious way. 16 | // 17 | // Note that in either case, a Register can be initialized like so: 18 | // 19 | // Register r = { 0 }; 20 | // 21 | // In the debug case it's a struct initializer, in the non-debug case it's 22 | // a scalar initializer. 23 | // 24 | // XXX: The exception to all the above is that if NJ_USE_UINT32_REGISTER 25 | // is defined, the back-end is responsible for defining its own Register 26 | // type, which will probably be an enum. This is just to give all the 27 | // back-ends a chance to transition smoothly. 28 | #if defined(NJ_USE_UINT32_REGISTER) 29 | #define REGNUM(r) (r) 30 | 31 | #elif defined(DEBUG) || defined(__SUNPRO_CC) 32 | // Always use struct declaration for 'Register' with 33 | // Solaris Studio C++ compiler, because it has a bug: 34 | // Scalar type can not be initialized by '{1}'. 35 | // See bug 603560. 36 | 37 | struct Register { 38 | uint32_t n; // the register number 39 | }; 40 | 41 | static inline uint32_t REGNUM(Register r) { 42 | return r.n; 43 | } 44 | 45 | static inline Register operator+(Register r, int c) 46 | { 47 | r.n += c; 48 | return r; 49 | } 50 | 51 | static inline bool operator==(Register r1, Register r2) 52 | { 53 | return r1.n == r2.n; 54 | } 55 | 56 | static inline bool operator!=(Register r1, Register r2) 57 | { 58 | return r1.n != r2.n; 59 | } 60 | 61 | static inline bool operator<=(Register r1, Register r2) 62 | { 63 | return r1.n <= r2.n; 64 | } 65 | 66 | static inline bool operator<(Register r1, Register r2) 67 | { 68 | return r1.n < r2.n; 69 | } 70 | 71 | static inline bool operator>=(Register r1, Register r2) 72 | { 73 | return r1.n >= r2.n; 74 | } 75 | 76 | static inline bool operator>(Register r1, Register r2) 77 | { 78 | return r1.n > r2.n; 79 | } 80 | #else 81 | typedef uint32_t Register; 82 | 83 | static inline uint32_t REGNUM(Register r) { 84 | return r; 85 | } 86 | #endif 87 | 88 | #ifndef RA_REGISTERS_OVERLAP 89 | #define rmask(r) ( (RegisterMask(1)) << REGNUM(r) ) 90 | #endif // otherwishe, it's the platform's responsibility to define rmask 91 | 92 | } // namespace nanojit 93 | 94 | #endif // __nanojit_NativeCommon__ 95 | -------------------------------------------------------------------------------- /nanojit/manifest.mk: -------------------------------------------------------------------------------- 1 | 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | 6 | nanojit_cpu_cxxsrc = $(error Unrecognized target CPU.) 7 | 8 | ifeq (i686,$(TARGET_CPU)) 9 | nanojit_cpu_cxxsrc := Nativei386.cpp 10 | endif 11 | 12 | ifeq (x86_64,$(TARGET_CPU)) 13 | nanojit_cpu_cxxsrc := NativeX64.cpp 14 | endif 15 | 16 | ifeq (powerpc,$(TARGET_CPU)) 17 | nanojit_cpu_cxxsrc := NativePPC.cpp 18 | endif 19 | 20 | ifeq (ppc64,$(TARGET_CPU)) 21 | nanojit_cpu_cxxsrc := NativePPC.cpp 22 | endif 23 | 24 | ifeq (arm,$(TARGET_CPU)) 25 | nanojit_cpu_cxxsrc := NativeARM.cpp 26 | endif 27 | 28 | ifeq (thumb2,$(TARGET_CPU)) 29 | nanojit_cpu_cxxsrc := NativeThumb2.cpp 30 | endif 31 | 32 | ifeq (sparc,$(TARGET_CPU)) 33 | nanojit_cpu_cxxsrc := NativeSparc.cpp 34 | endif 35 | 36 | ifeq (sh4,$(TARGET_CPU)) 37 | nanojit_cpu_cxxsrc := NativeSH4.cpp 38 | endif 39 | 40 | ifeq (mips,$(TARGET_CPU)) 41 | nanojit_cpu_cxxsrc := NativeMIPS.cpp 42 | endif 43 | 44 | avmplus_CXXSRCS := $(avmplus_CXXSRCS) \ 45 | $(curdir)/Allocator.cpp \ 46 | $(curdir)/Assembler.cpp \ 47 | $(curdir)/CodeAlloc.cpp \ 48 | $(curdir)/Containers.cpp \ 49 | $(curdir)/Fragmento.cpp \ 50 | $(curdir)/LIR.cpp \ 51 | $(curdir)/njconfig.cpp \ 52 | $(curdir)/RegAlloc.cpp \ 53 | $(curdir)/$(nanojit_cpu_cxxsrc) \ 54 | $(NULL) 55 | 56 | ifeq ($(COMPILER),VS) 57 | # Disable the 'cast truncates constant value' warning, incurred by 58 | # macros encoding instruction operands in machine code fields. 59 | $(curdir)/Assembler.obj $(curdir)/Nativei386.obj: avmplus_CXXFLAGS += -wd4310 60 | endif 61 | -------------------------------------------------------------------------------- /nanojit/njconfig.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "nanojit.h" 8 | 9 | #ifdef FEATURE_NANOJIT 10 | 11 | namespace nanojit 12 | { 13 | #ifdef NANOJIT_IA32 14 | static void setCpuFeatures(Config* config) 15 | { 16 | int ecx_flags = 0; 17 | int edx_flags = 0; 18 | #if defined _MSC_VER 19 | __asm 20 | { 21 | pushad 22 | mov eax, 1 23 | cpuid 24 | mov edx_flags, edx 25 | mov ecx_flags, ecx 26 | popad 27 | } 28 | #elif defined __GNUC__ 29 | asm("xchg %%esi, %%ebx\n" /* we can't clobber ebx on gcc (PIC register) */ 30 | "mov $0x01, %%eax\n" 31 | "cpuid\n" 32 | "mov %%edx, %0\n" 33 | "mov %%ecx, %1\n" 34 | "xchg %%esi, %%ebx\n" 35 | : "=m" (edx_flags), "=m" (ecx_flags) 36 | : /* We have no inputs */ 37 | : "%eax", "%esi", "%ecx", "%edx" 38 | ); 39 | #elif defined __SUNPRO_C || defined __SUNPRO_CC 40 | asm("push %%ebx\n" 41 | "mov $0x01, %%eax\n" 42 | "cpuid\n" 43 | "pop %%ebx\n" 44 | : "=d" (edx_flags), "=c", (ecx_flags) 45 | : /* We have no inputs */ 46 | : "%eax", "%ecx" 47 | ); 48 | #endif 49 | 50 | config->i386_sse2 = (edx_flags & (1 << 26)) != 0; 51 | config->i386_sse3 = (ecx_flags & (1 << 0)) != 0; 52 | config->i386_sse41 = (ecx_flags & (1 << 19)) != 0; 53 | config->i386_use_cmov = (edx_flags & (1<<15)) != 0; 54 | config->i386_fixed_esp = false; 55 | } 56 | #endif 57 | 58 | Config::Config() 59 | { 60 | VMPI_memset(this, 0, sizeof(*this)); 61 | 62 | cseopt = true; 63 | harden_function_alignment = false; 64 | harden_nop_insertion = false; 65 | harden_blind_constants = false; 66 | check_page_flags = false; 67 | 68 | #ifdef NANOJIT_STRESS_FORCE_LONG_BRANCH 69 | force_long_branch = true; 70 | #else 71 | force_long_branch = false; 72 | #endif 73 | 74 | #ifdef NANOJIT_IA32 75 | setCpuFeatures(this); 76 | #endif 77 | 78 | // FIXME: Thumb2 requires V7+. 79 | #if defined(NANOJIT_ARM) || defined(NANOJIT_THUMB2) 80 | NanoStaticAssert(NJ_COMPILER_ARM_ARCH >= 4 && NJ_COMPILER_ARM_ARCH <= 7); 81 | arm_arch = NJ_COMPILER_ARM_ARCH; 82 | arm_vfp = (arm_arch >= 7); 83 | 84 | #if defined(DEBUG) || defined(_DEBUG) 85 | arm_show_stats = true; 86 | #else 87 | arm_show_stats = false; 88 | #endif 89 | 90 | soft_float = !arm_vfp; 91 | 92 | #endif // NANOJIT_ARM 93 | } 94 | } 95 | #endif /* FEATURE_NANOJIT */ 96 | -------------------------------------------------------------------------------- /nanojit/njconfig.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #ifndef __njconfig_h__ 8 | #define __njconfig_h__ 9 | 10 | #include "avmplus.h" 11 | 12 | // Do not include nanojit.h here; this file should be usable without it. 13 | 14 | #ifdef FEATURE_NANOJIT 15 | 16 | namespace nanojit 17 | { 18 | /** 19 | * A struct used to configure the assumptions that Assembler can make when 20 | * generating code. The ctor will fill in all fields with the most reasonable 21 | * values it can derive from compiler flags and/or runtime detection, but 22 | * the embedder is free to override any or all of them as it sees fit. 23 | * Using the ctor-provided default setup is guaranteed to provide a safe 24 | * runtime environment (though perhaps suboptimal in some cases), so an embedder 25 | * should replace these values with great care. 26 | * 27 | * Note that although many fields are used on only specific architecture(s), 28 | * this struct is deliberately declared without ifdef's for them, so (say) ARM-specific 29 | * fields are declared everywhere. This reduces build dependencies (so that this 30 | * files does not require nanojit.h to be included beforehand) and also reduces 31 | * clutter in this file; the extra storage space required is trivial since most 32 | * fields are single bits. 33 | */ 34 | struct Config 35 | { 36 | public: 37 | // fills in reasonable default values for all fields. 38 | Config(); 39 | 40 | // ARM architecture to assume when generate instructions for (currently, 4 <= arm_arch <= 7) 41 | uint8_t arm_arch; 42 | 43 | // If true, use CSE. 44 | uint32_t cseopt:1; 45 | 46 | // If true, use full-range addressing for branches even when a short branch will suffice (x86-64 only) 47 | uint32_t force_long_branch:1; 48 | 49 | // Can we use SSE2 instructions? (x86-only) 50 | uint32_t i386_sse2:1; 51 | 52 | // Can we use SSE3 instructions? (x86-only) 53 | uint32_t i386_sse3:1; 54 | 55 | // Can we use SSE4.1 instructions? (x86 only) 56 | uint32_t i386_sse41:1; 57 | 58 | // Can we use cmov instructions? (x86-only) 59 | uint32_t i386_use_cmov:1; 60 | 61 | // Should we use a virtual stack pointer? (x86-only) 62 | uint32_t i386_fixed_esp:1; 63 | 64 | // Whether or not to generate VFP instructions. (ARM only) 65 | uint32_t arm_vfp:1; 66 | 67 | // @todo, document me 68 | uint32_t arm_show_stats:1; 69 | 70 | // If true, use softfloat for all floating point operations, 71 | // whether or not an FPU is present. (ARM only for now, but might also includes MIPS in the future) 72 | uint32_t soft_float:1; 73 | 74 | // If true, compiler will insert a random amount of space in between functions (x86-32 only) 75 | uint32_t harden_function_alignment:1; 76 | 77 | // If true, compiler will insert randomly choosen no-op instructions at random locations within a compiled method (x86-32 only) 78 | uint32_t harden_nop_insertion:1; 79 | 80 | // If true, compiler will attempt to minimize the ability of an attacker to control literal constants appearing in the code 81 | uint32_t harden_blind_constants:1; 82 | 83 | // Check protection flags when allocating memory for compiled code. 84 | uint32_t check_page_flags:1; 85 | 86 | inline bool 87 | use_cmov() 88 | { 89 | #ifdef AVMPLUS_IA32 90 | return i386_use_cmov; 91 | #else 92 | return true; 93 | #endif 94 | } 95 | }; 96 | 97 | 98 | /** 99 | * Abstract class for source of random numbers for JIT hardening. 100 | */ 101 | 102 | // Moved here from Assembler.h so it can be used without including nanojit.h. 103 | // The header files are a mess and could stand some rationalization. 104 | 105 | class Noise 106 | { 107 | public: 108 | virtual ~Noise() {} 109 | // Produce a random signed integer in the range 0..maxValue, where maxValue > 0. 110 | virtual int32_t getValue(int32_t maxValue) = 0; 111 | // Produce a random 32-bit unsigned integer. 112 | virtual uint32_t getValue32() = 0; 113 | }; 114 | 115 | } 116 | 117 | #endif // FEATURE_NANOJIT 118 | #endif // __njconfig_h__ 119 | -------------------------------------------------------------------------------- /nanojit/njcpudetect.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #ifndef __njcpudetect__ 8 | #define __njcpudetect__ 9 | 10 | /*** 11 | * Note: this file should not include *any* other files, nor should it wrap 12 | * itself in ifdef FEATURE_NANOJIT, nor should it do anything other than 13 | * define preprocessor symbols. 14 | */ 15 | 16 | /*** 17 | * NJ_COMPILER_ARM_ARCH attempts to specify the minimum ARM architecture 18 | * that the C++ compiler has specified. Note that although Config::arm_arch 19 | * is initialized to this value by default, there is no requirement that they 20 | * be in sync. 21 | * 22 | * Note, this is done via #define so that downstream preprocessor usage can 23 | * examine it, but please don't attempt to redefine it. 24 | * 25 | * Note, this is deliberately not encased in "ifdef NANOJIT_ARM", as this file 26 | * may be included before that is defined. On non-ARM platforms we will hit the 27 | * "Unable to determine" case. 28 | */ 29 | 30 | // GCC and RealView usually define __ARM_ARCH__ 31 | #if defined(__ARM_ARCH__) 32 | 33 | #define NJ_COMPILER_ARM_ARCH __ARM_ARCH__ 34 | 35 | // ok, try well-known GCC flags ( see http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html ) 36 | #elif defined(__ARM_ARCH_7__) || \ 37 | defined(__ARM_ARCH_7A__) || \ 38 | defined(__ARM_ARCH_7M__) || \ 39 | defined(__ARM_ARCH_7R__) || \ 40 | defined(_ARM_ARCH_7) 41 | 42 | #define NJ_COMPILER_ARM_ARCH 7 43 | 44 | #elif defined(__ARM_ARCH_6__) || \ 45 | defined(__ARM_ARCH_6J__) || \ 46 | defined(__ARM_ARCH_6K__) || \ 47 | defined(__ARM_ARCH_6T2__) || \ 48 | defined(__ARM_ARCH_6Z__) || \ 49 | defined(__ARM_ARCH_6ZK__) || \ 50 | defined(__ARM_ARCH_6M__) || \ 51 | defined(_ARM_ARCH_6) 52 | 53 | #define NJ_COMPILER_ARM_ARCH 6 54 | 55 | #elif defined(__ARM_ARCH_5__) || \ 56 | defined(__ARM_ARCH_5T__) || \ 57 | defined(__ARM_ARCH_5E__) || \ 58 | defined(__ARM_ARCH_5TE__) 59 | 60 | #define NJ_COMPILER_ARM_ARCH 5 61 | 62 | #elif defined(__ARM_ARCH_4T__) 63 | 64 | #define NJ_COMPILER_ARM_ARCH 4 65 | 66 | // Visual C has its own mojo 67 | #elif defined(_MSC_VER) && defined(_M_ARM) 68 | 69 | #define NJ_COMPILER_ARM_ARCH _M_ARM 70 | 71 | // RVCT 72 | #elif defined(__TARGET_ARCH_ARM) 73 | 74 | #define NJ_COMPILER_ARM_ARCH __TARGET_ARCH_ARM 75 | 76 | #else 77 | 78 | // non-numeric value 79 | #define NJ_COMPILER_ARM_ARCH "Unable to determine valid NJ_COMPILER_ARM_ARCH (nanojit only supports ARMv4T or later)" 80 | 81 | #endif 82 | 83 | #endif // __njcpudetect__ 84 | -------------------------------------------------------------------------------- /nanojitextra/spi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "nanojit/nanojit.h" 4 | 5 | using namespace nanojit; 6 | using namespace std; 7 | 8 | // We lump everything into a single access region for lirasm. 9 | static const AccSet ACCSET_OTHER = (1 << 0); 10 | static const uint8_t LIRASM_NUM_USED_ACCS = 1; 11 | 12 | 13 | #ifdef AVMPLUS_ARM 14 | float4_t vsqrtq_f32( float4_t q_x ) 15 | { 16 | const float4_t q_step_0 = vrsqrteq_f32( q_x ); 17 | // step 18 | const float4_t q_step_parm0 = vmulq_f32( q_x, q_step_0 ); 19 | const float4_t q_step_result0 = vrsqrtsq_f32( q_step_parm0, q_step_0 ); 20 | // step 21 | const float4_t q_step_1 = vmulq_f32( q_step_0, q_step_result0 ); 22 | const float4_t q_step_parm1 = vmulq_f32( q_x, q_step_1 ); 23 | const float4_t q_step_result1 = vrsqrtsq_f32( q_step_parm1, q_step_1 ); 24 | // take the res 25 | const float4_t q_step_2 = vmulq_f32( q_step_1, q_step_result1 ); 26 | // mul by x to get sqrt, not rsqrt 27 | return vmulq_f32( q_x, q_step_2 ); 28 | } 29 | #endif 30 | 31 | // FIXME: work around hard float coutn printing bug 32 | static std::ostream& print_float(float f) { 33 | cout << flush; 34 | printf("%g", f); 35 | return cout; 36 | } 37 | 38 | static std::ostream& print_double(double f) { 39 | cout << flush; 40 | printf("%g", f); 41 | return cout; 42 | } 43 | 44 | /* Macro to print floating point special vals. consistently across platforms */ 45 | #ifdef _MSC_VER 46 | #define print(x) (_isnan(x)? cout<<"NAN": _finite(x)?cout<0)? cout<<"INF":cout<<"-INF") 47 | #else 48 | #define print(x) (isnan(x)? cout<<"NAN": (x==INFINITY)?cout<<"INF":(x==-INFINITY)?cout<<"-INF":print_float(x)) 49 | #endif 50 | 51 | /* Allocator SPI implementation. */ 52 | 53 | void* 54 | nanojit::Allocator::allocChunk(size_t nbytes) 55 | { 56 | void *p = malloc(nbytes); 57 | if (!p) 58 | exit(1); 59 | return p; 60 | } 61 | 62 | void 63 | nanojit::Allocator::freeChunk(void *p) { 64 | free(p); 65 | } 66 | 67 | void 68 | nanojit::Allocator::postReset() { 69 | } 70 | 71 | 72 | struct LasmSideExit : public SideExit { 73 | size_t line; 74 | }; 75 | 76 | 77 | /* LIR SPI implementation */ 78 | 79 | int 80 | nanojit::StackFilter::getTop(LIns*) 81 | { 82 | return 0; 83 | } 84 | 85 | #if defined NJ_VERBOSE 86 | void 87 | nanojit::LInsPrinter::formatGuard(InsBuf *buf, LIns *ins) 88 | { 89 | RefBuf b1, b2; 90 | LasmSideExit *x = (LasmSideExit *)ins->record()->exit; 91 | VMPI_snprintf(buf->buf, buf->len, 92 | "%s: %s %s -> line=%ld (GuardID=%03d)", 93 | formatRef(&b1, ins), 94 | lirNames[ins->opcode()], 95 | ins->oprnd1() ? formatRef(&b2, ins->oprnd1()) : "", 96 | (long)x->line, 97 | ins->record()->profGuardID); 98 | } 99 | 100 | void 101 | nanojit::LInsPrinter::formatGuardXov(InsBuf *buf, LIns *ins) 102 | { 103 | RefBuf b1, b2, b3; 104 | LasmSideExit *x = (LasmSideExit *)ins->record()->exit; 105 | VMPI_snprintf(buf->buf, buf->len, 106 | "%s = %s %s, %s -> line=%ld (GuardID=%03d)", 107 | formatRef(&b1, ins), 108 | lirNames[ins->opcode()], 109 | formatRef(&b2, ins->oprnd1()), 110 | formatRef(&b3, ins->oprnd2()), 111 | (long)x->line, 112 | ins->record()->profGuardID); 113 | } 114 | 115 | const char* 116 | nanojit::LInsPrinter::accNames[] = { 117 | "o", // (1 << 0) == ACCSET_OTHER 118 | "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 1..10 (unused) 119 | "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 11..20 (unused) 120 | "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", // 21..30 (unused) 121 | "?" // 31 (unused) 122 | }; 123 | #endif 124 | 125 | #ifdef DEBUG 126 | void ValidateWriter::checkAccSet(LOpcode op, LIns* base, int32_t disp, AccSet accSet) 127 | { 128 | (void)op; 129 | (void)base; 130 | (void)disp; 131 | NanoAssert(accSet == ACCSET_OTHER); 132 | } 133 | #endif 134 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/Makefile.in: -------------------------------------------------------------------------------- 1 | # -*- Mode: makefile -*- 2 | # 3 | # This Source Code Form is subject to the terms of the Mozilla Public 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | ################## 8 | # autoconf imports 9 | ################## 10 | 11 | CC := @CC@ 12 | CXX := @CXX@ 13 | GNU_CC := @GNU_CC@ 14 | LD := @LD@ 15 | NANOJIT_ARCH := @NANOJIT_ARCH@ 16 | DEFS := @DEFS@ -DNANOJIT_CENTRAL 17 | srcdir := @srcdir@ 18 | CFLAGS := @CFLAGS@ 19 | LDFLAGS := @LDFLAGS@ 20 | TESTCFG := @TESTCFG@ 21 | CXXFLAGS := @CXXFLAGS@ 22 | WARNINGS_AS_ERRORS := @WARNINGS_AS_ERRORS@ 23 | EXE_SUFFIX := @EXE_SUFFIX@ 24 | OBJ_SUFFIX := @OBJ_SUFFIX@ 25 | 26 | # NB: delayed substitution on this one. 27 | LINK = @LINK@ 28 | 29 | ####################### 30 | # normal GNU make rules 31 | ####################### 32 | 33 | VPATH = $(srcdir) \ 34 | $(srcdir)/VMPI.nj \ 35 | $(srcdir)/../../nanojit\ 36 | $(srcdir)/../../vprof \ 37 | $(srcdir)/lirasm \ 38 | $(srcdir)/lirasm/tests 39 | 40 | NATIVE_SRC=Native$(NANOJIT_ARCH).cpp 41 | OTHER_SRCS=Allocator.cpp \ 42 | Assembler.cpp \ 43 | avmplus.cpp \ 44 | CodeAlloc.cpp \ 45 | Containers.cpp \ 46 | Fragmento.cpp \ 47 | LIR.cpp \ 48 | lirasm.cpp \ 49 | njconfig.cpp \ 50 | RegAlloc.cpp \ 51 | VMPI.cpp \ 52 | vprof.cpp 53 | 54 | 55 | SRCS := $(OTHER_SRCS) $(NATIVE_SRC) 56 | HDRS := $(wildcard $(srcdir)/../../nanojit/*.h) 57 | INS := $(wildcard $(srcdir)/lirasm/tests/*.in) 58 | 59 | OBJS := $(notdir $(SRCS:.cpp=$(OBJ_SUFFIX))) 60 | OUTS := $(filter-out random.out random-opt.out, $(notdir $(INS:.in=.out))) 61 | 62 | LIRASM := bin/lirasm$(EXE_SUFFIX) 63 | 64 | CPPFLAGS += $(DEFS) 65 | CPPFLAGS += -I. -I$(srcdir)/VMPI.nj -I$(srcdir)/../.. -I$(srcdir)/../../nanojit 66 | 67 | ############# 68 | # Build rules 69 | ############# 70 | 71 | $(LIRASM): $(OBJS) 72 | mkdir -p $(dir $(LIRASM)) 73 | $(call LINK,$@) $(OBJS) -ldl 74 | chmod 0755 $(LIRASM) 75 | 76 | %$(OBJ_SUFFIX): %.cpp $(HDRS) Makefile 77 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(WARNINGS_AS_ERRORS) -c $< 78 | 79 | 80 | ############ 81 | # Test rules 82 | ############ 83 | 84 | .PHONY: check 85 | 86 | check: $(LIRASM) $(OUTS) 87 | $(srcdir)/lirasm/testlirc.sh $(LIRASM) $(TESTCFG) 88 | 89 | 90 | ################### 91 | # Reconfigury rules 92 | ################### 93 | 94 | $(srcdir)/configure: configure.in 95 | cd $(srcdir) && autoconf 96 | 97 | Makefile: configure Makefile.in 98 | $< 99 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/README: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | This is lirasm, a standalone LIR assembler for nanojit. 6 | 7 | To build: 8 | 9 | $ autoconf 10 | $ ./configure 11 | $ make 12 | 13 | To run unit tests: 14 | 15 | $ make check 16 | 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/VMPI.nj/VMPI.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include "nanojit.h" 8 | 9 | #ifdef SOLARIS 10 | typedef caddr_t maddr_ptr; 11 | #else 12 | typedef void *maddr_ptr; 13 | #endif 14 | 15 | using namespace avmplus; 16 | 17 | size_t 18 | VMPI_getVMPageSize() 19 | { 20 | return 4096; 21 | } 22 | 23 | #ifdef WIN32 24 | void 25 | VMPI_setPageProtection(void *address, 26 | size_t size, 27 | bool executableFlag, 28 | bool writeableFlag) 29 | { 30 | DWORD oldProtectFlags = 0; 31 | DWORD newProtectFlags = 0; 32 | if ( executableFlag && writeableFlag ) { 33 | newProtectFlags = PAGE_EXECUTE_READWRITE; 34 | } else if ( executableFlag ) { 35 | newProtectFlags = PAGE_EXECUTE_READ; 36 | } else if ( writeableFlag ) { 37 | newProtectFlags = PAGE_READWRITE; 38 | } else { 39 | newProtectFlags = PAGE_READONLY; 40 | } 41 | 42 | BOOL retval; 43 | MEMORY_BASIC_INFORMATION mbi; 44 | do { 45 | VirtualQuery(address, &mbi, sizeof(MEMORY_BASIC_INFORMATION)); 46 | size_t markSize = size > mbi.RegionSize ? mbi.RegionSize : size; 47 | 48 | retval = VirtualProtect(address, markSize, newProtectFlags, &oldProtectFlags); 49 | NanoAssert(retval); 50 | 51 | address = (char*) address + markSize; 52 | size -= markSize; 53 | } while(size > 0 && retval); 54 | 55 | // We should not be clobbering PAGE_GUARD protections 56 | NanoAssert((oldProtectFlags & PAGE_GUARD) == 0); 57 | } 58 | 59 | #elif defined(AVMPLUS_OS2) 60 | 61 | void 62 | VMPI_setPageProtection(void *address, 63 | size_t size, 64 | bool executableFlag, 65 | bool writeableFlag) 66 | { 67 | ULONG flags = PAG_READ; 68 | if (executableFlag) { 69 | flags |= PAG_EXECUTE; 70 | } 71 | if (writeableFlag) { 72 | flags |= PAG_WRITE; 73 | } 74 | address = (void*)((size_t)address & ~(0xfff)); 75 | size = (size + 0xfff) & ~(0xfff); 76 | 77 | ULONG attribFlags = PAG_FREE; 78 | while (size) { 79 | ULONG attrib; 80 | ULONG range = size; 81 | ULONG retval = DosQueryMem(address, &range, &attrib); 82 | NanoAssert(retval == 0); 83 | 84 | // exit if this is the start of the next memory object 85 | if (attrib & attribFlags) { 86 | break; 87 | } 88 | attribFlags |= PAG_BASE; 89 | 90 | range = size > range ? range : size; 91 | retval = DosSetMem(address, range, flags); 92 | NanoAssert(retval == 0); 93 | 94 | address = (char*)address + range; 95 | size -= range; 96 | } 97 | } 98 | 99 | #else // !WIN32 && !AVMPLUS_OS2 100 | 101 | void VMPI_setPageProtection(void *address, 102 | size_t size, 103 | bool executableFlag, 104 | bool writeableFlag) 105 | { 106 | int bitmask = sysconf(_SC_PAGESIZE) - 1; 107 | // mprotect requires that the addresses be aligned on page boundaries 108 | void *endAddress = (void*) ((char*)address + size); 109 | void *beginPage = (void*) ((size_t)address & ~bitmask); 110 | void *endPage = (void*) (((size_t)endAddress + bitmask) & ~bitmask); 111 | size_t sizePaged = (size_t)endPage - (size_t)beginPage; 112 | 113 | int flags = PROT_READ; 114 | if (executableFlag) { 115 | flags |= PROT_EXEC; 116 | } 117 | if (writeableFlag) { 118 | flags |= PROT_WRITE; 119 | } 120 | int retval = mprotect((maddr_ptr)beginPage, (unsigned int)sizePaged, flags); 121 | NanoAssert(retval == 0); 122 | (void)retval; 123 | } 124 | 125 | #endif // WIN32 126 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/VMPI.nj/VMPI.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | /* 8 | * Stub VMPI implementation to support standalone nanojit repository. 9 | * 10 | * Really only works if you *don't* have a busted-up C library. 11 | */ 12 | 13 | #ifndef __VMPI_h__ 14 | #define __VMPI_h__ 15 | 16 | #if defined(HAVE_CONFIG_H) && defined(NANOJIT_CENTRAL) 17 | #include "config.h" 18 | #endif 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #if defined(AVMPLUS_UNIX) || defined(AVMPLUS_OS2) 29 | #include 30 | #include 31 | #endif 32 | 33 | #ifdef AVMPLUS_WIN32 34 | #if ! defined(_STDINT_H) 35 | typedef signed char int8_t; 36 | typedef signed short int16_t; 37 | typedef signed int int32_t; 38 | typedef signed __int64 int64_t; 39 | typedef unsigned char uint8_t; 40 | typedef unsigned short uint16_t; 41 | typedef unsigned int uint32_t; 42 | typedef unsigned __int64 uint64_t; 43 | #endif 44 | #else 45 | #include 46 | #include 47 | #endif 48 | 49 | #define VMPI_abort abort 50 | #define VMPI_strlen strlen 51 | #ifdef _MSC_VER 52 | # define VMPI_strcat(d, n, s) strcat_s(d, n, s) 53 | #else 54 | # define VMPI_strcat(d, n, s) strcat(d, s) 55 | #endif 56 | #define VMPI_strcmp strcmp 57 | #define VMPI_strncat strncat 58 | #define VMPI_strcpy strcpy 59 | #define VMPI_sprintf sprintf 60 | #ifdef _MSC_VER 61 | # define VMPI_snprintf sprintf_s 62 | #else 63 | # define VMPI_snprintf snprintf 64 | #endif 65 | #define VMPI_vfprintf vfprintf 66 | #define VMPI_memset memset 67 | #define VMPI_memcmp memcmp 68 | #define VMPI_isdigit isdigit 69 | #define VMPI_getDate() 70 | 71 | #define REALLY_INLINE inline 72 | 73 | #include "AVMPI/float4Support.h" 74 | 75 | extern size_t VMPI_getVMPageSize(); 76 | 77 | extern void VMPI_setPageProtection(void *address, 78 | size_t size, 79 | bool executableFlag, 80 | bool writeableFlag); 81 | 82 | // Keep this warning-set relatively in sync with platform/win32/win32-platform.h in tamarin. 83 | 84 | #ifdef _MSC_VER 85 | #pragma warning(disable:4201) // nonstandard extension used : nameless struct/union 86 | #pragma warning(disable:4512) // assignment operator could not be generated 87 | #pragma warning(disable:4511) // can't generate copy ctor 88 | #pragma warning(disable:4127) // conditional expression is constant - appears to be compiler noise primarily 89 | #pragma warning(disable:4611) // interaction between _setjmp and destruct 90 | #pragma warning(disable:4725) // instruction may be inaccurate on some Pentiums 91 | #pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable 92 | #pragma warning(disable:4251) // X needs to have dll-interface to be used by clients of class Y 93 | 94 | // enable some that are off even in /W4 mode, but are still handy 95 | #pragma warning(default:4265) // 'class' : class has virtual functions, but destructor is not virtual 96 | #pragma warning(default:4905) // wide string literal cast to 'LPSTR' 97 | #pragma warning(default:4906) // string literal cast to 'LPWSTR' 98 | #pragma warning(default:4263) // 'function' : member function does not override any base class virtual member function 99 | #pragma warning(default:4264) // 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden 100 | #pragma warning(default:4266) // 'function' : no override available for virtual member function from base 'type'; function is hidden 101 | #pragma warning(default:4242) // 'identifier' : conversion from 'type1' to 'type2', possible loss of data 102 | #pragma warning(default:4263) // member function does not override any base class virtual member function 103 | #pragma warning(default:4296) // expression is always true (false) (Generally, an unsigned variable was used in a comparison operation with zero.) 104 | #endif 105 | 106 | // This part defined in avmshell.h but similarly required for a warning-free nanojit experience. 107 | #ifdef _MSC_VER 108 | #pragma warning(disable:4996) // 'scanf' was declared deprecated 109 | #endif 110 | 111 | // This part is inhibited manually by the CFLAGS in the tamarin configury. 112 | #ifdef _MSC_VER 113 | #pragma warning(disable:4291) // presence of a 'new' operator in nanojit/Allocator.h without matching 'delete' 114 | #endif 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/VMPI.nj/avmplus.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #include 8 | #include "nanojit.h" 9 | 10 | #ifdef SOLARIS 11 | typedef caddr_t maddr_ptr; 12 | #else 13 | typedef void *maddr_ptr; 14 | #endif 15 | 16 | using namespace avmplus; 17 | 18 | void 19 | avmplus::AvmLog(char const *msg, ...) { 20 | va_list ap; 21 | va_start(ap, msg); 22 | VMPI_vfprintf(stderr, msg, ap); 23 | va_end(ap); 24 | } 25 | 26 | #ifdef _DEBUG 27 | namespace avmplus { 28 | void AvmAssertFail(const char* /* msg */) { 29 | fflush(stderr); 30 | #if defined(WIN32) 31 | DebugBreak(); 32 | exit(3); 33 | #elif defined(__APPLE__) 34 | /* 35 | * On Mac OS X, Breakpad ignores signals. Only real Mach exceptions are 36 | * trapped. 37 | */ 38 | *((int *) NULL) = 0; /* To continue from here in GDB: "return" then "continue". */ 39 | raise(SIGABRT); /* In case above statement gets nixed by the optimizer. */ 40 | #else 41 | raise(SIGABRT); /* To continue from here in GDB: "signal 0". */ 42 | #endif 43 | } 44 | } 45 | #endif 46 | 47 | #if defined(WIN32) 48 | 49 | void* 50 | nanojit::CodeAlloc::allocCodeChunk(size_t nbytes) { 51 | return VirtualAlloc(NULL, 52 | nbytes, 53 | MEM_COMMIT | MEM_RESERVE, 54 | PAGE_EXECUTE_READWRITE); 55 | } 56 | 57 | void 58 | nanojit::CodeAlloc::freeCodeChunk(void *p, size_t) { 59 | VirtualFree(p, 0, MEM_RELEASE); 60 | } 61 | 62 | #elif defined(AVMPLUS_OS2) 63 | 64 | void* 65 | nanojit::CodeAlloc::allocCodeChunk(size_t nbytes) { 66 | 67 | // alloc from high memory, fallback to low memory if that fails 68 | void * addr; 69 | if (DosAllocMem(&addr, nbytes, OBJ_ANY | 70 | PAG_COMMIT | PAG_READ | PAG_WRITE | PAG_EXECUTE)) { 71 | if (DosAllocMem(&addr, nbytes, 72 | PAG_COMMIT | PAG_READ | PAG_WRITE | PAG_EXECUTE)) { 73 | return 0; 74 | } 75 | } 76 | return addr; 77 | } 78 | 79 | void 80 | nanojit::CodeAlloc::freeCodeChunk(void *p, size_t nbytes) { 81 | DosFreeMem(p); 82 | } 83 | 84 | #elif defined(AVMPLUS_UNIX) 85 | 86 | void* 87 | nanojit::CodeAlloc::allocCodeChunk(size_t nbytes) { 88 | return mmap(NULL, 89 | nbytes, 90 | PROT_READ | PROT_WRITE | PROT_EXEC, 91 | MAP_PRIVATE | MAP_ANON, 92 | -1, 93 | 0); 94 | } 95 | 96 | void 97 | nanojit::CodeAlloc::freeCodeChunk(void *p, size_t nbytes) { 98 | munmap((maddr_ptr)p, nbytes); 99 | } 100 | 101 | #else // !WIN32 && !AVMPLUS_OS2 && !AVMPLUS_UNIX 102 | 103 | void* 104 | nanojit::CodeAlloc::allocCodeChunk(size_t nbytes) { 105 | void* mem = valloc(nbytes); 106 | VMPI_setPageProtection(mem, nbytes, true /* exec */, true /* write */); 107 | return mem; 108 | } 109 | 110 | void 111 | nanojit::CodeAlloc::freeCodeChunk(void *p, size_t nbytes) { 112 | VMPI_setPageProtection(p, nbytes, false /* exec */, true /* write */); 113 | ::free(p); 114 | } 115 | 116 | #endif // WIN32 117 | 118 | // All of the allocCodeChunk/freeCodeChunk implementations above allocate 119 | // code memory as RWX and then free it, so the explicit page protection api's 120 | // below are no-ops. 121 | 122 | void 123 | nanojit::CodeAlloc::markCodeChunkWrite(void*, size_t) 124 | {} 125 | 126 | void 127 | nanojit::CodeAlloc::markCodeChunkExec(void*, size_t) 128 | {} 129 | 130 | bool 131 | nanojit::CodeAlloc::checkChunkMark(void* /*addr*/, size_t /*nbytes*/, bool /*isExec*/) { 132 | return true; // always correct 133 | } 134 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/VMPI.nj/avmplus.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */ 2 | /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */ 3 | /* This Source Code Form is subject to the terms of the Mozilla Public 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 | 7 | #ifndef avm_h___ 8 | #define avm_h___ 9 | 10 | #include "VMPI.h" 11 | #include "njcpudetect.h" 12 | #include "njconfig.h" 13 | 14 | #if !defined(AVMPLUS_LITTLE_ENDIAN) && !defined(AVMPLUS_BIG_ENDIAN) 15 | #ifdef IS_BIG_ENDIAN 16 | #define AVMPLUS_BIG_ENDIAN 17 | #else 18 | #define AVMPLUS_LITTLE_ENDIAN 19 | #endif 20 | #endif 21 | 22 | #if defined(_MSC_VER) && defined(_M_IX86) 23 | #define FASTCALL __fastcall 24 | #elif defined(__GNUC__) && defined(__i386__) && \ 25 | ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 26 | #define FASTCALL __attribute__((fastcall)) 27 | #else 28 | #define FASTCALL 29 | #define NO_FASTCALL 30 | #endif 31 | 32 | #if defined(NO_FASTCALL) 33 | #if defined(AVMPLUS_IA32) 34 | #define SIMULATE_FASTCALL(lr, state_ptr, frag_ptr, func_addr) \ 35 | asm volatile( \ 36 | "call *%%esi" \ 37 | : "=a" (lr) \ 38 | : "c" (state_ptr), "d" (frag_ptr), "S" (func_addr) \ 39 | : "memory", "cc" \ 40 | ); 41 | #endif /* defined(AVMPLUS_IA32) */ 42 | #endif /* defined(NO_FASTCALL) */ 43 | 44 | #ifdef WIN32 45 | #include 46 | #elif defined(AVMPLUS_OS2) 47 | #define INCL_DOSMEMMGR 48 | #include 49 | #endif 50 | 51 | #if defined(__SUNPRO_CC) 52 | #define __asm__ asm 53 | #define __volatile__ volatile 54 | #define __inline__ inline 55 | #endif 56 | 57 | #if defined(DEBUG) 58 | #if !defined _DEBUG 59 | #define _DEBUG 60 | #endif 61 | #define NJ_VERBOSE 1 62 | #include 63 | #endif 64 | 65 | #ifdef _DEBUG 66 | namespace avmplus { 67 | void AvmAssertFail(const char* msg); 68 | } 69 | #endif 70 | 71 | #if defined(AVMPLUS_IA32) 72 | #if defined(_MSC_VER) 73 | 74 | # define AVMPLUS_HAS_RDTSC 1 75 | 76 | __declspec(naked) static inline __int64 rdtsc() 77 | { 78 | __asm 79 | { 80 | rdtsc; 81 | ret; 82 | } 83 | } 84 | 85 | #elif defined(__i386__) || defined(__i386) 86 | 87 | # define AVMPLUS_HAS_RDTSC 1 88 | 89 | static __inline__ unsigned long long rdtsc(void) 90 | { 91 | unsigned long long int x; 92 | __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); 93 | return x; 94 | } 95 | 96 | #endif /* compilers */ 97 | 98 | #elif defined(__x86_64__) 99 | 100 | # define AVMPLUS_HAS_RDTSC 1 101 | 102 | static __inline__ uint64_t rdtsc(void) 103 | { 104 | unsigned hi, lo; 105 | __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); 106 | return ( (uint64_t)lo)|( ((uint64_t)hi)<<32 ); 107 | } 108 | 109 | #elif defined(_MSC_VER) && defined(_M_AMD64) 110 | 111 | # define AVMPLUS_HAS_RDTSC 1 112 | 113 | #include 114 | #pragma intrinsic(__rdtsc) 115 | 116 | static inline unsigned __int64 rdtsc(void) 117 | { 118 | return __rdtsc(); 119 | } 120 | 121 | #elif defined(__GNUC__) && defined(__powerpc__) 122 | 123 | # define AVMPLUS_HAS_RDTSC 1 124 | 125 | typedef unsigned long long int unsigned long long; 126 | 127 | static __inline__ unsigned long long rdtsc(void) 128 | { 129 | unsigned long long int result=0; 130 | unsigned long int upper, lower,tmp; 131 | __asm__ volatile( 132 | "0: \n" 133 | "\tmftbu %0 \n" 134 | "\tmftb %1 \n" 135 | "\tmftbu %2 \n" 136 | "\tcmpw %2,%0 \n" 137 | "\tbne 0b \n" 138 | : "=r"(upper),"=r"(lower),"=r"(tmp) 139 | ); 140 | result = upper; 141 | result = result<<32; 142 | result = result|lower; 143 | 144 | return(result); 145 | } 146 | 147 | #endif /* architecture */ 148 | 149 | #ifndef AVMPLUS_HAS_RDTSC 150 | # define AVMPLUS_HAS_RDTSC 0 151 | #endif 152 | 153 | #ifdef PERFM 154 | # define PERFM_NVPROF(n,v) _nvprof(n,v) 155 | # define PERFM_NTPROF(n) _ntprof(n) 156 | # define PERFM_TPROF_END() _tprof_end() 157 | #else 158 | # define PERFM_NVPROF(n,v) 159 | # define PERFM_NTPROF(n) 160 | # define PERFM_TPROF_END() 161 | #endif 162 | 163 | #ifdef VMCFG_FLOAT 164 | #define FLOAT_ONLY(...) __VA_ARGS__ 165 | #else 166 | #define FLOAT_ONLY(...) 167 | #endif 168 | 169 | namespace avmplus { 170 | 171 | extern void AvmLog(char const *msg, ...); 172 | 173 | } 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/autoconf/install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This Source Code Form is subject to the terms of the Mozilla Public 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this 4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | 6 | 7 | # 8 | # install - install a program, script, or datafile 9 | # This comes from X11R5; it is not part of GNU. 10 | # 11 | # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ 12 | # 13 | # This script is compatible with the BSD install script, but was written 14 | # from scratch. 15 | # 16 | 17 | 18 | # set DOITPROG to echo to test this script 19 | 20 | # Don't use :- since 4.3BSD and earlier shells don't like it. 21 | doit="${DOITPROG-}" 22 | 23 | 24 | # put in absolute paths if you don't have them in your path; or use env. vars. 25 | 26 | mvprog="${MVPROG-mv}" 27 | cpprog="${CPPROG-cp}" 28 | chmodprog="${CHMODPROG-chmod}" 29 | chownprog="${CHOWNPROG-chown}" 30 | chgrpprog="${CHGRPPROG-chgrp}" 31 | stripprog="${STRIPPROG-strip}" 32 | rmprog="${RMPROG-rm}" 33 | 34 | instcmd="$mvprog" 35 | chmodcmd="" 36 | chowncmd="" 37 | chgrpcmd="" 38 | stripcmd="" 39 | rmcmd="$rmprog -f" 40 | mvcmd="$mvprog" 41 | src="" 42 | dst="" 43 | 44 | while [ x"$1" != x ]; do 45 | case $1 in 46 | -c) instcmd="$cpprog" 47 | shift 48 | continue;; 49 | 50 | -m) chmodcmd="$chmodprog $2" 51 | shift 52 | shift 53 | continue;; 54 | 55 | -o) chowncmd="$chownprog $2" 56 | shift 57 | shift 58 | continue;; 59 | 60 | -g) chgrpcmd="$chgrpprog $2" 61 | shift 62 | shift 63 | continue;; 64 | 65 | -s) stripcmd="$stripprog" 66 | shift 67 | continue;; 68 | 69 | *) if [ x"$src" = x ] 70 | then 71 | src=$1 72 | else 73 | dst=$1 74 | fi 75 | shift 76 | continue;; 77 | esac 78 | done 79 | 80 | if [ x"$src" = x ] 81 | then 82 | echo "install: no input file specified" 83 | exit 1 84 | fi 85 | 86 | if [ x"$dst" = x ] 87 | then 88 | echo "install: no destination specified" 89 | exit 1 90 | fi 91 | 92 | 93 | # If destination is a directory, append the input filename; if your system 94 | # does not like double slashes in filenames, you may need to add some logic 95 | 96 | if [ -d $dst ] 97 | then 98 | dst="$dst"/`basename $src` 99 | fi 100 | 101 | # Make a temp file name in the proper directory. 102 | 103 | dstdir=`dirname $dst` 104 | dsttmp=$dstdir/#inst.$$# 105 | 106 | # Move or copy the file name to the temp name 107 | 108 | $doit $instcmd $src $dsttmp 109 | 110 | # and set any options; do chmod last to preserve setuid bits 111 | 112 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi 113 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi 114 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi 115 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi 116 | 117 | # Now rename the file to the real destination. 118 | 119 | $doit $rmcmd $dst 120 | $doit $mvcmd $dsttmp $dst 121 | 122 | 123 | exit 0 124 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/config.h.in: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | 6 | #undef DEBUG 7 | #undef AVMPLUS_AMD64 8 | #undef AVMPLUS_64BIT 9 | #undef AVMPLUS_ARM 10 | #undef AVMPLUS_IA32 11 | #undef AVMPLUS_LINUX 12 | #undef AVMPLUS_OS2 13 | #undef AVMPLUS_PPC 14 | #undef AVMPLUS_MIPS 15 | #undef VMCFG_SH4 16 | #undef VMCFG_FLOAT 17 | #undef VMCFG_SSE2 18 | #undef VMCFG_NEON 19 | #undef AVMPLUS_SPARC 20 | #undef SOLARIS 21 | #undef AVMPLUS_UNIX 22 | #undef AVMPLUS_WIN32 23 | #undef FEATURE_NANOJIT 24 | #undef WINVER 25 | #undef _CRT_NONSTDC_NO_DEPRECATE 26 | #undef _CRT_NONSTDC_NO_WARNINGS 27 | #undef _CRT_SECURE_NO_DEPRECATE 28 | #undef _CRT_SECURE_NO_WARNINGS 29 | #undef WIN32 30 | #undef _WIN32_IE 31 | #undef _WIN32_WINNT 32 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/LInsClasses.tbl: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 | * vim: set ts=8 sw=4 et tw=0 ft=c: 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 | 8 | /* LIns classes, as required for --random mode. Includers must define a CL___ 9 | * macro of the following form: 10 | * 11 | * #define CL___(name, only64bit, relFreq) ... 12 | * 13 | * Selected arguments can be used within the macro expansions. 14 | * 15 | * Field Description 16 | * ----- ----------- 17 | * name Name of the instruction class. The types are B (boolean), I 18 | * (32-bit integer), Q (64-bit integer), F (64-bit float), N 19 | * (null). A name of the form LOP_Z_XY means that it takes 20 | * arguments of type X and Y and produces a result of type Z. 21 | * 22 | * relFreq We weight each class differently, so that some classes are more 23 | * common than others. This field gives the relative frequency of 24 | * the instruction class. All the relFreqs together can sum up to 25 | * any number, but it's easier to think about if the sum is a 26 | * round number. (That's why the relFreqs add up to 100%; the 27 | * running total is shown in comments.) The sum also shouldn't be 28 | * too big, as we generate a table with that many elements in it. 29 | * 30 | * Note that we want a decent number of value sinks (eg. 31 | * stores, calls, guards) and not too many value sources (eg. 32 | * immediates, loads) so that the amount of dead code generated is 33 | * reasonable. 34 | * 35 | * Because certain opcode classes aren't supported on all platforms, CLxyz must be one 36 | * of the following: 37 | * 38 | * CL___: for opcode classes supported on all platforms. 39 | * CL_64: for opcode classes supported only on 64-bit platforms. 40 | */ 41 | 42 | #ifdef NANOJIT_64BIT 43 | # define CL_64(a, b) CL___(a, b) 44 | #else 45 | # define CL_64(a, b) 46 | #endif 47 | 48 | 49 | CL___( LFENCE, 1) // 1% LIR_regfence, LIR_xbarrier 50 | 51 | CL___( LALLOC, 1) // 2% LIR_alloc 52 | 53 | CL___( LIMM_I, 4) // 6% LIR_imm 54 | CL_64( LIMM_Q, 3) // 9% LIR_quad 55 | CL___( LIMM_D, 3) // 12% LIR_float 56 | 57 | CL___( LOP_I_I, 2) // 14% LIR_neg, LIR_not 58 | CL_64( LOP_Q_Q, 0) // 14% (none) 59 | CL___( LOP_D_D, 2) // 16% LIR_fneg 60 | 61 | CL___( LOP_I_II, 6) // 32% LIR_add, LIR_and, LIR_eq, etc. 62 | CL_64( LOP_Q_QQ, 7) // 39% LIR_qiadd, LIR_qiand, LIR_qeq, etc. 63 | CL_64( LOP_Q_QI, 2) // 41% LIR_qilsh, LIR_qirsh, LIR_qursh 64 | CL___( LOP_D_DD, 10) // 51% LIR_fadd, etc. 65 | 66 | // cmov has a low weight because is also used with LIR_div/LIR_mod. 67 | CL___( LOP_I_BII, 1) // 52% LIR_cmovi 68 | CL_64( LOP_Q_BQQ, 1) // 53% LIR_cmovq 69 | CL___( LOP_D_BDD, 1) // 54% LIR_cmovd 70 | 71 | CL___( LOP_B_II, 3) // 57% LIR_eq, LIR_lt, etc 72 | CL_64( LOP_B_QQ, 3) // 60% LIR_qeq, LIR_qlt, etc 73 | CL___( LOP_B_DD, 3) // 63% LIR_feq, LIR_flt, etc 74 | 75 | CL_64( LOP_Q_I, 1) // 64% LIR_i2q, LIR_u2q 76 | CL___( LOP_D_I, 1) // 65% LIR_i2d, LIR_ui2d 77 | CL_64( LOP_I_Q, 1) // 66% LIR_q2i 78 | CL___( LOP_I_D, 1) // 67% LIR_qlo, LIR_qhi, LIR_d2i 79 | CL_64( LOP_Q_D, 1) // 68% LIR_dasq 80 | CL_64( LOP_D_Q, 1) // 69% LIR_qasd 81 | CL___( LOP_D_II, 1) // 70% LIR_qjoin 82 | 83 | CL___( LLD_I, 3) // 73% LIR_ld, LIR_ld*b, LIR_ld*s 84 | CL_64( LLD_Q, 2) // 75% LIR_ldq 85 | CL___( LLD_D, 3) // 78% LIR_ldd 86 | 87 | CL___( LST_I, 5) // 83% LIR_sti 88 | CL_64( LST_Q, 4) // 87% LIR_stqi 89 | CL___( LST_D, 5) // 92% LIR_stfi 90 | 91 | CL___( LCALL_I_I1, 1) // 93% LIR_icall 92 | CL___( LCALL_I_I6, 1) // 94% LIR_icall 93 | CL_64( LCALL_Q_Q2, 1) // 95% LIR_qcall 94 | CL_64( LCALL_Q_Q7, 1) // 96% LIR_qcall 95 | CL___( LCALL_D_D3, 1) // 97% LIR_fcall 96 | CL___( LCALL_D_D8, 1) // 98% LIR_fcall 97 | CL_64( LCALL_V_IQD, 1) // 99% LIR_icall or LIR_qcall 98 | 99 | CL___( LLABEL, 1) //100% LIR_label 100 | 101 | CL___( LIMM_F, 1) // 101% LIR_float 102 | CL___( LOP_F_F, 1) // 102% LIR_fnegf 103 | CL___( LOP_F_FF, 1) // 103% LIR_faddf, etc. 104 | CL___( LOP_F_BFF, 1) // 104% LIR_cmovf 105 | CL___( LOP_B_FF, 1) // 105% LIR_eqf, LIR_ltf, etc 106 | CL___( LOP_F_I, 1) // 106% LIR_i2f, LIR_ui2f 107 | CL___( LOP_I_F, 1) // 107% LIR_f2i 108 | CL___( LOP_D_F, 1) // 108% LIR_f2d 109 | CL___( LOP_F_D, 1) // 109% LIR_d2f 110 | CL___( LST_F, 1) // 110% LIR_stf 111 | CL___( LLD_F, 1) // 111% LIR_ldf 112 | 113 | CL___( LIMM_F4, 1) // 112% LIR_float 114 | CL___( LOP_F4_F4, 1) // 113% LIR_fnegf4 115 | CL___( LOP_F4_F4F4, 1) // 114% LIR_faddf4, etc. 116 | CL___( LOP_F4_BF4F4, 1) // 115% LIR_cmovf4 117 | CL___( LOP_B_F4F4, 1) // 116% LIR_eqf4 118 | CL___( LOP_F4_F, 1) // 117% LIR_f4x, LIR_f4y, LIR_f4z, LIR_f4w 119 | CL___( LOP_F_F4, 1) // 118% LIR_f2f4 120 | CL___( LST_F4, 1) // 110% LIR_stf4 121 | CL___( LLD_F4, 1) // 111% LIR_ldf4 122 | 123 | #undef CL_64 124 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/float/livef.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin many_params 6 | pa = parami 0 0 7 | pb = parami 1 0 8 | pc = parami 2 0 9 | pd = parami 3 0 10 | pe = parami 4 0 11 | pf = parami 5 0 12 | pg = parami 6 0 13 | ph = parami 7 0 14 | fa = i2f pa 15 | fb = i2f pb 16 | fc = i2f pc 17 | fd = i2f pd 18 | fe = ui2f pe 19 | ff = ui2f pf 20 | fg = ui2f pg 21 | fh = ui2f ph 22 | 23 | res1 = addf fa fb 24 | res2 = addf res1 fc 25 | res3 = addf res2 fd 26 | res4 = addf res3 fe 27 | res5 = addf res4 ff 28 | res6 = addf res5 fg 29 | res7 = addf res6 fh 30 | res8 = negf res7 31 | res9 = addf res8 res1 32 | res = f2i res9 33 | reti res 34 | 35 | ; stress the register allocator 36 | livef fa 37 | livef fb 38 | livef fc 39 | livef fd 40 | livef fe 41 | livef ff 42 | livef fg 43 | livef fh 44 | livef res1 45 | livef res2 46 | livef res3 47 | livef res4 48 | livef res5 49 | livef res6 50 | livef res7 51 | livef res8 52 | livef res9 53 | 54 | .end 55 | 56 | .begin main 57 | a = immi 1 58 | b = immi 2 59 | c = immi 3 60 | d = immi 4 61 | e = immi 5 62 | f = immi 6 63 | g = immi 7 64 | h = immi 8 65 | res = calli many_params fastcall a b c d e f g h 66 | reti res 67 | .end 68 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/float/livef.out: -------------------------------------------------------------------------------- 1 | Output is: -33 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/lived.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin many_params 6 | pa = parami 0 0 7 | pb = parami 1 0 8 | pc = parami 2 0 9 | pd = parami 3 0 10 | pe = parami 4 0 11 | pf = parami 5 0 12 | pg = parami 6 0 13 | ph = parami 7 0 14 | da = i2d pa 15 | db = i2d pb 16 | dc = i2d pc 17 | dd = i2d pd 18 | de = ui2d pe 19 | df = ui2d pf 20 | dg = ui2d pg 21 | dh = ui2d ph 22 | 23 | res1 = addd da db 24 | res2 = addd res1 dc 25 | res3 = addd res2 dd 26 | res4 = addd res3 de 27 | res5 = addd res4 df 28 | res6 = addd res5 dg 29 | res7 = addd res6 dh 30 | res8 = negd res7 31 | res9 = addd res8 res1 32 | res = d2i res9 33 | reti res 34 | 35 | ; stress the register allocator 36 | lived da 37 | lived db 38 | lived dc 39 | lived dd 40 | lived de 41 | lived df 42 | lived dg 43 | lived dh 44 | lived res1 45 | lived res2 46 | lived res3 47 | lived res4 48 | lived res5 49 | lived res6 50 | lived res7 51 | lived res8 52 | lived res9 53 | 54 | .end 55 | 56 | .begin main 57 | a = immi 1 58 | b = immi 2 59 | c = immi 3 60 | d = immi 4 61 | e = immi 5 62 | f = immi 6 63 | g = immi 7 64 | h = immi 8 65 | res = calli many_params fastcall a b c d e f g h 66 | reti res 67 | .end 68 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/lived.out: -------------------------------------------------------------------------------- 1 | Output is: -33 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/many_params.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin many_params 6 | pa = parami 0 0 7 | pb = parami 1 0 8 | pc = parami 2 0 9 | pd = parami 3 0 10 | pe = parami 4 0 11 | pf = parami 5 0 12 | pg = parami 6 0 13 | ph = parami 7 0 14 | res1 = addi pa pb 15 | res2 = addi res1 pc 16 | res3 = addi res2 pd 17 | res4 = addi res3 pe 18 | res5 = addi res4 pf 19 | res6 = addi res5 pg 20 | res7 = addi res6 ph 21 | reti res7 22 | .end 23 | 24 | .begin main 25 | a = immi 1 26 | b = immi 2 27 | c = immi 3 28 | d = immi 4 29 | e = immi 5 30 | f = immi 6 31 | g = immi 7 32 | h = immi 8 33 | res = calli many_params fastcall a b c d e f g h 34 | reti res 35 | .end 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/32-bit/many_params.out: -------------------------------------------------------------------------------- 1 | Output is: 36 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/dasq.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | q = immq 12345 6 | d = qasd q 7 | q2 = dasq d 8 | one = immd 1.0 ; do some intermediate stuff to make it less trivial 9 | two = immd 2.0 10 | three = addd one two 11 | i2 = q2i q2 12 | reti i2 13 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/dasq.out: -------------------------------------------------------------------------------- 1 | Output is: 12345 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/float/livef.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin many_params 6 | qa = paramq 0 0 7 | qb = paramq 1 0 8 | qc = paramq 2 0 9 | qd = paramq 3 0 10 | ; Stack-based args not supported yet, use immediates instead of param 11 | qq = immq 4 12 | qe = addq qa qq ;qe = paramq 4 0 13 | qf = addq qb qq ;qf = paramq 5 0 14 | qg = addq qc qq ;qg = paramq 6 0 15 | qh = addq qd qq ;qh = paramq 7 0 16 | pa = q2i qa 17 | pb = q2i qb 18 | pc = q2i qc 19 | pd = q2i qd 20 | pe = q2i qe 21 | pf = q2i qf 22 | pg = q2i qg 23 | ph = q2i qh 24 | fa = i2f pa 25 | fb = i2f pb 26 | fc = i2f pc 27 | fd = i2f pd 28 | fe = ui2f pe 29 | ff = ui2f pf 30 | fg = ui2f pg 31 | fh = ui2f ph 32 | 33 | res1 = addf fa fb 34 | res2 = addf res1 fc 35 | res3 = addf res2 fd 36 | res4 = addf res3 fe 37 | res5 = addf res4 ff 38 | res6 = addf res5 fg 39 | res7 = addf res6 fh 40 | res8 = negf res7 41 | res9 = addf res8 res1 42 | res = f2i res9 43 | reti res 44 | 45 | ; stress the register allocator 46 | livef fa 47 | livef fb 48 | livef fc 49 | livef fd 50 | livef fe 51 | livef ff 52 | livef fg 53 | livef fh 54 | livef res1 55 | livef res2 56 | livef res3 57 | livef res4 58 | livef res5 59 | livef res6 60 | livef res7 61 | livef res8 62 | livef res9 63 | 64 | .end 65 | 66 | .begin main 67 | a = immq 1 68 | b = immq 2 69 | c = immq 3 70 | d = immq 4 71 | e = immq 5 72 | f = immq 6 73 | g = immq 7 74 | h = immq 8 75 | res = calli many_params fastcall a b c d ; Don't pass (e f g h) - se comment in function 76 | reti res 77 | .end 78 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/float/livef.out: -------------------------------------------------------------------------------- 1 | Output is: -33 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/lived.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin many_params 6 | qa = paramq 0 0 7 | qb = paramq 1 0 8 | qc = paramq 2 0 9 | qd = paramq 3 0 10 | ; Stack-based args not supported yet, use immediates instead of param 11 | qq = immq 4 12 | qe = addq qa qq ;qe = paramq 4 0 13 | qf = addq qb qq ;qf = paramq 5 0 14 | qg = addq qc qq ;qg = paramq 6 0 15 | qh = addq qd qq ;qh = paramq 7 0 16 | pa = q2i qa 17 | pb = q2i qb 18 | pc = q2i qc 19 | pd = q2i qd 20 | pe = q2i qe 21 | pf = q2i qf 22 | pg = q2i qg 23 | ph = q2i qh 24 | da = i2d pa 25 | db = i2d pb 26 | dc = i2d pc 27 | dd = i2d pd 28 | de = ui2d pe 29 | df = ui2d pf 30 | dg = ui2d pg 31 | dh = ui2d ph 32 | 33 | res1 = addd da db 34 | res2 = addd res1 dc 35 | res3 = addd res2 dd 36 | res4 = addd res3 de 37 | res5 = addd res4 df 38 | res6 = addd res5 dg 39 | res7 = addd res6 dh 40 | res8 = negd res7 41 | res9 = addd res8 res1 42 | res = d2i res9 43 | resq = i2q res 44 | retq resq 45 | 46 | ; stress the register allocator 47 | lived da 48 | lived db 49 | lived dc 50 | lived dd 51 | lived de 52 | lived df 53 | lived dg 54 | lived dh 55 | lived res1 56 | lived res2 57 | lived res3 58 | lived res4 59 | lived res5 60 | lived res6 61 | lived res7 62 | lived res8 63 | lived res9 64 | 65 | .end 66 | 67 | .begin main 68 | a = immq 1 69 | b = immq 2 70 | c = immq 3 71 | d = immq 4 72 | e = immq 5 73 | f = immq 6 74 | g = immq 7 75 | h = immq 8 76 | res = callq many_params fastcall a b c d ; Don't pass (e f g h) - se comment in function 77 | retq res 78 | .end 79 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/lived.out: -------------------------------------------------------------------------------- 1 | Output is: -33 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/qasd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | one = immq 1 6 | d = immd 123.45 7 | q = dasq d 8 | q2 = addq q one ; do some intermediate stuff just to complicate things 9 | q3 = subq q2 one 10 | d2 = qasd q3 11 | retd d2 12 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/qasd.out: -------------------------------------------------------------------------------- 1 | Output is: 123.45 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/shq.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Only the bottom 6 bits of the shift amount in lshq/rshq/rshuq are used. 6 | 7 | two = immq 2 8 | 9 | sh1 = immi 1 10 | sh2 = immi 65 ; 0100_0001b 11 | sh3 = immi 268435393 ; 0000_1111_1111_1111_1111_1111_1100_0001b 12 | 13 | a1 = lshq two sh1 ; --> 4 14 | a2 = lshq two sh2 ; --> 4 15 | a3 = lshq two sh3 ; --> 4 16 | 17 | b1 = rshq two sh1 ; --> 1 18 | b2 = rshq two sh2 ; --> 1 19 | b3 = rshq two sh3 ; --> 1 20 | 21 | c1 = rshuq two sh1 ; --> 1 22 | c2 = rshuq two sh2 ; --> 1 23 | c3 = rshuq two sh3 ; --> 1 24 | 25 | s0 = immq 0 26 | s1 = addq s0 a1 27 | s2 = addq s1 a2 28 | s3 = addq s2 a3 29 | s4 = addq s3 b1 30 | s5 = addq s4 b2 31 | s6 = addq s5 b3 32 | s7 = addq s6 c1 33 | s8 = addq s7 c2 34 | s9 = addq s8 c2 ; --> 18 35 | 36 | retq s9 37 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/64-bit/shq.out: -------------------------------------------------------------------------------- 1 | Output is: 18 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/add.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | two = immi 2 6 | three = immi 3 7 | res = addi two three 8 | reti res 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/add.out: -------------------------------------------------------------------------------- 1 | Output is: 5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 8 9 | p2 = allocp 8 10 | 11 | d1a = immd 1.5 12 | d1 = addd d1a d1a ; X = X + X 13 | std d1 p1 0 14 | 15 | d2a = immd 2.5 16 | d2b = immd 3.0 17 | d2 = addd d2a d2b ; X = X + Y 18 | std d2b p2 0 19 | std d2 p2 0 20 | 21 | d3a = ldd p1 0 22 | d3b = ldd p2 0 23 | d3 = addd d3a d3b ; X = Y + X 24 | std d3a p2 0 25 | std d3 p2 0 26 | 27 | d4a = ldd p2 0 28 | d4b = ldd p1 0 29 | d4 = addd d4a d4b ; X = Y + Z 30 | std d4a p1 0 31 | std d4b p2 0 32 | std d4 p1 0 33 | 34 | d = ldd p1 0 35 | retd d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addd.out: -------------------------------------------------------------------------------- 1 | Output is: 11.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addjovi.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi 2147483647 8 | b = immi 0 9 | c = addjovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addjovi.out: -------------------------------------------------------------------------------- 1 | Output is: 2147483647 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addjovi_ovf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi 2147483647 8 | b = immi 1 9 | c = addjovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addjovi_ovf.out: -------------------------------------------------------------------------------- 1 | Output is: 12345678 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addsub.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | two = immi 7 6 | three = immi 3 7 | targ = addi two three 8 | res = subi targ three 9 | reti res 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/addsub.out: -------------------------------------------------------------------------------- 1 | Output is: 7 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/backjump.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | zero = immi 0 7 | one = immi 1 8 | neg_one = immi -1 9 | sti one ptr 0 10 | sti zero ptr 4 11 | start: a = ldi ptr 0 12 | x = ldi ptr 4 13 | b = muli a neg_one 14 | y = addi x one 15 | sti y ptr 4 16 | sti b ptr 0 17 | t = eqi b one 18 | jf t start 19 | end: reti y 20 | 21 | 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/backjump.out: -------------------------------------------------------------------------------- 1 | Output is: 2 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/fuzz-527178.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | base = allocp 512 6 | five = immi 5 7 | sti five base 256 8 | x = ldus2ui base 258 9 | reti x 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/fuzz-527178.out: -------------------------------------------------------------------------------- 1 | Output is: 5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/ldc2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi 1288908529 ; 0x4cd32ef1 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi -15 ; sign_extend(0xf1) 10 | n1chk = immi 46 ; sign_extend(0x2e) 11 | n2chk = immi -45 ; sign_extend(0xd3) 12 | n3chk = immi 76 ; sign_extend(0x4c) 13 | 14 | n0 = ldc2i p 3 15 | n1 = ldc2i p 2 16 | n2 = ldc2i p 1 17 | n3 = ldc2i p 0 18 | 19 | ; Collate the results. 20 | r0 = xori n0chk n0 21 | r1 = xori n1chk n1 22 | r2 = xori n2chk n2 23 | r3 = xori n3chk n3 24 | 25 | r0_1 = ori r0 r1 26 | r2_3 = ori r2 r3 27 | 28 | r = ori r0_1 r2_3 29 | reti r 30 | 31 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/ldc2i.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/lds2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -249334698 ; 0xf1237456 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 29782 ; sign_extend(0x7456) 10 | n1chk = immi -3805 ; sign_extend(0xf123) 11 | 12 | n0 = lds2i p 2 13 | n1 = lds2i p 0 14 | 15 | ; Collate the results. 16 | r0 = xori n0chk n0 17 | r1 = xori n1chk n1 18 | 19 | r = ori r0 r1 20 | reti r 21 | 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/lds2i.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/lduc2ui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -992746767 ; 0xc4d3e2f1 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 241 ; 0xf1 10 | n1chk = immi 226 ; 0xe2 11 | n2chk = immi 211 ; 0xd3 12 | n3chk = immi 196 ; 0xc4 13 | 14 | n0 = lduc2ui p 3 15 | n1 = lduc2ui p 2 16 | n2 = lduc2ui p 1 17 | n3 = lduc2ui p 0 18 | 19 | ; Collate the results. 20 | r0 = xori n0chk n0 21 | r1 = xori n1chk n1 22 | r2 = xori n2chk n2 23 | r3 = xori n3chk n3 24 | 25 | r0_1 = ori r0 r1 26 | r2_3 = ori r2 r3 27 | 28 | r = ori r0_1 r2_3 29 | reti r 30 | 31 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/lduc2ui.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/ldus2ui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -249334698 ; 0xf1237456 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 29782 ; sign_extend(0x7456) 10 | n1chk = immi 61731 ; sign_extend(0xf123) 11 | 12 | n0 = ldus2ui p 2 13 | n1 = ldus2ui p 0 14 | 15 | ; Collate the results. 16 | r0 = xori n0chk n0 17 | r1 = xori n1chk n1 18 | 19 | r = ori r0 r1 20 | reti r 21 | 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bigendian/ldus2ui.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bug596923.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to get asm_load64 (ldd) to store straight to a stack slot with a large 6 | ; offset from FP (on ARM, at least). 7 | 8 | a = immd 1.1 9 | p = allocp 1024 10 | std a p 0 11 | 12 | ; Emit the load just before a regfence, so the result does not have a register 13 | ; assigned. 14 | d = ldd p 0 15 | regfence 16 | 17 | retd d 18 | 19 | ; Ensure that 'p' is live here, so it gets a stack slot before 'd' does (and so 20 | ; extends the range required to store out 'd'). 21 | livep p 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bug596923.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bug643969.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | 6 | ptr = allocp 8 7 | j start 8 | 9 | success: zero = immd 0.0 10 | retd zero 11 | 12 | 13 | ; do a store+load so we don't optimize away the test 14 | start: a = immd 1.0 15 | b = immd 2.0 16 | c = addd a b 17 | std c ptr 0 18 | 19 | expect = immd 4.0 20 | actual = ldd ptr 0 21 | 22 | ; Test is for this code pattern, i386/x64 backend 23 | ; could generate bad code for the != case of LIR_jf 24 | ; if the branch is backwards. (Note that we compare 3.0 25 | ; to 4.0 because we need the test to fail.) 26 | cond = eqd expect actual 27 | jf cond success 28 | 29 | bad = immd -1.0 30 | retd bad 31 | 32 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/bug643969.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/call1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | a = immi 65 7 | sti2c a ptr 0 8 | b = immi 66 9 | sti2c b ptr 1 10 | c = immi 67 11 | sti2c c ptr 2 12 | zero = immi 0 13 | sti2c zero ptr 3 14 | ss = calli puts cdecl ptr 15 | nn = gei ss zero 16 | reti nn 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/call1.out: -------------------------------------------------------------------------------- 1 | ABC 2 | Output is: 1 3 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/call2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | pi = immd 3.14 6 | half = immd 0.5 7 | halfpi = muld pi half 8 | res = calld sin cdecl halfpi 9 | retd res 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/call2.out: -------------------------------------------------------------------------------- 1 | Output is: 1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/calld1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | a = immd 1.1; 6 | b = immd 2.2 7 | c = immd 3.3; 8 | d = immd 4.4; 9 | e = immd 5.5; 10 | f = immd 6.6; 11 | g = immd 7.7; 12 | h = immd 8.8; 13 | 14 | res = calld calld1 cdecl a b c d e f g h 15 | retd res 16 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/calld1.out: -------------------------------------------------------------------------------- 1 | Output is: -62.9667 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immd 1.1; 9 | y = immd 3.3; 10 | z = immd 4.4; 11 | 12 | res = calld callid1 cdecl i x y j k z 13 | retd res 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid1.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immd 8.8; 9 | 10 | res = calld callid2 cdecl i j k x 11 | retd res 12 | 13 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid2.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid3.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immd 1.1; 9 | y = immd 3.3; 10 | z = immd 4.4; 11 | 12 | res = calld callid3 cdecl i j x k y z 13 | retd res 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callid3.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callv.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; test call to void function 6 | 7 | forty_two = immi 42 8 | callv printi cdecl forty_two 9 | reti forty_two 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/callv.out: -------------------------------------------------------------------------------- 1 | 42 2 | Output is: 42 3 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cmov.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1 6 | j = immi 0 7 | k = immi 1 8 | 9 | ; Test each comparison operator. In each case, the result is set to k (1) if it 10 | ; did what it should do, or i (-1) if not. 11 | 12 | c1 = eqi j k 13 | r1 = cmovi c1 i k 14 | 15 | c2 = lti j k 16 | r2 = cmovi c2 k i 17 | 18 | c3 = lei j k 19 | r3 = cmovi c3 k i 20 | 21 | c4 = gti j k 22 | r4 = cmovi c4 i k 23 | 24 | c5 = gei j k 25 | r5 = cmovi c5 i k 26 | 27 | c6 = ltui j k 28 | r6 = cmovi c6 k i 29 | 30 | c7 = leui j k 31 | r7 = cmovi c7 k i 32 | 33 | c8 = gtui j k 34 | r8 = cmovi c8 i k 35 | 36 | c9 = geui j k 37 | r9 = cmovi c9 i k 38 | 39 | ; A few weird cases: Perform unsigned tests on a signed quantity to ensure that 40 | ; they do what they should. This is dependent on the platform using two's 41 | ; complement arithmetic, but we don't support anything that doesn't do that. 42 | 43 | c10 = ltui i k 44 | r10 = cmovi c10 i k 45 | 46 | c11 = leui i k 47 | r11 = cmovi c11 i k 48 | 49 | c12 = gtui i k 50 | r12 = cmovi c12 k i 51 | 52 | c13 = geui i k 53 | r13 = cmovi c13 k i 54 | 55 | ; Sum the results. They should all be 1 so an overall result of 13 is a pass. 56 | 57 | r1_2 = addi r1 r2 58 | r3_4 = addi r3 r4 59 | r5_6 = addi r5 r6 60 | r7_8 = addi r7 r8 61 | r9_10 = addi r9 r10 62 | r11_12 = addi r11 r12 63 | 64 | r1_4 = addi r1_2 r3_4 65 | r5_8 = addi r5_6 r7_8 66 | r9_12 = addi r9_10 r11_12 67 | 68 | r1_8 = addi r1_4 r5_8 69 | r9_13 = addi r9_12 r13 70 | 71 | res = addi r1_8 r9_13 72 | reti res 73 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cmov.out: -------------------------------------------------------------------------------- 1 | Output is: 13 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cmovd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immd -1.1 6 | j = immd 0.0 7 | k = immd 1.1 8 | 9 | ; Test each comparison operator. In each case, the result is set to k (1) if it 10 | ; did what it should do, or i (-1) if not. 11 | 12 | c1 = eqd j k 13 | r1 = cmovd c1 i k 14 | 15 | c2 = ltd j k 16 | r2 = cmovd c2 k i 17 | 18 | c3 = led j k 19 | r3 = cmovd c3 k i 20 | 21 | c4 = gtd j k 22 | r4 = cmovd c4 i k 23 | 24 | c5 = ged j k 25 | r5 = cmovd c5 i k 26 | 27 | 28 | 29 | ; Sum the results. They should all be 1 so an overall result of 5.5 is a pass. 30 | 31 | r1_2 = addd r1 r2 32 | r3_4 = addd r3 r4 33 | 34 | r1_4 = addd r1_2 r3_4 35 | 36 | res = addd r1_4 r5 37 | retd res 38 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cmovd.out: -------------------------------------------------------------------------------- 1 | Output is: 5.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_eqd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants. 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immd 0 17 | i1 = immd 1 18 | i2 = immd -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'eqd'. 22 | eq0 = eqd i0 i0 ; 1 23 | eq1 = eqd i0 i1 ; 0 24 | eq2 = eqd i0 i2 ; 0 25 | eq3 = eqd i1 i0 ; 0 26 | eq4 = eqd i1 i1 ; 1 27 | eq5 = eqd i1 i2 ; 0 28 | eq6 = eqd i2 i0 ; 0 29 | eq7 = eqd i2 i1 ; 0 30 | eq8 = eqd i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | eq0sh = lshi eq0 sh0 34 | eq1sh = lshi eq1 sh1 35 | eq2sh = lshi eq2 sh2 36 | eq3sh = lshi eq3 sh3 37 | eq4sh = lshi eq4 sh4 38 | eq5sh = lshi eq5 sh5 39 | eq6sh = lshi eq6 sh6 40 | eq7sh = lshi eq7 sh7 41 | eq8sh = lshi eq8 sh8 42 | 43 | eq0_1 = ori eq0sh eq1sh 44 | eq2_3 = ori eq2sh eq3sh 45 | eq4_5 = ori eq4sh eq5sh 46 | eq6_7 = ori eq6sh eq7sh 47 | 48 | eq0_3 = ori eq0_1 eq2_3 49 | eq4_7 = ori eq4_5 eq6_7 50 | 51 | eq0_7 = ori eq0_3 eq4_7 52 | 53 | eq = ori eq0_7 eq8sh 54 | 55 | ; The result should be {0001,0001,0001}, 0x111, or 273. 56 | 57 | reti eq 58 | 59 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_eqd.out: -------------------------------------------------------------------------------- 1 | Output is: 273 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_eqi.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'eqi'. 22 | eq0 = eqi i0 i0 ; 1 23 | eq1 = eqi i0 i1 ; 0 24 | eq2 = eqi i0 i2 ; 0 25 | eq3 = eqi i1 i0 ; 0 26 | eq4 = eqi i1 i1 ; 1 27 | eq5 = eqi i1 i2 ; 0 28 | eq6 = eqi i2 i0 ; 0 29 | eq7 = eqi i2 i1 ; 0 30 | eq8 = eqi i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | eq0sh = lshi eq0 sh0 34 | eq1sh = lshi eq1 sh1 35 | eq2sh = lshi eq2 sh2 36 | eq3sh = lshi eq3 sh3 37 | eq4sh = lshi eq4 sh4 38 | eq5sh = lshi eq5 sh5 39 | eq6sh = lshi eq6 sh6 40 | eq7sh = lshi eq7 sh7 41 | eq8sh = lshi eq8 sh8 42 | 43 | eq0_1 = ori eq0sh eq1sh 44 | eq2_3 = ori eq2sh eq3sh 45 | eq4_5 = ori eq4sh eq5sh 46 | eq6_7 = ori eq6sh eq7sh 47 | 48 | eq0_3 = ori eq0_1 eq2_3 49 | eq4_7 = ori eq4_5 eq6_7 50 | 51 | eq0_7 = ori eq0_3 eq4_7 52 | 53 | eq = ori eq0_7 eq8sh 54 | 55 | ; The result should be {0001,0001,0001}, 0x111, or 273. 56 | 57 | reti eq 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_eqi.out: -------------------------------------------------------------------------------- 1 | Output is: 273 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ged.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immd 0 17 | i1 = immd 1 18 | i2 = immd -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'ged'. 22 | ge0 = ged i0 i0 ; 1 23 | ge1 = ged i0 i1 ; 0 24 | ge2 = ged i0 i2 ; 1 25 | ge3 = ged i1 i0 ; 1 26 | ge4 = ged i1 i1 ; 1 27 | ge5 = ged i1 i2 ; 1 28 | ge6 = ged i2 i0 ; 0 29 | ge7 = ged i2 i1 ; 0 30 | ge8 = ged i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | ge0sh = lshi ge0 sh0 34 | ge1sh = lshi ge1 sh1 35 | ge2sh = lshi ge2 sh2 36 | ge3sh = lshi ge3 sh3 37 | ge4sh = lshi ge4 sh4 38 | ge5sh = lshi ge5 sh5 39 | ge6sh = lshi ge6 sh6 40 | ge7sh = lshi ge7 sh7 41 | ge8sh = lshi ge8 sh8 42 | 43 | ge0_1 = ori ge0sh ge1sh 44 | ge2_3 = ori ge2sh ge3sh 45 | ge4_5 = ori ge4sh ge5sh 46 | ge6_7 = ori ge6sh ge7sh 47 | 48 | ge0_3 = ori ge0_1 ge2_3 49 | ge4_7 = ori ge4_5 ge6_7 50 | 51 | ge0_7 = ori ge0_3 ge4_7 52 | 53 | ge = ori ge0_7 ge8sh 54 | 55 | ; The result should be {0001,0011,1101}, 0x13d, or 44. 56 | 57 | reti ge 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ged.out: -------------------------------------------------------------------------------- 1 | Output is: 317 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gei.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'gei'. 22 | ge0 = gei i0 i0 ; 1 23 | ge1 = gei i0 i1 ; 0 24 | ge2 = gei i0 i2 ; 1 25 | ge3 = gei i1 i0 ; 1 26 | ge4 = gei i1 i1 ; 1 27 | ge5 = gei i1 i2 ; 1 28 | ge6 = gei i2 i0 ; 0 29 | ge7 = gei i2 i1 ; 0 30 | ge8 = gei i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | ge0sh = lshi ge0 sh0 34 | ge1sh = lshi ge1 sh1 35 | ge2sh = lshi ge2 sh2 36 | ge3sh = lshi ge3 sh3 37 | ge4sh = lshi ge4 sh4 38 | ge5sh = lshi ge5 sh5 39 | ge6sh = lshi ge6 sh6 40 | ge7sh = lshi ge7 sh7 41 | ge8sh = lshi ge8 sh8 42 | 43 | ge0_1 = ori ge0sh ge1sh 44 | ge2_3 = ori ge2sh ge3sh 45 | ge4_5 = ori ge4sh ge5sh 46 | ge6_7 = ori ge6sh ge7sh 47 | 48 | ge0_3 = ori ge0_1 ge2_3 49 | ge4_7 = ori ge4_5 ge6_7 50 | 51 | ge0_7 = ori ge0_3 ge4_7 52 | 53 | ge = ori ge0_7 ge8sh 54 | 55 | ; The result should be {0001,0011,1101}, 0x13d, or 44. 56 | 57 | reti ge 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gei.out: -------------------------------------------------------------------------------- 1 | Output is: 317 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_geui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'geui'. 22 | ge0 = geui i0 i0 ; 1 23 | ge1 = geui i0 i1 ; 0 24 | ge2 = geui i0 i2 ; 0 25 | ge3 = geui i1 i0 ; 1 26 | ge4 = geui i1 i1 ; 1 27 | ge5 = geui i1 i2 ; 0 28 | ge6 = geui i2 i0 ; 1 29 | ge7 = geui i2 i1 ; 1 30 | ge8 = geui i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | ge0sh = lshi ge0 sh0 34 | ge1sh = lshi ge1 sh1 35 | ge2sh = lshi ge2 sh2 36 | ge3sh = lshi ge3 sh3 37 | ge4sh = lshi ge4 sh4 38 | ge5sh = lshi ge5 sh5 39 | ge6sh = lshi ge6 sh6 40 | ge7sh = lshi ge7 sh7 41 | ge8sh = lshi ge8 sh8 42 | 43 | ge0_1 = ori ge0sh ge1sh 44 | ge2_3 = ori ge2sh ge3sh 45 | ge4_5 = ori ge4sh ge5sh 46 | ge6_7 = ori ge6sh ge7sh 47 | 48 | ge0_3 = ori ge0_1 ge2_3 49 | ge4_7 = ori ge4_5 ge6_7 50 | 51 | ge0_7 = ori ge0_3 ge4_7 52 | 53 | ge = ori ge0_7 ge8sh 54 | 55 | ; The result should be {0001,1101,1001}, 0x1d9, or 473. 56 | 57 | reti ge 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_geui.out: -------------------------------------------------------------------------------- 1 | Output is: 473 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gtd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immd 0 17 | i1 = immd 1 18 | i2 = immd -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'gtd'. 22 | gt0 = gtd i0 i0 ; 0 23 | gt1 = gtd i0 i1 ; 0 24 | gt2 = gtd i0 i2 ; 1 25 | gt3 = gtd i1 i0 ; 1 26 | gt4 = gtd i1 i1 ; 0 27 | gt5 = gtd i1 i2 ; 1 28 | gt6 = gtd i2 i0 ; 0 29 | gt7 = gtd i2 i1 ; 0 30 | gt8 = gtd i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | gt0sh = lshi gt0 sh0 34 | gt1sh = lshi gt1 sh1 35 | gt2sh = lshi gt2 sh2 36 | gt3sh = lshi gt3 sh3 37 | gt4sh = lshi gt4 sh4 38 | gt5sh = lshi gt5 sh5 39 | gt6sh = lshi gt6 sh6 40 | gt7sh = lshi gt7 sh7 41 | gt8sh = lshi gt8 sh8 42 | 43 | gt0_1 = ori gt0sh gt1sh 44 | gt2_3 = ori gt2sh gt3sh 45 | gt4_5 = ori gt4sh gt5sh 46 | gt6_7 = ori gt6sh gt7sh 47 | 48 | gt0_3 = ori gt0_1 gt2_3 49 | gt4_7 = ori gt4_5 gt6_7 50 | 51 | gt0_7 = ori gt0_3 gt4_7 52 | 53 | gt = ori gt0_7 gt8sh 54 | 55 | ; The result should be {0000,0010,1100}, 0x02c, or 194. 56 | 57 | reti gt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gtd.out: -------------------------------------------------------------------------------- 1 | Output is: 44 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gti.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'gti'. 22 | gt0 = gti i0 i0 ; 0 23 | gt1 = gti i0 i1 ; 0 24 | gt2 = gti i0 i2 ; 1 25 | gt3 = gti i1 i0 ; 1 26 | gt4 = gti i1 i1 ; 0 27 | gt5 = gti i1 i2 ; 1 28 | gt6 = gti i2 i0 ; 0 29 | gt7 = gti i2 i1 ; 0 30 | gt8 = gti i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | gt0sh = lshi gt0 sh0 34 | gt1sh = lshi gt1 sh1 35 | gt2sh = lshi gt2 sh2 36 | gt3sh = lshi gt3 sh3 37 | gt4sh = lshi gt4 sh4 38 | gt5sh = lshi gt5 sh5 39 | gt6sh = lshi gt6 sh6 40 | gt7sh = lshi gt7 sh7 41 | gt8sh = lshi gt8 sh8 42 | 43 | gt0_1 = ori gt0sh gt1sh 44 | gt2_3 = ori gt2sh gt3sh 45 | gt4_5 = ori gt4sh gt5sh 46 | gt6_7 = ori gt6sh gt7sh 47 | 48 | gt0_3 = ori gt0_1 gt2_3 49 | gt4_7 = ori gt4_5 gt6_7 50 | 51 | gt0_7 = ori gt0_3 gt4_7 52 | 53 | gt = ori gt0_7 gt8sh 54 | 55 | ; The result should be {0000,0010,1100}, 0x02c, or 194. 56 | 57 | reti gt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gti.out: -------------------------------------------------------------------------------- 1 | Output is: 44 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gtui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants. 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'gtui'. 22 | gt0 = gtui i0 i0 ; 0 23 | gt1 = gtui i0 i1 ; 0 24 | gt2 = gtui i0 i2 ; 0 25 | gt3 = gtui i1 i0 ; 1 26 | gt4 = gtui i1 i1 ; 0 27 | gt5 = gtui i1 i2 ; 0 28 | gt6 = gtui i2 i0 ; 1 29 | gt7 = gtui i2 i1 ; 1 30 | gt8 = gtui i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | gt0sh = lshi gt0 sh0 34 | gt1sh = lshi gt1 sh1 35 | gt2sh = lshi gt2 sh2 36 | gt3sh = lshi gt3 sh3 37 | gt4sh = lshi gt4 sh4 38 | gt5sh = lshi gt5 sh5 39 | gt6sh = lshi gt6 sh6 40 | gt7sh = lshi gt7 sh7 41 | gt8sh = lshi gt8 sh8 42 | 43 | gt0_1 = ori gt0sh gt1sh 44 | gt2_3 = ori gt2sh gt3sh 45 | gt4_5 = ori gt4sh gt5sh 46 | gt6_7 = ori gt6sh gt7sh 47 | 48 | gt0_3 = ori gt0_1 gt2_3 49 | gt4_7 = ori gt4_5 gt6_7 50 | 51 | gt0_7 = ori gt0_3 gt4_7 52 | 53 | gt = ori gt0_7 gt8sh 54 | 55 | ; The result should be {0000,1100,1000}, 0x0c8, or 200. 56 | 57 | reti gt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_gtui.out: -------------------------------------------------------------------------------- 1 | Output is: 200 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_led.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immd 0 17 | i1 = immd 1 18 | i2 = immd -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'led'. 22 | le0 = led i0 i0 ; 1 23 | le1 = led i0 i1 ; 1 24 | le2 = led i0 i2 ; 0 25 | le3 = led i1 i0 ; 0 26 | le4 = led i1 i1 ; 1 27 | le5 = led i1 i2 ; 0 28 | le6 = led i2 i0 ; 1 29 | le7 = led i2 i1 ; 1 30 | le8 = led i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | le0sh = lshi le0 sh0 34 | le1sh = lshi le1 sh1 35 | le2sh = lshi le2 sh2 36 | le3sh = lshi le3 sh3 37 | le4sh = lshi le4 sh4 38 | le5sh = lshi le5 sh5 39 | le6sh = lshi le6 sh6 40 | le7sh = lshi le7 sh7 41 | le8sh = lshi le8 sh8 42 | 43 | le0_1 = ori le0sh le1sh 44 | le2_3 = ori le2sh le3sh 45 | le4_5 = ori le4sh le5sh 46 | le6_7 = ori le6sh le7sh 47 | 48 | le0_3 = ori le0_1 le2_3 49 | le4_7 = ori le4_5 le6_7 50 | 51 | le0_7 = ori le0_3 le4_7 52 | 53 | le = ori le0_7 le8sh 54 | 55 | ; The result should be {0001,1101,0011}, 0x1d3, or 194. 56 | 57 | reti le 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_led.out: -------------------------------------------------------------------------------- 1 | Output is: 467 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_lei.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'lei'. 22 | le0 = lei i0 i0 ; 1 23 | le1 = lei i0 i1 ; 1 24 | le2 = lei i0 i2 ; 0 25 | le3 = lei i1 i0 ; 0 26 | le4 = lei i1 i1 ; 1 27 | le5 = lei i1 i2 ; 0 28 | le6 = lei i2 i0 ; 1 29 | le7 = lei i2 i1 ; 1 30 | le8 = lei i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | le0sh = lshi le0 sh0 34 | le1sh = lshi le1 sh1 35 | le2sh = lshi le2 sh2 36 | le3sh = lshi le3 sh3 37 | le4sh = lshi le4 sh4 38 | le5sh = lshi le5 sh5 39 | le6sh = lshi le6 sh6 40 | le7sh = lshi le7 sh7 41 | le8sh = lshi le8 sh8 42 | 43 | le0_1 = ori le0sh le1sh 44 | le2_3 = ori le2sh le3sh 45 | le4_5 = ori le4sh le5sh 46 | le6_7 = ori le6sh le7sh 47 | 48 | le0_3 = ori le0_1 le2_3 49 | le4_7 = ori le4_5 le6_7 50 | 51 | le0_7 = ori le0_3 le4_7 52 | 53 | le = ori le0_7 le8sh 54 | 55 | ; The result should be {0001,1101,0011}, 0x1d3, or 194. 56 | 57 | reti le 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_lei.out: -------------------------------------------------------------------------------- 1 | Output is: 467 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_leui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'leui'. 22 | le0 = leui i0 i0 ; 1 23 | le1 = leui i0 i1 ; 1 24 | le2 = leui i0 i2 ; 1 25 | le3 = leui i1 i0 ; 0 26 | le4 = leui i1 i1 ; 1 27 | le5 = leui i1 i2 ; 1 28 | le6 = leui i2 i0 ; 0 29 | le7 = leui i2 i1 ; 0 30 | le8 = leui i2 i2 ; 1 31 | 32 | ; Aggregate the results. 33 | le0sh = lshi le0 sh0 34 | le1sh = lshi le1 sh1 35 | le2sh = lshi le2 sh2 36 | le3sh = lshi le3 sh3 37 | le4sh = lshi le4 sh4 38 | le5sh = lshi le5 sh5 39 | le6sh = lshi le6 sh6 40 | le7sh = lshi le7 sh7 41 | le8sh = lshi le8 sh8 42 | 43 | le0_1 = ori le0sh le1sh 44 | le2_3 = ori le2sh le3sh 45 | le4_5 = ori le4sh le5sh 46 | le6_7 = ori le6sh le7sh 47 | 48 | le0_3 = ori le0_1 le2_3 49 | le4_7 = ori le4_5 le6_7 50 | 51 | le0_7 = ori le0_3 le4_7 52 | 53 | le = ori le0_7 le8sh 54 | 55 | ; The result should be {0001,0011,0111}, 0x137, or 311. 56 | 57 | reti le 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_leui.out: -------------------------------------------------------------------------------- 1 | Output is: 311 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ltd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immd 0 17 | i1 = immd 1 18 | i2 = immd -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'ltd'. 22 | lt0 = ltd i0 i0 ; 0 23 | lt1 = ltd i0 i1 ; 1 24 | lt2 = ltd i0 i2 ; 0 25 | lt3 = ltd i1 i0 ; 0 26 | lt4 = ltd i1 i1 ; 0 27 | lt5 = ltd i1 i2 ; 0 28 | lt6 = ltd i2 i0 ; 1 29 | lt7 = ltd i2 i1 ; 1 30 | lt8 = ltd i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | lt0sh = lshi lt0 sh0 34 | lt1sh = lshi lt1 sh1 35 | lt2sh = lshi lt2 sh2 36 | lt3sh = lshi lt3 sh3 37 | lt4sh = lshi lt4 sh4 38 | lt5sh = lshi lt5 sh5 39 | lt6sh = lshi lt6 sh6 40 | lt7sh = lshi lt7 sh7 41 | lt8sh = lshi lt8 sh8 42 | 43 | lt0_1 = ori lt0sh lt1sh 44 | lt2_3 = ori lt2sh lt3sh 45 | lt4_5 = ori lt4sh lt5sh 46 | lt6_7 = ori lt6sh lt7sh 47 | 48 | lt0_3 = ori lt0_1 lt2_3 49 | lt4_7 = ori lt4_5 lt6_7 50 | 51 | lt0_7 = ori lt0_3 lt4_7 52 | 53 | lt = ori lt0_7 lt8sh 54 | 55 | ; The result should be {0000,1100,0010}, 0x0c2, or 194. 56 | 57 | reti lt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ltd.out: -------------------------------------------------------------------------------- 1 | Output is: 194 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_lti.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'lti'. 22 | lt0 = lti i0 i0 ; 0 23 | lt1 = lti i0 i1 ; 1 24 | lt2 = lti i0 i2 ; 0 25 | lt3 = lti i1 i0 ; 0 26 | lt4 = lti i1 i1 ; 0 27 | lt5 = lti i1 i2 ; 0 28 | lt6 = lti i2 i0 ; 1 29 | lt7 = lti i2 i1 ; 1 30 | lt8 = lti i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | lt0sh = lshi lt0 sh0 34 | lt1sh = lshi lt1 sh1 35 | lt2sh = lshi lt2 sh2 36 | lt3sh = lshi lt3 sh3 37 | lt4sh = lshi lt4 sh4 38 | lt5sh = lshi lt5 sh5 39 | lt6sh = lshi lt6 sh6 40 | lt7sh = lshi lt7 sh7 41 | lt8sh = lshi lt8 sh8 42 | 43 | lt0_1 = ori lt0sh lt1sh 44 | lt2_3 = ori lt2sh lt3sh 45 | lt4_5 = ori lt4sh lt5sh 46 | lt6_7 = ori lt6sh lt7sh 47 | 48 | lt0_3 = ori lt0_1 lt2_3 49 | lt4_7 = ori lt4_5 lt6_7 50 | 51 | lt0_7 = ori lt0_3 lt4_7 52 | 53 | lt = ori lt0_7 lt8sh 54 | 55 | ; The result should be {0000,1100,0010}, 0x0c2, or 194. 56 | 57 | reti lt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_lti.out: -------------------------------------------------------------------------------- 1 | Output is: 194 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ltui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; A few utility constants . 6 | sh0 = immi 0 7 | sh1 = immi 1 8 | sh2 = immi 2 9 | sh3 = immi 3 10 | sh4 = immi 4 11 | sh5 = immi 5 12 | sh6 = immi 6 13 | sh7 = immi 7 14 | sh8 = immi 8 15 | 16 | i0 = immi 0 17 | i1 = immi 1 18 | i2 = immi -1 19 | 20 | ; ---------------------------------------------------------------------------- 21 | ; Combinations of 'ltui'. 22 | lt0 = ltui i0 i0 ; 0 23 | lt1 = ltui i0 i1 ; 1 24 | lt2 = ltui i0 i2 ; 1 25 | lt3 = ltui i1 i0 ; 0 26 | lt4 = ltui i1 i1 ; 0 27 | lt5 = ltui i1 i2 ; 1 28 | lt6 = ltui i2 i0 ; 0 29 | lt7 = ltui i2 i1 ; 0 30 | lt8 = ltui i2 i2 ; 0 31 | 32 | ; Aggregate the results. 33 | lt0sh = lshi lt0 sh0 34 | lt1sh = lshi lt1 sh1 35 | lt2sh = lshi lt2 sh2 36 | lt3sh = lshi lt3 sh3 37 | lt4sh = lshi lt4 sh4 38 | lt5sh = lshi lt5 sh5 39 | lt6sh = lshi lt6 sh6 40 | lt7sh = lshi lt7 sh7 41 | lt8sh = lshi lt8 sh8 42 | 43 | lt0_1 = ori lt0sh lt1sh 44 | lt2_3 = ori lt2sh lt3sh 45 | lt4_5 = ori lt4sh lt5sh 46 | lt6_7 = ori lt6sh lt7sh 47 | 48 | lt0_3 = ori lt0_1 lt2_3 49 | lt4_7 = ori lt4_5 lt6_7 50 | 51 | lt0_7 = ori lt0_3 lt4_7 52 | 53 | lt = ori lt0_7 lt8sh 54 | 55 | ; The result should be {0000,0010,0110}, 0x026, or 38. 56 | 57 | reti lt 58 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/cond_ltui.out: -------------------------------------------------------------------------------- 1 | Output is: 38 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/divd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 8 9 | p2 = allocp 8 10 | 11 | d1a = immd 1.5 12 | d1 = divd d1a d1a ; X = X / X 13 | std d1 p1 0 14 | 15 | d2a = immd 4.0 16 | d2b = immd 8.0 17 | d2 = divd d2a d2b ; X = X / Y 18 | std d2b p2 0 19 | std d2 p2 0 20 | 21 | d3a = ldd p1 0 22 | d3b = ldd p2 0 23 | d3 = divd d3a d3b ; X = Y / X 24 | std d3a p2 0 25 | std d3 p2 0 26 | 27 | d4a = ldd p2 0 28 | d4b = ldd p1 0 29 | d4 = divd d4a d4b ; X = Y / Z 30 | std d4a p1 0 31 | std d4b p2 0 32 | std d4 p1 0 33 | 34 | d = ldd p1 0 35 | retd d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/divd.out: -------------------------------------------------------------------------------- 1 | Output is: 2 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/addf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 4 9 | p2 = allocp 4 10 | 11 | f1a = immf 1.5 12 | f1 = addf f1a f1a ; X = X + X 13 | stf f1 p1 0 14 | 15 | f2a = immf 2.5 16 | f2b = immf 3.0 17 | f2 = addf f2a f2b ; X = X + Y 18 | stf f2b p2 0 19 | stf f2 p2 0 20 | 21 | f3a = ldf p1 0 22 | f3b = ldf p2 0 23 | f3 = addf f3a f3b ; X = Y + X 24 | stf f3a p2 0 25 | stf f3 p2 0 26 | 27 | f4a = ldf p2 0 28 | f4b = ldf p1 0 29 | f4 = addf f4a f4b ; X = Y + Z 30 | stf f4a p1 0 31 | stf f4b p2 0 32 | stf f4 p1 0 33 | 34 | f = ldf p1 0 35 | retf f 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/addf.out: -------------------------------------------------------------------------------- 1 | Output is: 11.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/addf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 16 9 | p2 = allocp 16 10 | 11 | 12 | f1 = immf 1.5 13 | stf f1 p1 0 14 | f2 = immf 1.6 15 | stf f2 p1 4 16 | f3 = immf 1.7 17 | stf f3 p1 8 18 | f4 = immf 1.8 19 | stf f4 p1 12 20 | d1a = ldf4 p1 0 21 | d1 = addf4 d1a d1a ; X = X + X 22 | stf4 d1 p1 0 ;// 3 3.2 3.4 3.6 23 | 24 | 25 | d2a = immf4 2.5 2.6 2.7 2.8 26 | d2b = immf4 3.0 2.9 2.8 2.7 27 | d2 = addf4 d2a d2b ; X = X + Y 28 | stf4 d2b p2 0 29 | stf4 d2 p2 0 ;// 5.5 5.5 5.5 5.5 30 | 31 | d3a = ldf4 p1 0 32 | d3b = ldf4 p2 0 33 | d3 = addf4 d3a d3b ; X = Y + X 34 | stf4 d3a p2 0 35 | stf4 d3 p2 0 ;// 8.5 8.7 8.9 9.1 36 | 37 | 38 | d4a = ldf4 p2 0 39 | d4b = ldf4 p1 0 40 | d4 = addf4 d4a d4b ; X = Y + Z 41 | stf4 d4a p1 0 42 | stf4 d4b p2 0 43 | stf4 d4 p1 0 ;// 11.5 11.9 12.3 12.7 44 | 45 | d = ldf4 p1 0 46 | retf4 d 47 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/addf4.out: -------------------------------------------------------------------------------- 1 | Output is: 11.5,11.9,12.3,12.7 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/call2f.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | pi = immf 3.14 6 | half = immf 0.5 7 | halfpi1 = mulf pi half 8 | halfpi = f2d halfpi1 9 | res = callf sin cdecl halfpi 10 | resf = d2f res 11 | retf resf 12 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/call2f.out: -------------------------------------------------------------------------------- 1 | Output is: 1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | a = immf 1.1; 6 | b = immf 2.2 7 | c = immf 3.3; 8 | d = immf 4.4; 9 | e = immf 5.5; 10 | f = immf 6.6; 11 | g = immf 7.7; 12 | h = immf 8.8; 13 | 14 | res = callf callf1 cdecl a b c d e f g h 15 | retf res 16 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf1.out: -------------------------------------------------------------------------------- 1 | Output is: -62.9667 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf4_1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | a = immf4 1 2 4 9 6 | res = callf4 callf4_sqrt cdecl a 7 | retf4 res 8 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf4_1.out: -------------------------------------------------------------------------------- 1 | Output is: 1,1.41421,2,3 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf4_2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | f4 = immf4 1 2 4 9 6 | g4 = immf4 -0 0 0.5 1e100 7 | i = immi 10 8 | j = immi -1 9 | d = immd 9.9e9 10 | e = immd -5.5e-5 11 | f = immf 1.1 12 | g = immf 5.5 13 | res = callf4 callf4_mt cdecl f i d f4 j e g g4 14 | retf4 res 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callf4_2.out: -------------------------------------------------------------------------------- 1 | Output is: 0.0900905,0.180181,0.405407,INF 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf 1.1; 9 | y = immf 3.3; 10 | z = immf 4.4; 11 | 12 | res = callf callif1 cdecl i x y j k z 13 | retf res 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif1.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf 8.8; 9 | 10 | res = callf callif2 cdecl i j k x 11 | retf res 12 | 13 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif2.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif3.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf 1.1; 9 | y = immf 3.3; 10 | z = immf 4.4; 11 | 12 | res = callf callif3 cdecl i j x k y z 13 | retf res 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif3.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf4 1.1 2.2 3.3 4.4; 9 | y = immf4 3.3 6.6 3.3 6.6; 10 | z = immf4 4.4 8.8 3.3 4.4; 11 | 12 | res = callf4 callif4_1 cdecl i x y j k z ;// (8.8 17.6 9.9 15.4)/ 8 [8=(-1+3+6) ] 13 | retf4 res ;// 1.1 2.2 1.2375 1.925 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_1.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1,2.2,1.2375,1.925 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf4 8.8 -8.8 -0 20; 9 | 10 | res = callf4 callif4_2 cdecl i j k x 11 | retf4 res 12 | 13 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_2.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1,-1.1,-0,2.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_3.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1; 6 | j = immi 3; 7 | k = immi 6; 8 | x = immf4 1.1 1.25 1.1 -1.1 9 | y = immf4 3.3 3.75 3.3 -3.3 10 | z = immf4 4.4 -5 4.4 -4.4 11 | 12 | res = callf4 callif4_3 cdecl i j x k y z 13 | retf4 res 14 | 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/callif4_3.out: -------------------------------------------------------------------------------- 1 | Output is: 1.1,0,1.1,-1.1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/cmovf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immf -1.1 6 | j = immf 0.0 7 | k = immf 1.1 8 | 9 | ; Test each comparison operator. In each case, the result is set to k (1) if it 10 | ; did what it should do, or i (-1) if not. 11 | 12 | c1 = eqf j k 13 | r1 = cmovf c1 i k 14 | 15 | c2 = ltf j k 16 | r2 = cmovf c2 k i 17 | 18 | c3 = lef j k 19 | r3 = cmovf c3 k i 20 | 21 | c4 = gtf j k 22 | r4 = cmovf c4 i k 23 | 24 | c5 = gef j k 25 | r5 = cmovf c5 i k 26 | 27 | 28 | 29 | ; Sum the results. They should all be 1 so an overall result of 5.5 is a pass. 30 | 31 | r1_2 = addf r1 r2 32 | r3_4 = addf r3 r4 33 | 34 | r1_4 = addf r1_2 r3_4 35 | 36 | res = addf r1_4 r5 37 | retf res 38 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/cmovf.out: -------------------------------------------------------------------------------- 1 | Output is: 5.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/cmovf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immf4 1.1 -1.1 0.0 1.1 6 | j = immf4 1.1 -1.1 0.0 1.2 7 | k = immf4 1.1 -1.1 0.0 1.1 8 | 9 | ; Test each comparison operator. In each case, the result is set to i if true 10 | ; or j if false. 11 | 12 | c1 = eqf4 j k 13 | r1 = cmovf4 c1 i j ; should be 'j' 14 | 15 | c2 = eqf4 i j 16 | r2 = cmovf4 c2 i j ; should be 'j' 17 | 18 | c3 = eqf4 i k ; should be 'i' 19 | r3 = cmovf4 c3 i j 20 | 21 | ; Sum the results. An overall result of (3.3 -3.3 0.0 3.5) is a pass. 22 | 23 | r1_2 = addf4 r1 r2 24 | res = addf4 r3 r1_2 25 | 26 | retf4 res 27 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/cmovf4.out: -------------------------------------------------------------------------------- 1 | Output is: 3.3,-3.3,0,3.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/divf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 4 9 | p2 = allocp 4 10 | 11 | d1a = immf 1.5 12 | d1 = divf d1a d1a ; X = X / X 13 | stf d1 p1 0 14 | 15 | d2a = immf 4.0 16 | d2b = immf 8.0 17 | d2 = divf d2a d2b ; X = X / Y 18 | stf d2b p2 0 19 | stf d2 p2 0 20 | 21 | d3a = ldf p1 0 22 | d3b = ldf p2 0 23 | d3 = divf d3a d3b ; X = Y / X 24 | stf d3a p2 0 25 | stf d3 p2 0 26 | 27 | d4a = ldf p2 0 28 | d4b = ldf p1 0 29 | d4 = divf d4a d4b ; X = Y / Z 30 | stf d4a p1 0 31 | stf d4b p2 0 32 | stf d4 p1 0 33 | 34 | d = ldf p1 0 35 | retf d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/divf.out: -------------------------------------------------------------------------------- 1 | Output is: 2 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/divf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 16 9 | p2 = allocp 16 10 | 11 | d1a = immf4 1.5 -1.5 0.0 1 12 | d1 = divf4 d1a d1a ; X = X / X 13 | stf4 d1 p1 0 ; 1,1,-1.#IND,1 14 | 15 | d2a = immf4 4.0 -8.0 4.0 -8.0 16 | d2b = immf4 8.0 4.0 -8.0 -4.0 17 | d2 = divf4 d2a d2b ; X = X / Y 18 | stf4 d2b p2 0 19 | stf4 d2 p2 0 ; 0.5,-2,-0.5,2 20 | 21 | d3a = ldf4 p1 0 22 | d3b = ldf4 p2 0 23 | d3 = divf4 d3a d3b ; X = Y / X 24 | stf4 d3a p2 0 25 | stf4 d3 p2 0 ; 2,-0.5,-1.#IND,0.5 26 | 27 | f1 = immf -1 28 | f2 = immf -0 29 | inf = divf f1 f2 30 | stf inf p1 8 31 | stf f1 p2 8 32 | 33 | d4a = ldf4 p2 0 34 | d4b = ldf4 p1 0 35 | d4 = divf4 d4a d4b ; X = Y / Z 36 | stf4 d4a p1 0 37 | stf4 d4b p2 0 38 | stf4 d4 p1 0 ; 2,-0.5,-0,0.5 39 | 40 | d = ldf4 p1 0 41 | retf4 d 42 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/divf4.out: -------------------------------------------------------------------------------- 1 | Output is: 2,-0.5,-0,0.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fnegf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | p = immf 123.456 6 | n = negf p 7 | retf n 8 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fnegf.out: -------------------------------------------------------------------------------- 1 | Output is: -123.456 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fnegf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | d = allocp 16 6 | zero = immf -0 7 | f4 = f2f4 zero 8 | stf4 f4 d 0 9 | nan = divf zero zero 10 | stf nan d 8 11 | 12 | p0 = immf4 123.456 0 -0 -9e99 13 | 14 | p1 = ldf4 d 0 15 | p = addf4 p0 p1 16 | 17 | n = negf4 p 18 | retf4 n 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fnegf4.out: -------------------------------------------------------------------------------- 1 | Output is: -123.456,-0,NAN,INF 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fpu1-598151-flt.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immf 1.0 8 | b = immf 2.5 9 | c = addf a b 10 | stf c ptr 0 11 | j done 12 | 13 | foo: stf c ptr 0 14 | 15 | done: res = ldf ptr 0 16 | retf res 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fpu1-598151-flt.out: -------------------------------------------------------------------------------- 1 | Output is: 3.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fpu2-598151-flt.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | k = immf 1.0 8 | stf k ptr 0 9 | 10 | a = immf 1.0 11 | b = immf 2.5 12 | c = addf a b 13 | stf c ptr 0 14 | 15 | x = ldf ptr 0 16 | z = immf 0.0 17 | p = eqf x z 18 | jt p skip 19 | 20 | j done 21 | 22 | skip: stf c ptr 0 23 | 24 | done: res = ldf ptr 0 25 | retf res 26 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/fpu2-598151-flt.out: -------------------------------------------------------------------------------- 1 | Output is: 3.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/mulf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 4 9 | p2 = allocp 4 10 | 11 | d1a = immf 2.0 12 | d1 = mulf d1a d1a ; X = X * X 13 | stf d1 p1 0 14 | 15 | d2a = immf 2.5 16 | d2b = immf 3.0 17 | d2 = mulf d2a d2b ; X = X * Y 18 | stf d2b p2 0 19 | stf d2 p2 0 20 | 21 | d3a = ldf p1 0 22 | d3b = ldf p2 0 23 | d3 = mulf d3a d3b ; X = Y * X 24 | stf d3a p2 0 25 | stf d3 p2 0 26 | 27 | d4a = ldf p2 0 28 | d4b = ldf p1 0 29 | d4 = mulf d4a d4b ; X = Y * Z 30 | stf d4a p1 0 31 | stf d4b p2 0 32 | stf d4 p1 0 33 | 34 | f = ldf p1 0 35 | retf f 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/mulf.out: -------------------------------------------------------------------------------- 1 | Output is: 120 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/mulf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 16 9 | p2 = allocp 16 10 | 11 | d1a = immf4 2.0 2.5 3.0 -0 12 | d1 = mulf4 d1a d1a ; X = X * X 13 | stf4 d1 p1 0 ; 4,6.25,9,0 14 | 15 | d2a = immf4 2.5 0.3 2.5 0.3 16 | d2b = immf4 -5 5 -0 0 17 | d2 = mulf4 d2a d2b ; Y = X1 * X2 18 | stf4 d2b p2 0 19 | stf4 d2 p2 0 ; -12.5,1.5,-0,0 20 | 21 | d3a = ldf4 p1 0 22 | d3b = ldf4 p2 0 23 | d3 = mulf4 d3a d3b ; Y = Y * X 24 | stf4 d3a p2 0 25 | stf4 d3 p2 0 ; -50,9.375,-0,0 26 | 27 | d4a = ldf4 p2 0 28 | d4b = ldf4 p1 0 29 | d4 = mulf4 d4a d4b ; X = X * Y 30 | stf4 d4a p1 0 31 | stf4 d4b p2 0 32 | stf4 d4 p1 0 ; -200,58.59375,-0,0 33 | 34 | f = ldf4 p1 0 35 | retf4 f 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/mulf4.out: -------------------------------------------------------------------------------- 1 | Output is: -200,58.5938,-0,0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/multfrag2f.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin sinpibytwo 6 | pi = immf 3.14 7 | half = immf 0.5 8 | halfpi = mulf pi half 9 | par = f2d halfpi 10 | res = calld sin cdecl par 11 | resf = d2f res 12 | retf resf 13 | .end 14 | 15 | .begin main 16 | aa = callf sinpibytwo fastcall 17 | bb = immf 5.53 18 | res = addf aa bb 19 | retf res 20 | .end 21 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/multfrag2f.out: -------------------------------------------------------------------------------- 1 | Output is: 6.53 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/multfrag2f4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin sinpibytwo 6 | pi = immf 3.1415926535897932384626433832795 7 | pi4 = f2f4 pi 8 | factor = immf4 0.5 1 1.5 2 9 | mpi = mulf4 pi4 factor 10 | 11 | pf1 = f4x mpi 12 | pd1 = f2d pf1 13 | res1 = calld sin cdecl pd1 14 | pf2 = f4y mpi 15 | pd2 = f2d pf2 16 | res2 = calld sin cdecl pd2 17 | pf3 = f4z mpi 18 | pd3 = f2d pf3 19 | res3 = calld sin cdecl pd3 20 | pf4 = f4w mpi 21 | pd4 = f2d pf4 22 | res4 = calld sin cdecl pd4 23 | 24 | p = allocp 16 25 | std2f res1 p 0 26 | std2f res2 p 4 27 | std2f res3 p 8 28 | std2f res4 p 12 29 | res = ldf4 p 0 30 | retf4 res 31 | .end 32 | 33 | .begin main 34 | aa4 = callf4 sinpibytwo fastcall 35 | bb = immf 5.53 36 | bb4 = f2f4 bb 37 | res = addf4 aa4 bb4 38 | retf4 res 39 | .end 40 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/multfrag2f4.out: -------------------------------------------------------------------------------- 1 | Output is: 6.53,5.53,4.53,5.53 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/subf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 4 9 | p2 = allocp 4 10 | 11 | d1a = immf 1.5 12 | d1 = subf d1a d1a ; X = X - X 13 | stf d1 p1 0 14 | 15 | d2a = immf 2.5 16 | d2b = immf 3.0 17 | d2 = subf d2a d2b ; X = X - Y 18 | stf d2b p2 0 19 | stf d2 p2 0 20 | 21 | d3a = ldf p1 0 22 | d3b = ldf p2 0 23 | d3 = subf d3a d3b ; X = Y - X 24 | stf d3a p2 0 25 | stf d3 p2 0 26 | 27 | d4a = ldf p2 0 28 | d4b = ldf p1 0 29 | d4 = subf d4a d4b ; X = Y - Z 30 | stf d4a p1 0 31 | stf d4b p2 0 32 | stf d4 p1 0 33 | 34 | d = ldf p1 0 35 | retf d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/subf.out: -------------------------------------------------------------------------------- 1 | Output is: 0.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/subf4.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 16 9 | p2 = allocp 16 10 | 11 | d1a = immf4 1.5 0 -0 -1.5 12 | d1 = subf4 d1a d1a ; X = X - X 13 | stf4 d1 p1 0 14 | 15 | d2a = immf4 2.5 3.14159267 1e-30 1 16 | d2b = immf4 3.0 3.1415926 1e-29 1e-9 17 | d2 = subf4 d2a d2b ; X = X - Y 18 | stf4 d2b p2 0 19 | stf4 d2 p2 0 20 | 21 | d3a = ldf4 p1 0 22 | d3b = ldf4 p2 0 23 | d3 = subf4 d3a d3b ; X = Y - X 24 | stf4 d3a p2 0 25 | stf4 d3 p2 0 ; 0.5, small_negative, very_small_positive, -1 26 | 27 | d4a = ldf4 p2 0 28 | d4b = ldf4 p1 0 29 | d4 = subf4 d4a d4b ; X = Y - Z 30 | stf4 d4a p1 0 31 | stf4 d4b p2 0 32 | stf4 d4 p1 0 33 | 34 | f1 = f4x d4 35 | f2 = f4y d4 36 | f3 = f4z d4 37 | f4 = f4w d4 38 | f12 = addf f1 f2 39 | f34 = addf f3 f4 40 | fres = subf f12 f34 ;// approx 1.5 41 | 42 | f4res = f2f4 fres 43 | retf4 f4res 44 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float/subf4.out: -------------------------------------------------------------------------------- 1 | Output is: 1.5,1.5,1.5,1.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float_double.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | doubleA = immd 1.25 ; single precision 6 | doubleB = immd 4.5 ; single precision 7 | doubleC = immd 1.2 ; not single precision 8 | 9 | ptr = allocp 12 10 | std2f doubleA ptr 0 11 | std2f doubleB ptr 4 12 | std2f doubleC ptr 8 13 | 14 | doubleD = ldf2d ptr 0 15 | doubleE = ldf2d ptr 4 16 | doubleF = ldf2d ptr 8 17 | 18 | resA = eqd doubleA doubleD ; true 19 | resB = eqd doubleB doubleE ; true 20 | resC = eqd doubleB doubleF ; false 21 | resD = addi resA resB 22 | resE = addi resC resD 23 | 24 | reti resE 25 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/float_double.out: -------------------------------------------------------------------------------- 1 | Output is: 2 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/floatingpoint.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | pi = immd 3.14 6 | two = immd 2.0 7 | TwoPi = muld pi two 8 | retd two 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/floatingpoint.out: -------------------------------------------------------------------------------- 1 | Output is: 2 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fneg.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | p = immd 123.456 6 | n = negd p 7 | retd n 8 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fneg.out: -------------------------------------------------------------------------------- 1 | Output is: -123.456 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fpu1-598151.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immd 1.0 8 | b = immd 2.5 9 | c = addd a b 10 | std c ptr 0 11 | j done 12 | 13 | foo: std c ptr 0 14 | 15 | done: res = ldd ptr 0 16 | retd res 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fpu1-598151.out: -------------------------------------------------------------------------------- 1 | Output is: 3.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fpu2-598151.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | k = immd 1.0 8 | std k ptr 0 9 | 10 | a = immd 1.0 11 | b = immd 2.5 12 | c = addd a b 13 | std c ptr 0 14 | 15 | x = ldd ptr 0 16 | z = immd 0.0 17 | p = eqd x z 18 | jt p skip 19 | 20 | j done 21 | 22 | skip: std c ptr 0 23 | 24 | done: res = ldd ptr 0 25 | retd res 26 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/fpu2-598151.out: -------------------------------------------------------------------------------- 1 | Output is: 3.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/d2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; The rounding rules for d2i are pretty relaxed, but integer values should 6 | ; convert cleanly. 7 | c1 = immi -2147483648 8 | d1 = immd -2147483648 9 | i1 = d2i d1 10 | r1 = xori c1 i1 11 | 12 | c2 = immi 2147483647 13 | d2 = immd 2147483647 14 | i2 = d2i d2 15 | r2 = xori i2 c2 16 | 17 | ; The ARM back-end will do something different if there is no machine register 18 | ; allocated for d2i, and it doesn't hurt to test the same thing on other 19 | ; platforms too: 20 | 21 | c3 = immi 123456 22 | d3 = immd 123456 23 | i3 = d2i d3 24 | regfence 25 | r3 = xori i3 c3 26 | 27 | res1_2 = ori r1 r2 28 | res1_3 = ori res1_2 r3 29 | 30 | reti res1_3 31 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/d2i.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/f2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | a = allocp 8 6 | d = immd 5.0 7 | std d a 0 8 | x = ldd a 0 9 | i = d2i x 10 | reti i 11 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/f2i.out: -------------------------------------------------------------------------------- 1 | Output is: 5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/i2d.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; This test assumes that d2i and 32-bit integer arithmetic works properly. 6 | 7 | ; Start with 0x80000000 8 | i1 = immi -2147483648 9 | d1 = i2d i1 10 | o1 = d2i d1 11 | 12 | ; Test with -1 13 | c2 = immi 2147483647 14 | i2 = addi o1 c2 15 | d2 = i2d i2 16 | o2 = d2i d2 17 | 18 | ; Test with 2147483647 19 | i3 = subi o2 i1 20 | d3 = i2d i3 21 | o3 = d2i d3 22 | 23 | ; Test with 0 24 | i4 = subi o3 c2 25 | d4 = i2d i4 26 | o4 = d2i d4 27 | 28 | reti o4 29 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/i2d.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/ui2d.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi -1 6 | d = ui2d i 7 | 8 | retd d 9 | 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/hardfloat/ui2d.out: -------------------------------------------------------------------------------- 1 | Output is: 4.29497e+09 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/largeframe.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Allocate frame larger than a Win32 page 6 | ; and write to the end of the frame first. 7 | ; This test is just an exerciser for the page 8 | ; probing code, as lirasm will not crash without it. 9 | 10 | foo = allocp 8192 11 | bar = allocp 4 12 | k = immi 555 13 | sti k bar 0 14 | sti k foo 0 15 | res = ldi bar 0 16 | reti res 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/largeframe.out: -------------------------------------------------------------------------------- 1 | Output is: 555 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/fuzz-527178.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | base = allocp 512 6 | five = immi 5 7 | sti five base 256 8 | x = ldus2ui base 256 9 | reti x 10 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/fuzz-527178.out: -------------------------------------------------------------------------------- 1 | Output is: 5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/ldc2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi 1288908529 ; 0x4cd32ef1 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi -15 ; sign_extend(0xf1) 10 | n1chk = immi 46 ; sign_extend(0x2e) 11 | n2chk = immi -45 ; sign_extend(0xd3) 12 | n3chk = immi 76 ; sign_extend(0x4c) 13 | 14 | n0 = ldc2i p 0 15 | n1 = ldc2i p 1 16 | n2 = ldc2i p 2 17 | n3 = ldc2i p 3 18 | 19 | ; Collate the results. 20 | r0 = xori n0chk n0 21 | r1 = xori n1chk n1 22 | r2 = xori n2chk n2 23 | r3 = xori n3chk n3 24 | 25 | r0_1 = ori r0 r1 26 | r2_3 = ori r2 r3 27 | 28 | r = ori r0_1 r2_3 29 | reti r 30 | 31 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/ldc2i.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/lds2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -249334698 ; 0xf1237456 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 29782 ; sign_extend(0x7456) 10 | n1chk = immi -3805 ; sign_extend(0xf123) 11 | 12 | n0 = lds2i p 0 13 | n1 = lds2i p 2 14 | 15 | ; Collate the results. 16 | r0 = xori n0chk n0 17 | r1 = xori n1chk n1 18 | 19 | r = ori r0 r1 20 | reti r 21 | 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/lds2i.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/lduc2ui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -992746767 ; 0xc4d3e2f1 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 241 ; 0xf1 10 | n1chk = immi 226 ; 0xe2 11 | n2chk = immi 211 ; 0xd3 12 | n3chk = immi 196 ; 0xc4 13 | 14 | n0 = lduc2ui p 0 15 | n1 = lduc2ui p 1 16 | n2 = lduc2ui p 2 17 | n3 = lduc2ui p 3 18 | 19 | ; Collate the results. 20 | r0 = xori n0chk n0 21 | r1 = xori n1chk n1 22 | r2 = xori n2chk n2 23 | r3 = xori n3chk n3 24 | 25 | r0_1 = ori r0 r1 26 | r2_3 = ori r2 r3 27 | 28 | r = ori r0_1 r2_3 29 | reti r 30 | 31 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/lduc2ui.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/ldus2ui.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | full = immi -249334698 ; 0xf1237456 6 | p = allocp 4 7 | sti full p 0 8 | 9 | n0chk = immi 29782 ; sign_extend(0x7456) 10 | n1chk = immi 61731 ; sign_extend(0xf123) 11 | 12 | n0 = ldus2ui p 0 13 | n1 = ldus2ui p 2 14 | 15 | ; Collate the results. 16 | r0 = xori n0chk n0 17 | r1 = xori n1chk n1 18 | 19 | r = ori r0 r1 20 | reti r 21 | 22 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/littleendian/ldus2ui.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/loadstore.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | five = immi 5 7 | sti five ptr 0 8 | three = immi 3 9 | sti three ptr 4 10 | v = ldi ptr 0 11 | u = ldi ptr 4 12 | res = addi u v 13 | reti res 14 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/loadstore.out: -------------------------------------------------------------------------------- 1 | Output is: 8 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xxx.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46340 * 46340 < 2^31, and will not overflow. 6 | big = immi 46340 7 | 8 | res = muli big big 9 | 10 | reti res 11 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xxx.out: -------------------------------------------------------------------------------- 1 | Output is: 2147395600 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xxy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741823 * 2 < 2^31, and will not overflow. 6 | big = immi 1073741823 7 | two = immi 2 8 | 9 | res = muli big two 10 | 11 | reti res 12 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xxy.out: -------------------------------------------------------------------------------- 1 | Output is: 2147483646 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xyy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46340 * 46340 < 2^31, and will not overflow. 6 | big = immi 46340 7 | 8 | res = muli big big 9 | 10 | ; Ensure that 'big' gets its own register and isn't shared with 'res'. 11 | m = allocp 8 12 | sti big m 0 13 | 14 | reti res 15 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xyy.out: -------------------------------------------------------------------------------- 1 | Output is: 2147395600 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xyz.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741823 * 2 < 2^31, and will not overflow. 6 | big = immi 1073741823 7 | two = immi 2 8 | 9 | res = muli big two 10 | 11 | ; Ensure that 'big' and 'two' get their own registers and 12 | ; aren't shared with 'res'. 13 | m = allocp 12 14 | sti big m 0 15 | sti two m 4 16 | 17 | reti res 18 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mul_xyz.out: -------------------------------------------------------------------------------- 1 | Output is: 2147483646 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muld.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 8 9 | p2 = allocp 8 10 | 11 | d1a = immd 2.0 12 | d1 = muld d1a d1a ; X = X * X 13 | std d1 p1 0 14 | 15 | d2a = immd 2.5 16 | d2b = immd 3.0 17 | d2 = muld d2a d2b ; X = X * Y 18 | std d2b p2 0 19 | std d2 p2 0 20 | 21 | d3a = ldd p1 0 22 | d3b = ldd p2 0 23 | d3 = muld d3a d3b ; X = Y * X 24 | std d3a p2 0 25 | std d3 p2 0 26 | 27 | d4a = ldd p2 0 28 | d4b = ldd p1 0 29 | d4 = muld d4a d4b ; X = Y * Z 30 | std d4a p1 0 31 | std d4b p2 0 32 | std d4 p1 0 33 | 34 | d = ldd p1 0 35 | retd d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muld.out: -------------------------------------------------------------------------------- 1 | Output is: 120 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi 65536 8 | b = immi 32767 9 | c = muljovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | 20 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi.out: -------------------------------------------------------------------------------- 1 | Output is: 2147418112 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_ovf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi 65536 8 | b = immi 32768 9 | c = muljovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_ovf.out: -------------------------------------------------------------------------------- 1 | Output is: 12345678 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xxx.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46340 * 46340 < 2^31, and will not overflow. 6 | big = immi 46340 7 | 8 | res = muljovi big big err 9 | 10 | reti res 11 | 12 | ; ---- Exit route for the error handler. 13 | 14 | err: e = immi -1 15 | reti e 16 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xxx.out: -------------------------------------------------------------------------------- 1 | Output is: 2147395600 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xxy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741823 * 2 < 2^31, and will not overflow. 6 | big = immi 1073741823 7 | two = immi 2 8 | 9 | res = muljovi big two err 10 | 11 | reti res 12 | 13 | ; ---- Exit route for the error handler. 14 | 15 | err: e = immi -1 16 | reti e 17 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xxy.out: -------------------------------------------------------------------------------- 1 | Output is: 2147483646 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xyy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46340 * 46340 < 2^31, and will not overflow. 6 | big = immi 46340 7 | 8 | res = muljovi big big err 9 | 10 | ; Ensure that 'big' gets its own register and isn't shared with 'res'. 11 | m = allocp 8 12 | sti big m 0 13 | 14 | reti res 15 | 16 | ; ---- Exit route for the error handler. 17 | 18 | err: e = immi -1 19 | reti e 20 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xyy.out: -------------------------------------------------------------------------------- 1 | Output is: 2147395600 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xyz.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741823 * 2 < 2^31, and will not overflow. 6 | big = immi 1073741823 7 | two = immi 2 8 | 9 | res = muljovi big two err 10 | 11 | ; Ensure that 'big' and 'two' get their own registers and 12 | ; aren't shared with 'res'. 13 | m = allocp 12 14 | sti big m 0 15 | sti two m 4 16 | 17 | reti res 18 | 19 | ; ---- Exit route for the error handler. 20 | 21 | err: e = immi -1 22 | reti e 23 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/muljovi_xyz.out: -------------------------------------------------------------------------------- 1 | Output is: 2147483646 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xxx.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46341 * 46341 >= 2^31, and will overflow. 6 | big = immi 46341 7 | 8 | ; Because 'big' isn't used after mul, it _may_ get allocated to the same 9 | ; register as 'res'. This is the case with the ARM back-end, and that is where 10 | ; this test is important as rX=rX*rX isn't possible on ARMv5 without some 11 | ; trickery. 12 | res = mulxovi big big ; overflow, so we exit here 13 | 14 | ; Store 'res' so it isn't dead. 15 | m = allocp 4 16 | sti res m 0 17 | x ; we don't exit here 18 | 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xxx.out: -------------------------------------------------------------------------------- 1 | Exited block on line: 12 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xxy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741824 * 2 >= 2^31, and will overflow. 6 | big = immi 1073741824 7 | two = immi 2 8 | 9 | ; Because 'big' isn't used after mul, it _may_ get allocated to the same 10 | ; register as 'res'. This is the case with the ARM back-end, and that is where 11 | ; this test is important as rX=rX*rY isn't possible on ARMv5 without some 12 | ; trickery. 13 | res = mulxovi big two ; overflow, so we exit here 14 | 15 | ; Store 'res' so it isn't dead. 16 | m = allocp 4 17 | sti res m 0 18 | x ; we don't exit here 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xxy.out: -------------------------------------------------------------------------------- 1 | Exited block on line: 13 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xyy.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 46341 * 46341 >= 2^31, and will overflow. 6 | big = immi 46341 7 | 8 | res = mulxovi big big ; overflow, so we exit here 9 | 10 | ; Ensure that 'big' gets its own register and isn't shared with 'res'. 11 | ; Also store 'res' so it isn't dead. 12 | m = allocp 8 13 | sti big m 0 14 | sti res m 4 15 | x ; we don't exit here 16 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xyy.out: -------------------------------------------------------------------------------- 1 | Exited block on line: 8 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xyz.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; 1073741824 * 2 >= 2^31, and will overflow. 6 | big = immi 1073741824 7 | two = immi 2 8 | 9 | res = mulxovi big two ; overflow, so we exit here 10 | 11 | ; Ensure that 'big' and 'two' get their own registers and 12 | ; aren't shared with 'res'. Also store 'res' so it isn't dead. 13 | m = allocp 12 14 | sti big m 0 15 | sti two m 4 16 | sti res m 8 17 | x ; we don't exit here 18 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/mulov_xyz.out: -------------------------------------------------------------------------------- 1 | Exited block on line: 9 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag1.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin a 6 | ptr = allocp 8 7 | a = immi 65 8 | sti2c a ptr 0 9 | b = immi 66 10 | sti2c b ptr 1 11 | c = immi 67 12 | sti2c c ptr 2 13 | zero = immi 0 14 | sti2c zero ptr 3 15 | ss = calli puts cdecl ptr 16 | nn = gei ss zero 17 | reti nn 18 | .end 19 | 20 | .begin b 21 | rr = calli a fastcall 22 | reti rr 23 | .end 24 | 25 | .begin main 26 | ans = calli b fastcall 27 | five = immi 5 28 | res = addi five ans 29 | reti res 30 | .end 31 | 32 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag1.out: -------------------------------------------------------------------------------- 1 | ABC 2 | Output is: 6 3 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag2.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | .begin sinpibytwo 6 | pi = immd 3.14 7 | half = immd 0.5 8 | halfpi = muld pi half 9 | res = calld sin cdecl halfpi 10 | retd res 11 | .end 12 | 13 | .begin main 14 | aa = calld sinpibytwo fastcall 15 | bb = immd 5.53 16 | res = addd aa bb 17 | retd res 18 | .end 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag2.out: -------------------------------------------------------------------------------- 1 | Output is: 6.53 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag3.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; See bug 541232 for why the params are commented out. 6 | .begin avg 7 | oneh = immi 100 ; should be: p1 = paramp 0 0 8 | twoh = immi 200 ; should be: p2 = paramp 1 0 9 | sum = addi oneh twoh ; should be: sum = addp p1 p2 10 | one = immi 1 11 | avg = rshi sum one 12 | reti avg 13 | .end 14 | 15 | .begin main 16 | oneh = immi 100 17 | twoh = immi 200 18 | res = calli avg fastcall twoh oneh 19 | reti res 20 | .end 21 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/multfrag3.out: -------------------------------------------------------------------------------- 1 | Output is: 150 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/negnot.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immi 0 6 | a = noti i 7 | b = negi a 8 | reti b 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/negnot.out: -------------------------------------------------------------------------------- 1 | Output is: 1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/negnotq.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | i = immq 0 6 | a = notq i 7 | b = negq a 8 | retq b 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/negnotq.out: -------------------------------------------------------------------------------- 1 | Output is: 1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/random.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/shi.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Only the bottom 5 bits of the shift amount in lshi/rshi/rshui are used. 6 | 7 | two = immi 2 8 | 9 | sh1 = immi 1 10 | sh2 = immi 33 ; 0010_0001b 11 | sh3 = immi 268435425 ; 0000_1111_1111_1111_1111_1111_1110_0001b 12 | 13 | a1 = lshi two sh1 ; --> 4 14 | a2 = lshi two sh2 ; --> 4 15 | a3 = lshi two sh3 ; --> 4 16 | 17 | b1 = rshi two sh1 ; --> 1 18 | b2 = rshi two sh2 ; --> 1 19 | b3 = rshi two sh3 ; --> 1 20 | 21 | c1 = rshui two sh1 ; --> 1 22 | c2 = rshui two sh2 ; --> 1 23 | c3 = rshui two sh3 ; --> 1 24 | 25 | s0 = immi 0 26 | s1 = addi s0 a1 27 | s2 = addi s1 a2 28 | s3 = addi s2 a3 29 | s4 = addi s3 b1 30 | s5 = addi s4 b2 31 | s6 = addi s5 b3 32 | s7 = addi s6 c1 33 | s8 = addi s7 c2 34 | s9 = addi s8 c2 ; --> 18 35 | 36 | reti s9 37 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/shi.out: -------------------------------------------------------------------------------- 1 | Output is: 18 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/dhi2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; IEEE-754 encodes -0.0 as 0x80000000,00000000 6 | d = immd -0.0 7 | hi = dhi2i d 8 | reti hi 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/dhi2i.out: -------------------------------------------------------------------------------- 1 | Output is: -2147483648 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/dlo2i.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; IEEE-754 encodes the following constant as 0x3ff00000,ffffffff 6 | d = immd 1.0000009536743162 7 | lo = dlo2i d 8 | reti lo 9 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/dlo2i.out: -------------------------------------------------------------------------------- 1 | Output is: -1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/ii2d.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; It's very difficult to test that the 'lo' part is actually doing anything 6 | ; because it tends to get lost when lirasm dumps the result to the console. 7 | ; By far the easiest way to check this is to use dlo2i and dhi2i to see if we 8 | ; get what we started with (assuming that those instructions work). 9 | 10 | hi = immi 1127219201 ; 0x43300001 (positive, exponent of +52 ... 11 | lo = immi -1 ; 0xffffffff (... mantissa of 0x100001ffffffff) 12 | d = ii2d lo hi 13 | hi2 = dhi2i d 14 | lo2 = dlo2i d 15 | 16 | ; XOR to check for differences, then OR the two results. 0 indicates success, 17 | ; but anything else indicates some kind of loss of data. 18 | rhi = xori hi hi2 19 | rlo = xori lo lo2 20 | 21 | res = ori rhi rlo 22 | 23 | reti res 24 | 25 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/softfloat/ii2d.out: -------------------------------------------------------------------------------- 1 | Output is: 0 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/std2f.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | d = immd -1 7 | ; Store the value twice in consecutive slots to check that it's really stored as 32 bits. 8 | std2f d ptr 4 9 | std2f d ptr 0 10 | d2 = ldf2d ptr 4 11 | retd d2 12 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/std2f.out: -------------------------------------------------------------------------------- 1 | Output is: -1 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subd.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ; Try to exercise as many different possibilities for the register allocator as 6 | ; is feasible. 7 | 8 | p1 = allocp 8 9 | p2 = allocp 8 10 | 11 | d1a = immd 1.5 12 | d1 = subd d1a d1a ; X = X - X 13 | std d1 p1 0 14 | 15 | d2a = immd 2.5 16 | d2b = immd 3.0 17 | d2 = subd d2a d2b ; X = X - Y 18 | std d2b p2 0 19 | std d2 p2 0 20 | 21 | d3a = ldd p1 0 22 | d3b = ldd p2 0 23 | d3 = subd d3a d3b ; X = Y - X 24 | std d3a p2 0 25 | std d3 p2 0 26 | 27 | d4a = ldd p2 0 28 | d4b = ldd p1 0 29 | d4 = subd d4a d4b ; X = Y - Z 30 | std d4a p1 0 31 | std d4b p2 0 32 | std d4 p1 0 33 | 34 | d = ldd p1 0 35 | retd d 36 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subd.out: -------------------------------------------------------------------------------- 1 | Output is: 0.5 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subjovi.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi -2147483647 8 | b = immi 1 9 | c = subjovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | 20 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subjovi.out: -------------------------------------------------------------------------------- 1 | Output is: -2147483648 2 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subjovi_ovf.in: -------------------------------------------------------------------------------- 1 | ; This Source Code Form is subject to the terms of the Mozilla Public 2 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 3 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | ptr = allocp 8 6 | 7 | a = immi -2147483647 8 | b = immi 2 9 | c = subjovi a b ovf 10 | sti c ptr 0 11 | 12 | j done 13 | 14 | ovf: i = immi 12345678 15 | sti i ptr 0 16 | 17 | done: res = ldi ptr 0 18 | reti res 19 | -------------------------------------------------------------------------------- /utils/nanojit-lirasm/lirasm/tests/subjovi_ovf.out: -------------------------------------------------------------------------------- 1 | Output is: 12345678 2 | -------------------------------------------------------------------------------- /vprof/manifest.mk: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | avmplus_CXXSRCS := $(avmplus_CXXSRCS) \ 6 | $(curdir)/vprof.cpp \ 7 | $(NULL) 8 | -------------------------------------------------------------------------------- /vprof/readme.txt: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | The two files vprof.h and vprof.cpp implement a simple value-profiling mechanism. By including these two files in avmplus (or any other project), you can value profile data as you wish (currently integers). 6 | 7 | Usage: 8 | #include "vprof.h" // in the source file you want to use it 9 | 10 | _vprof (value); 11 | 12 | At the end of the execution, for each probe you'll get the data associated with the probe, such as: 13 | 14 | File line avg [min : max] total count 15 | ..\..\pcre\pcre_valid_utf8.cpp 182 50222.75916 [0 : 104947] 4036955604 80381 16 | 17 | The probe is defined at line 182 of file pcre_vali_utf8.cpp. It was called 80381 times. The min value of the probe was 0 while its max was 10497 and its average was 50222.75916. The total sum of all values of the probe is 4036955604. Later, I plan to add more options on the spectrum of data among others. 18 | 19 | A few typical uses 20 | ------------------ 21 | 22 | To see how many times a given function gets executed do: 23 | 24 | void f() 25 | { 26 | _vprof(1); 27 | ... 28 | } 29 | 30 | void f() 31 | { 32 | _vprof(1); 33 | ... 34 | if (...) { 35 | _vprof(1); 36 | ... 37 | } else { 38 | _vprof(1); 39 | ... 40 | } 41 | } 42 | 43 | Here are a few examples of using the value-profiling utility: 44 | 45 | _vprof (e); 46 | at the end of program execution, you'll get a dump of the source location of this probe, 47 | its min, max, average, the total sum of all instances of e, and the total number of times this probe was called. 48 | 49 | _vprof (x > 0); 50 | shows how many times and what percentage of the cases x was > 0, 51 | that is the probablitiy that x > 0. 52 | 53 | _vprof (n % 2 == 0); 54 | shows how many times n was an even number 55 | as well as th probablitiy of n being an even number. 56 | 57 | _hprof (n, 4, 1000, 5000, 5001, 10000); 58 | gives you the histogram of n over the given 4 bucket boundaries: 59 | # cases < 1000 60 | # cases >= 1000 and < 5000 61 | # cases >= 5000 and < 5001 62 | # cases >= 5001 and < 10000 63 | # cases >= 10000 64 | 65 | _nvprof ("event name", value); 66 | all instances with the same name are merged 67 | so, you can call _vprof with the same event name at difference places 68 | 69 | _vprof (e, myProbe); 70 | value profile e and call myProbe (void* vprofID) at the profiling point. 71 | inside the probe, the client has the predefined variables: 72 | _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers 73 | _IVAR1, ..., IVAR4 general integer registrs 74 | _I64VAR1, ..., I64VAR4 general integer64 registrs 75 | _DVAR1, ..., _DVAR4 general double registers 76 | _GENPTR a generic pointer that can be used by the client 77 | the number of registers can be changed in vprof.h 78 | 79 | Named Events 80 | ------------ 81 | _nvprof ("event name", value); 82 | all instances with the same name are merged 83 | so, you can call _vprof with the same event name at difference places 84 | 85 | 86 | Custom Probes 87 | -------------- 88 | You can call your own custom probe at the profiling point. 89 | _vprof (v, myProbe); 90 | value profile v and call myProbe (void* vprofID) at the profiling point 91 | inside the probe, the client has the predefined variables: 92 | _VAL, _COUNT, _SUM, _MIN, _MAX, and the general purpose registers 93 | _IVAR1, ..., IVAR4 general integer registrs 94 | _I64VAR1, ..., I64VAR4 general integer64 registrs 95 | _DVAR1, ..., _DVAR4 general double registers 96 | the number of registers can be changed in vprof.h 97 | _GENPTR a generic pointer that can be used for almost anything 98 | -------------------------------------------------------------------------------- /vprof/testVprofMT.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 4 -*- */ 2 | /* This Source Code Form is subject to the terms of the Mozilla Public 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "vprof.h" 11 | 12 | static void cProbe (void* vprofID) 13 | { 14 | if (_VAL == _IVAR1) _I64VAR1 ++; 15 | _IVAR1 = _IVAR0; 16 | 17 | if (_VAL == _IVAR0) _I64VAR0 ++; 18 | _IVAR0 = (int) _VAL; 19 | 20 | _DVAR0 = ((double)_I64VAR0) / _COUNT; 21 | _DVAR1 = ((double)_I64VAR1) / _COUNT; 22 | } 23 | 24 | //__declspec (thread) boolean cv; 25 | //#define if(c) cv = (c); _vprof (cv); if (cv) 26 | //#define if(c) cv = (c); _vprof (cv, cProbe); if (cv) 27 | 28 | #define THREADS 1 29 | #define COUNT 100000 30 | #define SLEEPTIME 0 31 | 32 | static int64_t evens = 0; 33 | static int64_t odds = 0; 34 | 35 | void sub(int val) 36 | { 37 | int i; 38 | //_vprof (1); 39 | for (i = 0; i < COUNT; i++) { 40 | //_nvprof ("Iteration", 1); 41 | //_nvprof ("Iteration", 1); 42 | _vprof (i); 43 | //_vprof (i); 44 | //_hprof(i, 3, (int64_t) 1000, (int64_t)2000, (int64_t)3000); 45 | //_hprof(i, 3, 10000, 10001, 3000000); 46 | //_nhprof("Event", i, 3, 10000, 10001, 3000000); 47 | //_nhprof("Event", i, 3, 10000, 10001, 3000000); 48 | //Sleep(SLEEPTIME); 49 | if (i % 2 == 0) { 50 | //_vprof (i); 51 | ////_hprof(i, 3, 10000, 10001, 3000000); 52 | //_nvprof ("Iteration", i); 53 | evens ++; 54 | } else { 55 | //_vprof (1); 56 | _vprof (i, cProbe); 57 | odds ++; 58 | } 59 | //_nvprof ("Iterate", 1); 60 | } 61 | //printf("sub %d done.\n", val); 62 | } 63 | 64 | HANDLE array[THREADS]; 65 | 66 | static int run (void) 67 | { 68 | int i; 69 | 70 | time_t start_time = time(0); 71 | 72 | for (i = 0; i < THREADS; i++) { 73 | array[i] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sub, (LPVOID)i, 0, 0); 74 | } 75 | 76 | for (i = 0; i < THREADS; i++) { 77 | WaitForSingleObject(array[i], INFINITE); 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | int main () 84 | { 85 | DWORD start, end; 86 | 87 | start = GetTickCount (); 88 | run (); 89 | end = GetTickCount (); 90 | 91 | printf ("\nRun took %d msecs\n\n", end-start); 92 | } 93 | --------------------------------------------------------------------------------