/* * Handle a unary opcode. */ static void JITCoder_Unary(ILCoder *coder, int opcode, ILEngineType type) { ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder); _ILJitStackItemNew(value); ILJitValue result = 0; _ILJitStackPop(jitCoder, value); switch(opcode) { case IL_OP_NEG: { result = jit_insn_neg(jitCoder->jitFunction, _ILJitStackItemValue(value)); } break; case IL_OP_NOT: { result = jit_insn_not(jitCoder->jitFunction, _ILJitStackItemValue(value)); } break; case IL_OP_CKFINITE: { /* Check the stack Top-most F value to see if it is finite */ result = jit_insn_is_finite(jitCoder->jitFunction, _ILJitStackItemValue(value)); } break; } _ILJitStackPushValue(jitCoder, result); }
void *LibJITFormula::emit (UnaryMinusExprAST *expr) { // Generate the contents of the unary-minus jit_value_t val = (jit_value_t)expr->child->generate (this); if (val == NULL) return NULL; return jit_insn_neg (function, val); }
static jit_value_t pj_jit_internal_op(jit_function_t function, jit_value_t *var_values, int nvars, pj_op_t *op) { jit_value_t tmp1, tmp2, rv; tmp1 = pj_jit_internal(function, var_values, nvars, op->op1); if (op->op2 != NULL) tmp2 = pj_jit_internal(function, var_values, nvars, op->op2); switch (op->optype) { case pj_unop_negate: rv = jit_insn_neg(function, tmp1); break; case pj_unop_sin: rv = jit_insn_sin(function, tmp1); break; case pj_unop_cos: rv = jit_insn_cos(function, tmp1); break; case pj_unop_abs: rv = jit_insn_abs(function, tmp1); break; case pj_unop_sqrt: rv = jit_insn_sqrt(function, tmp1); break; case pj_unop_log: rv = jit_insn_log(function, tmp1); break; case pj_unop_exp: rv = jit_insn_exp(function, tmp1); break; case pj_unop_not: rv = jit_insn_not(function, tmp1); break; case pj_unop_not_bool: rv = jit_insn_to_not_bool(function, tmp1); break; case pj_binop_add: rv = jit_insn_add(function, tmp1, tmp2); break; case pj_binop_subtract: rv = jit_insn_sub(function, tmp1, tmp2); break; case pj_binop_multiply: rv = jit_insn_mul(function, tmp1, tmp2); break; case pj_binop_divide: rv = jit_insn_div(function, tmp1, tmp2); break; case pj_binop_modulo: rv = jit_insn_rem(function, tmp1, tmp2); /* FIXME should this use jit_insn_rem_ieee? */ break; case pj_binop_atan2: rv = jit_insn_atan2(function, tmp1, tmp2); break; case pj_binop_left_shift: rv = jit_insn_shl(function, tmp1, tmp2); break; case pj_binop_right_shift: rv = jit_insn_shr(function, tmp1, tmp2); break; case pj_binop_and: rv = jit_insn_and(function, tmp1, tmp2); break; case pj_binop_or: rv = jit_insn_or(function, tmp1, tmp2); break; case pj_binop_xor: rv = jit_insn_xor(function, tmp1, tmp2); break; case pj_binop_eq: rv = jit_insn_eq(function, tmp1, tmp2); break; case pj_binop_ne: rv = jit_insn_ne(function, tmp1, tmp2); break; case pj_binop_lt: rv = jit_insn_lt(function, tmp1, tmp2); break; case pj_binop_le: rv = jit_insn_le(function, tmp1, tmp2); break; case pj_binop_gt: rv = jit_insn_gt(function, tmp1, tmp2); break; case pj_binop_ge: rv = jit_insn_ge(function, tmp1, tmp2); break; default: abort(); } return rv; }
jit_value jit_function::insn_neg(const jit_value& value1) { value_wrap(jit_insn_neg(func, value1.raw())); }
jit_value operator-(const jit_value& value1) { return jit_value(jit_insn_neg(jit_value_get_function(value1.raw()), value1.raw())); }