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

If perl isn't found, use pregenerated files #53

Merged
merged 5 commits into from
Sep 5, 2024
Merged
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
64 changes: 51 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
# The directory label is used for CDash to treat DILL as a subproject of GTKorvo
set(CMAKE_DIRECTORY_LABELS DILL)

project(DILL VERSION 3.1.0 LANGUAGES C CXX)
project(DILL VERSION 3.1.1 LANGUAGES C CXX)

# Some boilerplate to setup nice output directories
include(GNUInstallDirs)
Expand Down Expand Up @@ -88,6 +88,7 @@ set(SRC_list
dill_virtual.c
virtual.c
dill.c
dill.h
vm.c
x86_64_disassembler.c
)
Expand Down Expand Up @@ -267,29 +268,65 @@ else()
set(EMULATION_POSSIBLE FALSE)
endif()

find_package(Perl REQUIRED)

option(DILL_ENABLE_DISASSEMBLY
"enable binutils-based disassembly (default is OFF)" OFF)

find_package(Perl)

set(ARCHITECTURES sparc ppc64le virtual x86 x86_64 ia64 arm5 arm6 arm8)
foreach(_arch ${ARCHITECTURES})
add_custom_command(
OUTPUT dill_${_arch}.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_arch}.ops
DEPENDS ${_arch}.ops
)
if(PERL_FOUND)
if(_arch STREQUAL "virtual")
add_custom_command(
OUTPUT dill_${_arch}.c vm_include.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_arch}.ops
DEPENDS ${_arch}.ops
)
else()
add_custom_command(
OUTPUT dill_${_arch}.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_arch}.ops
DEPENDS ${_arch}.ops
)
endif()
else()
add_custom_command(OUTPUT dill_${_arch}.c
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/pregen-source/dill_${_arch}.c dill_${_arch}.c
COMMENT "Copying pregen diil_${_arch}.c build area")
if(_arch STREQUAL "virtual")
add_custom_command(OUTPUT vm_include.c
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/pregen-source/vm_include.c vm_include.c
COMMENT "Copying pregen vm_include.c build area")
endif()
endif()
list(APPEND arch_files dill_${_arch}.c ${_arch}.c)
if(NOT _arch STREQUAL "virtual")
list(APPEND arch_files ${_arch}_rt.c)
else()
add_custom_target(generate_vm_include DEPENDS vm_include.c)
endif()
endforeach()

add_custom_command(
OUTPUT dill.h dill.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/base.ops ${BASE_OPS_ARG}
DEPENDS base.ops
)
if (PERL_FOUND)
add_custom_command(
OUTPUT dill.h dill.c
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/base.ops ${BASE_OPS_ARG}
DEPENDS base.ops
)
else()
string(MAKE_C_IDENTIFIER "${BASE_OPS_ARG}" FLAGS_STR)
add_custom_command(OUTPUT dill.c
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/pregen-source/dill${FLAGS_STR}.c dill.c
COMMENT "Copying pregen diil.c build area")
add_custom_command(OUTPUT dill.h
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/pregen-source/dill${FLAGS_STR}.h dill.h
COMMENT "Copying pregen diil.h build area")

endif()

option(DILL_MULTI_TARGET "Build all available target architectures" OFF)

Expand Down Expand Up @@ -388,6 +425,7 @@ set(DILL_LIBRARY_PREFIX "" CACHE STRING
mark_as_advanced(DILL_LIBRARY_PREFIX)

add_library(dill ${SRC_list})
add_dependencies(dill generate_vm_include)
set_target_properties(dill PROPERTIES
OUTPUT_NAME ${DILL_LIBRARY_PREFIX}dill
VERSION ${DILL_VERSION}
Expand Down
45 changes: 45 additions & 0 deletions pregen-source/dill.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
char *branch_op_names[] = {"eqc", "equc", "eqs", "equs", "eqi", "equ", "eql", "equl", "eqp", "eqf", "eqd", "gec", "geuc", "ges", "geus", "gei", "geu", "gel", "geul", "gep", "gef", "ged", "gtc", "gtuc", "gts", "gtus", "gti", "gtu", "gtl", "gtul", "gtp", "gtf", "gtd", "lec", "leuc", "les", "leus", "lei", "leu", "lel", "leul", "lep", "lef", "led", "ltc", "ltuc", "lts", "ltus", "lti", "ltu", "ltl", "ltul", "ltp", "ltf", "ltd", "nec", "neuc", "nes", "neus", "nei", "neu", "nel", "neul", "nep", "nef", "ned", 0};
char *compare_op_names[] = {"eqc", "equc", "eqs", "equs", "eqi", "equ", "eql", "equl", "eqp", "eqf", "eqd", "gec", "geuc", "ges", "geus", "gei", "geu", "gel", "geul", "gep", "gef", "ged", "gtc", "gtuc", "gts", "gtus", "gti", "gtu", "gtl", "gtul", "gtp", "gtf", "gtd", "lec", "leuc", "les", "leus", "lei", "leu", "lel", "leul", "lep", "lef", "led", "ltc", "ltuc", "lts", "ltus", "lti", "ltu", "ltl", "ltul", "ltp", "ltf", "ltd", "nec", "neuc", "nes", "neus", "nei", "neu", "nel", "neul", "nep", "nef", "ned", 0};

/* This file is generated from base.ops. Do not edit directly. */

#include "dill.h"

char *arith3_name[] = {"addi", "addu", "addul", "addl", "subi", "subu", "subul", "subl", "muli", "mulu", "mulul", "mull", "divi", "divu", "divul", "divl", "modi", "modu", "modul", "modl", "xori", "xoru", "xorul", "xorl", "andi", "andu", "andul", "andl", "ori", "oru", "orul", "orl", "lshi", "lshu", "lshul", "lshl", "rshi", "rshu", "rshul", "rshl", "addp", "subp", "addf", "addd", "subf", "subd", "mulf", "muld", "divf", "divd"};

char *arith2_name[] = {"noti", "notu", "notul", "notl", "comi", "comu", "comul", "coml", "negi", "negu", "negul", "negl", "bswaps", "bswapus", "bswapi", "bswapu", "bswapul", "bswapl", "bswapf", "bswapd", "negf", "negd"};
int dill_add_poly_map[] = {
dill_jmp_addl, dill_jmp_addul, dill_jmp_addl, dill_jmp_addul, dill_jmp_addi, dill_jmp_addu, dill_jmp_addl, dill_jmp_addul, dill_jmp_addp, dill_jmp_addf, dill_jmp_addd, dill_jmp_addl, dill_jmp_addl, 0};
int dill_and_poly_map[] = {
dill_jmp_andl, dill_jmp_andul, dill_jmp_andl, dill_jmp_andul, dill_jmp_andi, dill_jmp_andu, dill_jmp_andl, dill_jmp_andul, dill_jmp_andl, dill_jmp_andl, dill_jmp_andl, dill_jmp_andl, dill_jmp_andl, 0};
int dill_div_poly_map[] = {
dill_jmp_divl, dill_jmp_divul, dill_jmp_divl, dill_jmp_divul, dill_jmp_divi, dill_jmp_divu, dill_jmp_divl, dill_jmp_divul, dill_jmp_divl, dill_jmp_divf, dill_jmp_divd, dill_jmp_divl, dill_jmp_divl, 0};
int dill_lsh_poly_map[] = {
dill_jmp_lshl, dill_jmp_lshul, dill_jmp_lshl, dill_jmp_lshul, dill_jmp_lshi, dill_jmp_lshu, dill_jmp_lshl, dill_jmp_lshul, dill_jmp_lshl, dill_jmp_lshl, dill_jmp_lshl, dill_jmp_lshl, dill_jmp_lshl, 0};
int dill_mod_poly_map[] = {
dill_jmp_modl, dill_jmp_modul, dill_jmp_modl, dill_jmp_modul, dill_jmp_modi, dill_jmp_modu, dill_jmp_modl, dill_jmp_modul, dill_jmp_modl, dill_jmp_modl, dill_jmp_modl, dill_jmp_modl, dill_jmp_modl, 0};
int dill_mul_poly_map[] = {
dill_jmp_mull, dill_jmp_mulul, dill_jmp_mull, dill_jmp_mulul, dill_jmp_muli, dill_jmp_mulu, dill_jmp_mull, dill_jmp_mulul, dill_jmp_mull, dill_jmp_mulf, dill_jmp_muld, dill_jmp_mull, dill_jmp_mull, 0};
int dill_or_poly_map[] = {
dill_jmp_orl, dill_jmp_orul, dill_jmp_orl, dill_jmp_orul, dill_jmp_ori, dill_jmp_oru, dill_jmp_orl, dill_jmp_orul, dill_jmp_orl, dill_jmp_orl, dill_jmp_orl, dill_jmp_orl, dill_jmp_orl, 0};
int dill_rsh_poly_map[] = {
dill_jmp_rshl, dill_jmp_rshul, dill_jmp_rshl, dill_jmp_rshul, dill_jmp_rshi, dill_jmp_rshu, dill_jmp_rshl, dill_jmp_rshul, dill_jmp_rshl, dill_jmp_rshl, dill_jmp_rshl, dill_jmp_rshl, dill_jmp_rshl, 0};
int dill_sub_poly_map[] = {
dill_jmp_subl, dill_jmp_subul, dill_jmp_subl, dill_jmp_subul, dill_jmp_subi, dill_jmp_subu, dill_jmp_subl, dill_jmp_subul, dill_jmp_subp, dill_jmp_subf, dill_jmp_subd, dill_jmp_subl, dill_jmp_subl, 0};
int dill_xor_poly_map[] = {
dill_jmp_xorl, dill_jmp_xorul, dill_jmp_xorl, dill_jmp_xorul, dill_jmp_xori, dill_jmp_xoru, dill_jmp_xorl, dill_jmp_xorul, dill_jmp_xorl, dill_jmp_xorl, dill_jmp_xorl, dill_jmp_xorl, dill_jmp_xorl, 0};
char *dill_type_names[] = {
"c", /* char */
"uc", /* unsigned char */
"s", /* short */
"us", /* unsigned short */
"i", /* int */
"u", /* unsigned */
"l", /* long (full register size) */
"ul", /* unsigned long (full register size) */
"p", /* pointer */
"f", /* floating */
"d", /* double */
"v", /* void */
"b", /* block structure */
};
Loading
Loading