view release on metacpan or search on metacpan
libjit/ChangeLog view on Meta::CPAN
generating the opcode intrinsic table.
2010-09-12 Klaus Treichel <ktreichel@web.de>
* config/jit-opcodes.ops: Remove the *eq_inv and *ne_inv float
compare a branch opcodes because they behave exactly the same as
the corresponding opcodes without the _INV suffix.
Add macros to map the removed opcodes to their counterparts without
the _INV suffix.
* jit/jit-insn.c (jit_insn_to_not_bool): Replace the mappings
to *EQ_INV and *NE_INV by mappings to *EQ and *NE.
Remove the mappings for *EQ_INV and *NE_INV.
(jit_insn_branch_if): likwise
(jit_insn_branch_if_not): likewise
* jit/jit-interp.c (_jit_run_function): Remove handling of
the *EQ_INV and *NE_INV opcodes.
* jt/jit-rules-interp.c (_jit_gen_insn): Remove the *EQ_INV
and *NE_INV cases.
libjit/dpas/dpas-parser.y view on Meta::CPAN
/* TODO */
dpas_error("set expressions not yet implemented");
dpas_sem_set_error($$);
}
| K_NOT Factor {
jit_value_t value;
$2 = dpas_lvalue_to_rvalue($2);
if(dpas_sem_is_rvalue($2) &&
dpas_type_is_boolean(dpas_sem_get_type($2)))
{
value = jit_insn_to_not_bool
(dpas_current_function(), dpas_sem_get_value($2));
dpas_sem_set_rvalue($$, dpas_type_boolean, value);
}
else if(dpas_sem_is_rvalue($2) &&
dpas_type_is_integer(dpas_sem_get_type($2)))
{
value = jit_insn_not
(dpas_current_function(), dpas_sem_get_value($2));
dpas_sem_set_rvalue($$, jit_value_get_type(value), value);
}
libjit/include/jit/jit-insn.h view on Meta::CPAN
jit_value_t jit_insn_gt
(jit_function_t func, jit_value_t value1, jit_value_t value2) JIT_NOTHROW;
jit_value_t jit_insn_ge
(jit_function_t func, jit_value_t value1, jit_value_t value2) JIT_NOTHROW;
jit_value_t jit_insn_cmpl
(jit_function_t func, jit_value_t value1, jit_value_t value2) JIT_NOTHROW;
jit_value_t jit_insn_cmpg
(jit_function_t func, jit_value_t value1, jit_value_t value2) JIT_NOTHROW;
jit_value_t jit_insn_to_bool
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_to_not_bool
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_acos
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_asin
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_atan
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_atan2
(jit_function_t func, jit_value_t value1, jit_value_t value2) JIT_NOTHROW;
jit_value_t jit_insn_ceil
libjit/include/jit/jit-insn.h view on Meta::CPAN
int jit_insn_return(jit_function_t func, jit_value_t value) JIT_NOTHROW;
int jit_insn_return_ptr
(jit_function_t func, jit_value_t value, jit_type_t type) JIT_NOTHROW;
int jit_insn_default_return(jit_function_t func) JIT_NOTHROW;
int jit_insn_throw(jit_function_t func, jit_value_t value) JIT_NOTHROW;
jit_value_t jit_insn_get_call_stack(jit_function_t func) JIT_NOTHROW;
jit_value_t jit_insn_thrown_exception(jit_function_t func) JIT_NOTHROW;
int jit_insn_uses_catcher(jit_function_t func) JIT_NOTHROW;
jit_value_t jit_insn_start_catcher(jit_function_t func) JIT_NOTHROW;
int jit_insn_branch_if_pc_not_in_range
(jit_function_t func, jit_label_t start_label,
jit_label_t end_label, jit_label_t *label) JIT_NOTHROW;
int jit_insn_rethrow_unhandled(jit_function_t func) JIT_NOTHROW;
int jit_insn_start_finally
(jit_function_t func, jit_label_t *finally_label) JIT_NOTHROW;
int jit_insn_return_from_finally(jit_function_t func) JIT_NOTHROW;
int jit_insn_call_finally
(jit_function_t func, jit_label_t *finally_label) JIT_NOTHROW;
jit_value_t jit_insn_start_filter
(jit_function_t func, jit_label_t *label, jit_type_t type) JIT_NOTHROW;
libjit/include/jit/jit-plus.h view on Meta::CPAN
jit_value insn_sshr(const jit_value& value1, const jit_value& value2);
jit_value insn_eq(const jit_value& value1, const jit_value& value2);
jit_value insn_ne(const jit_value& value1, const jit_value& value2);
jit_value insn_lt(const jit_value& value1, const jit_value& value2);
jit_value insn_le(const jit_value& value1, const jit_value& value2);
jit_value insn_gt(const jit_value& value1, const jit_value& value2);
jit_value insn_ge(const jit_value& value1, const jit_value& value2);
jit_value insn_cmpl(const jit_value& value1, const jit_value& value2);
jit_value insn_cmpg(const jit_value& value1, const jit_value& value2);
jit_value insn_to_bool(const jit_value& value1);
jit_value insn_to_not_bool(const jit_value& value1);
jit_value insn_acos(const jit_value& value1);
jit_value insn_asin(const jit_value& value1);
jit_value insn_atan(const jit_value& value1);
jit_value insn_atan2(const jit_value& value1, const jit_value& value2);
jit_value insn_ceil(const jit_value& value1);
jit_value insn_cos(const jit_value& value1);
jit_value insn_cosh(const jit_value& value1);
jit_value insn_exp(const jit_value& value1);
jit_value insn_floor(const jit_value& value1);
jit_value insn_log(const jit_value& value1);
libjit/include/jit/jit-plus.h view on Meta::CPAN
void insn_push_return_area_ptr();
void insn_return(const jit_value& value);
void insn_return();
void insn_return_ptr(const jit_value& value, jit_type_t type);
void insn_default_return();
void insn_throw(const jit_value& value);
jit_value insn_get_call_stack();
jit_value insn_thrown_exception();
void insn_uses_catcher();
jit_value insn_start_catcher();
void insn_branch_if_pc_not_in_range
(const jit_label& start_label, const jit_label& end_label,
jit_label& label);
void insn_rethrow_unhandled();
void insn_start_finally(jit_label& label);
void insn_return_from_finally();
void insn_call_finally(jit_label& label);
jit_value insn_start_filter(jit_label& label, jit_type_t type);
void insn_return_from_filter(const jit_value& value);
jit_value insn_call_filter
(jit_label& label, const jit_value& value, jit_type_t type);
libjit/jit/jit-gen-x86-64.h view on Meta::CPAN
} while(0)
#define x86_64_neg_memindex_size(inst, basereg, disp, indexreg, shift, size) \
do { \
x86_64_alu1_memindex_size((inst), 0xf6, 3, (basereg), (disp), (indexreg), (shift), (size)); \
} while(0)
/*
* not
*/
#define x86_64_not_reg_size(inst, reg, size) \
do { \
x86_64_alu1_reg_size((inst), 0xf6, 2, (reg), (size)); \
} while(0)
#define x86_64_not_regp_size(inst, regp, size) \
do { \
x86_64_alu1_regp_size((inst), 0xf6, 2, (regp), (size)); \
} while(0)
#define x86_64_not_mem_size(inst, mem, size) \
do { \
x86_64_alu1_mem_size((inst), 0xf6, 2, (mem), (size)); \
} while(0)
#define x86_64_not_membase_size(inst, basereg, disp, size) \
do { \
x86_64_alu1_membase_size((inst), 0xf6, 2, (basereg), (disp), (size)); \
} while(0)
#define x86_64_not_memindex_size(inst, basereg, disp, indexreg, shift, size) \
do { \
x86_64_alu1_memindex_size((inst), 0xf6, 2, (basereg), (disp), (indexreg), (shift), (size)); \
} while(0)
/*
* Note: x86_64_clear_reg () changes the condition code!
*/
#define x86_64_clear_reg(inst, reg) \
x86_64_xor_reg_reg_size((inst), (reg), (reg), 4)
libjit/jit/jit-gen-x86.h view on Meta::CPAN
} while (0)
#define x86_dec_membase(inst,basereg,disp) \
do { \
*(inst)++ = (unsigned char)0xff; \
x86_membase_emit ((inst), 1, (basereg), (disp)); \
} while (0)
#define x86_dec_reg(inst,reg) do { *(inst)++ = (unsigned char)0x48 + (reg); } while (0)
#define x86_not_mem(inst,mem) \
do { \
*(inst)++ = (unsigned char)0xf7; \
x86_mem_emit ((inst), 2, (mem)); \
} while (0)
#define x86_not_membase(inst,basereg,disp) \
do { \
*(inst)++ = (unsigned char)0xf7; \
x86_membase_emit ((inst), 2, (basereg), (disp)); \
} while (0)
#define x86_not_reg(inst,reg) \
do { \
*(inst)++ = (unsigned char)0xf7; \
x86_reg_emit ((inst), 2, (reg)); \
} while (0)
#define x86_neg_mem(inst,mem) \
do { \
*(inst)++ = (unsigned char)0xf7; \
x86_mem_emit ((inst), 3, (mem)); \
} while (0)
libjit/jit/jit-insn.c view on Meta::CPAN
}
/*@
* @deftypefun jit_value_t jit_insn_not (jit_function_t @var{func}, jit_value_t @var{value1})
* Bitwise NOT a value and return the result in a new temporary value.
* @end deftypefun
@*/
jit_value_t jit_insn_not
(jit_function_t func, jit_value_t value1)
{
static jit_opcode_descr const not_descr = {
JIT_OP_INOT,
JIT_OP_INOT,
JIT_OP_LNOT,
JIT_OP_LNOT,
0, 0, 0,
jit_intrinsic(jit_int_not, descr_i_i),
jit_intrinsic(jit_uint_not, descr_I_I),
jit_intrinsic(jit_long_not, descr_l_l),
jit_intrinsic(jit_ulong_not, descr_L_L),
jit_no_intrinsic,
jit_no_intrinsic,
jit_no_intrinsic
};
return apply_unary_arith(func, ¬_descr, value1, 1, 0, 0);
}
/*@
* @deftypefun jit_value_t jit_insn_shl (jit_function_t @var{func}, jit_value_t @var{value1}, jit_value_t @var{value2})
* Perform a bitwise left shift on two values and return the
* result in a new temporary value.
* @end deftypefun
@*/
jit_value_t jit_insn_shl
(jit_function_t func, jit_value_t value1, jit_value_t value2)
libjit/jit/jit-insn.c view on Meta::CPAN
else
{
return jit_insn_ne
(func, value1,
jit_value_create_nfloat_constant
(func, jit_type_nfloat, (jit_nfloat)0.0));
}
}
/*@
* @deftypefun jit_value_t jit_insn_to_not_bool (jit_function_t @var{func}, jit_value_t @var{value1})
* Convert a value into a boolean 1 or 0 result of type @code{jit_type_int}
* (i.e. the inverse of @code{jit_insn_to_bool}).
* @end deftypefun
@*/
jit_value_t jit_insn_to_not_bool(jit_function_t func, jit_value_t value1)
{
jit_type_t type;
jit_block_t block;
jit_insn_t last;
int opcode;
/* Bail out if the parameters are invalid */
if(!value1)
{
return 0;
libjit/jit/jit-insn.c view on Meta::CPAN
last_exception = jit_insn_call_native(
func, "jit_exception_get_last",
(void *)jit_exception_get_last, type, 0, 0, JIT_CALL_NOTHROW);
jit_insn_store(func, value, last_exception);
jit_type_free(type);
#endif
return value;
}
/*@
* @deftypefun int jit_insn_branch_if_pc_not_in_range (jit_function_t @var{func}, jit_label_t @var{start_label}, jit_label_t @var{end_label}, jit_label_t *@var{label})
* Branch to @var{label} if the program counter where an exception occurred
* does not fall between @var{start_label} and @var{end_label}.
* @end deftypefun
@*/
int jit_insn_branch_if_pc_not_in_range
(jit_function_t func, jit_label_t start_label,
jit_label_t end_label, jit_label_t *label)
{
jit_value_t value1;
jit_value_t value2;
/* Ensure that we have a function builder and a try block */
if(!_jit_function_ensure_builder(func))
{
return 0;
libjit/jit/jit-rules-x86-64.ins view on Meta::CPAN
}
[reg, local] -> {
x86_64_xor_reg_membase_size(inst, $1, X86_64_RBP, $2, 4);
}
[reg, reg] -> {
x86_64_xor_reg_reg_size(inst, $1, $2, 4);
}
JIT_OP_INOT:
[reg] -> {
x86_64_not_reg_size(inst, $1, 4);
}
JIT_OP_ISHL:
[reg, imm] -> {
x86_64_shl_reg_imm_size(inst, $1, ($2 & 0x1F), 4);
}
[sreg, reg("rcx")] -> {
x86_64_shl_reg_size(inst, $1, 4);
}
libjit/jit/jit-rules-x86-64.ins view on Meta::CPAN
}
[reg, local] -> {
x86_64_xor_reg_membase_size(inst, $1, X86_64_RBP, $2, 8);
}
[reg, reg] -> {
x86_64_xor_reg_reg_size(inst, $1, $2, 8);
}
JIT_OP_LNOT:
[reg] -> {
x86_64_not_reg_size(inst, $1, 8);
}
JIT_OP_LSHL:
[reg, imm] -> {
x86_64_shl_reg_imm_size(inst, $1, ($2 & 0x3F), 8);
}
[sreg, reg("rcx")] -> {
x86_64_shl_reg_size(inst, $1, 8);
}
libjit/jit/jit-rules-x86.ins view on Meta::CPAN
}
[reg, local] -> {
x86_alu_reg_membase(inst, X86_XOR, $1, X86_EBP, $2);
}
[reg, reg] -> {
x86_alu_reg_reg(inst, X86_XOR, $1, $2);
}
JIT_OP_INOT:
[reg] -> {
x86_not_reg(inst, $1);
}
JIT_OP_ISHL:
[reg, imm] -> {
x86_shift_reg_imm(inst, X86_SHL, $1, ($2 & 0x1F));
}
[reg, reg("ecx")] -> {
x86_shift_reg(inst, X86_SHL, $1);
}
libjit/jit/jit-rules-x86.ins view on Meta::CPAN
x86_alu_reg_membase(inst, X86_XOR, $1, X86_EBP, $2);
x86_alu_reg_membase(inst, X86_XOR, %1, X86_EBP, $2 + 4);
}
[lreg, lreg] -> {
x86_alu_reg_reg(inst, X86_XOR, $1, $2);
x86_alu_reg_reg(inst, X86_XOR, %1, %2);
}
JIT_OP_LNOT:
[lreg] -> {
x86_not_reg(inst, $1);
x86_not_reg(inst, %1);
}
/*
* Branch opcodes.
*/
JIT_OP_BR: branch
[] -> {
inst = output_branch(func, inst, 0xEB /* jmp */, insn);
}
libjit/jitplus/jit-plus-function.cpp view on Meta::CPAN
* @deftypemethodx jit_function jit_value insn_sshr (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_eq (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_ne (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_lt (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_le (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_gt (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_ge (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_cmpl (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_cmpg (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_to_bool (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_to_not_bool (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_acos (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_asin (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_atan (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_atan2 (const jit_value& @var{value1}, const jit_value& @var{value2})
* @deftypemethodx jit_function jit_value insn_ceil (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_cos (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_cosh (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_exp (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_floor (const jit_value& @var{value1})
* @deftypemethodx jit_function jit_value insn_log (const jit_value& @var{value1})
libjit/jitplus/jit-plus-function.cpp view on Meta::CPAN
* @deftypemethodx jit_function void insn_push_return_area_ptr ()
* @deftypemethodx jit_function void insn_return (const jit_value& @var{value})
* @deftypemethodx jit_function void insn_return ()
* @deftypemethodx jit_function void insn_return_ptr (const jit_value& @var{value}, jit_type_t @var{type})
* @deftypemethodx jit_function void insn_default_return ()
* @deftypemethodx jit_function void insn_throw (const jit_value& @var{value})
* @deftypemethodx jit_function jit_value insn_get_call_stack ()
* @deftypemethodx jit_function jit_value insn_thrown_exception ()
* @deftypemethodx jit_function void insn_uses_catcher ()
* @deftypemethodx jit_function jit_value insn_start_catcher ()
* @deftypemethodx jit_function void insn_branch_if_pc_not_in_range (const jit_label& @var{start_label}, const jit_label& @var{end_label}, jit_label& @var{label})
* @deftypemethodx jit_function void insn_rethrow_unhandled ()
* @deftypemethodx jit_function void insn_start_finally (jit_label& @var{label})
* @deftypemethodx jit_function void insn_return_from_finally ()
* @deftypemethodx jit_function void insn_call_finally (jit_label& @var{label})
* @deftypemethodx jit_function jit_value insn_start_filter (jit_label& @var{label}, jit_type_t @var{type})
* @deftypemethodx jit_function void insn_return_from_filter (const jit_value& @var{value})
* @deftypemethodx jit_function jit_value insn_call_filter (jit_label& @var{label}, const jit_value& @var{value}, jit_type_t @var{type})
* @deftypemethodx jit_function void insn_memcpy (const jit_value& @var{dest}, const jit_value& @var{src}, const jit_value& @var{size})
* @deftypemethodx jit_function void insn_memmove (const jit_value& @var{dest}, const jit_value& @var{src}, const jit_value& @var{size})
* @deftypemethodx jit_function void jit_insn_memset (const jit_value& @var{dest}, const jit_value& @var{value}, const jit_value& @var{size})
libjit/jitplus/jit-plus-function.cpp view on Meta::CPAN
(const jit_value& value1, const jit_value& value2)
{
value_wrap(jit_insn_cmpg(func, value1.raw(), value2.raw()));
}
jit_value jit_function::insn_to_bool(const jit_value& value1)
{
value_wrap(jit_insn_to_bool(func, value1.raw()));
}
jit_value jit_function::insn_to_not_bool(const jit_value& value1)
{
value_wrap(jit_insn_to_not_bool(func, value1.raw()));
}
jit_value jit_function::insn_acos(const jit_value& value1)
{
value_wrap(jit_insn_acos(func, value1.raw()));
}
jit_value jit_function::insn_asin(const jit_value& value1)
{
value_wrap(jit_insn_asin(func, value1.raw()));
libjit/jitplus/jit-plus-function.cpp view on Meta::CPAN
{
out_of_memory();
}
}
jit_value jit_function::insn_start_catcher()
{
value_wrap(jit_insn_start_catcher(func));
}
void jit_function::insn_branch_if_pc_not_in_range
(const jit_label& start_label, const jit_label& end_label,
jit_label& label)
{
if(!jit_insn_branch_if_pc_not_in_range
(func, start_label.raw(), end_label.raw(), label.rawp()))
{
out_of_memory();
}
}
void jit_function::insn_rethrow_unhandled()
{
if(!jit_insn_rethrow_unhandled(func))
{
libjit/jitruby/ext/insns.inc.rpp view on Meta::CPAN
[ 'sshr' , V, V, V ] ,
[ 'eq' , V, V, V ] ,
[ 'ne' , V, V, V ] ,
[ 'lt' , V, V, V ] ,
[ 'le' , V, V, V ] ,
[ 'gt' , V, V, V ] ,
[ 'ge' , V, V, V ] ,
[ 'cmpl' , V, V, V ] ,
[ 'cmpg' , V, V, V ] ,
[ 'to_bool' , V, V ] ,
[ 'to_not_bool' , V, V ] ,
[ 'acos' , V, V ] ,
[ 'asin' , V, V ] ,
[ 'atan' , V, V ] ,
[ 'atan2' , V, V, V ] ,
[ 'ceil' , V, V ] ,
[ 'cos' , V, V ] ,
[ 'cosh' , V, V ] ,
[ 'exp' , V, V ] ,
[ 'floor' , V, V ] ,
[ 'log' , V, V ] ,
libjit/jitruby/test/test_jit_function.rb view on Meta::CPAN
f.while{ value < f.const(JIT::Type::INT, 2) }.do {
value.store(value + f.const(JIT::Type::INT, 1))
}.end
f.insn_return value
end
end
assert_equal(2, function.apply)
end
def test_while_false_does_not_enter_loop
function = nil
JIT::Context.build do |context|
signature = JIT::Type.create_signature(
JIT::ABI::CDECL,
JIT::Type::INT,
[ ])
function = JIT::Function.compile(context, signature) do |f|
true_value = f.const(JIT::Type::INT, 1)
false_value = f.const(JIT::Type::INT, 0)
f.while{ false_value }.do {
libjit/jitruby/test/test_jit_function.rb view on Meta::CPAN
f.until{ value == f.const(JIT::Type::INT, 2) }.do {
value.store(value + f.const(JIT::Type::INT, 1))
}.end
f.insn_return value
end
end
assert_equal(2, function.apply)
end
def test_until_true_does_not_enter_loop
function = nil
JIT::Context.build do |context|
signature = JIT::Type.create_signature(
JIT::ABI::CDECL,
JIT::Type::INT,
[ ])
function = JIT::Function.compile(context, signature) do |f|
true_value = f.const(JIT::Type::INT, 1)
false_value = f.const(JIT::Type::INT, 0)
f.until{ true_value }.do {
libjit/tests/coerce.pas view on Meta::CPAN
{ Test libjit's coercion rules for unary operators }
run("coerce_neg_byte", SameType(Integer, -b));
run("coerce_neg_short", SameType(Integer, -s));
run("coerce_neg_int", SameType(Integer, -3));
run("coerce_neg_uint", SameType(Integer, -080000000H));
run("coerce_neg_long", SameType(LongInt, -0800000000H));
run("coerce_neg_ulong", SameType(LongInt, -08000000000000000H));
run("coerce_neg_float32", SameType(ShortReal, -f));
run("coerce_neg_float64", SameType(Real, -d));
run("coerce_neg_nfloat", SameType(LongReal, -n));
run("coerce_not_byte", SameType(Cardinal, not b));
run("coerce_not_short", SameType(Integer, not s));
run("coerce_not_int", SameType(Integer, not 3));
run("coerce_not_uint", SameType(Cardinal, not 080000000H));
run("coerce_not_long", SameType(LongInt, not 0800000000H));
run("coerce_not_ulong", SameType(LongCard, not 08000000000000000H));
end;
begin
failed := False;
run_tests;
if failed then begin
Terminate(1);
end;
end.