mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Expose find_operands.
It has proven to be a generally useful function, not just for dags.
This commit is contained in:
parent
0a2ce6d381
commit
c00e666668
3 changed files with 49 additions and 47 deletions
|
@ -85,6 +85,8 @@ typedef struct sblock_s {
|
|||
|
||||
struct expr_s;
|
||||
|
||||
int find_operands (statement_t *s, operand_t **x, operand_t **y, operand_t **z,
|
||||
operand_t **w);
|
||||
sblock_t *make_statements (struct expr_s *expr);
|
||||
void print_statement (statement_t *s);
|
||||
void print_sblock (sblock_t *sblock, const char *filename);
|
||||
|
|
|
@ -200,53 +200,6 @@ node (operand_t *op)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_operands (statement_t *s, operand_t **x, operand_t **y, operand_t **z,
|
||||
operand_t **w)
|
||||
{
|
||||
int simp = 0;
|
||||
|
||||
if (s->opc) {
|
||||
*y = s->opa;
|
||||
if (s->opb) {
|
||||
// except for move, indexed pointer store, rcall2+, and state,
|
||||
// all are of the form c = a op b
|
||||
*z = s->opb;
|
||||
if (!strncmp (s->opcode, "<MOVE", 5)
|
||||
|| !strncmp (s->opcode, "<RCALL", 6)
|
||||
|| !strcmp (s->opcode, "<STATE>")
|
||||
|| !strcmp (s->opcode, ".=")) {
|
||||
*w = s->opc;
|
||||
} else {
|
||||
*x = s->opc;
|
||||
}
|
||||
} else {
|
||||
// these are all c = op a
|
||||
*x = s->opc;
|
||||
}
|
||||
} else if (s->opb) {
|
||||
*y = s->opa;
|
||||
if (s->opcode[1] == 'I') {
|
||||
// conditional
|
||||
} else if (s->opcode[0] == '<' || s->opcode[0] == '.') {
|
||||
// pointer store or branch
|
||||
*z = s->opb;
|
||||
} else {
|
||||
// b = a
|
||||
*x = s->opb;
|
||||
simp = 1;
|
||||
}
|
||||
} else if (s->opa) {
|
||||
if (s->opcode[1] == 'G') {
|
||||
} else {
|
||||
*y = s->opa;
|
||||
if (s->opcode[1] == 'R')
|
||||
simp = 1;
|
||||
}
|
||||
}
|
||||
return simp;
|
||||
}
|
||||
|
||||
static int
|
||||
dagnode_match (const dagnode_t *n, const daglabel_t *op,
|
||||
const dagnode_t *y, const dagnode_t *z, const dagnode_t *w)
|
||||
|
|
|
@ -211,6 +211,53 @@ print_statement (statement_t *s)
|
|||
printf (")\n");
|
||||
}
|
||||
|
||||
int
|
||||
find_operands (statement_t *s, operand_t **x, operand_t **y, operand_t **z,
|
||||
operand_t **w)
|
||||
{
|
||||
int simp = 0;
|
||||
|
||||
if (s->opc) {
|
||||
*y = s->opa;
|
||||
if (s->opb) {
|
||||
// except for move, indexed pointer store, rcall2+, and state,
|
||||
// all are of the form c = a op b
|
||||
*z = s->opb;
|
||||
if (!strncmp (s->opcode, "<MOVE", 5)
|
||||
|| !strncmp (s->opcode, "<RCALL", 6)
|
||||
|| !strcmp (s->opcode, "<STATE>")
|
||||
|| !strcmp (s->opcode, ".=")) {
|
||||
*w = s->opc;
|
||||
} else {
|
||||
*x = s->opc;
|
||||
}
|
||||
} else {
|
||||
// these are all c = op a
|
||||
*x = s->opc;
|
||||
}
|
||||
} else if (s->opb) {
|
||||
*y = s->opa;
|
||||
if (s->opcode[1] == 'I') {
|
||||
// conditional
|
||||
} else if (s->opcode[0] == '<' || s->opcode[0] == '.') {
|
||||
// pointer store or branch
|
||||
*z = s->opb;
|
||||
} else {
|
||||
// b = a
|
||||
*x = s->opb;
|
||||
simp = 1;
|
||||
}
|
||||
} else if (s->opa) {
|
||||
if (s->opcode[1] == 'G') {
|
||||
} else {
|
||||
*y = s->opa;
|
||||
if (s->opcode[1] == 'R')
|
||||
simp = 1;
|
||||
}
|
||||
}
|
||||
return simp;
|
||||
}
|
||||
|
||||
static sblock_t *free_sblocks;
|
||||
static statement_t *free_statements;
|
||||
static operand_t *free_operands;
|
||||
|
|
Loading…
Reference in a new issue