-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
174 lines (116 loc) · 5.03 KB
/
README
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
This is the llvmtcl extension based on the Tcl Extension Architecture (TEA).
Please see the webpage
http://github.com/jdc8/llvmtcl
or
http://wiki.tcl.tk/26308
for more details.
This package is a freely available open source package. You can do virtually
anything you like with it, such as modifying it, redistributing it, and selling
it either in whole or in part. See the file "license.terms" for complete
information.
REQUIREMENTS
============
- Tcl 8.6
- LLVM 3.7
CONTENTS
========
The following is a short description of the files you will find in
the sample extension.
Makefile.in Makefile template. The configure script uses this file to
produce the final Makefile.
README This file.
license.terms License info for thie package.
aclocal.m4 Generated file. Do not edit. Autoconf uses this as input
when generating the final configure script. See "tcl.m4"
below.
configure Generated file. Do not edit. This must be regenerated
anytime configure.in or tclconfig/tcl.m4 changes.
configure.in Configure script template. Autoconf uses this file as input
to produce the final configure script.
pkgIndex.tcl.in Package index template. The configure script will use
this file as input to create pkgIndex.tcl.
llvmtcl-gen.inp Input for llvmtcl-gen.tcl. It contains reformatted function
declarations of the llvm C API.
llvmtcl-gen.tcl Script to generate the Tcl API to the llvm C API. The
llvmtcl-gen.inp is the input for this script.
generic/ This directory contains various source files, some only
generated during compilation (i.e., after 'make').
llvmtcl.cpp File containing all non-generated parts of the Tcl
API to the LLVM C API. Also includes some sections
which can only be implemented using the LLVM C++ API.
llvmtcl.cpp File containing most non-generated parts of the Tcl
API to the LLVM C API. Also includes some sections
which can only be implemented using the LLVM C++ API.
llvmtcl.h File containing all the internal APIs of llvmtcl.
attributes.cpp File containing the Tcl API to the LLVM attribute
management code.
debuginfo.cpp File containing the Tcl API to the LLVM debugging
information generation code.
powidf2.cpp File continaing the implementation of one of the LLVM
intrinsics, needed on some platforms and with some
linkers.
testcode.cpp Code only used for testing purposes.
llvmtcl.tcl Scripts using the Tcl API to the llvm C API.
tests Some tests for the package.
tclconfig/ This directory contains various template files that build
the configure script. They should not need modification.
install-sh Program used for copying binaries and script files
to their install locations.
tcl.m4 Collection of Tcl autoconf macros. Included by
aclocal.m4 to define SC_* macros.
UNIX BUILD
==========
This is a C++ extension, so make sure to set the CC environment variable to a
c++ compiler (e.g. g++).
Building under most UNIX systems is easy, just run the configure script
and then run make. For more information about the build process, see
the tcl/unix/README file in the Tcl src dist. The following minimal
example will build and install the extension:
$ cd llvmtcl
$ ./configure --with-tcl=... --with-llvm-config=...
$ make
$ make test
$ make install
Add the llvm lib directory containing the llvm shared object files to the
LD_LIBRARY_PATH environment variable.
WINDOWS BUILD
=============
Not available.
INSTALLATION
============
The installation of a TEA package is structure like so:
$exec_prefix
/ \
lib bin
| |
PACKAGEx.y (dependent .dll files on Windows)
|
pkgIndex.tcl (.so|.dll files)
The main .so|.dll library file gets installed in the versioned PACKAGE
directory, which is OK on all platforms because it will be directly
referenced with by 'load' in the pkgIndex.tcl file. Dependent DLL files on
Windows must go in the bin directory (or other directory on the user's
PATH) in order for them to be found.
USING llvmtcl
=============
- to load the extension into a Tcl interpreter:
package require llvmtcl
- The package makes a llvmtcl ensemble command. The subcommands are the LLVM C
API functions with LLVM trimmed from the front. All supported types,
enumerators and functions can be found in:
http://github.com/jdc8/llvmtcl/blob/master/llvmtcl-gen.inp
- Functions taking a pointer argument followed by an unsigned argument to
specified the number of elements the pointer is pointing to are converted to
ensemble commands where the pointer and the unsigned argument are replaced by
a Tcl list.
EXAMPLES
========
examples/test.tcl
Example using the LLVM API to create a factorial function
examples/test2.tcl
Example using the LLVM API to create a function adding 4 and 6 to an
argument, optimize that function and execute it.
examples/tebc.tcl
Example converting Tcl into LLVM
examples/ffidle.tcl
Example calling functions in shared libraries