261
|
1
|
269
|
2 """
|
270
|
3 Abstract assembly language instructions.
|
|
4
|
|
5 This is the second intermediate representation.
|
|
6
|
|
7 Instructions are selected and scheduled at this stage.
|
269
|
8 """
|
261
|
9
|
274
|
10 class Frame:
|
|
11 """
|
|
12 Activation record abstraction. This class contains a flattened
|
|
13 function. Instructions are selected and scheduled at this stage.
|
|
14 Frames differ per machine.
|
|
15 """
|
|
16 def __init__(self, name):
|
|
17 self.name = name
|
|
18 self.instructions = []
|
|
19
|
|
20 def __repr__(self):
|
|
21 return 'Frame'
|
|
22
|
261
|
23
|
268
|
24 class AbstractInstruction:
|
274
|
25 """
|
|
26 Abstract machine instruction class. This is a very simple
|
|
27 abstraction of machine instructions.
|
|
28 """
|
268
|
29 def __init__(self, assem, src=(), dst=(), jumps=()):
|
|
30 self.assem = assem
|
|
31 self.src = tuple(src)
|
|
32 self.dst = tuple(dst)
|
|
33 self.jumps = tuple(jumps)
|
|
34
|
|
35 def __repr__(self):
|
274
|
36 s = str(self.src) if self.src else ''
|
|
37 d = str(self.dst) if self.dst else ''
|
|
38 l = str(self.jumps) if self.jumps else ''
|
|
39 return self.assem + s + d + l
|
261
|
40
|
|
41
|