ack/mach/proto/mcg/predicates.c
David Given cfe5312fcc Predicates can now take numeric arguments. The PowerPC predicates have been
turned into generic ones (as they'll be useful everywhere). Node arguments for
predicates require the '%' prefix for consistency. Hex numbers are permitted.
2016-10-09 12:32:36 +02:00

33 lines
695 B
C

#include "mcg.h"
bool burm_predicate_signed_constant(struct burm_node* node, arith size)
{
struct ir* ir = node->ir;
arith pivot = 1<<(size-1);
arith mask = ~((1<<size) - 1);
assert(ir->opcode == IR_CONST);
return ((ir->u.ivalue + pivot) & mask) == 0;
}
bool burm_predicate_unsigned_constant(struct burm_node* node, arith size)
{
struct ir* ir = node->ir;
arith mask = ~((1<<size) - 1);
assert(ir->opcode == IR_CONST);
return (ir->u.ivalue & mask) == 0;
}
bool burm_predicate_specific_constant(struct burm_node* node, arith val)
{
struct ir* ir = node->ir;
assert(ir->opcode == IR_CONST);
return ir->u.ivalue == val;
}
/* vim: set sw=4 ts=4 expandtab : */