Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Backend Support for LoongArch64 #1903

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ else()
set(UNICORN_TARGET_ARCH "tricore")
break()
endif()
string(FIND ${UC_COMPILER_MACRO} "loongarch64" UC_RET)
if (${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "loongarch64")
break()
endif()
message(FATAL_ERROR "Unknown host compiler: ${CMAKE_C_COMPILER}.")
endwhile(TRUE)
endif()
Expand Down Expand Up @@ -315,6 +320,12 @@ else()
set(TARGET_LIST "${TARGET_LIST} ")

# GEN config-host.mak & target directories
# MESSAGE(STATUS "sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure
# --cc=${CMAKE_C_COMPILER}
# ${EXTRA_CFLAGS}
# ${TARGET_LIST}
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}"
# )
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure
--cc=${CMAKE_C_COMPILER}
${EXTRA_CFLAGS}
Expand Down
16 changes: 16 additions & 0 deletions qemu/configure
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ elif check_define __aarch64__ ; then
cpu="aarch64"
elif check_define __tricore__ ; then
cpu="tricore"
elif check_define __loongarch64 ; then
cpu="loongarch64"
else
cpu=$(uname -m)
fi
Expand Down Expand Up @@ -534,6 +536,10 @@ case "$cpu" in
cpu="tricore"
supported_cpu="yes"
;;
loongarch64)
cpu="loongarch64"
supported_cpu="yes"
;;
*)
# This will result in either an error or falling back to TCI later
ARCH=unknown
Expand Down Expand Up @@ -844,6 +850,11 @@ case "$cpu" in
CPU_CFLAGS="-m64 -mcx16"
QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
;;
loongarch*)
CPU_CFLAGS=""
QEMU_LDFLAGS=" $QEMU_LDFLAGS"
;;

x32)
CPU_CFLAGS="-mx32"
QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
Expand Down Expand Up @@ -2628,6 +2639,11 @@ case "$target_name" in
mttcg="yes"
TARGET_SYSTBL_ABI=i386
;;
loongarch64)
mttcg="yes"
TARGET_ARCH=loongarch64
TARGET_SYSTBL_ABI=common,64
;;
x86_64)
TARGET_BASE_ARCH=i386
TARGET_SYSTBL_ABI=common,64
Expand Down
1 change: 1 addition & 0 deletions qemu/include/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ typedef struct mips_elf_abiflags_v0 {

#define EM_NANOMIPS 249 /* Wave Computing nanoMIPS */

#define EM_LOONGARCH 258 /* LoongArch */
/*
* This is an interim value that we will use until the committee comes
* up with a final number.
Expand Down
Loading
Loading