author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 10 Aug 2015 10:33:42 +0100 | |
changeset 23 | 0744cd9c0acc |
parent 22 | 789a35bd30ac |
child 24 | 7e7ddd55174c |
permissions | -rw-r--r-- |
14
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
1 |
" |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
2 |
Copyright (C) 2015-now Jan Vrany |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
3 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
4 |
This code is not an open-source (yet). You may use this code |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
5 |
for your own experiments and projects, given that: |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
6 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
7 |
* all modification to the code will be sent to the |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
8 |
original author for inclusion in future releases |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
9 |
* this is not used in any commercial software |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
10 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
11 |
This license is provisional and may (will) change in |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
12 |
a future. |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
13 |
" |
12
f98e97fd02ef
Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
14 |
"{ Package: 'jv:llvm_s' }" |
4 | 15 |
|
16 |
"{ NameSpace: Smalltalk }" |
|
17 |
||
18 |
LLVMValue subclass:#LLVMFunction |
|
5 | 19 |
instanceVariableNames:'numArgs' |
4 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
13
fa967c0e1827
Renamed class categories to begin with LLVM-S
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12
diff
changeset
|
22 |
category:'LLVM-S-Core' |
4 | 23 |
! |
24 |
||
14
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
25 |
!LLVMFunction class methodsFor:'documentation'! |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
26 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
27 |
copyright |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
28 |
" |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
29 |
Copyright (C) 2015-now Jan Vrany |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
30 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
31 |
This code is not an open-source (yet). You may use this code |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
32 |
for your own experiments and projects, given that: |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
33 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
34 |
* all modification to the code will be sent to the |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
35 |
original author for inclusion in future releases |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
36 |
* this is not used in any commercial software |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
37 |
|
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
38 |
This license is provisional and may (will) change in |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
39 |
a future. |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
40 |
" |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
41 |
! ! |
c7dea3fcc5a7
Added short README, license.txt and updated copyright information
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13
diff
changeset
|
42 |
|
4 | 43 |
!LLVMFunction methodsFor:'accessing'! |
44 |
||
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
45 |
builder |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
46 |
^ self entry builder |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
47 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
48 |
"Created: / 08-08-2015 / 03:17:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
49 |
! |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
50 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
51 |
entry |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
52 |
"Returns function's entry basic block" |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
53 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
54 |
| numBBs | |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
55 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
56 |
numBBs := LLVM CountBasicBlocks: self. |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
57 |
numBBs == 0 ifTrue:[ |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
58 |
^ self addBasicBlockNamed: 'entry'. |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
59 |
] ifFalse:[ |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
60 |
^ LLVM GetEntryBasicBlock: self. |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
61 |
] |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
62 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
63 |
"Created: / 08-08-2015 / 03:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
64 |
! |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
65 |
|
4 | 66 |
numArgs |
5 | 67 |
| last current | |
68 |
||
69 |
numArgs isNil ifTrue:[ |
|
70 |
numArgs := 0. |
|
71 |
"/ current := LLVM GetFirstParam: self. |
|
72 |
"/ last := LLVM GetLastParam: self. |
|
73 |
"/ [ current ~= last ] whileTrue:[ |
|
74 |
"/ numArgs := numArgs + 1. |
|
75 |
"/ current := LLVM GetNextFunction: current. |
|
76 |
"/ self halt. |
|
77 |
"/ ]. |
|
78 |
]. |
|
79 |
^ numArgs |
|
4 | 80 |
|
81 |
"Created: / 11-07-2015 / 09:42:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
5 | 82 |
"Modified: / 11-07-2015 / 11:23:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4 | 83 |
! |
84 |
||
85 |
parameterAt: index |
|
5 | 86 |
^ LLVM GetParam: self _: index - 1. |
4 | 87 |
|
88 |
"Created: / 07-07-2015 / 22:49:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
5 | 89 |
"Modified: / 11-07-2015 / 10:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4 | 90 |
! ! |
91 |
||
92 |
!LLVMFunction methodsFor:'functions-adding'! |
|
93 |
||
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
94 |
addBasicBlock |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
95 |
"Adds an (anonymous) basic block with given nane." |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
96 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
97 |
^ self addBasicBlockNamed: '' |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
98 |
|
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
99 |
"Created: / 08-08-2015 / 04:11:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
100 |
! |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
101 |
|
4 | 102 |
addBasicBlockNamed: name |
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
103 |
"Adds a basic block with given nane." |
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
104 |
|
5 | 105 |
| bb | |
106 |
||
4 | 107 |
self assert: name isSingleByteString. |
5 | 108 |
bb := LLVM AppendBasicBlock: self _: name. |
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
109 |
bb function: self. |
5 | 110 |
^ bb |
4 | 111 |
|
112 |
"Created: / 08-07-2015 / 23:09:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
113 |
"Modified (comment): / 08-08-2015 / 04:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4 | 114 |
! ! |
115 |
||
5 | 116 |
!LLVMFunction methodsFor:'initialization'! |
117 |
||
118 |
initialize |
|
119 |
super initialize. |
|
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
120 |
self initializeArgumentsNames. |
5 | 121 |
|
122 |
"Created: / 11-07-2015 / 10:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22
789a35bd30ac
Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
123 |
"Modified: / 08-08-2015 / 04:11:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
5 | 124 |
! |
125 |
||
126 |
initializeArgumentsNames |
|
127 |
1 to: self numArgs do:[:numArg | |
|
128 |
(self parameterAt: numArg) name: 'arg', numArg printString |
|
129 |
]. |
|
130 |
||
131 |
"Created: / 11-07-2015 / 10:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! ! |
|
133 |