Skip to content

Commit

Permalink
Merge pull request #276 from flaviojs/add-ppc32-jit-build-system
Browse files Browse the repository at this point in the history
Add ppc32 jit architecture to the build system.
  • Loading branch information
grossmj authored Nov 14, 2024
2 parents 4a8af7d + 0c76505 commit 08101d9
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 98 deletions.
22 changes: 18 additions & 4 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,41 @@ int main (void) { return 0; }
set_cmake_required ()
list ( INSERT CMAKE_REQUIRED_FLAGS 0 -m32 )
check_c_source_compiles ( "${_code}" ARCH_X86 )
set ( _code "
#if defined(__powerpc) || defined(__powerpc__) || defined(_M_PPC) || defined(_ARCH_PPC)
int main (void) { return 0; }
#else
#error cmake_FAIL
#endif
" )
set_cmake_required ()
list ( INSERT CMAKE_REQUIRED_FLAGS 0 -m32 )
check_c_source_compiles ( "${_code}" ARCH_PPC32 )
if ( ARCH_AMD64 )
set ( _default "amd64" )
elseif ( ARCH_X86 )
set ( _default "x86" )
elseif ( ARCH_PPC32 )
set ( _default "ppc32" )
else ()
set ( _default "nojit" )
endif ()
set ( DYNAMIPS_ARCH "${_default}" CACHE STRING "Target architecture (amd64;x86;nojit)" )
set_property ( CACHE DYNAMIPS_ARCH PROPERTY STRINGS "amd64" "x86" "nojit" )
set ( DYNAMIPS_ARCH "${_default}" CACHE STRING "Target architecture (amd64;x86;ppc32;nojit)" )
set_property ( CACHE DYNAMIPS_ARCH PROPERTY STRINGS "amd64" "x86" "ppc32" "nojit" )
if ( NOT DYNAMIPS_ARCH )
set ( DYNAMIPS_ARCH "${_default}" )
endif ()
if ( "amd64" STREQUAL "${DYNAMIPS_ARCH}" AND ARCH_AMD64 )
list ( INSERT DYNAMIPS_FLAGS 0 -m64 )
elseif ( "x86" STREQUAL "${DYNAMIPS_ARCH}" AND ARCH_X86 )
list ( INSERT DYNAMIPS_FLAGS 0 -m32 )
elseif ( "ppc32" STREQUAL "${DYNAMIPS_ARCH}" AND ARCH_PPC32 )
list ( INSERT DYNAMIPS_FLAGS 0 -m32 )
elseif ( NOT "nojit" STREQUAL "${DYNAMIPS_ARCH}" )
print_variables ( ARCH_AMD64 ARCH_X86 DYNAMIPS_ARCH )
print_variables ( ARCH_AMD64 ARCH_X86 ARCH_PPC32 DYNAMIPS_ARCH )
message ( FATAL_ERROR "cannot build target arch DYNAMIPS_ARCH=${DYNAMIPS_ARCH}" )
endif ()
print_variables ( ARCH_AMD64 ARCH_X86 DYNAMIPS_ARCH )
print_variables ( ARCH_AMD64 ARCH_X86 ARCH_PPC32 DYNAMIPS_ARCH )

# Compiler flags
foreach ( _flag
Expand Down
2 changes: 2 additions & 0 deletions common/ppc32_ppc32_trans.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* not supported */
#include "ppc32_nojit_trans.c"
2 changes: 2 additions & 0 deletions common/ppc32_ppc32_trans.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* not supported */
#include "ppc32_nojit_trans.h"
14 changes: 14 additions & 0 deletions stable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ maybe_rename_to_dynamips ( dynamips_x86_stable )
install_executable ( dynamips_x86_stable )
endif ()

# dynamips_ppc32_stable
if ( "ppc32" STREQUAL "${DYNAMIPS_ARCH}" )
add_compile_options( -Wa,-mregnames ) # allow powerpc register names
add_executable ( dynamips_ppc32_stable
${_files}
"${LOCAL}/mips64_ppc32_trans.c"
"${COMMON}/ppc32_ppc32_trans.c"
)
add_dependencies ( dynamips_ppc32_stable ${_dependencies} )
target_link_libraries ( dynamips_ppc32_stable ${DYNAMIPS_LIBRARIES} )
maybe_rename_to_dynamips ( dynamips_ppc32_stable )
install_executable ( dynamips_ppc32_stable )
endif ()

# dynamips_nojit_stable
if ( "nojit" STREQUAL "${DYNAMIPS_ARCH}" )
add_executable ( dynamips_nojit_stable
Expand Down
2 changes: 2 additions & 0 deletions stable/mips64_ppc32_trans.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* not supported */
#include "mips64_nojit_trans.c"
2 changes: 2 additions & 0 deletions stable/mips64_ppc32_trans.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* not supported */
#include "mips64_nojit_trans.h"
14 changes: 14 additions & 0 deletions unstable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ maybe_rename_to_dynamips ( dynamips_x86_unstable )
install_executable ( dynamips_x86_unstable )
endif ()

# dynamips_ppc32_unstable
if ( "ppc32" STREQUAL "${DYNAMIPS_ARCH}" )
add_compile_options( -Wa,-mregnames ) # allow powerpc register names
add_executable ( dynamips_ppc32_unstable
${_files}
"${LOCAL}/mips64_ppc32_trans.c"
"${COMMON}/ppc32_ppc32_trans.c"
)
add_dependencies ( dynamips_ppc32_unstable ${_dependencies} )
target_link_libraries ( dynamips_ppc32_unstable ${DYNAMIPS_LIBRARIES} -mregnames )
maybe_rename_to_dynamips ( dynamips_ppc32_unstable )
install_executable ( dynamips_ppc32_unstable )
endif ()

# dynamips_nojit_unstable
if ( "nojit" STREQUAL "${DYNAMIPS_ARCH}" )
add_executable ( dynamips_nojit_unstable
Expand Down
Loading

0 comments on commit 08101d9

Please sign in to comment.