Example #1
0
  static void fixnum_neg(JITOperations& ops, Inliner& i) {
    BasicBlock* use_send = i.failure();
    BasicBlock* inlined = ops.new_block("fixnum_neg");

    Value* self = i.recv();
    Value* cmp = ops.check_if_fixnum(self);
    ops.create_conditional_branch(inlined, use_send, cmp);

    ops.set_block(inlined);
    Value* native = ops.fixnum_strip(self);
    Value* neg = BinaryOperator::CreateSub(
        ops.Zero, native, "to_neg",
        ops.current_block());

    Value* more = BinaryOperator::CreateShl(neg, ops.One, "shl", ops.current_block());
    Value* tagged = BinaryOperator::CreateOr(more, ops.One, "or", ops.current_block());

    i.exception_safe();
    i.set_result(ops.as_obj(tagged));
  }