-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathifunfext.ppcs
183 lines (169 loc) · 6.93 KB
/
ifunfext.ppcs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: ALPHA-AXP-INTERNALS; Base: 10; Lowercase: T -*-
;(include-header "aihead.s")
;(include-header "aistat.s")
;(include-header "ifunhead.s")
(comment "Field extraction instruction.")
;; |DoLdb| is is IFUNCOM1.PPCS
(define-instruction |DoCharLdb| :field-extraction ()
(li t7 -1)
(stack-read2-signed iSP arg3 arg4 "get ARG1 tag/data")
(ADDI arg1 arg1 1 "Size of field")
(SLD t7 t7 arg1 "Unmask")
(TagType arg3 t8)
(ADDI t9 t8 #.(- |type$K-character|))
(clrldi arg4 arg4 32 "Clear sign extension now")
(branch-if-nonzero t9 charldbexc "Not a character")
(SLD t4 arg4 arg2 "T4= shifted value if PP==0")
(GetNextPC)
(srdi t5 t4 32 "T5= shifted value if PP<>0")
(GetNextCP)
(CMPI 0 1 arg2 0)
(BC 4 2 skip8a "B.NE")
(mov t5 t4 "T5= shifted value")
(unlikely-label skip8a)
(ANDC t3 t5 t7 "T3= masked value.")
(stack-write-ir |TypeFixnum| t3 t4)
(ContinueToNextInstruction-NoStall)
(label charldbexc)
(illegal-operand char-ldb-type-error))
(define-instruction |DoPLdb| :field-extraction ()
(stack-read2 iSP t1 t2 "get arg1 tag/data")
(ADDI t3 t1 #.(- |type$K-physicaladdress|))
(ANDI-DOT t3 t3 #x3F)
(branch-if-zero t3 pldbillop)
;; We don't use the tag here, but MEMORY-READ needs it
(memory-read t2 arg3 arg4 PROCESSORSTATE_RAW t3 t4 t5 t6)
(li t7 -1)
(ADDI arg1 arg1 1 "Size of field")
(SLD t4 arg4 arg2 "T4= shifted value if PP==0")
(srdi t5 t4 32 "T5= shifted value if PP<>0")
(SLD t7 t7 arg1 "Unmask")
(CMPI 0 1 arg2 0)
(BC 4 2 skip10 "B.NE")
(mov t5 t4 "T5= shifted value")
(unlikely-label skip10)
(ANDC t3 t5 t7 "T3= masked value.")
(GetNextPCandCP)
(stack-write-ir |TypeFixnum| t3 t4)
(ContinueToNextInstruction-NoStall)
(label pldbillop)
(SCAtoVMA iSP t1 t2)
(illegal-operand (memory-data-error data-read) t2 "Physical not supported"))
(define-instruction |DoPTagLdb| :field-extraction ()
(stack-read2 iSP t1 t2 "get arg1 tag/data")
(ADDI t3 t1 #.(- |type$K-physicaladdress|))
(ANDI-DOT t3 t3 #x3F)
(branch-if-zero t3 ptagldbillop)
;; We don't use the data here, but MEMORY-READ needs it
(memory-read t2 arg3 arg4 PROCESSORSTATE_RAW t3 t4 t5 t6 nil t)
(li t7 -1)
(ADDI arg1 arg1 1 "Size of field")
(SLD t4 arg3 arg2 "T4= shifted value if PP==0")
(srdi t5 t4 32 "T5= shifted value if PP<>0")
(SLD t7 t7 arg1 "Unmask")
(CMPI 0 1 arg2 0)
(BC 4 2 skip9 "B.NE")
(mov t5 t4 "T5= shifted value")
(unlikely-label skip9)
(ANDC t3 t5 t7 "T3= masked value.")
(GetNextPCandCP)
(stack-write-ir |TypeFixnum| t3 t4)
(ContinueToNextInstruction-NoStall)
(label ptagldbillop)
(SCAtoVMA iSP t1 t2)
(illegal-operand (memory-data-error data-read) t2 "Physical not supported"))
;;; arg1 new-value iSP-8
;;; arg2 integer iSP
;;; arg3 bytespec instn operand
(define-instruction |DoDpb| :field-extraction ()
(stack-pop2 t5 t6 "Get arg2 tag/data")
(stack-read2 iSP arg3 arg4 "get arg1 tag/data")
(binary-type-dispatch (t5 arg3 t1 t2 arg6 arg5)
((|TypeFixnum| |TypeFixnum|)
(li t7 -2) ;11111111111111111110
(SLD t7 t7 arg1 "Unmask") ;11111111111111110000
(NAND t5 t7 t7 "reuse t5 as mask") ;00000000000000001111
(ANDC t3 arg4 t7 "T3= masked new value.") ;unshifted new bits t3
(SLD t5 t5 arg2 "t5 is the inplace mask") ;00000001111000000 t5
(SLD t4 t3 arg2 "t4 is the shifted field") ;0000000bbbb000000 t4
(ANDC t6 t6 t5 "Clear out existing bits in arg2 field")
(OR t6 t4 t6 "Put the new bits in")
(GetNextPCandCP)
(stack-write-ir |TypeFixnum| t6 t4)
(ContinueToNextInstruction-NoStall))
(:else1
(NumericTypeException t5 dpb))
(:else2
(NumericTypeException arg3 dpb))))
(define-instruction |DoCharDpb| :field-extraction ()
(stack-pop2 t5 t6 "Get arg2 tag/data")
(stack-read2 iSP arg3 arg4 "get arg1 tag/data")
(binary-type-dispatch (t5 arg3 t1 t2 arg6 arg5)
((|TypeCharacter| |TypeFixnum|)
(li t7 -2) ;11111111111111111110
(SLD t7 t7 arg1 "Unmask") ;11111111111111110000
(NAND t5 t7 t7 "reuse t5 as mask") ;00000000000000001111
(ANDC t3 arg4 t7 "T3= masked new value.") ;unshifted new bits t3
(SLD t5 t5 arg2 "t5 is the inplace mask") ;00000001111000000 t5
(SLD t4 t3 arg2 "t4 is the shifted field") ;0000000bbbb000000 t4
(ANDC t6 t6 t5 "Clear out existing bits in arg2 field")
(OR t6 t4 t6 "Put the new bits in")
(GetNextPCandCP)
(stack-write-ir |TypeCharacter| t6 t4)
(ContinueToNextInstruction-NoStall))
(:else1
(SpareTypeException t5 char-dpb nil char-dpb-type-error))
(:else2
(illegal-operand char-dpb-type-error))))
(define-instruction |DoPDpb| :field-extraction ()
(stack-pop2 t1 t2 "Get arg2 tag/data")
(ADDI t3 t1 #.(- |type$K-physicaladdress|))
(ANDI-DOT t3 t3 #x3F)
(branch-if-zero t3 pdpbillop)
(stack-pop2 arg3 arg4 "get arg1 tag/data")
(memory-read t2 t8 t6 PROCESSORSTATE_RAW t3 t4 t1 t5)
(clrldi t6 t6 32)
(type-dispatch arg3 t1 t10
(|TypeFixnum|
(li t7 -2) ;11111111111111111110
(SLD t7 t7 arg1 "Unmask") ;11111111111111110000
(NAND t5 t7 t7 "reuse t5 as mask") ;00000000000000001111
(ANDC t3 arg4 t7 "T3= masked new value.") ;unshifted new bits t3
(SLD t5 t5 arg2 "t5 is the inplace mask") ;00000001111000000 t5
(SLD t4 t3 arg2 "t4 is the shifted field") ;0000000bbbb000000 t4
(ANDC t6 t6 t5 "Clear out existing bits in arg2 field")
(OR t6 t4 t6 "Put the new bits in")
(memory-write t2 t8 t6 PROCESSORSTATE_RAW t3 t4 t1 t5 t10
NextInstruction)
(ContinueToNextInstruction))
(:else
(illegal-operand %p-dpb-type-error)))
(label pdpbillop)
(SCAtoVMA iSP t1 t2)
(illegal-operand (memory-data-error data-read) t2 "Physical not supported"))
(define-instruction |DoPTagDpb| :field-extraction ()
(stack-pop2 t1 t2 "Get arg2 tag/data")
(ADDI t3 t1 #.(- |type$K-physicaladdress|))
(ANDI-DOT t3 t3 #x3F)
(branch-if-zero t3 ptagdpbillop)
(stack-pop2 arg3 arg4 "get arg1 tag/data")
(memory-read t2 t6 t8 PROCESSORSTATE_RAW t3 t4 t1 t5 nil t)
(type-dispatch arg3 t1 t10
(|TypeFixnum|
(li t7 -2) ;11111111111111111110
(SLD t7 t7 arg1 "Unmask") ;11111111111111110000
(NAND t5 t7 t7 "reuse t5 as mask") ;00000000000000001111
(ANDC t3 arg4 t7 "T3= masked new value.") ;unshifted new bits t3
(SLD t5 t5 arg2 "t5 is the inplace mask") ;00000001111000000 t5
(SLD t4 t3 arg2 "t4 is the shifted field") ;0000000bbbb000000 t4
(ANDC t6 t6 t5 "Clear out existing bits in arg2 field")
(OR t6 t4 t6 "Put the new bits in")
(memory-write t2 t6 t8 PROCESSORSTATE_RAW t3 t4 t1 t5 t10
NextInstruction)
(ContinueToNextInstruction))
(:else
(illegal-operand %p-dpb-type-error)))
(label ptagdpbillop)
(SCAtoVMA iSP t1 t2)
(illegal-operand (memory-data-error data-read) t2 "Physical not supported"))
(comment "Fin.")