mirror of
https://github.com/frida/tinycc
synced 2024-11-23 16:19:35 +03:00
0b8ee7364a
Checked on: - i386/x86_64 (linux/windows) - arm/arm64 (rapberry pi) - riscv64 (simulator) Not tested for arm softfloat because raspberry pi does not support it. Modifications: Makefile: add arm-asm.c to arm64_FILES add riscv64-asm.c (new file) to riscv64_FILES lib/Makefile: add fetch_and_add_arm.o(new file) to ARM_O add fetch_and_add_arm64.o(new file) to ARM64_O add fetch_and_add_riscv64.o(new file) to RISCV64_O add $(BCHECK_O) to OBJ-arm/OBJ-arm64/OBJ-riscv64 tcc.h: Enable CONFIG_TCC_BCHECK for arm32/arm64/riscv64 Add arm-asm.c, riscv64-asm.c tcctok.h: for arm use memmove4 instead of memcpy4 for arm use memmove8 instead of memcpy8 tccgen.c: put_extern_sym2: for arm check memcpy/memmove/memset/memmove4/memmove8 only use alloca for i386/x86_64 for arm use memmove4 instead of memcpy4 for arm use memmove8 instead of memcpy8 fix builtin_frame_address/builtin_return_address for arm/riscv64 tccrun.c: Add riscv64 support fix rt_getcontext/rt_get_caller_pc for arm tccelf.c: tcc_load_dll: Print filename for bad architecture libtcc.c: add arm-asm.c/riscv64-asm.c tcc-doc.texi: Add arm, arm64, riscv64 support for bound checking lib/bcheck.c: add __bound___aeabi_memcpy/__bound___aeabi_memmove __bound___aeabi_memmove4/__bound___aeabi_memmove8 __bound___aeabi_memset for arm call fetch_and_add_arm/fetch_and_add_arm64/fetch_and_add_riscv64 __bound_init: Fix type for start/end/ad __bound_malloc/__bound_memalign/__bound_realloc/__bound_calloc: Use size + 1 arm-gen.c: add bound checking code like i386/x86_64 assign_regs: only malloc if nb_args != 0 gen_opi/gen_opf: Fix reload problems arm-link.c: relocate_plt: Fix address calculating arm64-gen.c: add bound checking code like i386/x86_64 load/store: remove VT_BOUNDED from sv->r arm64_hfa_aux/arm64_hfa_aux: Fix array code gfunc_prolog: only malloc if n != 0 arm64-link.c: code_reloc/gotplt_entry_type/relocate: add R_AARCH64_LDST64_ABS_LO12_NC relocate: Use addXXle instead of writeXXle riscv64-gen.c: add bound checking code like i386/x86_64 add NB_ASM_REGS/CONFIG_TCC_ASM riscv64-link.c: relocate: Use addXXle instead of writeXXle i386-gen.c/x86_64-gen.c gen_bounds_epilog: Fix code (unrelated) tests/Makefile: add $(BTESTS) for arm/arm64/riscv64 tests/tests2/Makefile: Use 85 only on i386/x86_64 because of asm code Use 113 only on i386/x86_64 because of DLL code Add 112/114/115/116 for arm/arm64/riscv64 Fix FILTER (failed on riscv64) tests/boundtest.c: Only use alloca for i386/x86_64
95 lines
1.9 KiB
C
95 lines
1.9 KiB
C
/*************************************************************/
|
|
/*
|
|
* RISCV64 dummy assembler for TCC
|
|
*
|
|
*/
|
|
|
|
#ifdef TARGET_DEFS_ONLY
|
|
|
|
#define CONFIG_TCC_ASM
|
|
#define NB_ASM_REGS 32
|
|
|
|
ST_FUNC void g(int c);
|
|
ST_FUNC void gen_le16(int c);
|
|
ST_FUNC void gen_le32(int c);
|
|
|
|
/*************************************************************/
|
|
#else
|
|
/*************************************************************/
|
|
#define USING_GLOBALS
|
|
#include "tcc.h"
|
|
|
|
static void asm_error(void)
|
|
{
|
|
tcc_error("RISCV64 asm not implemented.");
|
|
}
|
|
|
|
/* XXX: make it faster ? */
|
|
ST_FUNC void g(int c)
|
|
{
|
|
int ind1;
|
|
if (nocode_wanted)
|
|
return;
|
|
ind1 = ind + 1;
|
|
if (ind1 > cur_text_section->data_allocated)
|
|
section_realloc(cur_text_section, ind1);
|
|
cur_text_section->data[ind] = c;
|
|
ind = ind1;
|
|
}
|
|
|
|
ST_FUNC void gen_le16 (int i)
|
|
{
|
|
g(i);
|
|
g(i>>8);
|
|
}
|
|
|
|
ST_FUNC void gen_le32 (int i)
|
|
{
|
|
gen_le16(i);
|
|
gen_le16(i>>16);
|
|
}
|
|
|
|
ST_FUNC void gen_expr32(ExprValue *pe)
|
|
{
|
|
gen_le32(pe->v);
|
|
}
|
|
|
|
ST_FUNC void asm_opcode(TCCState *s1, int opcode)
|
|
{
|
|
asm_error();
|
|
}
|
|
|
|
ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier)
|
|
{
|
|
asm_error();
|
|
}
|
|
|
|
/* generate prolog and epilog code for asm statement */
|
|
ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands,
|
|
int nb_outputs, int is_output,
|
|
uint8_t *clobber_regs,
|
|
int out_reg)
|
|
{
|
|
}
|
|
|
|
ST_FUNC void asm_compute_constraints(ASMOperand *operands,
|
|
int nb_operands, int nb_outputs,
|
|
const uint8_t *clobber_regs,
|
|
int *pout_reg)
|
|
{
|
|
}
|
|
|
|
ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
|
|
{
|
|
asm_error();
|
|
}
|
|
|
|
ST_FUNC int asm_parse_regvar (int t)
|
|
{
|
|
asm_error();
|
|
return -1;
|
|
}
|
|
|
|
/*************************************************************/
|
|
#endif /* ndef TARGET_DEFS_ONLY */
|