diff options
Diffstat (limited to 'include/ejit/ejit.h')
-rw-r--r-- | include/ejit/ejit.h | 130 |
1 files changed, 120 insertions, 10 deletions
diff --git a/include/ejit/ejit.h b/include/ejit/ejit.h index 03137ab..eeac089 100644 --- a/include/ejit/ejit.h +++ b/include/ejit/ejit.h @@ -322,10 +322,10 @@ void ejit_movi(struct ejit_func *s, struct ejit_gpr r0, int64_t i); void ejit_movr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); void ejit_movr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1); -void ejit_ldi_8(struct ejit_func *s, struct ejit_gpr r0, void *p); -void ejit_ldi_16(struct ejit_func *s, struct ejit_gpr r0, void *p); -void ejit_ldi_32(struct ejit_func *s, struct ejit_gpr r0, void *p); -void ejit_ldi_64(struct ejit_func *s, struct ejit_gpr r0, void *p); +void ejit_ldi_i8(struct ejit_func *s, struct ejit_gpr r0, void *p); +void ejit_ldi_i16(struct ejit_func *s, struct ejit_gpr r0, void *p); +void ejit_ldi_i32(struct ejit_func *s, struct ejit_gpr r0, void *p); +void ejit_ldi_i64(struct ejit_func *s, struct ejit_gpr r0, void *p); void ejit_ldi_u8(struct ejit_func *s, struct ejit_gpr r0, void *p); void ejit_ldi_u16(struct ejit_func *s, struct ejit_gpr r0, void *p); @@ -366,7 +366,8 @@ void ejit_ldxi_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1, void ejit_ldxi_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1, int64_t o); -static inline void ejit_ldxi_ptr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, int64_t o) +static inline void ejit_ldxi_ptr(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_gpr r1, int64_t o) { if (sizeof(void *) == sizeof(int64_t)) ejit_ldxi_u64(s, r0, r1, o); @@ -376,8 +377,15 @@ static inline void ejit_ldxi_ptr(struct ejit_func *s, struct ejit_gpr r0, struct abort(); } -#define EJIT_LDXI(f, t, r0, r1, o) \ - _Generic((t)(0), \ +static inline void ejit_ldxi_label(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_gpr r1, int64_t o) +{ + /** @todo implement properly */ + ejit_ldxi_ptr(s, r0, r1, o); +} + +#define EJIT_LDXI(f, t, r0, r1, o) \ + _Generic((t)(0), \ int8_t: ejit_ldxi_i8, \ uint8_t: ejit_ldxi_u8, \ int16_t: ejit_ldxi_i16, \ @@ -386,10 +394,72 @@ static inline void ejit_ldxi_ptr(struct ejit_func *s, struct ejit_gpr r0, struct uint32_t: ejit_ldxi_u32, \ int64_t: ejit_ldxi_i64, \ uint64_t: ejit_ldxi_u64, \ - float: ejit_ldxi_f, \ - double: ejit_ldxi_d, \ + float: ejit_ldxi_f, \ + double: ejit_ldxi_d, \ default: ejit_ldxi_ptr)((f), (r0), (r1), (o)) +void ejit_ldxr_i8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_i16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_i32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_i64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_u8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_u16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_u32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_u64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +void ejit_ldxr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + +static inline void ejit_ldxr_ptr(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_gpr r1, struct ejit_gpr r2) +{ + if (sizeof(void *) == sizeof(int64_t)) + ejit_ldxr_u64(s, r0, r1, r2); + else if (sizeof(void *) == sizeof(int32_t)) + ejit_ldxr_u32(s, r0, r1, r2); + else + abort(); +} + +static inline void ejit_ldxr_label(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_gpr r1, struct ejit_gpr r2) +{ + /** @todo implement properly */ + ejit_ldxr_ptr(s, r0, r1, r2); +} + +#define EJIT_LDXR(f, t, r0, r1, r2) \ + _Generic((t)(0), \ + int8_t: ejit_ldxr_i8, \ + uint8_t: ejit_ldxr_u8, \ + int16_t: ejit_ldxr_i16, \ + uint16_t: ejit_ldxr_u16, \ + int32_t: ejit_ldxr_i32, \ + uint32_t: ejit_ldxr_u32, \ + int64_t: ejit_ldxr_i64, \ + uint64_t: ejit_ldxr_u64, \ + float: ejit_ldxr_f, \ + double: ejit_ldxr_d, \ + default: ejit_ldxr_ptr)((f), (r0), (r1), (r2)) + void ejit_sti_8(struct ejit_func *s, struct ejit_gpr r0, void *p); void ejit_sti_16(struct ejit_func *s, struct ejit_gpr r0, void *p); void ejit_sti_32(struct ejit_func *s, struct ejit_gpr r0, void *p); @@ -447,6 +517,13 @@ static inline void ejit_stxi_ptr(struct ejit_func *s, struct ejit_gpr r0, double: ejit_stxi_d, \ default: ejit_stxi_ptr)((f), (r0), (r1), (o)) +void ejit_extr_8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); +void ejit_extr_16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); +void ejit_extr_32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); +void ejit_extr_u8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); +void ejit_extr_u16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); +void ejit_extr_u32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); + void ejit_addr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2); @@ -479,6 +556,15 @@ void ejit_divr_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, void ejit_divr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, struct ejit_fpr r2); +void ejit_lshi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + int64_t o); +void ejit_lshr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_rshi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + int64_t o); +void ejit_rshr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); + void ejit_andr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2); void ejit_andi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, @@ -490,10 +576,33 @@ void ejit_negr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); void ejit_eqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2); void ejit_eqr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, - struct ejit_fpr r2); + struct ejit_fpr r2); + +void ejit_gtr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_gtr_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_gtr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2); void ejit_ltr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2); +void ejit_ltr_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_ltr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2); + +void ejit_ger(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_ger_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_ger_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2); + +void ejit_ler(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2); +void ejit_ler_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2); struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1); @@ -557,6 +666,7 @@ struct ejit_reloc ejit_bltgtr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1); struct ejit_reloc ejit_jmp(struct ejit_func *s); +struct ejit_reloc ejit_jmpr(struct ejit_func *s, struct ejit_gpr r0); struct ejit_reloc ejit_bmci(struct ejit_func *s, struct ejit_gpr r0, int64_t o); struct ejit_reloc ejit_bmcr(struct ejit_func *s, struct ejit_gpr r0, |