simple constexpr
This commit is contained in:
@@ -148,10 +148,20 @@ DEFINE_UNARY_FLOAT(fneg)
|
||||
value* builder::create_insert_nuwnswb_binop(binary_operator::op_t op, value *lhs,
|
||||
value *rhs, const std::string &name,
|
||||
bool has_nuw, bool has_nsw) {
|
||||
binary_operator* result = insert(binary_operator::create(op, lhs, rhs), name);
|
||||
if (has_nuw) result->set_has_no_unsigned_wrap();
|
||||
if (has_nsw) result->set_has_no_signed_wrap();
|
||||
return result;
|
||||
if(auto *clhs = dynamic_cast<constant_int*>(lhs)){
|
||||
if(auto *crhs = dynamic_cast<constant_int*>(rhs)){
|
||||
constant_expression* result = constant_expression::create(op, clhs, crhs);
|
||||
if (has_nuw) result->set_has_no_unsigned_wrap();
|
||||
if (has_nsw) result->set_has_no_signed_wrap();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
binary_operator* result = insert(binary_operator::create(op, lhs, rhs), name);
|
||||
if (has_nuw) result->set_has_no_unsigned_wrap();
|
||||
if (has_nsw) result->set_has_no_signed_wrap();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_NOWRAP_BINARY(SUFFIX, OPCODE)\
|
||||
@@ -161,7 +171,7 @@ value* builder::create_insert_nuwnswb_binop(binary_operator::op_t op, value *lhs
|
||||
|
||||
#define DEFINE_BINARY_INT(SUFFIX, OPCODE)\
|
||||
value *builder::create_ ## SUFFIX(value *lhs, value *rhs, const std::string &name){\
|
||||
return insert(binary_operator::create(OPCODE, lhs, rhs), name);\
|
||||
return create_insert_nuwnswb_binop(OPCODE, lhs, rhs, name, false, false);\
|
||||
}
|
||||
|
||||
#define DEFINE_UNARY_INT(SUFFIX)\
|
||||
|
Reference in New Issue
Block a user