summaryrefslogtreecommitdiff
path: root/template/optinsn.inc.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'template/optinsn.inc.tmpl')
-rw-r--r--template/optinsn.inc.tmpl44
1 files changed, 34 insertions, 10 deletions
diff --git a/template/optinsn.inc.tmpl b/template/optinsn.inc.tmpl
index 3c4f732290..186ec46982 100644
--- a/template/optinsn.inc.tmpl
+++ b/template/optinsn.inc.tmpl
@@ -13,18 +13,42 @@
*/
static INSN *
-insn_operands_unification(INSN *insnobj){
+insn_operands_unification(INSN *insnobj)
+{
#ifdef OPT_OPERANDS_UNIFICATION
- /* optimize rule */
- switch(insnobj->insn_id){
+ /* optimize rule */
+ switch(insnobj->insn_id){
+% opt_insns_map.each do |originsn, optinsns|
+ case BIN(<%=originsn.name%>):
+% optinsns.each {|opti|
+ if (
+% opti.defopes.each_with_index {|opinfo, i|
+% next if opinfo[1] == '*'
+ insnobj->operands[<%=i%>] == <%=val_as_type(opinfo)%> &&
+% }
+ 1) {
+% idx = 0
+% opti.defopes.each_with_index {|opinfo, n|
+% if opinfo[1] == '*'
+% if idx != n
+ insnobj->operands[<%=idx%>] = insnobj->operands[<%=n%>];
+% end
+% idx += 1
+% end
+% }
+ insnobj->insn_id = BIN(<%=opti.name%>);
+ insnobj->operand_size = <%=idx%>;
+ break;
+ }
+% }
+ break;
+% end
-<%= rule %>
-
- default:
- /* do nothing */;
- break;
- }
+ default:
+ /* do nothing */;
+ break;
+ }
#endif
- return insnobj;
+ return insnobj;
}