mirror of
https://gitflic.ru/project/e2khome/lccrt.git
synced 2024-11-21 09:25:22 +01:00
ecomp.r141248 cmake- liblccrt_s/liblcbe.
: liblccopt: ecomp.r141248 cmake- -DLCCRT_ARCHS=, - liblccrt_s . . : x86_64, e2k64. -, -. , $ cmake -DLCCRT_ARCHS=e2k64 -DCC_e2k64=<cross-e2k-compiler> LCCRT_ARCHS : cmake/targets/<arch>/CMakeLists.txt . lcbe - .
This commit is contained in:
parent
530ae2fbb6
commit
089841db7a
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
# vim swap files
|
||||||
|
.*.sw?
|
||||||
|
.sw?
|
||||||
|
|
||||||
|
# build directory
|
||||||
|
build
|
@ -2,6 +2,13 @@ cmake_minimum_required( VERSION 3.16)
|
|||||||
|
|
||||||
project( lccrt)
|
project( lccrt)
|
||||||
|
|
||||||
|
# Function cat for concatenation files.
|
||||||
|
function(cat IN_VALUE OUT_FILE)
|
||||||
|
file(APPEND ${OUT_FILE} "${IN_VALUE}\n")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Define main library source files.
|
||||||
set( lccrt_SOURCE
|
set( lccrt_SOURCE
|
||||||
lib/common/lccrt_ctx.c
|
lib/common/lccrt_ctx.c
|
||||||
lib/common/lccrt_fs.c
|
lib/common/lccrt_fs.c
|
||||||
@ -18,11 +25,84 @@ set( lccrt_SOURCE
|
|||||||
lib/irv/lccrt_var.c
|
lib/irv/lccrt_var.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Define main library include directories.
|
||||||
|
set( lccrt_INCLUDE include include/internal)
|
||||||
|
|
||||||
|
# Define main target.
|
||||||
add_library( lccrt SHARED ${lccrt_SOURCE})
|
add_library( lccrt SHARED ${lccrt_SOURCE})
|
||||||
target_include_directories( lccrt PRIVATE include include/internal)
|
target_include_directories( lccrt PRIVATE ${lccrt_INCLUDE})
|
||||||
|
|
||||||
set_target_properties( lccrt PROPERTIES PUBLIC_HEADER "include/lccrt.h")
|
set_target_properties( lccrt PROPERTIES PUBLIC_HEADER "include/lccrt.h")
|
||||||
|
|
||||||
|
# Define main library install directories.
|
||||||
install( TARGETS lccrt
|
install( TARGETS lccrt
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
PUBLIC_HEADER DESTINATION include
|
PUBLIC_HEADER DESTINATION include
|
||||||
RUNTIME DESTINATION bin)
|
RUNTIME DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Define runtime-support library source files.
|
||||||
|
set( lccrt_s_SOURCE
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lccrt_s/src/lccrt.c
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lccrt_s/src/lccrt_n.c
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lccrt_s/src/lccrt_overflow.c
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lccrt_s/src/lccrt_vec.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Define runtime-support library include directories.
|
||||||
|
set( lccrt_s_INCLUDE ${CMAKE_SOURCE_DIR}/tools/lccrt_s/include)
|
||||||
|
|
||||||
|
|
||||||
|
# Define C-backend library source files.
|
||||||
|
set( lcbe_SOURCE
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lcbe/src/lcbe_driver.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/tools/lcbe/src/lcbe_emit.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Define C-backend library include directories.
|
||||||
|
set( lcbe_INCLUDE ${CMAKE_SOURCE_DIR}/tools/lcbe/include/internal)
|
||||||
|
|
||||||
|
|
||||||
|
# Prepare a temporary file to "cat" backend-plugins.
|
||||||
|
set( ASM_PLUGIN_CONF ${CMAKE_BINARY_DIR}/asm.plugin.conf)
|
||||||
|
file( WRITE ${ASM_PLUGIN_CONF} "")
|
||||||
|
|
||||||
|
if( NOT DEFINED LCCRT_ARCHS )
|
||||||
|
set( LCCRT_ARCHS "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define targets for every architecture from build-set.
|
||||||
|
foreach ( X_ARCH IN LISTS LCCRT_ARCHS)
|
||||||
|
set(X_SUFF "-${X_ARCH}")
|
||||||
|
set(X_CC_VAR "CC_${X_ARCH}")
|
||||||
|
if(NOT DEFINED "${X_CC_VAR}")
|
||||||
|
if("${X_ARCH}" STREQUAL "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
set( X_CC_ARCH ${CMAKE_C_COMPILER})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "compiler for arch '${X_ARCH}' must be specified as '-D${CC_VAR}=...'")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(X_CC_ARCH "${${X_CC_VAR}}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("lccrt_s target:${X_ARCH} compiler:${X_CC_ARCH}")
|
||||||
|
|
||||||
|
# Define target for runtime-support library under current architecture.
|
||||||
|
add_subdirectory(cmake/targets/${X_ARCH})
|
||||||
|
|
||||||
|
# Define target for C-backend library under current architecture.
|
||||||
|
add_library( lcbe${X_SUFF} SHARED ${lcbe_SOURCE})
|
||||||
|
target_include_directories( lcbe${X_SUFF} PRIVATE include tools/lcbe/include/internal)
|
||||||
|
|
||||||
|
install( TARGETS lcbe${X_SUFF}
|
||||||
|
DESTINATION lib/lccrt/plugin/asm
|
||||||
|
)
|
||||||
|
|
||||||
|
# Update plugin.conf for asm backend plugins.
|
||||||
|
cat( "liblcbe${X_SUFF}.so" ${ASM_PLUGIN_CONF})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Install plugin.conf for asm backend plugins.
|
||||||
|
install( FILES ${ASM_PLUGIN_CONF} DESTINATION lib/lccrt/plugin/asm/ RENAME plugin.conf)
|
||||||
|
|
||||||
|
3
cmake/targets/e2k64/CMakeLists.txt
Normal file
3
cmake/targets/e2k64/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/targets/target.cmake)
|
||||||
|
|
16
cmake/targets/target.cmake
Normal file
16
cmake/targets/target.cmake
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
set(CMAKE_C_COMPILER ${X_CC_ARCH})
|
||||||
|
|
||||||
|
|
||||||
|
add_library( lccrt_s${X_SUFF} STATIC ${lccrt_s_SOURCE})
|
||||||
|
target_include_directories( lccrt_s${X_SUFF} PRIVATE ${lccrt_s_INCLUDE})
|
||||||
|
|
||||||
|
set_target_properties( lccrt_s${X_SUFF} PROPERTIES
|
||||||
|
CMAKE_C_COMPILER ${X_CC_ARCH}
|
||||||
|
OUTPUT_NAME lccrt_s
|
||||||
|
)
|
||||||
|
|
||||||
|
install( TARGETS lccrt_s${X_SUFF}
|
||||||
|
DESTINATION lib/lccrt/lib/${X_ARCH}
|
||||||
|
)
|
||||||
|
|
3
cmake/targets/x86_64/CMakeLists.txt
Normal file
3
cmake/targets/x86_64/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/targets/target.cmake)
|
||||||
|
|
@ -1013,12 +1013,12 @@ static void
|
|||||||
lcbe_init_library_tools( lcbe_config_t *cnf, lcbe_tools_t *tls)
|
lcbe_init_library_tools( lcbe_config_t *cnf, lcbe_tools_t *tls)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
char *ld_args[] = {"cc-config", "-print-prog-name=ld", 0};
|
char *ld_args[] = {(char*)"cc-config", (char*)"-print-prog-name=ld", 0};
|
||||||
char *as_args[] = {"cc-config", "-print-prog-name=as", 0};
|
char *as_args[] = {(char*)"cc-config", (char*)"-print-prog-name=as", 0};
|
||||||
char *fs_args[] = {"cc-config", "-print-config=fs-dir", 0};
|
char *fs_args[] = {(char*)"cc-config", (char*)"-print-config=fs-dir", 0};
|
||||||
char *in_args[] = {"cc-config", "-print-internal-dir=include", 0};
|
char *in_args[] = {(char*)"cc-config", (char*)"-print-internal-dir=include", 0};
|
||||||
char *in_cpp_stl_args[] = {"cc-config", "-print-internal-dir=include-c++-stl", 0};
|
char *in_cpp_stl_args[] = {(char*)"cc-config", (char*)"-print-internal-dir=include-c++-stl", 0};
|
||||||
char *gcc_base_args[] = {"cc-config", "-print-internal-dir=base", 0};
|
char *gcc_base_args[] = {(char*)"cc-config", (char*)"-print-internal-dir=base", 0};
|
||||||
|
|
||||||
tls->ld = lcbe_reinit_str( tls->ld, getenv( "LCBE_LD"));
|
tls->ld = lcbe_reinit_str( tls->ld, getenv( "LCBE_LD"));
|
||||||
tls->as = lcbe_reinit_str( tls->as, getenv( "LCBE_AS"));
|
tls->as = lcbe_reinit_str( tls->as, getenv( "LCBE_AS"));
|
||||||
|
@ -567,7 +567,7 @@ __lccrt_zn_umod( uint32_t num_digits, uint32_t *zr, uint32_t * __restrict za, ui
|
|||||||
|
|
||||||
if ( (num_digits == 1) )
|
if ( (num_digits == 1) )
|
||||||
{
|
{
|
||||||
zc[0] = za[0] / zb[0];
|
zc[0] = za[0] % zb[0];
|
||||||
|
|
||||||
} else if ( (num_digits == 2) )
|
} else if ( (num_digits == 2) )
|
||||||
{
|
{
|
||||||
@ -599,7 +599,7 @@ __lccrt_zn_smod( uint32_t num_digits, uint32_t *zr, uint32_t * __restrict za, ui
|
|||||||
|
|
||||||
if ( (num_digits == 1) )
|
if ( (num_digits == 1) )
|
||||||
{
|
{
|
||||||
zc[0] = (int32_t)za[0] / (int32_t)zb[0];
|
zc[0] = (int32_t)za[0] % (int32_t)zb[0];
|
||||||
|
|
||||||
} else if ( (num_digits == 2) )
|
} else if ( (num_digits == 2) )
|
||||||
{
|
{
|
||||||
@ -828,11 +828,9 @@ __lccrt_select( uint32_t rb, uint32_t ab, uint32_t bb, uint32_t cb,
|
|||||||
assert( ab == 8);
|
assert( ab == 8);
|
||||||
assert( rb == bb);
|
assert( rb == bb);
|
||||||
assert( rb == cb);
|
assert( rb == cb);
|
||||||
if ( a[0] )
|
if ( a[0] ) {
|
||||||
{
|
|
||||||
__lccrt_bitcast_n( rb, bb, r, b);
|
__lccrt_bitcast_n( rb, bb, r, b);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
__lccrt_bitcast_n( rb, cb, r, c);
|
__lccrt_bitcast_n( rb, cb, r, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user