* be moved from register to register or spilt).
*/
- r12 int volatile;
- r11 int volatile;
- r10 int volatile;
+ r12 int volatile;
+ r11 int volatile;
+ r10 int volatile;
r9 int volatile;
r8 int volatile;
r7 int volatile;
r4 int volatile;
r3 int volatile iret;
- r31 int;
- r30 int;
- r29 int;
- r28 int;
- r27 int;
- r26 int;
- r25 int;
- r24 int;
- r23 int;
- r22 int;
- r21 int;
- r20 int;
- r19 int;
- r18 int;
- r17 int;
+ r31 int;
+ r30 int;
+ r29 int;
+ r28 int;
+ r27 int;
+ r26 int;
+ r25 int;
+ r24 int;
+ r23 int;
+ r22 int;
+ r21 int;
+ r20 int;
+ r19 int;
+ r18 int;
+ r17 int;
r16 int;
r15 int;
r14 int;
emit "lfs %out, 0(sp)"
emit "addi sp, sp, 4"
cost 8;
-
+
out:(double)reg = POP.D
emit "lfd %out, 0(sp)"
emit "addi sp, sp, 8"
cost 8;
-
+
SETRET.I(in:(iret)reg)
emit "! setret4"
cost 1;
SETSP.I(in:(int)reg)
emit "mr sp, %in"
cost 4;
-
+
out:(int)reg = ANY.I
cost 1;
cost 4;
out:(int)reg = FROMSD.I(in:(double)reg)
- with preserved(%in)
+ with corrupted(%in)
emit "fctiwz %in, %in"
emit "stfdu %in, -8(sp)"
emit "lwz %out, 4(sp)"
emit "mr %out.0, %in1"
emit "mr %out.1, %in2"
cost 8;
-
+
out:(int)reg = FROML0.I(in:(long)reg)
emit "mr %out, %in.0"
cost 4;
cost 4;
out:(int)reg = MOD.I(left:(int)reg, right:(int)reg)
- with preserved(%left), preserved(%right)
+ with corrupted(%left), corrupted(%right)
emit "divw %out, %left, %right"
emit "mullw %out, %out, %right"
emit "subf %out, %out, %left"
cost 12;
out:(int)reg = MODU.I(left:(int)reg, right:(int)reg)
- with preserved(%left), preserved(%right)
+ with corrupted(%left), corrupted(%right)
emit "divwu %out, %left, %right"
emit "mullw %out, %out, %right"
emit "subf %out, %out, %left"
out:(float)reg = LOAD.F(addr:address)
emit "lfs %out, %addr"
cost 4;
-
+
out:(double)reg = LOAD.D(addr:address)
emit "lfd %out, %addr"
cost 4;
out:(type)reg = add(mul(m1:(type)reg, m2:(type)reg), m3:(type)reg) \
emit insn " %out, %m1, %m2, %m3" \
cost 4; \
-
+
#define FMARIGHT(type, insn, add, mul) \
out:(type)reg = add(m3:(type)reg, mul(m1:(type)reg, m2:(type)reg)) \
emit insn " %out, %m1, %m2, %m3" \
out:(type)reg = neg(add(mul(m1:(type)reg, m2:(type)reg), m3:(type)reg)) \
emit insn " %out, %m1, %m2, %m3" \
cost 4; \
-
+
#define FMANEGRIGHT(type, insn, neg, add, mul) \
out:(type)reg = neg(add(m3:(type)reg, mul(m1:(type)reg, m2:(type)reg))) \
emit insn " %out, %m1, %m2, %m3" \
ARRAYOF(struct value) inputs;
ARRAYOF(struct value) outputs;
ARRAYOF(struct value) throughs;
+ ARRAYOF(struct value) corrupted;
struct hashtable* vregmapping;
};
value->attrs = attr;
}
-static void constrain_input_reg_preserved(int child)
+static void constrain_input_reg_corrupted(int child)
{
struct value* value = find_value_of_child(child);
struct constraint* c;
- array_appendu(¤t_hop->throughs, value);
+ array_appendu(¤t_hop->corrupted, value);
}
static uint32_t find_type_from_constraint(uint32_t attr)
&emit_value,
&emit_eoi,
&constrain_input_reg,
- &constrain_input_reg_preserved,
+ &constrain_input_reg_corrupted,
&constrain_output_reg,
&constrain_output_reg_equal_to,
};
%term NOTEQUALS
%term PATTERNS
%term PREFERS
-%term PRESERVED
%term REGISTERS
%term WHEN
%term WITH
%%
spec
- : REGISTERS registers
+ : REGISTERS registers
DECLARATIONS declarations
PATTERNS patterns
;
$$->type = CONSTRAINT_EQUALS; $$->left = $2; $$->right = $5; }
| CORRUPTED '(' ID ')' { $$ = calloc(1, sizeof(*$$));
$$->type = CONSTRAINT_CORRUPTED_ATTR; $$->left = $3; }
- | PRESERVED '(' '%' ID ')' { $$ = calloc(1, sizeof(*$$));
- $$->type = CONSTRAINT_PRESERVED; $$->left = $4; }
+ | CORRUPTED '(' '%' ID ')' { $$ = calloc(1, sizeof(*$$));
+ $$->type = CONSTRAINT_CORRUPTED_REG; $$->left = $4; }
;
qfragments
exit(1);
}
}
-
+
emitheader();
registerterminals();
return true;
return false;
}
-
+
static void emit_predicate_expr(Rule r, struct expr* p)
{
bool first = true;
int index;
struct constraint* c = r->constraints.item[i];
- if (c->type == CONSTRAINT_PRESERVED)
+ if (c->type == CONSTRAINT_CORRUPTED_REG)
{
if (strcmp(c->left, r->label) == 0)
- yyerror("cannot preserve an output register!");
+ yyerror("only input registers can be corrupted!");
index = 0;
if (!find_child_index(r->pattern, c->left, &index, NULL))
label_not_found(r, c->left);
- print("%1data->constrain_input_reg_preserved(%d);\n", index);
+ print("%1data->constrain_input_reg_corrupted(%d);\n", index);
}
}
}
int index = 0;
emit_input_regs(r->pattern, &index);
}
-
+
emit_output_constraints(r);
emit_input_constraints(r);
-
+
while (f)
{
char* data = strdup(f->data);
assert(f->data[1] == 0);
print("%1data->emit_eoi();\n");
break;
-
+
default:
print("%1data->emit_string(\"%s\");\n", f->data);
}
{
CONSTRAINT_EQUALS,
CONSTRAINT_CORRUPTED_ATTR,
- CONSTRAINT_PRESERVED,
+ CONSTRAINT_CORRUPTED_REG,
};
struct constraint
void (*emit_value)(int child);
void (*emit_eoi)(void);
void (*constrain_input_reg)(int child, uint32_t attr);
- void (*constrain_input_reg_preserved)(int child);
+ void (*constrain_input_reg_corrupted)(int child);
void (*constrain_output_reg)(uint32_t attr);
void (*constrain_output_reg_equal_to)(int child);
};
"fragment" return FRAGMENT;
"named" return NAMED;
"prefers" return PREFERS;
-"preserved" return PRESERVED;
"when" return WHEN;
"with" return WITH;
"==" return EQUALS;