/
CogIA32CompilerForTests.class.st
86 lines (75 loc) · 2.68 KB
/
CogIA32CompilerForTests.class.st
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
Class {
#name : #CogIA32CompilerForTests,
#superclass : #CogIA32Compiler,
#category : #'VMMaker-OriginalTests'
}
{ #category : #'test support' }
CogIA32CompilerForTests class >> byteRegistersWithNamesDo: aBinaryBlock [
(self registers first: 4)
with: #('%al' '%cl' '%dl' '%bl')
do: aBinaryBlock
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> dataRegistersWithAccessorsDo: aTrinaryBlock [
self registers withIndexDo:
[:reg :i|
aTrinaryBlock
value: reg
value: (#(eax ecx edx ebx esp ebp esi edi) at: i)
value: (#(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: i)]
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> dataRegistersWithAccessorsExcept: accessorsToExclude do: aTrinaryBlock [
self registers withIndexDo:
[:reg :i| | getter setter |
getter := #(eax ecx edx ebx esp ebp esi edi) at: i.
setter := #(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: i.
(accessorsToExclude includes: getter) ifFalse:
[aTrinaryBlock value: reg value: getter value: setter]]
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> fp64RegistersWithAccessorsDo: aTrinaryBlock [
self fp64registers withIndexDo:
[:reg :i|
aTrinaryBlock
value: reg
value: (#(xmm0low xmm1low xmm2low xmm3low xmm4low xmm5low xmm6low xmm7low) at: i)
value: (#(xmm0low: xmm1low: xmm2low: xmm3low: xmm4low: xmm5low: xmm6low: xmm7low:) at: i)]
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> fp64registers [
^{ DPFPReg0. DPFPReg1. DPFPReg2. DPFPReg3. DPFPReg4. DPFPReg5. DPFPReg6. DPFPReg7 } "a.k.a. (-9 to: -16 by: -1)"
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> registers [
^(0 to: 7) "a.k.a. { EAX. ECX. EDX. EBX. ESP. EBP. ESI. EDI }"
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> registersWithNamesDo: aBinaryBlock [
self registers
with: #('%eax' '%ecx' '%edx' '%ebx' '%esp' '%ebp' '%esi' '%edi')
do: aBinaryBlock
]
{ #category : #'test support' }
CogIA32CompilerForTests class >> xmmRegistersWithNamesDo: aBinaryBlock [
{XMM0L. XMM1L. XMM2L. XMM3L. XMM4L. XMM5L. XMM6L. XMM7L}
with: #('%xmm0' '%xmm1' '%xmm2' '%xmm3' '%xmm4' '%xmm5' '%xmm6' '%xmm7')
do: aBinaryBlock
]
{ #category : #'generate machine code' }
CogIA32CompilerForTests >> concretizeAt: actualAddress [
"Override to check maxSize and machineCodeSize"
| result |
maxSize ifNil: [maxSize := self computeMaximumSize].
result := super concretizeAt: actualAddress.
self assert: (maxSize notNil
and: [self isPCDependent
ifTrue: [maxSize >= machineCodeSize]
ifFalse: [maxSize = machineCodeSize]]).
^result
]
{ #category : #testing }
CogIA32CompilerForTests >> hasSSE2Instructions [
"Answer if we support SSE2"
^true
]