MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / parse_binop

Function parse_binop

tools/alive_parser.cpp:716–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716static unique_ptr<Instr> parse_binop(string_view name, token op_token) {
717 auto flags = parse_binop_flags(op_token);
718 auto *explicit_rettype =
719 op_token == UCMP || op_token == SCMP ? &parse_type() : nullptr;
720 auto &type = parse_type();
721 auto &a = parse_operand(type);
722 parse_comma();
723 Type &type_rhs = try_parse_type(type);
724 auto &b = parse_operand(type_rhs);
725 Type *rettype =
726 op_token == UCMP || op_token == SCMP ? explicit_rettype : &type;
727
728 BinOp::Op op;
729 switch (op_token) {
730 case ADD: op = BinOp::Add; break;
731 case SUB: op = BinOp::Sub; break;
732 case MUL: op = BinOp::Mul; break;
733 case SDIV: op = BinOp::SDiv; break;
734 case UDIV: op = BinOp::UDiv; break;
735 case SREM: op = BinOp::SRem; break;
736 case UREM: op = BinOp::URem; break;
737 case SHL: op = BinOp::Shl; break;
738 case LSHR: op = BinOp::LShr; break;
739 case ASHR: op = BinOp::AShr; break;
740 case AND: op = BinOp::And; break;
741 case OR: op = BinOp::Or; break;
742 case XOR: op = BinOp::Xor; break;
743 case CTTZ: op = BinOp::Cttz; break;
744 case CTLZ: op = BinOp::Ctlz; break;
745 case SADD_SAT: op = BinOp::SAdd_Sat; break;
746 case UADD_SAT: op = BinOp::UAdd_Sat; break;
747 case SSUB_SAT: op = BinOp::SSub_Sat; break;
748 case USUB_SAT: op = BinOp::USub_Sat; break;
749 case SSHL_SAT: op = BinOp::SShl_Sat; break;
750 case USHL_SAT: op = BinOp::UShl_Sat; break;
751 case SADD_OVERFLOW:
752 op = BinOp::SAdd_Overflow;
753 rettype = &get_overflow_type(type);
754 break;
755 case UADD_OVERFLOW:
756 op = BinOp::UAdd_Overflow;
757 rettype = &get_overflow_type(type);
758 break;
759 case SSUB_OVERFLOW:
760 op = BinOp::SSub_Overflow;
761 rettype = &get_overflow_type(type);
762 break;
763 case USUB_OVERFLOW:
764 op = BinOp::USub_Overflow;
765 rettype = &get_overflow_type(type);
766 break;
767 case SMUL_OVERFLOW:
768 op = BinOp::SMul_Overflow;
769 rettype = &get_overflow_type(type);
770 break;
771 case UMUL_OVERFLOW:
772 op = BinOp::UMul_Overflow;
773 rettype = &get_overflow_type(type);

Callers 1

parse_instrFunction · 0.85

Calls 2

parse_binop_flagsFunction · 0.85
parse_commaFunction · 0.85

Tested by

no test coverage detected