1
# Copyright (C) 2011 David Manzanares <manxi.david@gmail.com>
2
#This file is part of PyEffect.
4
# PyEffect is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# PyEffect is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with PyEffect. If not, see <http://www.gnu.org/licenses/>.
17
#This is the matcher for the Stage 3
32
def __init__(self, oldAct, newAct):
33
if oldAct.loc.Type == "reg" and newAct.loc.Type == "reg" and oldAct.loc.index == newAct.loc.index:
36
self.n = nms.__len__()
39
self.interferences = None
40
locs.append(oldAct.loc)
46
if var.Type == "char" and var.up.Type == "string":
47
lns.now.a1 = var.newAct("read", self.oldAct.loc)
48
lns.now.a1.pointer = True
49
lns.now.a2 = var.newAct("write", self.newAct.loc)
52
lns.now.a1 = var.newAct("read", self.oldAct.loc)
53
lns.now.a2 = var.newAct("write", self.newAct.loc)
54
if self.newAct.pointer == True:
55
lns.now.a1.pointer = True
56
size = max(self.oldAct.size, self.newAct.up)
59
lns.now.ins = "mov" + ins.suffixDic[size]
60
#This makes the match just after the oldAct:
61
#if self.oldAct.isNone==False:
62
# lns.now.insert(lns.lines.index(self.oldAct.line)+1)
64
# lns.now.insert(self.newAct.line)
65
lns.now.flow = self.newAct.line.flow
66
lns.now.insert(self.newAct.line)
67
locs.remove(self.oldAct.loc)
68
self.interferences = -1
70
if self.interferences != -1:
73
if l == self.newAct.loc and self.newAct.loc.asm != None:
75
self.interferences = c
77
return "NM " + str(self.n) + " Interferences: " + str(self.interferences) + "\nOld: " + str(self.oldAct) + "\nNew: " + str(self.newAct) + "\n"
80
lns.by.append("Match")
84
default = act.newNone(loc.new(None, None))
86
if a.loc != default.loc:
91
la = act.newNone(loc.new(None))
93
if a.loc != la.loc and a.Type == "read" or a.Type == "modify":
95
if a.Type == "write" or a.Type == "modify":
101
la = act.newNone(loc.new(None,))
103
if a.loc != la.loc and a.Type == "read":
111
if x.interferences == 0:
114
lns.by.remove("Match")