author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 06 Jul 2016 22:40:59 +0100 | |
changeset 71 | ab03b0a6d037 |
parent 66 | 0125c050d0f1 |
permissions | -rw-r--r-- |
63
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
"{ Package: 'jv:llvm_s/tests' }" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
4 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
TestCase subclass:#LLVMIRBuilderTests |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
6 |
instanceVariableNames:'module' |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
7 |
classVariableNames:'' |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
8 |
poolDictionaries:'LLVMIntPredicate' |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
9 |
category:'LLVM-S-Core-Tests' |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
10 |
! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
11 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
12 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
13 |
!LLVMIRBuilderTests methodsFor:'running'! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
15 |
setUp |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
16 |
super setUp. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
18 |
module := LLVMModule newWithName: testSelector |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
"Modified (format): / 23-04-2016 / 23:08:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
tearDown |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
module := nil. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
26 |
super tearDown. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
"Modified: / 23-04-2016 / 23:08:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
29 |
! ! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
30 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
31 |
!LLVMIRBuilderTests methodsFor:'tests - terminators'! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
32 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
33 |
test_if_then_else_01a |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
34 |
| f fTy asm jit | |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
35 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
36 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
37 |
f := module addFunctionNamed: testSelector type: fTy. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
38 |
asm := f builder. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
39 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
40 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
41 |
asm ret: (LLVMConstant sintptr: 1) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
42 |
] else:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
43 |
asm ret: (LLVMConstant sintptr: 0) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
44 |
]. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
45 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
46 |
jit := LLVMExecutionEngine newForModule: module. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
47 |
self assert: ((jit externalOfFunction: f) callWith: 3) == 0. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
48 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
49 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
50 |
"Created: / 25-04-2016 / 23:26:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
51 |
! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
52 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
53 |
test_if_then_else_01b |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
54 |
| f fTy asm jit | |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
55 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
56 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
57 |
f := module addFunctionNamed: testSelector type: fTy. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
58 |
asm := f builder. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
59 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
60 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
61 |
asm ret: (LLVMConstant sintptr: 1) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
62 |
]. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
63 |
asm ret: (LLVMConstant sintptr: 0). |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
64 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
65 |
jit := LLVMExecutionEngine newForModule: module. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
66 |
self assert: ((jit externalOfFunction: f) callWith: 3) == 0. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
67 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
68 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
69 |
"Created: / 25-04-2016 / 23:26:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
70 |
! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
71 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
72 |
test_if_then_else_02a |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
73 |
| f fTy asm jit | |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
74 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
75 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
76 |
f := module addFunctionNamed: testSelector type: fTy. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
77 |
asm := f builder. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
78 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
79 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
80 |
asm ret: (LLVMConstant sintptr: 0) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
81 |
] else:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
82 |
asm if: (asm icmp: (f parameterAt:1) _: (LLVMConstant sintptr: 0) cond: LLVMIntSGT) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
83 |
asm ret: (LLVMConstant sintptr: 1) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
84 |
] else:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
85 |
asm ret: (LLVMConstant sintptr: -1) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
86 |
]. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
87 |
]. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
88 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
89 |
jit := LLVMExecutionEngine newForModule: module. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
90 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 0. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
91 |
self assert: ((jit externalOfFunction: f) callWith: 100) == 1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
92 |
self assert: ((jit externalOfFunction: f) callWith: -100) == -1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
93 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
94 |
"Created: / 25-04-2016 / 23:26:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
95 |
! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
96 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
97 |
test_if_then_else_02b |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
98 |
| f fTy asm jit | |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
99 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
100 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
101 |
f := module addFunctionNamed: testSelector type: fTy. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
102 |
asm := f builder. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
103 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
104 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
105 |
asm ret: (LLVMConstant sintptr: 0) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
106 |
] else:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
107 |
asm if: (asm icmp: (f parameterAt:1) _: (LLVMConstant sintptr: 0) cond: LLVMIntSGT) then:[ |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
108 |
asm ret: (LLVMConstant sintptr: 1) |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
109 |
] |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
110 |
]. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
111 |
asm ret: (LLVMConstant sintptr: -1). |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
112 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
113 |
jit := LLVMExecutionEngine newForModule: module. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
114 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 0. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
115 |
self assert: ((jit externalOfFunction: f) callWith: 100) == 1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
116 |
self assert: ((jit externalOfFunction: f) callWith: -100) == -1. |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
117 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
118 |
"Created: / 25-04-2016 / 23:27:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
66
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
119 |
! |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
120 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
121 |
test_if_then_else_02c |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
122 |
| f fTy asm jit | |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
123 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
124 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
125 |
f := module addFunctionNamed: testSelector type: fTy. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
126 |
asm := f builder. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
127 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
128 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
129 |
asm ret: (LLVMConstant sintptr: 0) |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
130 |
] else:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
131 |
asm if: (asm icmp: (f parameterAt:1) _: (LLVMConstant sintptr: 0) cond: LLVMIntSGT) then:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
132 |
asm ret: (LLVMConstant sintptr: 1) |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
133 |
] else:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
134 |
asm ret: (LLVMConstant sintptr: -1). |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
135 |
]. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
136 |
]. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
137 |
jit := LLVMExecutionEngine newForModule: module. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
138 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 0. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
139 |
self assert: ((jit externalOfFunction: f) callWith: 100) == 1. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
140 |
self assert: ((jit externalOfFunction: f) callWith: -100) == -1. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
141 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
142 |
"Created: / 18-06-2016 / 11:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
143 |
! |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
144 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
145 |
test_if_then_else_02d |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
146 |
| f fTy asm retval jit | |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
147 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
148 |
fTy := LLVMType function: { LLVMType intptr } returning: LLVMType intptr. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
149 |
f := module addFunctionNamed: testSelector type: fTy. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
150 |
asm := f builder. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
151 |
retval := asm alloca: LLVMType intptr. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
152 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
153 |
asm if: (asm icmp: (LLVMConstant sintptr: 0) _: (f parameterAt:1) cond: LLVMIntEQ) then:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
154 |
asm store: (LLVMConstant sintptr: 0) at: retval. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
155 |
] else:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
156 |
asm if: (asm icmp: (f parameterAt:1) _: (LLVMConstant sintptr: 0) cond: LLVMIntSGT) then:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
157 |
asm store: (LLVMConstant sintptr: 1) at: retval. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
158 |
] else:[ |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
159 |
asm store: (LLVMConstant sintptr: -1) at: retval. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
160 |
]. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
161 |
]. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
162 |
asm ret: (asm load: retval). |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
163 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
164 |
module verify. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
165 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
166 |
jit := LLVMExecutionEngine newForModule: module. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
167 |
self assert: ((jit externalOfFunction: f) callWith: 0) == 0. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
168 |
self assert: ((jit externalOfFunction: f) callWith: 100) == 1. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
169 |
self assert: ((jit externalOfFunction: f) callWith: -100) == -1. |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
170 |
|
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
171 |
"Created: / 18-06-2016 / 11:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0125c050d0f1
Fixed LLVMIRBuilder>>if:then:else: for nested ifs and complex branches.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
63
diff
changeset
|
172 |
"Modified: / 18-06-2016 / 16:51:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
63
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
173 |
! ! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
174 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
175 |
!LLVMIRBuilderTests class methodsFor:'documentation'! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
176 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
177 |
version_HG |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
178 |
|
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
179 |
^ '$Changeset: <not expanded> $' |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
180 |
! ! |
923ad3de94f3
Tests: Added LLBMIRBuilderTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
181 |