aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-05-18 14:20:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-05-18 14:20:18 +0300
commitc078339496f43ff3c5340ddd19badcf11038198d (patch)
tree40db7ed8ac380e57a1baa89dc799b88f6ed82f28
parentb9372c7be73a7cad6d741f5323dc8b2b758198d4 (diff)
downloadejit-c078339496f43ff3c5340ddd19badcf11038198d.tar.gz
ejit-c078339496f43ff3c5340ddd19badcf11038198d.zip
add generic EJIT_LDI
-rw-r--r--include/ejit/ejit.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/ejit/ejit.h b/include/ejit/ejit.h
index d3bc6c3..9343110 100644
--- a/include/ejit/ejit.h
+++ b/include/ejit/ejit.h
@@ -564,6 +564,16 @@ static inline void ejit_ldxi_ptr(struct ejit_func *s, struct ejit_gpr r0,
abort();
}
+static inline void ejit_ldi_ptr(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ if (sizeof(void *) == sizeof(int64_t))
+ ejit_ldi_u64(s, r0, p);
+ else if (sizeof(void *) == sizeof(int32_t))
+ ejit_ldi_u32(s, r0, p);
+ else
+ abort();
+}
+
static inline void ejit_ldxi_label(struct ejit_func *s, struct ejit_gpr r0,
struct ejit_gpr r1, int64_t o)
{
@@ -571,6 +581,20 @@ static inline void ejit_ldxi_label(struct ejit_func *s, struct ejit_gpr r0,
ejit_ldxi_ptr(s, r0, r1, o);
}
+#define EJIT_LDI(f, t, r0, o) \
+ _Generic((t)(0), \
+ int8_t: ejit_ldi_i8, \
+ uint8_t: ejit_ldi_u8, \
+ int16_t: ejit_ldi_i16, \
+ uint16_t: ejit_ldi_u16, \
+ int32_t: ejit_ldi_i32, \
+ uint32_t: ejit_ldi_u32, \
+ int64_t: ejit_ldi_i64, \
+ uint64_t: ejit_ldi_u64, \
+ float: ejit_ldi_f, \
+ double: ejit_ldi_d, \
+ default: ejit_ldi_ptr)((f), (r0), (o))
+
#define EJIT_LDXI(f, t, r0, r1, o) \
_Generic((t)(0), \
int8_t: ejit_ldxi_i8, \