+static inline _Bool is_big_endian(void)
+{
+ return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
+}
+
+static inline _Bool lut_is_32bit(const struct lightrec_state *state)
+{
+ return __WORDSIZE == 32 ||
+ (ENABLE_CODE_BUFFER && state->with_32bit_lut);
+}
+
+static inline size_t lut_elm_size(const struct lightrec_state *state)
+{
+ return lut_is_32bit(state) ? 4 : sizeof(void *);
+}
+
+static inline void ** lut_address(struct lightrec_state *state, u32 offset)
+{
+ if (lut_is_32bit(state))
+ return (void **) ((uintptr_t) state->code_lut + offset * 4);
+ else
+ return &state->code_lut[offset];
+}
+
+static inline void * lut_read(struct lightrec_state *state, u32 offset)
+{
+ void **lut_entry = lut_address(state, offset);
+
+ if (lut_is_32bit(state))
+ return (void *)(uintptr_t) *(u32 *) lut_entry;
+ else
+ return *lut_entry;
+}
+
+static inline void lut_write(struct lightrec_state *state, u32 offset, void *ptr)
+{
+ void **lut_entry = lut_address(state, offset);
+
+ if (lut_is_32bit(state))
+ *(u32 *) lut_entry = (u32)(uintptr_t) ptr;
+ else
+ *lut_entry = ptr;
+}
+
+static inline u32 get_ds_pc(const struct block *block, u16 offset, s16 imm)
+{
+ u16 flags = block->opcode_list[offset].flags;
+
+ offset += op_flag_no_ds(flags);
+
+ return block->pc + (offset + imm << 2);
+}
+
+static inline u32 get_branch_pc(const struct block *block, u16 offset, s16 imm)
+{
+ u16 flags = block->opcode_list[offset].flags;
+
+ offset -= op_flag_no_ds(flags);
+
+ return block->pc + (offset + imm << 2);
+}
+