Skip to content

Commit 3004fbe

Browse files
committed
Initial commit
0 parents  commit 3004fbe

File tree

5 files changed

+213
-0
lines changed

5 files changed

+213
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
llvm-*.src.tar.xz
2+
llvm-*/

LICENSE.txt

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
==============================================================================
2+
LLVM Release License
3+
==============================================================================
4+
University of Illinois/NCSA
5+
Open Source License
6+
7+
Copyright (c) 2003-2018 University of Illinois at Urbana-Champaign.
8+
All rights reserved.
9+
10+
Developed by:
11+
12+
LLVM Team
13+
14+
University of Illinois at Urbana-Champaign
15+
16+
http://llvm.org
17+
18+
Permission is hereby granted, free of charge, to any person obtaining a copy of
19+
this software and associated documentation files (the "Software"), to deal with
20+
the Software without restriction, including without limitation the rights to
21+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
22+
of the Software, and to permit persons to whom the Software is furnished to do
23+
so, subject to the following conditions:
24+
25+
* Redistributions of source code must retain the above copyright notice,
26+
this list of conditions and the following disclaimers.
27+
28+
* Redistributions in binary form must reproduce the above copyright notice,
29+
this list of conditions and the following disclaimers in the
30+
documentation and/or other materials provided with the distribution.
31+
32+
* Neither the names of the LLVM Team, University of Illinois at
33+
Urbana-Champaign, nor the names of its contributors may be used to
34+
endorse or promote products derived from this Software without specific
35+
prior written permission.
36+
37+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
39+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40+
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
43+
SOFTWARE.
44+
45+
==============================================================================
46+
Copyrights and Licenses for Third Party Software Distributed with LLVM:
47+
==============================================================================
48+
The LLVM software contains code written by third parties. Such software will
49+
have its own individual LICENSE.TXT file in the directory in which it appears.
50+
This file will describe the copyrights, license, and restrictions which apply
51+
to that code.
52+
53+
The disclaimer of warranty in the University of Illinois Open Source License
54+
applies to all code in the LLVM Distribution, and nothing in any of the
55+
other licenses gives permission to use the names of the LLVM Team or the
56+
University of Illinois to endorse or promote products derived from this
57+
Software.
58+
59+
The following pieces of software have additional or alternate copyrights,
60+
licenses, and/or restrictions:
61+
62+
Program Directory
63+
------- ---------
64+
Google Test llvm/utils/unittest/googletest
65+
OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex}
66+
pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT}
67+
ARM contributions llvm/lib/Target/ARM/LICENSE.TXT
68+
md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h

Makefile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
all: help
3+
4+
.PHONY: all help config update
5+
6+
COMPONENTS = all-targets analysis asmparser asmprinter bitreader bitwriter codegen core debuginfodwarf executionengine instrumentation interpreter ipo irreader linker mc mcjit objcarcopts option profiledata scalaropts support target
7+
8+
VERSION=7.0.0
9+
VERSION_MAJOR=$(firstword $(subst ., ,$(VERSION)))
10+
11+
SRCDIR=llvm-$(VERSION)
12+
13+
ifeq ($(BUILDDIR),)
14+
CONFIG=llvm-config-$(VERSION_MAJOR)
15+
else
16+
CONFIG=$(BUILDDIR)/bin/llvm-config
17+
endif
18+
19+
help:
20+
@echo "Use one of the following commands:"
21+
@echo " config: update llvm_config.go to use a locally installed LLVM version"
22+
@echo " update: update local .go/.cpp/.h files (see SRCDIR)"
23+
@echo " clean: remove local .go/.cpp/.h files"
24+
@echo " clean-all: remove all LLVM files, including downloads"
25+
@echo ""
26+
@echo "Provided flags:"
27+
@echo " VERSION=$(VERSION)"
28+
@echo " LLVM version to use"
29+
@echo " SRCDIR=$(SRCDIR)"
30+
@echo " LLVM sources root"
31+
@echo " BUILDDIR=$(BUILDDIR)"
32+
@echo " LLVM sources root"
33+
34+
config:
35+
@echo "package llvm" > llvm_config.go
36+
@echo "" >> llvm_config.go
37+
@echo "// Automatically generated by \`make config BUILDDIR=$(BUILDDIR)\`, do not edit." >> llvm_config.go
38+
@echo "" >> llvm_config.go
39+
@echo "// #cgo CPPFLAGS: $(shell $(CONFIG) --cppflags)" >> llvm_config.go
40+
@echo "// #cgo CXXFLAGS: -std=c++11" >> llvm_config.go
41+
@echo "// #cgo LDFLAGS: $(shell $(CONFIG) --ldflags --libs --system-libs $(COMPONENTS))" >> llvm_config.go
42+
@echo "import \"C\"" >> llvm_config.go
43+
@echo "" >> llvm_config.go
44+
@echo "type (run_build_sh int)" >> llvm_config.go
45+
46+
update: $(SRCDIR) clean
47+
@cp -rp "$(SRCDIR)"/bindings/go/llvm/*.go .
48+
@cp -rp "$(SRCDIR)"/bindings/go/llvm/*.cpp .
49+
@cp -rp "$(SRCDIR)"/bindings/go/llvm/*.h .
50+
51+
clean:
52+
@rm -f llvm_config.go
53+
@rm -f $(sort $(filter-out backport%,$(wildcard *.go)))
54+
@rm -f $(sort $(filter-out backport%,$(wildcard *.cpp)))
55+
@rm -f $(sort $(filter-out backport%,$(wildcard *.h)))
56+
57+
clean-all: clean
58+
@rm -rf llvm-$(VERSION)
59+
@rm -f llvm-$(VERSION).src.tar.xz
60+
61+
# Downlaod the given LLVM release.
62+
llvm-$(VERSION).src.tar.xz:
63+
wget -O llvm-$(VERSION).src.tar.xz http://releases.llvm.org/$(VERSION)/llvm-$(VERSION).src.tar.xz
64+
65+
# Extract the given LLVM release to a temporary directory.
66+
llvm-$(VERSION): llvm-$(VERSION).src.tar.xz
67+
mkdir -p $@
68+
tar -C $@ --strip-components=1 -xf $< $@.src

README.markdown

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Go bindings to system LLVM
2+
3+
This library provides bindings to a system-installed LLVM.
4+
5+
Currently supported:
6+
7+
* LLVM 7 from [apt.llvm.org](http://apt.llvm.org/) on Debian.
8+
9+
## Usage
10+
11+
If you have a supported LLVM installation, you should be able to do a simple `go get`:
12+
13+
go get github.com/aykevl/go-llvm
14+
15+
After downloading, you may have to update the configuration for your system:
16+
17+
make config
18+
19+
If you built your own LLVM, you can also use that:
20+
21+
# update LLVM files
22+
make update SRCDIR=<dir>
23+
24+
# configure this LLVM build
25+
make config BUILDDIR=<builddir>
26+
27+
Note that you may have to comment out parts of `backports.go` if you use a
28+
newer version of LLVM.
29+
30+
## License
31+
32+
Most of the files are extracted from the LLVM source tree, specifically all
33+
\*.go, \*.cpp, and \*.h files come directly from
34+
[bindings/go/llvm](https://github.com/llvm-mirror/llvm/tree/release_70/bindings/go/llvm)
35+
in the LLVM source tree. They are all released under the [University of
36+
Illinois/NCSA Open Source License](http://releases.llvm.org/7.0.0/LICENSE.TXT)
37+
which is a permissive BSD-like license. Check upstream LLVM for detailed
38+
copyright information.
39+
40+
This README, the backports\* files, and the Makefile are separate from LLVM but
41+
are licensed under the same license.

backports.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package llvm
2+
3+
// This file contains functions backported from LLVM master.
4+
5+
// #include "llvm-c/Core.h"
6+
// #include <stdlib.h>
7+
import "C"
8+
import "unsafe"
9+
10+
// Token type (used by coroutines)
11+
// https://reviews.llvm.org/D47684
12+
13+
const TokenTypeKind TypeKind = C.LLVMTokenTypeKind
14+
15+
func (c Context) TokenType() (t Type) { t.C = C.LLVMTokenTypeInContext(c.C); return }
16+
17+
// Inline assembly
18+
// https://reviews.llvm.org/D46437
19+
20+
type InlineAsmDialect C.LLVMInlineAsmDialect
21+
22+
const (
23+
InlineAsmDialectATT InlineAsmDialect = C.LLVMInlineAsmDialectATT
24+
InlineAsmDialectIntel InlineAsmDialect = C.LLVMInlineAsmDialectIntel
25+
)
26+
27+
func InlineAsm(t Type, asmString, constraints string, hasSideEffects, isAlignStack bool, dialect InlineAsmDialect) (rv Value) {
28+
casm := C.CString(asmString)
29+
defer C.free(unsafe.Pointer(casm))
30+
cconstraints := C.CString(constraints)
31+
defer C.free(unsafe.Pointer(cconstraints))
32+
rv.C = C.LLVMGetInlineAsm(t.C, casm, C.size_t(len(asmString)), cconstraints, C.size_t(len(constraints)), boolToLLVMBool(hasSideEffects), boolToLLVMBool(isAlignStack), C.LLVMInlineAsmDialect(dialect))
33+
return
34+
}

0 commit comments

Comments
 (0)