<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 20, 2014 at 4:14 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">How are you invoking the compiler in your build (i.e. what are the values<br>
of config.host_cc and config.host_cxx in $builddir/test/lit.site.cfg)?<br></blockquote><div><br></div><div><div>config.host_cc = "/usr/local/google/home/blaikie/install/bin/clang "</div><div>config.host_cxx = "/usr/local/google/home/blaikie/install/bin/clang++ "</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Some of the Go tools are somewhat finicky about the exact format of the<br>
compiler command line and I've had to introduce a number of hacks to get it<br>
to deal with symlinks and ccache (see test/Bindings/Go/lit.local.cfg).<br>
<br>
Peter<br>
<br>
On Mon, Oct 20, 2014 at 04:03:32PM -0700, David Blaikie wrote:<br>
> Not sure what I might be missing here, but I'm seeing the following failure<br>
> due to a test in this patch:<br>
><br>
> cd /mnt/fast/dev/llvm/src/test/Bindings/Go/../../../bindings/go/llvm &&<br>
>  env<br>
> CGO_CPPFLAGS="$(.../llvm/build/clang/debug/split/notypes/nostandalone/./bin/llvm-config<br>
> --cppflags)"      CGO_CXXFLAGS=-std=c++11<br>
>  CGO_LDFLAGS="$(.../llvm/build/clang/debug/split/notypes/nostandalone/./bin/llvm-config<br>
> --ldflags --libs --system-libs<br>
> $(../build.sh --print-components))"      /usr/lib/google-golang/bin/go test<br>
> -tags byollvm .<br>
> --<br>
> Exit Code: 2<br>
><br>
> Command Output (stdout):<br>
> --<br>
> FAIL    _/mnt/fast/dev/llvm/src/bindings/go/llvm [build failed]<br>
><br>
> --<br>
> Command Output (stderr):<br>
> --<br>
> + llvm_components='all-targets analysis asmparser asmprinter bitreader<br>
> bitwriter codegen core debuginfo executionengine instrumentation<br>
> interpreter ipo irreader linker mc mcjit objcarcopts option profiledata<br>
> scalaropts support target '<br>
> + '[' --print-components = --print-components ']'<br>
> + echo all-targets analysis asmparser asmprinter bitreader bitwriter<br>
> codegen core debuginfo executionengine instrumentation interpreter ipo<br>
> irreader linker mc mcjit objcarcopts option profiledata scalaropts support<br>
> target<br>
> + exit 0<br>
> # _/mnt/fast/dev/llvm/src/bindings/go/llvm<br>
> ./analysis.go:23:28: type C.LLVMVerifierFailureAction: undefined C type<br>
> 'LLVMVerifierFailureAction'<br>
> ./analysis.go:27:45: unable to find value of constant<br>
> C.LLVMAbortProcessAction<br>
> ./analysis.go:29:45: unable to find value of constant<br>
> C.LLVMPrintMessageAction<br>
> ./analysis.go:31:45: unable to find value of constant<br>
> C.LLVMReturnStatusAction<br>
> ./analysis.go:37:12: type C.char: undefined C type 'char'<br>
> ./analysis.go:38:12: call of non-function C.LLVMVerifyModule<br>
> panic: runtime error: invalid memory address or nil pointer dereference<br>
> [signal 0xb code=0x1 addr=0x0 pc=0x40e2bc]<br>
><br>
> goroutine 16 [running]:<br>
> runtime.panic(0x5da020, 0x719a33)<br>
>         .../src/pkg/runtime/panic.c:279 +0xf5<br>
> main.(*Package).rewriteRef(0x4c2080011e0, 0x4c20804a100)<br>
>         .../src/cmd/cgo/gcc.go:610 +0x103c<br>
> main.(*Package).Translate(0x4c2080011e0, 0x4c20804a100)<br>
>         .../src/cmd/cgo/gcc.go:184 +0x16e<br>
> main.main()<br>
>         .../src/cmd/cgo/main.go:259 +0xef1<br>
><br>
> goroutine 19 [finalizer wait]:<br>
> runtime.park(0x44eec0, 0x71f478, 0x71dfc9)<br>
>         .../src/pkg/runtime/proc.c:1369 +0x89<br>
> runtime.parkunlock(0x71f478, 0x71dfc9)<br>
>         .../src/pkg/runtime/proc.c:1385 +0x3b<br>
> runfinq()<br>
>         .../src/pkg/runtime/mgc0.c:2644 +0xcf<br>
> runtime.goexit()<br>
>         .../src/pkg/runtime/proc.c:1445<br>
><br>
> --<br>
><br>
><br>
> On Thu, Oct 16, 2014 at 3:48 PM, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>><br>
> wrote:<br>
><br>
> > Author: pcc<br>
> > Date: Thu Oct 16 17:48:02 2014<br>
> > New Revision: 219976<br>
> ><br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=219976&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=219976&view=rev</a><br>
> > Log:<br>
> > Initial version of Go bindings.<br>
> ><br>
> > This code is based on the existing LLVM Go bindings project hosted at:<br>
> > <a href="https://github.com/go-llvm/llvm" target="_blank">https://github.com/go-llvm/llvm</a><br>
> ><br>
> > Note that all contributors to the gollvm project have agreed to relicense<br>
> > their changes under the LLVM license and submit them to the LLVM project.<br>
> ><br>
> > Differential Revision: <a href="http://reviews.llvm.org/D5684" target="_blank">http://reviews.llvm.org/D5684</a><br>
> ><br>
> > Added:<br>
> >     llvm/trunk/bindings/go/<br>
> >     llvm/trunk/bindings/go/README.txt<br>
> >     llvm/trunk/bindings/go/build.sh   (with props)<br>
> >     llvm/trunk/bindings/go/conftest.go<br>
> >     llvm/trunk/bindings/go/llvm/<br>
> >     llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp<br>
> >     llvm/trunk/bindings/go/llvm/DIBuilderBindings.h<br>
> >     llvm/trunk/bindings/go/llvm/IRBindings.cpp<br>
> >     llvm/trunk/bindings/go/llvm/IRBindings.h<br>
> >     llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp<br>
> >     llvm/trunk/bindings/go/llvm/InstrumentationBindings.h<br>
> >     llvm/trunk/bindings/go/llvm/SupportBindings.cpp<br>
> >     llvm/trunk/bindings/go/llvm/SupportBindings.h<br>
> >     llvm/trunk/bindings/go/llvm/analysis.go<br>
> >     llvm/trunk/bindings/go/llvm/bitreader.go<br>
> >     llvm/trunk/bindings/go/llvm/bitwriter.go<br>
> >     llvm/trunk/bindings/go/llvm/dibuilder.go<br>
> >     llvm/trunk/bindings/go/llvm/executionengine.go<br>
> >     llvm/trunk/bindings/go/llvm/executionengine_test.go<br>
> >     llvm/trunk/bindings/go/llvm/ir.go<br>
> >     llvm/trunk/bindings/go/llvm/ir_test.go<br>
> >     llvm/trunk/bindings/go/llvm/linker.go<br>
> >     llvm/trunk/bindings/go/llvm/<a href="http://llvm_config.go.in" target="_blank">llvm_config.go.in</a><br>
> >     llvm/trunk/bindings/go/llvm/llvm_dep.go<br>
> >     llvm/trunk/bindings/go/llvm/string.go<br>
> >     llvm/trunk/bindings/go/llvm/string_test.go<br>
> >     llvm/trunk/bindings/go/llvm/support.go<br>
> >     llvm/trunk/bindings/go/llvm/target.go<br>
> >     llvm/trunk/bindings/go/llvm/transforms_instrumentation.go<br>
> >     llvm/trunk/bindings/go/llvm/transforms_ipo.go<br>
> >     llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go<br>
> >     llvm/trunk/bindings/go/llvm/transforms_scalar.go<br>
> >     llvm/trunk/bindings/go/llvm/version.go<br>
> >     llvm/trunk/test/Bindings/Go/<br>
> >     llvm/trunk/test/Bindings/Go/go.test<br>
> >     llvm/trunk/test/Bindings/Go/lit.local.cfg<br>
> > Modified:<br>
> >     llvm/trunk/.gitignore<br>
> >     llvm/trunk/<a href="http://Makefile.config.in" target="_blank">Makefile.config.in</a><br>
> >     llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
> >     llvm/trunk/bindings/Makefile<br>
> >     llvm/trunk/cmake/config-ix.cmake<br>
> >     llvm/trunk/cmake/modules/AddLLVM.cmake<br>
> >     llvm/trunk/configure<br>
> >     llvm/trunk/test/Bindings/Ocaml/lit.local.cfg<br>
> >     llvm/trunk/test/Makefile<br>
> >     llvm/trunk/test/lit.cfg<br>
> >     llvm/trunk/test/<a href="http://lit.site.cfg.in" target="_blank">lit.site.cfg.in</a><br>
> >     llvm/trunk/utils/lit/lit/discovery.py<br>
> ><br>
> > Modified: llvm/trunk/.gitignore<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/.gitignore?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/.gitignore?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/.gitignore (original)<br>
> > +++ llvm/trunk/.gitignore Thu Oct 16 17:48:02 2014<br>
> > @@ -49,3 +49,9 @@ tools/lld<br>
> >  tools/polly<br>
> >  # Sphinx build tree, if building in-source dir.<br>
> >  docs/_build<br>
> > +<br>
> ><br>
> > +#==============================================================================#<br>
> > +# Files created in tree by the Go bindings.<br>
> ><br>
> > +#==============================================================================#<br>
> > +bindings/go/llvm/llvm_config.go<br>
> > +bindings/go/llvm/workdir<br>
> ><br>
> > Modified: llvm/trunk/<a href="http://Makefile.config.in" target="_blank">Makefile.config.in</a><br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/<a href="http://Makefile.config.in" target="_blank">Makefile.config.in</a> (original)<br>
> > +++ llvm/trunk/<a href="http://Makefile.config.in" target="_blank">Makefile.config.in</a> Thu Oct 16 17:48:02 2014<br>
> > @@ -202,6 +202,7 @@ DOT        := @DOT@<br>
> >  DOXYGEN    := @DOXYGEN@<br>
> >  GROFF      := @GROFF@<br>
> >  GZIPBIN    := @GZIPBIN@<br>
> > +GO         := @GO@<br>
> >  OCAMLC     := @OCAMLC@<br>
> >  OCAMLOPT   := @OCAMLOPT@<br>
> >  OCAMLDEP   := @OCAMLDEP@<br>
> ><br>
> > Modified: llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a> (original)<br>
> > +++ llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a> Thu Oct 16 17:48:02 2014<br>
> > @@ -1287,6 +1287,7 @@ AC_PATH_PROG(GROFF, [groff])<br>
> >  AC_PATH_PROG(GZIPBIN, [gzip])<br>
> >  AC_PATH_PROG(PDFROFF, [pdfroff])<br>
> >  AC_PATH_PROG(ZIP, [zip])<br>
> > +AC_PATH_PROG(GO, [go])<br>
> >  AC_PATH_PROGS(OCAMLC, [ocamlc])<br>
> >  AC_PATH_PROGS(OCAMLOPT, [ocamlopt])<br>
> >  AC_PATH_PROGS(OCAMLDEP, [ocamldep])<br>
> > @@ -1867,6 +1868,11 @@ if test "$BINDINGS_TO_BUILD" = auto ; th<br>
> >    if test "x$OCAMLC" != x -a "x$OCAMLDEP" != x ; then<br>
> >      BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD"<br>
> >    fi<br>
> > +  if test "x$GO" != x ; then<br>
> > +    if $GO run ${srcdir}/bindings/go/conftest.go ; then<br>
> > +      BINDINGS_TO_BUILD="go $BINDINGS_TO_BUILD"<br>
> > +    fi<br>
> > +  fi<br>
> >  fi<br>
> >  AC_SUBST(BINDINGS_TO_BUILD,$BINDINGS_TO_BUILD)<br>
> ><br>
> > @@ -1901,6 +1907,19 @@ for a_binding in $BINDINGS_TO_BUILD ; do<br>
> >        fi<br>
> >      fi<br>
> >      ;;<br>
> > +  go)<br>
> > +    if test "x$GO" = x ; then<br>
> > +      AC_MSG_WARN([--enable-bindings=go specified, but go not found. Try<br>
> > configure GO=/path/to/go])<br>
> > +      binding_prereqs_failed=1<br>
> > +    else<br>
> > +      if $GO run ${srcdir}/bindings/go/conftest.go ; then<br>
> > +        :<br>
> > +      else<br>
> > +        AC_MSG_WARN([--enable-bindings=go specified, but need at least Go<br>
> > 1.2. Try configure GO=/path/to/go])<br>
> > +        binding_prereqs_failed=1<br>
> > +      fi<br>
> > +    fi<br>
> > +    ;;<br>
> >    esac<br>
> >  done<br>
> >  if test "$binding_prereqs_failed" = 1 ; then<br>
> ><br>
> > Modified: llvm/trunk/bindings/Makefile<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/Makefile?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/Makefile?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/Makefile (original)<br>
> > +++ llvm/trunk/bindings/Makefile Thu Oct 16 17:48:02 2014<br>
> > @@ -11,6 +11,10 @@ LEVEL := ..<br>
> ><br>
> >  include $(LEVEL)/Makefile.config<br>
> ><br>
> > -PARALLEL_DIRS = $(BINDINGS_TO_BUILD)<br>
> > +PARALLEL_DIRS =<br>
> > +<br>
> > +ifneq (,$(filter ocaml,$(BINDINGS_TO_BUILD)))<br>
> > +PARALLEL_DIRS += ocaml<br>
> > +endif<br>
> ><br>
> >  include $(LEVEL)/Makefile.common<br>
> ><br>
> > Added: llvm/trunk/bindings/go/README.txt<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/README.txt?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/README.txt?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/README.txt (added)<br>
> > +++ llvm/trunk/bindings/go/README.txt Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,53 @@<br>
> > +This directory contains LLVM bindings for the Go programming language<br>
> > +(<a href="http://golang.org" target="_blank">http://golang.org</a>).<br>
> > +<br>
> > +Prerequisites<br>
> > +-------------<br>
> > +<br>
> > +* Go 1.2+.<br>
> > +* CMake (to build LLVM).<br>
> > +<br>
> > +Using the bindings<br>
> > +------------------<br>
> > +<br>
> > +The package path "<a href="http://llvm.org/llvm/bindings/go/llvm" target="_blank">llvm.org/llvm/bindings/go/llvm</a>" can be used to<br>
> > +import the latest development version of LLVM from SVN. Paths such as<br>
> > +"<a href="http://llvm.org/llvm.v36/bindings/go/llvm" target="_blank">llvm.org/llvm.v36/bindings/go/llvm</a>" refer to released versions of LLVM.<br>
> > +<br>
> > +It is recommended to use the "-d" flag with "go get" to download the<br>
> > +package or a dependency, as an additional step is required to build LLVM<br>
> > +(see "Building LLVM" below).<br>
> > +<br>
> > +Building LLVM<br>
> > +-------------<br>
> > +<br>
> > +The script "build.sh" in this directory can be used to build LLVM and<br>
> > prepare<br>
> > +it to be used by the bindings. If you receive an error message from "go<br>
> > build"<br>
> > +like this:<br>
> > +<br>
> > +    ./analysis.go:4:84: fatal error: llvm-c/Analysis.h: No such file or<br>
> > directory<br>
> > +     #include <llvm-c/Analysis.h> // If you are getting an error here<br>
> > read bindings/go/README.txt<br>
> > +<br>
> > +or like this:<br>
> > +<br>
> > +    ./llvm_dep.go:5: undefined: run_build_sh<br>
> > +<br>
> > +it means that LLVM needs to be built or updated by running the script.<br>
> > +<br>
> > +    $ $GOPATH/src/<a href="http://llvm.org/llvm/bindings/go/build.sh" target="_blank">llvm.org/llvm/bindings/go/build.sh</a><br>
> > +<br>
> > +Any command line arguments supplied to the script are passed to LLVM's<br>
> > CMake<br>
> > +build system. A good set of arguments to use during development are:<br>
> > +<br>
> > +    $ $GOPATH/src/<a href="http://llvm.org/llvm/bindings/go/build.sh" target="_blank">llvm.org/llvm/bindings/go/build.sh</a><br>
> > -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=host -DBUILD_SHARED_LIBS=ON<br>
> > +<br>
> > +Note that CMake keeps a cache of build settings so once you have built<br>
> > +LLVM there is no need to pass these arguments again after updating.<br>
> > +<br>
> > +Alternatively, you can build LLVM yourself, but you must then set the<br>
> > +CGO_CPPFLAGS, CGO_CXXFLAGS and CGO_LDFLAGS environment variables:<br>
> > +<br>
> > +    $ export CGO_CPPFLAGS="`/path/to/llvm-build/bin/llvm-config<br>
> > --cppflags`"<br>
> > +    $ export CGO_CXXFLAGS=-std=c++11<br>
> > +    $ export CGO_LDFLAGS="`/path/to/llvm-build/bin/llvm-config --ldflags<br>
> > --libs --system-libs all`"<br>
> > +    $ go build -tags byollvm<br>
> ><br>
> > Added: llvm/trunk/bindings/go/build.sh<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/build.sh?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/build.sh?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/build.sh (added)<br>
> > +++ llvm/trunk/bindings/go/build.sh Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,67 @@<br>
> > +#!/bin/sh -xe<br>
> > +<br>
> > +llvm_components="\<br>
> > +all-targets \<br>
> > +analysis \<br>
> > +asmparser \<br>
> > +asmprinter \<br>
> > +bitreader \<br>
> > +bitwriter \<br>
> > +codegen \<br>
> > +core \<br>
> > +debuginfo \<br>
> > +executionengine \<br>
> > +instrumentation \<br>
> > +interpreter \<br>
> > +ipo \<br>
> > +irreader \<br>
> > +linker \<br>
> > +mc \<br>
> > +mcjit \<br>
> > +objcarcopts \<br>
> > +option \<br>
> > +profiledata \<br>
> > +scalaropts \<br>
> > +support \<br>
> > +target \<br>
> > +"<br>
> > +<br>
> > +if [ "$1" == "--print-components" ] ; then<br>
> > +  echo $llvm_components<br>
> > +  exit 0<br>
> > +fi<br>
> > +<br>
> > +gollvmdir=$(dirname "$0")/llvm<br>
> > +<br>
> > +workdir=$gollvmdir/workdir<br>
> > +llvmdir=$gollvmdir/../../..<br>
> > +llvm_builddir=$workdir/llvm_build<br>
> > +<br>
> > +mkdir -p $llvm_builddir<br>
> > +<br>
> > +cmake_flags="../../../../.. $@"<br>
> > +llvm_config="$llvm_builddir/bin/llvm-config"<br>
> > +<br>
> > +if test -n "`which ninja`" ; then<br>
> > +  # If Ninja is available, we can speed up the build by building only the<br>
> > +  # required subset of LLVM.<br>
> > +  (cd $llvm_builddir && cmake -G Ninja $cmake_flags)<br>
> > +  ninja -C $llvm_builddir llvm-config<br>
> > +  llvm_buildtargets="$($llvm_config --libs $llvm_components | sed -e<br>
> > 's/-l//g')"<br>
> > +  ninja -C $llvm_builddir $llvm_buildtargets FileCheck<br>
> > +else<br>
> > +  (cd $llvm_builddir && cmake $cmake_flags)<br>
> > +  make -C $llvm_builddir -j4<br>
> > +fi<br>
> > +<br>
> > +llvm_version="$($llvm_config --version)"<br>
> > +llvm_cflags="$($llvm_config --cppflags)"<br>
> > +llvm_ldflags="$($llvm_config --ldflags) $($llvm_config --libs<br>
> > $llvm_components) $($llvm_config --system-libs)"<br>
> > +if [ $(uname) != "Darwin" ]; then<br>
> > +  # OS X doesn't like -rpath with cgo. See:<br>
> > +  # <a href="https://code.google.com/p/go/issues/detail?id=7293" target="_blank">https://code.google.com/p/go/issues/detail?id=7293</a><br>
> > +  llvm_ldflags="-Wl,-rpath,$($llvm_config --libdir) $llvm_ldflags"<br>
> > +fi<br>
> > +sed -e "s#@LLVM_CFLAGS@#$llvm_cflags#g; s#@LLVM_LDFLAGS@#$llvm_ldflags#g"<br>
> > $gollvmdir/<a href="http://llvm_config.go.in" target="_blank">llvm_config.go.in</a> > \<br>
> > +  $gollvmdir/llvm_config.go<br>
> > +printf "package llvm\n\nconst Version = \"%s\"\n" "$llvm_version" ><br>
> > $gollvmdir/version.go<br>
> ><br>
> > Propchange: llvm/trunk/bindings/go/build.sh<br>
> ><br>
> > ------------------------------------------------------------------------------<br>
> >     svn:executable = *<br>
> ><br>
> > Added: llvm/trunk/bindings/go/conftest.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/conftest.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/conftest.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/conftest.go (added)<br>
> > +++ llvm/trunk/bindings/go/conftest.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,16 @@<br>
> > +package main<br>
> > +<br>
> > +import (<br>
> > +       "go/build"<br>
> > +       "os"<br>
> > +)<br>
> > +<br>
> > +// Tests that the Go compiler is at least version 1.2.<br>
> > +func main() {<br>
> > +       for _, tag := range build.Default.ReleaseTags {<br>
> > +               if tag == "go1.2" {<br>
> > +                       os.Exit(0)<br>
> > +               }<br>
> > +       }<br>
> > +       os.Exit(1)<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp Thu Oct 16 17:48:02<br>
> > 2014<br>
> > @@ -0,0 +1,222 @@<br>
> > +//===- DIBuilderBindings.cpp - Bindings for DIBuilder<br>
> > ---------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines C bindings for the DIBuilder class.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#include "DIBuilderBindings.h"<br>
> > +<br>
> > +#include "llvm/IR/Module.h"<br>
> > +#include "llvm/IR/DIBuilder.h"<br>
> > +<br>
> > +using namespace llvm;<br>
> > +<br>
> > +namespace {<br>
> > +template <typename T><br>
> > +T unwrapDI(LLVMValueRef v) {<br>
> > +  return v ? T(unwrap<MDNode>(v)) : T();<br>
> > +}<br>
> > +}<br>
> > +<br>
> > +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)<br>
> > +<br>
> > +LLVMDIBuilderRef LLVMNewDIBuilder(LLVMModuleRef mref) {<br>
> > +  Module *m = unwrap(mref);<br>
> > +  return wrap(new DIBuilder(*m));<br>
> > +}<br>
> > +<br>
> > +void LLVMDIBuilderDestroy(LLVMDIBuilderRef dref) {<br>
> > +  DIBuilder *d = unwrap(dref);<br>
> > +  delete d;<br>
> > +}<br>
> > +<br>
> > +void LLVMDIBuilderFinalize(LLVMDIBuilderRef dref) {<br>
> > unwrap(dref)->finalize(); }<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef Dref,<br>
> > +                                            unsigned Lang, const char<br>
> > *File,<br>
> > +                                            const char *Dir,<br>
> > +                                            const char *Producer, int<br>
> > Optimized,<br>
> > +                                            const char *Flags,<br>
> > +                                            unsigned RuntimeVersion) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DICompileUnit CU = D->createCompileUnit(Lang, File, Dir, Producer,<br>
> > Optimized,<br>
> > +                                          Flags, RuntimeVersion);<br>
> > +  return wrap(CU);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Dref, const char<br>
> > *File,<br>
> > +                                     const char *Dir) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIFile F = D->createFile(File, Dir);<br>
> > +  return wrap(F);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref,<br>
> > +                                             LLVMValueRef Scope,<br>
> > +                                             LLVMValueRef File, unsigned<br>
> > Line,<br>
> > +                                             unsigned Column) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DILexicalBlock LB = D->createLexicalBlock(<br>
> > +      unwrapDI<DIDescriptor>(Scope), unwrapDI<DIFile>(File), Line,<br>
> > Column);<br>
> > +  return wrap(LB);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Dref,<br>
> > +                                                 LLVMValueRef Scope,<br>
> > +                                                 LLVMValueRef File,<br>
> > +                                                 unsigned Discriminator) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DILexicalBlockFile LBF = D->createLexicalBlockFile(<br>
> > +      unwrapDI<DIDescriptor>(Scope), unwrapDI<DIFile>(File),<br>
> > Discriminator);<br>
> > +  return wrap(LBF);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateFunction(<br>
> > +    LLVMDIBuilderRef Dref, LLVMValueRef Scope, const char *Name,<br>
> > +    const char *LinkageName, LLVMValueRef File, unsigned Line,<br>
> > +    LLVMValueRef CompositeType, int IsLocalToUnit, int IsDefinition,<br>
> > +    unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef<br>
> > Func) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DISubprogram SP = D->createFunction(<br>
> > +      unwrapDI<DIDescriptor>(Scope), Name, LinkageName,<br>
> > unwrapDI<DIFile>(File),<br>
> > +      Line, unwrapDI<DICompositeType>(CompositeType), IsLocalToUnit,<br>
> > +      IsDefinition, ScopeLine, Flags, IsOptimized,<br>
> > unwrap<Function>(Func));<br>
> > +  return wrap(SP);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLocalVariable(<br>
> > +    LLVMDIBuilderRef Dref, unsigned Tag, LLVMValueRef Scope, const char<br>
> > *Name,<br>
> > +    LLVMValueRef File, unsigned Line, LLVMValueRef Ty, int AlwaysPreserve,<br>
> > +    unsigned Flags, unsigned ArgNo) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIVariable V = D->createLocalVariable(<br>
> > +      Tag, unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File),<br>
> > Line,<br>
> > +      unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo);<br>
> > +  return wrap(V);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Dref,<br>
> > +                                          const char *Name, uint64_t<br>
> > SizeInBits,<br>
> > +                                          uint64_t AlignInBits,<br>
> > +                                          unsigned Encoding) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIBasicType T = D->createBasicType(Name, SizeInBits, AlignInBits,<br>
> > Encoding);<br>
> > +  return wrap(T);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Dref,<br>
> > +                                            LLVMValueRef PointeeType,<br>
> > +                                            uint64_t SizeInBits,<br>
> > +                                            uint64_t AlignInBits,<br>
> > +                                            const char *Name) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIDerivedType T = D->createPointerType(unwrapDI<DIType>(PointeeType),<br>
> > +                                         SizeInBits, AlignInBits, Name);<br>
> > +  return wrap(T);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Dref,<br>
> > +                                               LLVMValueRef File,<br>
> > +                                               LLVMValueRef<br>
> > ParameterTypes) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DICompositeType CT = D->createSubroutineType(<br>
> > +      unwrapDI<DIFile>(File), unwrapDI<DITypeArray>(ParameterTypes));<br>
> > +  return wrap(CT);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateStructType(<br>
> > +    LLVMDIBuilderRef Dref, LLVMValueRef Scope, const char *Name,<br>
> > +    LLVMValueRef File, unsigned Line, uint64_t SizeInBits, uint64_t<br>
> > AlignInBits,<br>
> > +    unsigned Flags, LLVMValueRef DerivedFrom, LLVMValueRef ElementTypes) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DICompositeType CT = D->createStructType(<br>
> > +      unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line,<br>
> > +      SizeInBits, AlignInBits, Flags, unwrapDI<DIType>(DerivedFrom),<br>
> > +      unwrapDI<DIArray>(ElementTypes));<br>
> > +  return wrap(CT);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateMemberType(<br>
> > +    LLVMDIBuilderRef Dref, LLVMValueRef Scope, const char *Name,<br>
> > +    LLVMValueRef File, unsigned Line, uint64_t SizeInBits, uint64_t<br>
> > AlignInBits,<br>
> > +    uint64_t OffsetInBits, unsigned Flags, LLVMValueRef Ty) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIDerivedType DT = D->createMemberType(<br>
> > +      unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), Line,<br>
> > +      SizeInBits, AlignInBits, OffsetInBits, Flags, unwrapDI<DIType>(Ty));<br>
> > +  return wrap(DT);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Dref,<br>
> > +                                          uint64_t SizeInBits,<br>
> > +                                          uint64_t AlignInBits,<br>
> > +                                          LLVMValueRef ElementType,<br>
> > +                                          LLVMValueRef Subscripts) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DICompositeType CT =<br>
> > +      D->createArrayType(SizeInBits, AlignInBits,<br>
> > unwrapDI<DIType>(ElementType),<br>
> > +                         unwrapDI<DIArray>(Subscripts));<br>
> > +  return wrap(CT);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,<br>
> > LLVMValueRef Ty,<br>
> > +                                        const char *Name, LLVMValueRef<br>
> > File,<br>
> > +                                        unsigned Line, LLVMValueRef<br>
> > Context) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIDerivedType DT =<br>
> > +      D->createTypedef(unwrapDI<DIType>(Ty), Name,<br>
> > unwrapDI<DIFile>(File), Line,<br>
> > +                       unwrapDI<DIDescriptor>(Context));<br>
> > +  return wrap(DT);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref,<br>
> > int64_t Lo,<br>
> > +                                              int64_t Count) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DISubrange S = D->getOrCreateSubrange(Lo, Count);<br>
> > +  return wrap(S);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref,<br>
> > +                                           LLVMValueRef *Data, size_t<br>
> > Length) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  Value **DataValue = unwrap(Data);<br>
> > +  ArrayRef<Value *> Elements(DataValue, Length);<br>
> > +  DIArray A = D->getOrCreateArray(Elements);<br>
> > +  return wrap(A);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref,<br>
> > +                                               LLVMValueRef *Data,<br>
> > +                                               size_t Length) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  Value **DataValue = unwrap(Data);<br>
> > +  ArrayRef<Value *> Elements(DataValue, Length);<br>
> > +  DITypeArray A = D->getOrCreateTypeArray(Elements);<br>
> > +  return wrap(A);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Dref, int64_t<br>
> > *Addr,<br>
> > +                                           size_t Length) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  DIExpression Expr = D->createExpression(ArrayRef<int64_t>(Addr,<br>
> > Length));<br>
> > +  return wrap(Expr);<br>
> > +}<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,<br>
> > +                                             LLVMValueRef Storage,<br>
> > +                                             LLVMValueRef VarInfo,<br>
> > +                                             LLVMValueRef Expr,<br>
> > +                                             LLVMBasicBlockRef Block) {<br>
> > +  DIBuilder *D = unwrap(Dref);<br>
> > +  Instruction *Instr =<br>
> > +      D->insertDeclare(unwrap(Storage), unwrapDI<DIVariable>(VarInfo),<br>
> > +                       unwrapDI<DIExpression>(Expr), unwrap(Block));<br>
> > +  return wrap(Instr);<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/DIBuilderBindings.h<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/DIBuilderBindings.h?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/DIBuilderBindings.h?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/DIBuilderBindings.h (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/DIBuilderBindings.h Thu Oct 16 17:48:02<br>
> > 2014<br>
> > @@ -0,0 +1,123 @@<br>
> > +//===- DIBuilderBindings.h - Bindings for DIBuilder -------------*- C++<br>
> > -*-===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines C bindings for the DIBuilder class.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#ifndef LLVM_BINDINGS_GO_LLVM_DIBUILDERBINDINGS_H<br>
> > +#define LLVM_BINDINGS_GO_LLVM_DIBUILDERBINDINGS_H<br>
> > +<br>
> > +#include "llvm-c/Core.h"<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +extern "C" {<br>
> > +#endif<br>
> > +<br>
> > +// FIXME: These bindings shouldn't be Go-specific and should eventually<br>
> > move to<br>
> > +// a (somewhat) less stable collection of C APIs for use in creating<br>
> > bindings of<br>
> > +// LLVM in other languages.<br>
> > +<br>
> > +typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef;<br>
> > +<br>
> > +LLVMDIBuilderRef LLVMNewDIBuilder(LLVMModuleRef m);<br>
> > +<br>
> > +void LLVMDIBuilderDestroy(LLVMDIBuilderRef d);<br>
> > +void LLVMDIBuilderFinalize(LLVMDIBuilderRef d);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef D,<br>
> > +                                            unsigned Language, const char<br>
> > *File,<br>
> > +                                            const char *Dir,<br>
> > +                                            const char *Producer, int<br>
> > Optimized,<br>
> > +                                            const char *Flags,<br>
> > +                                            unsigned RuntimeVersion);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef D, const char *File,<br>
> > +                                     const char *Dir);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef D,<br>
> > +                                             LLVMValueRef Scope,<br>
> > +                                             LLVMValueRef File, unsigned<br>
> > Line,<br>
> > +                                             unsigned Column);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef D,<br>
> > +                                                 LLVMValueRef Scope,<br>
> > +                                                 LLVMValueRef File,<br>
> > +                                                 unsigned Discriminator);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateFunction(<br>
> > +    LLVMDIBuilderRef D, LLVMValueRef Scope, const char *Name,<br>
> > +    const char *LinkageName, LLVMValueRef File, unsigned Line,<br>
> > +    LLVMValueRef CompositeType, int IsLocalToUnit, int IsDefinition,<br>
> > +    unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef<br>
> > Function);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateLocalVariable(<br>
> > +    LLVMDIBuilderRef D, unsigned Tag, LLVMValueRef Scope, const char<br>
> > *Name,<br>
> > +    LLVMValueRef File, unsigned Line, LLVMValueRef Ty, int AlwaysPreserve,<br>
> > +    unsigned Flags, unsigned ArgNo);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef D, const char<br>
> > *Name,<br>
> > +                                          uint64_t SizeInBits,<br>
> > +                                          uint64_t AlignInBits,<br>
> > +                                          unsigned Encoding);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef D,<br>
> > +                                            LLVMValueRef PointeeType,<br>
> > +                                            uint64_t SizeInBits,<br>
> > +                                            uint64_t AlignInBits,<br>
> > +                                            const char *Name);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef D,<br>
> > +                                               LLVMValueRef File,<br>
> > +                                               LLVMValueRef<br>
> > ParameterTypes);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateStructType(<br>
> > +    LLVMDIBuilderRef D, LLVMValueRef Scope, const char *Name,<br>
> > LLVMValueRef File,<br>
> > +    unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits, unsigned<br>
> > Flags,<br>
> > +    LLVMValueRef DerivedFrom, LLVMValueRef ElementTypes);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateMemberType(<br>
> > +    LLVMDIBuilderRef D, LLVMValueRef Scope, const char *Name,<br>
> > LLVMValueRef File,<br>
> > +    unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,<br>
> > +    uint64_t OffsetInBits, unsigned Flags, LLVMValueRef Ty);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef D,<br>
> > +                                          uint64_t SizeInBits,<br>
> > +                                          uint64_t AlignInBits,<br>
> > +                                          LLVMValueRef ElementType,<br>
> > +                                          LLVMValueRef Subscripts);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef D, LLVMValueRef<br>
> > Ty,<br>
> > +                                        const char *Name, LLVMValueRef<br>
> > File,<br>
> > +                                        unsigned Line, LLVMValueRef<br>
> > Context);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef D, int64_t<br>
> > Lo,<br>
> > +                                              int64_t Count);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef D,<br>
> > +                                           LLVMValueRef *Data, size_t<br>
> > Length);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef D,<br>
> > +                                               LLVMValueRef *Data,<br>
> > +                                               size_t Length);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Dref, int64_t<br>
> > *Addr,<br>
> > +                                           size_t Length);<br>
> > +<br>
> > +LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef D,<br>
> > +                                             LLVMValueRef Storage,<br>
> > +                                             LLVMValueRef VarInfo,<br>
> > +                                             LLVMValueRef Expr,<br>
> > +                                             LLVMBasicBlockRef Block);<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +}  // extern "C"<br>
> > +#endif<br>
> > +<br>
> > +#endif<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/IRBindings.cpp<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.cpp?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.cpp?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/IRBindings.cpp (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/IRBindings.cpp Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,47 @@<br>
> > +//===- IRBindings.cpp - Additional bindings for ir<br>
> > ------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines additional C bindings for the ir component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#include "IRBindings.h"<br>
> > +<br>
> > +#include "llvm/IR/Attributes.h"<br>
> > +#include "llvm/IR/Function.h"<br>
> > +<br>
> > +using namespace llvm;<br>
> > +<br>
> > +void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {<br>
> > +  Function *Func = unwrap<Function>(Fn);<br>
> > +  const AttributeSet PAL = Func->getAttributes();<br>
> > +  AttrBuilder B(PA);<br>
> > +  const AttributeSet PALnew =<br>
> > +    PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,<br>
> > +                      AttributeSet::get(Func->getContext(),<br>
> > +                                        AttributeSet::FunctionIndex, B));<br>
> > +  Func->setAttributes(PALnew);<br>
> > +}<br>
> > +<br>
> > +uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn) {<br>
> > +  Function *Func = unwrap<Function>(Fn);<br>
> > +  const AttributeSet PAL = Func->getAttributes();<br>
> > +  return PAL.Raw(AttributeSet::FunctionIndex);<br>
> > +}<br>
> > +<br>
> > +void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA) {<br>
> > +  Function *Func = unwrap<Function>(Fn);<br>
> > +  const AttributeSet PAL = Func->getAttributes();<br>
> > +  AttrBuilder B(PA);<br>
> > +  const AttributeSet PALnew =<br>
> > +    PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex,<br>
> > +                         AttributeSet::get(Func->getContext(),<br>
> > +                                           AttributeSet::FunctionIndex,<br>
> > B));<br>
> > +  Func->setAttributes(PALnew);<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/IRBindings.h<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.h?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.h?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/IRBindings.h (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/IRBindings.h Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,37 @@<br>
> > +//===- IRBindings.h - Additional bindings for IR ----------------*- C++<br>
> > -*-===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines additional C bindings for the IR component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#ifndef LLVM_BINDINGS_GO_LLVM_IRBINDINGS_H<br>
> > +#define LLVM_BINDINGS_GO_LLVM_IRBINDINGS_H<br>
> > +<br>
> > +#include "llvm-c/Core.h"<br>
> > +#include <stdint.h><br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +extern "C" {<br>
> > +#endif<br>
> > +<br>
> > +// These functions duplicate the LLVM*FunctionAttr functions in the<br>
> > stable C<br>
> > +// API. We cannot use the existing functions because they take 32-bit<br>
> > attribute<br>
> > +// values, and the Go bindings expose all of the LLVM attributes, some of<br>
> > which<br>
> > +// have values >= 1<<32.<br>
> > +<br>
> > +void LLVMAddFunctionAttr2(LLVMValueRef Fn, uint64_t PA);<br>
> > +uint64_t LLVMGetFunctionAttr2(LLVMValueRef Fn);<br>
> > +void LLVMRemoveFunctionAttr2(LLVMValueRef Fn, uint64_t PA);<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +}<br>
> > +#endif<br>
> > +<br>
> > +#endif<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/InstrumentationBindings.cpp Thu Oct 16<br>
> > 17:48:02 2014<br>
> > @@ -0,0 +1,42 @@<br>
> > +//===- InstrumentationBindings.cpp - instrumentation bindings<br>
> > -------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines C bindings for the instrumentation component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#include "InstrumentationBindings.h"<br>
> > +<br>
> > +#include "llvm-c/Core.h"<br>
> > +#include "llvm/IR/Module.h"<br>
> > +#include "llvm/PassManager.h"<br>
> > +#include "llvm/Transforms/Instrumentation.h"<br>
> > +<br>
> > +using namespace llvm;<br>
> > +<br>
> > +void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM) {<br>
> > +  unwrap(PM)->add(createAddressSanitizerFunctionPass());<br>
> > +}<br>
> > +<br>
> > +void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM) {<br>
> > +  unwrap(PM)->add(createAddressSanitizerModulePass());<br>
> > +}<br>
> > +<br>
> > +void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) {<br>
> > +  unwrap(PM)->add(createThreadSanitizerPass());<br>
> > +}<br>
> > +<br>
> > +void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM) {<br>
> > +  unwrap(PM)->add(createMemorySanitizerPass());<br>
> > +}<br>
> > +<br>
> > +void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,<br>
> > +                                  const char *ABIListFile) {<br>
> > +  unwrap(PM)->add(createDataFlowSanitizerPass(ABIListFile));<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/InstrumentationBindings.h<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/InstrumentationBindings.h?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/InstrumentationBindings.h?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/InstrumentationBindings.h (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/InstrumentationBindings.h Thu Oct 16<br>
> > 17:48:02 2014<br>
> > @@ -0,0 +1,38 @@<br>
> > +//===- InstrumentationBindings.h - instrumentation bindings -----*- C++<br>
> > -*-===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines C bindings for the Transforms/Instrumentation<br>
> > component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#ifndef LLVM_BINDINGS_GO_LLVM_INSTRUMENTATIONBINDINGS_H<br>
> > +#define LLVM_BINDINGS_GO_LLVM_INSTRUMENTATIONBINDINGS_H<br>
> > +<br>
> > +#include "llvm-c/Core.h"<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +extern "C" {<br>
> > +#endif<br>
> > +<br>
> > +// FIXME: These bindings shouldn't be Go-specific and should eventually<br>
> > move to<br>
> > +// a (somewhat) less stable collection of C APIs for use in creating<br>
> > bindings of<br>
> > +// LLVM in other languages.<br>
> > +<br>
> > +void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM);<br>
> > +void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM);<br>
> > +void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM);<br>
> > +void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM);<br>
> > +void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,<br>
> > +                                  const char *ABIListFile);<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +}<br>
> > +#endif<br>
> > +<br>
> > +#endif<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/SupportBindings.cpp<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/SupportBindings.cpp?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/SupportBindings.cpp?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/SupportBindings.cpp (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/SupportBindings.cpp Thu Oct 16 17:48:02<br>
> > 2014<br>
> > @@ -0,0 +1,27 @@<br>
> > +//===- SupportBindings.cpp - Additional bindings for support<br>
> > --------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines additional C bindings for the support component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#include "SupportBindings.h"<br>
> > +<br>
> > +#include "llvm/Support/DynamicLibrary.h"<br>
> > +#include <stdlib.h><br>
> > +#include <string.h><br>
> > +<br>
> > +void LLVMLoadLibraryPermanently2(const char *Filename, char **ErrMsg) {<br>
> > +  std::string ErrMsgStr;<br>
> > +  if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Filename,<br>
> > &ErrMsgStr)) {<br>
> > +    *ErrMsg = static_cast<char *>(malloc(ErrMsgStr.size() + 1));<br>
> > +    memcpy(static_cast<void *>(*ErrMsg),<br>
> > +           static_cast<const void *>(ErrMsgStr.c_str()), ErrMsgStr.size()<br>
> > + 1);<br>
> > +  }<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/SupportBindings.h<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/SupportBindings.h?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/SupportBindings.h?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/SupportBindings.h (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/SupportBindings.h Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,30 @@<br>
> > +//===- SupportBindings.h - Additional bindings for Support ------*- C++<br>
> > -*-===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines additional C bindings for the Support component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +#ifndef LLVM_BINDINGS_GO_LLVM_SUPPORTBINDINGS_H<br>
> > +#define LLVM_BINDINGS_GO_LLVM_SUPPORTBINDINGS_H<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +extern "C" {<br>
> > +#endif<br>
> > +<br>
> > +// This function duplicates the LLVMLoadLibraryPermanently function in the<br>
> > +// stable C API and adds an extra ErrMsg parameter to retrieve the error<br>
> > +// message.<br>
> > +void LLVMLoadLibraryPermanently2(const char *Filename, char **ErrMsg);<br>
> > +<br>
> > +#ifdef __cplusplus<br>
> > +}<br>
> > +#endif<br>
> > +<br>
> > +#endif<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/analysis.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/analysis.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/analysis.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/analysis.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/analysis.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,68 @@<br>
> > +//===- analysis.go - Bindings for analysis<br>
> > --------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the analysis component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Analysis.h" // If you are getting an error here read<br>
> > bindings/go/README.txt<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "errors"<br>
> > +<br>
> > +type VerifierFailureAction C.LLVMVerifierFailureAction<br>
> > +<br>
> > +const (<br>
> > +       // verifier will print to stderr and abort()<br>
> > +       AbortProcessAction VerifierFailureAction = C.LLVMAbortProcessAction<br>
> > +       // verifier will print to stderr and return 1<br>
> > +       PrintMessageAction VerifierFailureAction = C.LLVMPrintMessageAction<br>
> > +       // verifier will just return 1<br>
> > +       ReturnStatusAction VerifierFailureAction = C.LLVMReturnStatusAction<br>
> > +)<br>
> > +<br>
> > +// Verifies that a module is valid, taking the specified action if not.<br>
> > +// Optionally returns a human-readable description of any invalid<br>
> > constructs.<br>
> > +func VerifyModule(m Module, a VerifierFailureAction) error {<br>
> > +       var cmsg *C.char<br>
> > +       broken := C.LLVMVerifyModule(m.C, C.LLVMVerifierFailureAction(a),<br>
> > &cmsg)<br>
> > +<br>
> > +       // C++'s verifyModule means isModuleBroken, so it returns false if<br>
> > +       // there are no errors<br>
> > +       if broken != 0 {<br>
> > +               err := errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +               return err<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +var verifyFunctionError = errors.New("Function is broken")<br>
> > +<br>
> > +// Verifies that a single function is valid, taking the specified action.<br>
> > +// Useful for debugging.<br>
> > +func VerifyFunction(f Value, a VerifierFailureAction) error {<br>
> > +       broken := C.LLVMVerifyFunction(f.C, C.LLVMVerifierFailureAction(a))<br>
> > +<br>
> > +       // C++'s verifyFunction means isFunctionBroken, so it returns<br>
> > false if<br>
> > +       // there are no errors<br>
> > +       if broken != 0 {<br>
> > +               return verifyFunctionError<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +// Open up a ghostview window that displays the CFG of the current<br>
> > function.<br>
> > +// Useful for debugging.<br>
> > +func ViewFunctionCFG(f Value)     { C.LLVMViewFunctionCFG(f.C) }<br>
> > +func ViewFunctionCFGOnly(f Value) { C.LLVMViewFunctionCFGOnly(f.C) }<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/bitreader.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/bitreader.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/bitreader.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/bitreader.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/bitreader.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,50 @@<br>
> > +//===- bitreader.go - Bindings for bitreader<br>
> > ------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the bitreader component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/BitReader.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +import (<br>
> > +       "errors"<br>
> > +       "unsafe"<br>
> > +)<br>
> > +<br>
> > +// ParseBitcodeFile parses the LLVM IR (bitcode) in the file with the<br>
> > +// specified name, and returns a new LLVM module.<br>
> > +func ParseBitcodeFile(name string) (Module, error) {<br>
> > +       var buf C.LLVMMemoryBufferRef<br>
> > +       var errmsg *C.char<br>
> > +       var cfilename *C.char = C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cfilename))<br>
> > +       result := C.LLVMCreateMemoryBufferWithContentsOfFile(cfilename,<br>
> > &buf, &errmsg)<br>
> > +       if result != 0 {<br>
> > +               err := errors.New(C.GoString(errmsg))<br>
> > +               C.free(unsafe.Pointer(errmsg))<br>
> > +               return Module{}, err<br>
> > +       }<br>
> > +       defer C.LLVMDisposeMemoryBuffer(buf)<br>
> > +<br>
> > +       var m Module<br>
> > +       if C.LLVMParseBitcode(buf, &m.C, &errmsg) == 0 {<br>
> > +               return m, nil<br>
> > +       }<br>
> > +<br>
> > +       err := errors.New(C.GoString(errmsg))<br>
> > +       C.free(unsafe.Pointer(errmsg))<br>
> > +       return Module{}, err<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/bitwriter.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/bitwriter.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/bitwriter.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/bitwriter.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/bitwriter.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,39 @@<br>
> > +//===- bitwriter.go - Bindings for bitwriter<br>
> > ------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the bitwriter component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/BitWriter.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "os"<br>
> > +import "errors"<br>
> > +<br>
> > +var writeBitcodeToFileErr = errors.New("Failed to write bitcode to file")<br>
> > +<br>
> > +func WriteBitcodeToFile(m Module, file *os.File) error {<br>
> > +       fail := C.LLVMWriteBitcodeToFD(m.C, C.int(file.Fd()), C.int(0),<br>
> > C.int(0))<br>
> > +       if fail != 0 {<br>
> > +               return writeBitcodeToFileErr<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +func WriteBitcodeToMemoryBuffer(m Module) MemoryBuffer {<br>
> > +       mb := C.LLVMWriteBitcodeToMemoryBuffer(m.C)<br>
> > +       return MemoryBuffer{mb}<br>
> > +}<br>
> > +<br>
> > +// TODO(nsf): Figure out way how to make it work with io.Writer<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/dibuilder.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/dibuilder.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/dibuilder.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/dibuilder.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/dibuilder.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,492 @@<br>
> > +//===- dibuilder.go - Bindings for DIBuilder<br>
> > ------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the DIBuilder class.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "DIBuilderBindings.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +import (<br>
> > +       "debug/dwarf"<br>
> > +       "unsafe"<br>
> > +)<br>
> > +<br>
> > +type DwarfTag uint32<br>
> > +<br>
> > +const (<br>
> > +       DW_TAG_lexical_block   DwarfTag = 0x0b<br>
> > +       DW_TAG_compile_unit    DwarfTag = 0x11<br>
> > +       DW_TAG_variable        DwarfTag = 0x34<br>
> > +       DW_TAG_base_type       DwarfTag = 0x24<br>
> > +       DW_TAG_pointer_type    DwarfTag = 0x0F<br>
> > +       DW_TAG_structure_type  DwarfTag = 0x13<br>
> > +       DW_TAG_subroutine_type DwarfTag = 0x15<br>
> > +       DW_TAG_file_type       DwarfTag = 0x29<br>
> > +       DW_TAG_subprogram      DwarfTag = 0x2E<br>
> > +       DW_TAG_auto_variable   DwarfTag = 0x100<br>
> > +       DW_TAG_arg_variable    DwarfTag = 0x101<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       FlagPrivate = 1 << iota<br>
> > +       FlagProtected<br>
> > +       FlagFwdDecl<br>
> > +       FlagAppleBlock<br>
> > +       FlagBlockByrefStruct<br>
> > +       FlagVirtual<br>
> > +       FlagArtificial<br>
> > +       FlagExplicit<br>
> > +       FlagPrototyped<br>
> > +       FlagObjcClassComplete<br>
> > +       FlagObjectPointer<br>
> > +       FlagVector<br>
> > +       FlagStaticMember<br>
> > +       FlagIndirectVariable<br>
> > +)<br>
> > +<br>
> > +type DwarfLang uint32<br>
> > +<br>
> > +const (<br>
> > +       // <a href="http://dwarfstd.org/ShowIssue.php?issue=101014.1&type=open" target="_blank">http://dwarfstd.org/ShowIssue.php?issue=101014.1&type=open</a><br>
> > +       DW_LANG_Go DwarfLang = 0x0016<br>
> > +)<br>
> > +<br>
> > +type DwarfTypeEncoding uint32<br>
> > +<br>
> > +const (<br>
> > +       DW_ATE_address         DwarfTypeEncoding = 0x01<br>
> > +       DW_ATE_boolean         DwarfTypeEncoding = 0x02<br>
> > +       DW_ATE_complex_float   DwarfTypeEncoding = 0x03<br>
> > +       DW_ATE_float           DwarfTypeEncoding = 0x04<br>
> > +       DW_ATE_signed          DwarfTypeEncoding = 0x05<br>
> > +       DW_ATE_signed_char     DwarfTypeEncoding = 0x06<br>
> > +       DW_ATE_unsigned        DwarfTypeEncoding = 0x07<br>
> > +       DW_ATE_unsigned_char   DwarfTypeEncoding = 0x08<br>
> > +       DW_ATE_imaginary_float DwarfTypeEncoding = 0x09<br>
> > +       DW_ATE_packed_decimal  DwarfTypeEncoding = 0x0a<br>
> > +       DW_ATE_numeric_string  DwarfTypeEncoding = 0x0b<br>
> > +       DW_ATE_edited          DwarfTypeEncoding = 0x0c<br>
> > +       DW_ATE_signed_fixed    DwarfTypeEncoding = 0x0d<br>
> > +       DW_ATE_unsigned_fixed  DwarfTypeEncoding = 0x0e<br>
> > +       DW_ATE_decimal_float   DwarfTypeEncoding = 0x0f<br>
> > +       DW_ATE_UTF             DwarfTypeEncoding = 0x10<br>
> > +       DW_ATE_lo_user         DwarfTypeEncoding = 0x80<br>
> > +       DW_ATE_hi_user         DwarfTypeEncoding = 0xff<br>
> > +)<br>
> > +<br>
> > +// DIBuilder is a wrapper for the LLVM DIBuilder class.<br>
> > +type DIBuilder struct {<br>
> > +       ref C.LLVMDIBuilderRef<br>
> > +       m   Module<br>
> > +}<br>
> > +<br>
> > +// NewDIBuilder creates a new DIBuilder, associated with the given module.<br>
> > +func NewDIBuilder(m Module) *DIBuilder {<br>
> > +       d := C.LLVMNewDIBuilder(m.C)<br>
> > +       return &DIBuilder{ref: d, m: m}<br>
> > +}<br>
> > +<br>
> > +// Destroy destroys the DIBuilder.<br>
> > +func (d *DIBuilder) Destroy() {<br>
> > +       C.LLVMDIBuilderDestroy(d.ref)<br>
> > +}<br>
> > +<br>
> > +// FInalize finalizes the debug information generated by the DIBuilder.<br>
> > +func (d *DIBuilder) Finalize() {<br>
> > +       C.LLVMDIBuilderFinalize(d.ref)<br>
> > +}<br>
> > +<br>
> > +// DICompileUnit holds the values for creating compile unit debug<br>
> > metadata.<br>
> > +type DICompileUnit struct {<br>
> > +       Language       DwarfLang<br>
> > +       File           string<br>
> > +       Dir            string<br>
> > +       Producer       string<br>
> > +       Optimized      bool<br>
> > +       Flags          string<br>
> > +       RuntimeVersion int<br>
> > +}<br>
> > +<br>
> > +// CreateCompileUnit creates compile unit debug metadata.<br>
> > +func (d *DIBuilder) CreateCompileUnit(cu DICompileUnit) Value {<br>
> > +       file := C.CString(cu.File)<br>
> > +       defer C.free(unsafe.Pointer(file))<br>
> > +       dir := C.CString(cu.Dir)<br>
> > +       defer C.free(unsafe.Pointer(dir))<br>
> > +       producer := C.CString(cu.Producer)<br>
> > +       defer C.free(unsafe.Pointer(producer))<br>
> > +       flags := C.CString(cu.Flags)<br>
> > +       defer C.free(unsafe.Pointer(flags))<br>
> > +       result := C.LLVMDIBuilderCreateCompileUnit(<br>
> > +               d.ref,<br>
> > +               C.unsigned(cu.Language),<br>
> > +               file, dir,<br>
> > +               producer,<br>
> > +               boolToCInt(cu.Optimized),<br>
> > +               flags,<br>
> > +               C.unsigned(cu.RuntimeVersion),<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// CreateCompileUnit creates file debug metadata.<br>
> > +func (d *DIBuilder) CreateFile(filename, dir string) Value {<br>
> > +       cfilename := C.CString(filename)<br>
> > +       defer C.free(unsafe.Pointer(cfilename))<br>
> > +       cdir := C.CString(dir)<br>
> > +       defer C.free(unsafe.Pointer(cdir))<br>
> > +       result := C.LLVMDIBuilderCreateFile(d.ref, cfilename, cdir)<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DILexicalBlock holds the values for creating lexical block debug<br>
> > metadata.<br>
> > +type DILexicalBlock struct {<br>
> > +       File   Value<br>
> > +       Line   int<br>
> > +       Column int<br>
> > +}<br>
> > +<br>
> > +// CreateCompileUnit creates lexical block debug metadata.<br>
> > +func (d *DIBuilder) CreateLexicalBlock(diScope Value, b DILexicalBlock)<br>
> > Value {<br>
> > +       result := C.LLVMDIBuilderCreateLexicalBlock(<br>
> > +               d.ref,<br>
> > +               diScope.C,<br>
> > +               b.File.C,<br>
> > +               C.unsigned(b.Line),<br>
> > +               C.unsigned(b.Column),<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +func (d *DIBuilder) CreateLexicalBlockFile(diScope Value, diFile Value,<br>
> > discriminator int) Value {<br>
> > +       result := C.LLVMDIBuilderCreateLexicalBlockFile(d.ref, diScope.C,<br>
> > diFile.C,<br>
> > +               C.unsigned(discriminator))<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DIFunction holds the values for creating function debug metadata.<br>
> > +type DIFunction struct {<br>
> > +       Name         string<br>
> > +       LinkageName  string<br>
> > +       File         Value<br>
> > +       Line         int<br>
> > +       Type         Value<br>
> > +       LocalToUnit  bool<br>
> > +       IsDefinition bool<br>
> > +       ScopeLine    int<br>
> > +       Flags        int<br>
> > +       Optimized    bool<br>
> > +       Function     Value<br>
> > +}<br>
> > +<br>
> > +// CreateCompileUnit creates function debug metadata.<br>
> > +func (d *DIBuilder) CreateFunction(diScope Value, f DIFunction) Value {<br>
> > +       name := C.CString(f.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       linkageName := C.CString(f.LinkageName)<br>
> > +       defer C.free(unsafe.Pointer(linkageName))<br>
> > +       result := C.LLVMDIBuilderCreateFunction(<br>
> > +               d.ref,<br>
> > +               diScope.C,<br>
> > +               name,<br>
> > +               linkageName,<br>
> > +               f.File.C,<br>
> > +               C.unsigned(f.Line),<br>
> > +               f.Type.C,<br>
> > +               boolToCInt(f.LocalToUnit),<br>
> > +               boolToCInt(f.IsDefinition),<br>
> > +               C.unsigned(f.ScopeLine),<br>
> > +               C.unsigned(f.Flags),<br>
> > +               boolToCInt(f.Optimized),<br>
> > +               f.Function.C,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DILocalVariable holds the values for creating local variable debug<br>
> > metadata.<br>
> > +type DILocalVariable struct {<br>
> > +       Tag            dwarf.Tag<br>
> > +       Name           string<br>
> > +       File           Value<br>
> > +       Line           int<br>
> > +       Type           Value<br>
> > +       AlwaysPreserve bool<br>
> > +       Flags          int<br>
> > +<br>
> > +       // ArgNo is the 1-based index of the argument in the function's<br>
> > +       // parameter list if it is an argument, or 0 otherwise.<br>
> > +       ArgNo int<br>
> > +}<br>
> > +<br>
> > +// CreateLocalVariable creates local variable debug metadata.<br>
> > +func (d *DIBuilder) CreateLocalVariable(scope Value, v DILocalVariable)<br>
> > Value {<br>
> > +       name := C.CString(v.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreateLocalVariable(<br>
> > +               d.ref,<br>
> > +               C.unsigned(v.Tag),<br>
> > +               scope.C,<br>
> > +               name,<br>
> > +               v.File.C,<br>
> > +               C.unsigned(v.Line),<br>
> > +               v.Type.C,<br>
> > +               boolToCInt(v.AlwaysPreserve),<br>
> > +               C.unsigned(v.Flags),<br>
> > +               C.unsigned(v.ArgNo),<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DIBasicType holds the values for creating basic type debug metadata.<br>
> > +type DIBasicType struct {<br>
> > +       Name        string<br>
> > +       SizeInBits  uint64<br>
> > +       AlignInBits uint64<br>
> > +       Encoding    DwarfTypeEncoding<br>
> > +}<br>
> > +<br>
> > +// CreateBasicType creates basic type debug metadata.<br>
> > +func (d *DIBuilder) CreateBasicType(t DIBasicType) Value {<br>
> > +       name := C.CString(t.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreateBasicType(<br>
> > +               d.ref,<br>
> > +               name,<br>
> > +               C.uint64_t(t.SizeInBits),<br>
> > +               C.uint64_t(t.AlignInBits),<br>
> > +               C.unsigned(t.Encoding),<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DIPointerType holds the values for creating pointer type debug<br>
> > metadata.<br>
> > +type DIPointerType struct {<br>
> > +       Pointee     Value<br>
> > +       SizeInBits  uint64<br>
> > +       AlignInBits uint64 // optional<br>
> > +       Name        string // optional<br>
> > +}<br>
> > +<br>
> > +// CreateBasicType creates basic type debug metadata.<br>
> > +func (d *DIBuilder) CreatePointerType(t DIPointerType) Value {<br>
> > +       name := C.CString(t.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreatePointerType(<br>
> > +               d.ref,<br>
> > +               t.Pointee.C,<br>
> > +               C.uint64_t(t.SizeInBits),<br>
> > +               C.uint64_t(t.AlignInBits),<br>
> > +               name,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DISubroutineType holds the values for creating subroutine type debug<br>
> > metadata.<br>
> > +type DISubroutineType struct {<br>
> > +       // File is the file in which the subroutine type is defined.<br>
> > +       File Value<br>
> > +<br>
> > +       // Parameters contains the subroutine parameter types,<br>
> > +       // including the return type at the 0th index.<br>
> > +       Parameters []Value<br>
> > +}<br>
> > +<br>
> > +// CreateSubroutineType creates subroutine type debug metadata.<br>
> > +func (d *DIBuilder) CreateSubroutineType(t DISubroutineType) Value {<br>
> > +       params := d.getOrCreateTypeArray(t.Parameters)<br>
> > +       result := C.LLVMDIBuilderCreateSubroutineType(d.ref, t.File.C,<br>
> > params.C)<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DIStructType holds the values for creating struct type debug metadata.<br>
> > +type DIStructType struct {<br>
> > +       Name        string<br>
> > +       File        Value<br>
> > +       Line        int<br>
> > +       SizeInBits  uint64<br>
> > +       AlignInBits uint64<br>
> > +       Flags       int<br>
> > +       DerivedFrom Value<br>
> > +       Elements    []Value<br>
> > +}<br>
> > +<br>
> > +// CreateStructType creates struct type debug metadata.<br>
> > +func (d *DIBuilder) CreateStructType(scope Value, t DIStructType) Value {<br>
> > +       elements := d.getOrCreateArray(t.Elements)<br>
> > +       name := C.CString(t.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreateStructType(<br>
> > +               d.ref,<br>
> > +               scope.C,<br>
> > +               name,<br>
> > +               t.File.C,<br>
> > +               C.unsigned(t.Line),<br>
> > +               C.uint64_t(t.SizeInBits),<br>
> > +               C.uint64_t(t.AlignInBits),<br>
> > +               C.unsigned(t.Flags),<br>
> > +               t.DerivedFrom.C,<br>
> > +               elements.C,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DIMemberType holds the values for creating member type debug metadata.<br>
> > +type DIMemberType struct {<br>
> > +       Name         string<br>
> > +       File         Value<br>
> > +       Line         int<br>
> > +       SizeInBits   uint64<br>
> > +       AlignInBits  uint64<br>
> > +       OffsetInBits uint64<br>
> > +       Flags        int<br>
> > +       Type         Value<br>
> > +}<br>
> > +<br>
> > +// CreateMemberType creates struct type debug metadata.<br>
> > +func (d *DIBuilder) CreateMemberType(scope Value, t DIMemberType) Value {<br>
> > +       name := C.CString(t.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreateMemberType(<br>
> > +               d.ref,<br>
> > +               scope.C,<br>
> > +               name,<br>
> > +               t.File.C,<br>
> > +               C.unsigned(t.Line),<br>
> > +               C.uint64_t(t.SizeInBits),<br>
> > +               C.uint64_t(t.AlignInBits),<br>
> > +               C.uint64_t(t.OffsetInBits),<br>
> > +               C.unsigned(t.Flags),<br>
> > +               t.Type.C,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DISubrange describes an integer value range.<br>
> > +type DISubrange struct {<br>
> > +       Lo    int64<br>
> > +       Count int64<br>
> > +}<br>
> > +<br>
> > +// DIArrayType holds the values for creating array type debug metadata.<br>
> > +type DIArrayType struct {<br>
> > +       SizeInBits  uint64<br>
> > +       AlignInBits uint64<br>
> > +       ElementType Value<br>
> > +       Subscripts  []DISubrange<br>
> > +}<br>
> > +<br>
> > +// CreateArrayType creates struct type debug metadata.<br>
> > +func (d *DIBuilder) CreateArrayType(t DIArrayType) Value {<br>
> > +       subscriptsSlice := make([]Value, len(t.Subscripts))<br>
> > +       for i, s := range t.Subscripts {<br>
> > +               subscriptsSlice[i] = d.getOrCreateSubrange(s.Lo, s.Count)<br>
> > +       }<br>
> > +       subscripts := d.getOrCreateArray(subscriptsSlice)<br>
> > +       result := C.LLVMDIBuilderCreateArrayType(<br>
> > +               d.ref,<br>
> > +               C.uint64_t(t.SizeInBits),<br>
> > +               C.uint64_t(t.AlignInBits),<br>
> > +               t.ElementType.C,<br>
> > +               subscripts.C,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// DITypedef holds the values for creating typedef type debug metadata.<br>
> > +type DITypedef struct {<br>
> > +       Type    Value<br>
> > +       Name    string<br>
> > +       File    Value<br>
> > +       Line    int<br>
> > +       Context Value<br>
> > +}<br>
> > +<br>
> > +// CreateTypedef creates typedef type debug metadata.<br>
> > +func (d *DIBuilder) CreateTypedef(t DITypedef) Value {<br>
> > +       name := C.CString(t.Name)<br>
> > +       defer C.free(unsafe.Pointer(name))<br>
> > +       result := C.LLVMDIBuilderCreateTypedef(<br>
> > +               d.ref,<br>
> > +               t.Type.C,<br>
> > +               name,<br>
> > +               t.File.C,<br>
> > +               C.unsigned(t.Line),<br>
> > +               t.Context.C,<br>
> > +       )<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// getOrCreateSubrange gets a metadata node for the specified subrange,<br>
> > +// creating if required.<br>
> > +func (d *DIBuilder) getOrCreateSubrange(lo, count int64) Value {<br>
> > +       result := C.LLVMDIBuilderGetOrCreateSubrange(d.ref, C.int64_t(lo),<br>
> > C.int64_t(count))<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// getOrCreateArray gets a metadata node containing the specified values,<br>
> > +// creating if required.<br>
> > +func (d *DIBuilder) getOrCreateArray(values []Value) Value {<br>
> > +       if len(values) == 0 {<br>
> > +               return Value{}<br>
> > +       }<br>
> > +       var data *C.LLVMValueRef<br>
> > +       length := len(values)<br>
> > +       if length > 0 {<br>
> > +               data = &values[0].C<br>
> > +       }<br>
> > +       result := C.LLVMDIBuilderGetOrCreateArray(d.ref, data,<br>
> > C.size_t(length))<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// getOrCreateTypeArray gets a metadata node for a type array containing<br>
> > the<br>
> > +// specified values, creating if required.<br>
> > +func (d *DIBuilder) getOrCreateTypeArray(values []Value) Value {<br>
> > +       if len(values) == 0 {<br>
> > +               return Value{}<br>
> > +       }<br>
> > +       var data *C.LLVMValueRef<br>
> > +       length := len(values)<br>
> > +       if length > 0 {<br>
> > +               data = &values[0].C<br>
> > +       }<br>
> > +       result := C.LLVMDIBuilderGetOrCreateTypeArray(d.ref, data,<br>
> > C.size_t(length))<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// CreateExpression creates a new descriptor for the specified<br>
> > +// variable which has a complex address expression for its address.<br>
> > +func (d *DIBuilder) CreateExpression(addr []int64) Value {<br>
> > +       var data *C.int64_t<br>
> > +       if len(addr) > 0 {<br>
> > +               data = (*C.int64_t)(unsafe.Pointer(&addr[0]))<br>
> > +       }<br>
> > +       result := C.LLVMDIBuilderCreateExpression(d.ref, data,<br>
> > C.size_t(len(addr)))<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +// InsertDeclareAtEnd inserts a call to llvm.dbg.declare at the end of the<br>
> > +// specified basic block for the given value and associated debug<br>
> > metadata.<br>
> > +func (d *DIBuilder) InsertDeclareAtEnd(v, diVarInfo, expr Value, bb<br>
> > BasicBlock) Value {<br>
> > +       result := C.LLVMDIBuilderInsertDeclareAtEnd(d.ref, v.C,<br>
> > diVarInfo.C, expr.C, bb.C)<br>
> > +       return Value{C: result}<br>
> > +}<br>
> > +<br>
> > +func boolToCInt(v bool) C.int {<br>
> > +       if v {<br>
> > +               return 1<br>
> > +       }<br>
> > +       return 0<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/executionengine.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/executionengine.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/executionengine.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,163 @@<br>
> > +//===- executionengine.go - Bindings for executionengine<br>
> > ------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the executionengine component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/ExecutionEngine.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "unsafe"<br>
> > +import "errors"<br>
> > +<br>
> > +func LinkInMCJIT()       { C.LLVMLinkInMCJIT() }<br>
> > +func LinkInInterpreter() { C.LLVMLinkInInterpreter() }<br>
> > +<br>
> > +type GenericValue struct {<br>
> > +       C C.LLVMGenericValueRef<br>
> > +}<br>
> > +type ExecutionEngine struct {<br>
> > +       C C.LLVMExecutionEngineRef<br>
> > +}<br>
> > +type MCJITCompilerOptions struct {<br>
> > +       OptLevel           uint<br>
> > +       CodeModel          CodeModel<br>
> > +       NoFramePointerElim bool<br>
> > +       EnableFastISel     bool<br>
> > +}<br>
> > +<br>
> > +// helpers<br>
> > +func llvmGenericValueRefPtr(t *GenericValue) *C.LLVMGenericValueRef {<br>
> > +       return (*C.LLVMGenericValueRef)(unsafe.Pointer(t))<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.GenericValue<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +func NewGenericValueFromInt(t Type, n uint64, signed bool) (g<br>
> > GenericValue) {<br>
> > +       g.C = C.LLVMCreateGenericValueOfInt(t.C, C.ulonglong(n),<br>
> > boolToLLVMBool(signed))<br>
> > +       return<br>
> > +}<br>
> > +func NewGenericValueFromPointer(p unsafe.Pointer) (g GenericValue) {<br>
> > +       g.C = C.LLVMCreateGenericValueOfPointer(p)<br>
> > +       return<br>
> > +}<br>
> > +func NewGenericValueFromFloat(t Type, n float64) (g GenericValue) {<br>
> > +       g.C = C.LLVMCreateGenericValueOfFloat(t.C, C.double(n))<br>
> > +       return<br>
> > +}<br>
> > +func (g GenericValue) IntWidth() int { return<br>
> > int(C.LLVMGenericValueIntWidth(g.C)) }<br>
> > +func (g GenericValue) Int(signed bool) uint64 {<br>
> > +       return uint64(C.LLVMGenericValueToInt(g.C, boolToLLVMBool(signed)))<br>
> > +}<br>
> > +func (g GenericValue) Float(t Type) float64 {<br>
> > +       return float64(C.LLVMGenericValueToFloat(t.C, g.C))<br>
> > +}<br>
> > +func (g GenericValue) Pointer() unsafe.Pointer {<br>
> > +       return C.LLVMGenericValueToPointer(g.C)<br>
> > +}<br>
> > +func (g GenericValue) Dispose() { C.LLVMDisposeGenericValue(g.C) }<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.ExecutionEngine<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +func NewExecutionEngine(m Module) (ee ExecutionEngine, err error) {<br>
> > +       var cmsg *C.char<br>
> > +       fail := C.LLVMCreateExecutionEngineForModule(&ee.C, m.C, &cmsg)<br>
> > +       if fail != 0 {<br>
> > +               ee.C = nil<br>
> > +               err = errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func NewInterpreter(m Module) (ee ExecutionEngine, err error) {<br>
> > +       var cmsg *C.char<br>
> > +       fail := C.LLVMCreateInterpreterForModule(&ee.C, m.C, &cmsg)<br>
> > +       if fail != 0 {<br>
> > +               ee.C = nil<br>
> > +               err = errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func NewMCJITCompiler(m Module, options MCJITCompilerOptions) (ee<br>
> > ExecutionEngine, err error) {<br>
> > +       var cmsg *C.char<br>
> > +       copts := C.struct_LLVMMCJITCompilerOptions{<br>
> > +               OptLevel:           C.unsigned(options.OptLevel),<br>
> > +               CodeModel:          C.LLVMCodeModel(options.CodeModel),<br>
> > +               NoFramePointerElim:<br>
> > boolToLLVMBool(options.NoFramePointerElim),<br>
> > +               EnableFastISel:     boolToLLVMBool(options.EnableFastISel),<br>
> > +       }<br>
> > +       fail := C.LLVMCreateMCJITCompilerForModule(&ee.C, m.C, &copts,<br>
> > C.size_t(unsafe.Sizeof(copts)), &cmsg)<br>
> > +       if fail != 0 {<br>
> > +               ee.C = nil<br>
> > +               err = errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) Dispose()               {<br>
> > C.LLVMDisposeExecutionEngine(ee.C) }<br>
> > +func (ee ExecutionEngine) RunStaticConstructors() {<br>
> > C.LLVMRunStaticConstructors(ee.C) }<br>
> > +func (ee ExecutionEngine) RunStaticDestructors()  {<br>
> > C.LLVMRunStaticDestructors(ee.C) }<br>
> > +<br>
> > +func (ee ExecutionEngine) RunFunction(f Value, args []GenericValue) (g<br>
> > GenericValue) {<br>
> > +       nargs := len(args)<br>
> > +       var argptr *GenericValue<br>
> > +       if nargs > 0 {<br>
> > +               argptr = &args[0]<br>
> > +       }<br>
> > +       g.C = C.LLVMRunFunction(ee.C, f.C,<br>
> > +               C.unsigned(nargs), llvmGenericValueRefPtr(argptr))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) FreeMachineCodeForFunction(f Value) {<br>
> > +       C.LLVMFreeMachineCodeForFunction(ee.C, f.C)<br>
> > +}<br>
> > +func (ee ExecutionEngine) AddModule(m Module) { C.LLVMAddModule(ee.C,<br>
> > m.C) }<br>
> > +<br>
> > +func (ee ExecutionEngine) RemoveModule(m Module) {<br>
> > +       var modtmp C.LLVMModuleRef<br>
> > +       C.LLVMRemoveModule(ee.C, m.C, &modtmp, nil)<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) FindFunction(name string) (f Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       C.LLVMFindFunction(ee.C, cname, &f.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) RecompileAndRelinkFunction(f Value)<br>
> > unsafe.Pointer {<br>
> > +       return C.LLVMRecompileAndRelinkFunction(ee.C, f.C)<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) TargetData() (td TargetData) {<br>
> > +       td.C = C.LLVMGetExecutionEngineTargetData(ee.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) AddGlobalMapping(global Value, addr<br>
> > unsafe.Pointer) {<br>
> > +       C.LLVMAddGlobalMapping(ee.C, global.C, addr)<br>
> > +}<br>
> > +<br>
> > +func (ee ExecutionEngine) PointerToGlobal(global Value) unsafe.Pointer {<br>
> > +       return C.LLVMGetPointerToGlobal(ee.C, global.C)<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/executionengine_test.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine_test.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/executionengine_test.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/executionengine_test.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/executionengine_test.go Thu Oct 16<br>
> > 17:48:02 2014<br>
> > @@ -0,0 +1,93 @@<br>
> > +//===- executionengine_test.go - Tests for executionengine<br>
> > ----------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file tests bindings for the executionengine component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +import (<br>
> > +       "testing"<br>
> > +)<br>
> > +<br>
> > +func TestFactorial(t *testing.T) {<br>
> > +       LinkInMCJIT()<br>
> > +       InitializeNativeTarget()<br>
> > +       InitializeNativeAsmPrinter()<br>
> > +<br>
> > +       mod := NewModule("fac_module")<br>
> > +<br>
> > +       fac_args := []Type{Int32Type()}<br>
> > +       fac_type := FunctionType(Int32Type(), fac_args, false)<br>
> > +       fac := AddFunction(mod, "fac", fac_type)<br>
> > +       fac.SetFunctionCallConv(CCallConv)<br>
> > +       n := fac.Param(0)<br>
> > +<br>
> > +       entry := AddBasicBlock(fac, "entry")<br>
> > +       iftrue := AddBasicBlock(fac, "iftrue")<br>
> > +       iffalse := AddBasicBlock(fac, "iffalse")<br>
> > +       end := AddBasicBlock(fac, "end")<br>
> > +<br>
> > +       builder := NewBuilder()<br>
> > +       defer builder.Dispose()<br>
> > +<br>
> > +       builder.SetInsertPointAtEnd(entry)<br>
> > +       If := builder.CreateICmp(IntEQ, n, ConstInt(Int32Type(), 0,<br>
> > false), "cmptmp")<br>
> > +       builder.CreateCondBr(If, iftrue, iffalse)<br>
> > +<br>
> > +       builder.SetInsertPointAtEnd(iftrue)<br>
> > +       res_iftrue := ConstInt(Int32Type(), 1, false)<br>
> > +       builder.CreateBr(end)<br>
> > +<br>
> > +       builder.SetInsertPointAtEnd(iffalse)<br>
> > +       n_minus := builder.CreateSub(n, ConstInt(Int32Type(), 1, false),<br>
> > "subtmp")<br>
> > +       call_fac_args := []Value{n_minus}<br>
> > +       call_fac := builder.CreateCall(fac, call_fac_args, "calltmp")<br>
> > +       res_iffalse := builder.CreateMul(n, call_fac, "multmp")<br>
> > +       builder.CreateBr(end)<br>
> > +<br>
> > +       builder.SetInsertPointAtEnd(end)<br>
> > +       res := builder.CreatePHI(Int32Type(), "result")<br>
> > +       phi_vals := []Value{res_iftrue, res_iffalse}<br>
> > +       phi_blocks := []BasicBlock{iftrue, iffalse}<br>
> > +       res.AddIncoming(phi_vals, phi_blocks)<br>
> > +       builder.CreateRet(res)<br>
> > +<br>
> > +       err := VerifyModule(mod, ReturnStatusAction)<br>
> > +       if err != nil {<br>
> > +               t.Errorf("Error verifying module: %s", err)<br>
> > +               return<br>
> > +       }<br>
> > +<br>
> > +       engine, err := NewMCJITCompiler(mod,<br>
> > MCJITCompilerOptions{OptLevel: 2})<br>
> > +       if err != nil {<br>
> > +               t.Errorf("Error creating JIT: %s", err)<br>
> > +               return<br>
> > +       }<br>
> > +       defer engine.Dispose()<br>
> > +<br>
> > +       pass := NewPassManager()<br>
> > +       defer pass.Dispose()<br>
> > +<br>
> > +       pass.Add(engine.TargetData())<br>
> > +       pass.AddConstantPropagationPass()<br>
> > +       pass.AddInstructionCombiningPass()<br>
> > +       pass.AddPromoteMemoryToRegisterPass()<br>
> > +       pass.AddGVNPass()<br>
> > +       pass.AddCFGSimplificationPass()<br>
> > +       pass.Run(mod)<br>
> > +<br>
> > +       exec_args := []GenericValue{NewGenericValueFromInt(Int32Type(),<br>
> > 10, false)}<br>
> > +       exec_res := engine.RunFunction(fac, exec_args)<br>
> > +       var fac10 uint64 = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1<br>
> > +       if exec_res.Int(false) != fac10 {<br>
> > +               t.Errorf("Expected %d, got %d", fac10, exec_res.Int(false))<br>
> > +       }<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/ir.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/ir.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/ir.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,1823 @@<br>
> > +//===- ir.go - Bindings for ir<br>
> > --------------------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the ir component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Core.h"<br>
> > +#include "IRBindings.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "unsafe"<br>
> > +import "errors"<br>
> > +<br>
> > +type (<br>
> > +       // We use these weird structs here because *Ref types are pointers<br>
> > and<br>
> > +       // Go's spec says that a pointer cannot be used as a receiver base<br>
> > type.<br>
> > +       Context struct {<br>
> > +               C C.LLVMContextRef<br>
> > +       }<br>
> > +       Module struct {<br>
> > +               C C.LLVMModuleRef<br>
> > +       }<br>
> > +       Type struct {<br>
> > +               C C.LLVMTypeRef<br>
> > +       }<br>
> > +       Value struct {<br>
> > +               C C.LLVMValueRef<br>
> > +       }<br>
> > +       BasicBlock struct {<br>
> > +               C C.LLVMBasicBlockRef<br>
> > +       }<br>
> > +       Builder struct {<br>
> > +               C C.LLVMBuilderRef<br>
> > +       }<br>
> > +       ModuleProvider struct {<br>
> > +               C C.LLVMModuleProviderRef<br>
> > +       }<br>
> > +       MemoryBuffer struct {<br>
> > +               C C.LLVMMemoryBufferRef<br>
> > +       }<br>
> > +       PassManager struct {<br>
> > +               C C.LLVMPassManagerRef<br>
> > +       }<br>
> > +       Use struct {<br>
> > +               C C.LLVMUseRef<br>
> > +       }<br>
> > +       Attribute        uint64<br>
> > +       Opcode           C.LLVMOpcode<br>
> > +       TypeKind         C.LLVMTypeKind<br>
> > +       Linkage          C.LLVMLinkage<br>
> > +       Visibility       C.LLVMVisibility<br>
> > +       CallConv         C.LLVMCallConv<br>
> > +       IntPredicate     C.LLVMIntPredicate<br>
> > +       FloatPredicate   C.LLVMRealPredicate<br>
> > +       LandingPadClause C.LLVMLandingPadClauseTy<br>
> > +)<br>
> > +<br>
> > +func (c Context) IsNil() bool        { return c.C == nil }<br>
> > +func (c Module) IsNil() bool         { return c.C == nil }<br>
> > +func (c Type) IsNil() bool           { return c.C == nil }<br>
> > +func (c Value) IsNil() bool          { return c.C == nil }<br>
> > +func (c BasicBlock) IsNil() bool     { return c.C == nil }<br>
> > +func (c Builder) IsNil() bool        { return c.C == nil }<br>
> > +func (c ModuleProvider) IsNil() bool { return c.C == nil }<br>
> > +func (c MemoryBuffer) IsNil() bool   { return c.C == nil }<br>
> > +func (c PassManager) IsNil() bool    { return c.C == nil }<br>
> > +func (c Use) IsNil() bool            { return c.C == nil }<br>
> > +<br>
> > +// helpers<br>
> > +func llvmTypeRefPtr(t *Type) *C.LLVMTypeRef    { return<br>
> > (*C.LLVMTypeRef)(unsafe.Pointer(t)) }<br>
> > +func llvmValueRefPtr(t *Value) *C.LLVMValueRef { return<br>
> > (*C.LLVMValueRef)(unsafe.Pointer(t)) }<br>
> > +func llvmBasicBlockRefPtr(t *BasicBlock) *C.LLVMBasicBlockRef {<br>
> > +       return (*C.LLVMBasicBlockRef)(unsafe.Pointer(t))<br>
> > +}<br>
> > +func boolToLLVMBool(b bool) C.LLVMBool {<br>
> > +       if b {<br>
> > +               return C.LLVMBool(1)<br>
> > +       }<br>
> > +       return C.LLVMBool(0)<br>
> > +}<br>
> > +<br>
> > +func llvmValueRefs(values []Value) (*C.LLVMValueRef, C.unsigned) {<br>
> > +       var pt *C.LLVMValueRef<br>
> > +       ptlen := C.unsigned(len(values))<br>
> > +       if ptlen > 0 {<br>
> > +               pt = llvmValueRefPtr(&values[0])<br>
> > +       }<br>
> > +       return pt, ptlen<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Attribute<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       NoneAttribute               Attribute = 0<br>
> > +       ZExtAttribute               Attribute = C.LLVMZExtAttribute<br>
> > +       SExtAttribute               Attribute = C.LLVMSExtAttribute<br>
> > +       NoReturnAttribute           Attribute = C.LLVMNoReturnAttribute<br>
> > +       InRegAttribute              Attribute = C.LLVMInRegAttribute<br>
> > +       StructRetAttribute          Attribute = C.LLVMStructRetAttribute<br>
> > +       NoUnwindAttribute           Attribute = C.LLVMNoUnwindAttribute<br>
> > +       NoAliasAttribute            Attribute = C.LLVMNoAliasAttribute<br>
> > +       ByValAttribute              Attribute = C.LLVMByValAttribute<br>
> > +       NestAttribute               Attribute = C.LLVMNestAttribute<br>
> > +       ReadNoneAttribute           Attribute = C.LLVMReadNoneAttribute<br>
> > +       ReadOnlyAttribute           Attribute = C.LLVMReadOnlyAttribute<br>
> > +       NoInlineAttribute           Attribute = C.LLVMNoInlineAttribute<br>
> > +       AlwaysInlineAttribute       Attribute = C.LLVMAlwaysInlineAttribute<br>
> > +       OptimizeForSizeAttribute    Attribute =<br>
> > C.LLVMOptimizeForSizeAttribute<br>
> > +       StackProtectAttribute       Attribute = C.LLVMStackProtectAttribute<br>
> > +       StackProtectReqAttribute    Attribute =<br>
> > C.LLVMStackProtectReqAttribute<br>
> > +       Alignment                   Attribute = C.LLVMAlignment<br>
> > +       NoCaptureAttribute          Attribute = C.LLVMNoCaptureAttribute<br>
> > +       NoRedZoneAttribute          Attribute = C.LLVMNoRedZoneAttribute<br>
> > +       NoImplicitFloatAttribute    Attribute =<br>
> > C.LLVMNoImplicitFloatAttribute<br>
> > +       NakedAttribute              Attribute = C.LLVMNakedAttribute<br>
> > +       InlineHintAttribute         Attribute = C.LLVMInlineHintAttribute<br>
> > +       StackAlignment              Attribute = C.LLVMStackAlignment<br>
> > +       ReturnsTwiceAttribute       Attribute = C.LLVMReturnsTwice<br>
> > +       UWTableAttribute            Attribute = C.LLVMUWTable<br>
> > +       NonLazyBindAttribute        Attribute = 1 << 31<br>
> > +       SanitizeAddressAttribute    Attribute = 1 << 32<br>
> > +       MinSizeAttribute            Attribute = 1 << 33<br>
> > +       NoDuplicateAttribute        Attribute = 1 << 34<br>
> > +       StackProtectStrongAttribute Attribute = 1 << 35<br>
> > +       SanitizeThreadAttribute     Attribute = 1 << 36<br>
> > +       SanitizeMemoryAttribute     Attribute = 1 << 37<br>
> > +       NoBuiltinAttribute          Attribute = 1 << 38<br>
> > +       ReturnedAttribute           Attribute = 1 << 39<br>
> > +       ColdAttribute               Attribute = 1 << 40<br>
> > +       BuiltinAttribute            Attribute = 1 << 41<br>
> > +       OptimizeNoneAttribute       Attribute = 1 << 42<br>
> > +       InAllocaAttribute           Attribute = 1 << 43<br>
> > +       NonNullAttribute            Attribute = 1 << 44<br>
> > +       JumpTableAttribute          Attribute = 1 << 45<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Opcode<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       Ret         Opcode = C.LLVMRet<br>
> > +       Br          Opcode = C.LLVMBr<br>
> > +       Switch      Opcode = C.LLVMSwitch<br>
> > +       IndirectBr  Opcode = C.LLVMIndirectBr<br>
> > +       Invoke      Opcode = C.LLVMInvoke<br>
> > +       Unreachable Opcode = C.LLVMUnreachable<br>
> > +<br>
> > +       // Standard Binary Operators<br>
> > +       Add  Opcode = C.LLVMAdd<br>
> > +       FAdd Opcode = C.LLVMFAdd<br>
> > +       Sub  Opcode = C.LLVMSub<br>
> > +       FSub Opcode = C.LLVMFSub<br>
> > +       Mul  Opcode = C.LLVMMul<br>
> > +       FMul Opcode = C.LLVMFMul<br>
> > +       UDiv Opcode = C.LLVMUDiv<br>
> > +       SDiv Opcode = C.LLVMSDiv<br>
> > +       FDiv Opcode = C.LLVMFDiv<br>
> > +       URem Opcode = C.LLVMURem<br>
> > +       SRem Opcode = C.LLVMSRem<br>
> > +       FRem Opcode = C.LLVMFRem<br>
> > +<br>
> > +       // Logical Operators<br>
> > +       Shl  Opcode = C.LLVMShl<br>
> > +       LShr Opcode = C.LLVMLShr<br>
> > +       AShr Opcode = C.LLVMAShr<br>
> > +       And  Opcode = C.LLVMAnd<br>
> > +       Or   Opcode = C.LLVMOr<br>
> > +       Xor  Opcode = C.LLVMXor<br>
> > +<br>
> > +       // Memory Operators<br>
> > +       Alloca        Opcode = C.LLVMAlloca<br>
> > +       Load          Opcode = C.LLVMLoad<br>
> > +       Store         Opcode = C.LLVMStore<br>
> > +       GetElementPtr Opcode = C.LLVMGetElementPtr<br>
> > +<br>
> > +       // Cast Operators<br>
> > +       Trunc    Opcode = C.LLVMTrunc<br>
> > +       ZExt     Opcode = C.LLVMZExt<br>
> > +       SExt     Opcode = C.LLVMSExt<br>
> > +       FPToUI   Opcode = C.LLVMFPToUI<br>
> > +       FPToSI   Opcode = C.LLVMFPToSI<br>
> > +       UIToFP   Opcode = C.LLVMUIToFP<br>
> > +       SIToFP   Opcode = C.LLVMSIToFP<br>
> > +       FPTrunc  Opcode = C.LLVMFPTrunc<br>
> > +       FPExt    Opcode = C.LLVMFPExt<br>
> > +       PtrToInt Opcode = C.LLVMPtrToInt<br>
> > +       IntToPtr Opcode = C.LLVMIntToPtr<br>
> > +       BitCast  Opcode = C.LLVMBitCast<br>
> > +<br>
> > +       // Other Operators<br>
> > +       ICmp   Opcode = C.LLVMICmp<br>
> > +       FCmp   Opcode = C.LLVMFCmp<br>
> > +       PHI    Opcode = C.LLVMPHI<br>
> > +       Call   Opcode = C.LLVMCall<br>
> > +       Select Opcode = C.LLVMSelect<br>
> > +       // UserOp1<br>
> > +       // UserOp2<br>
> > +       VAArg          Opcode = C.LLVMVAArg<br>
> > +       ExtractElement Opcode = C.LLVMExtractElement<br>
> > +       InsertElement  Opcode = C.LLVMInsertElement<br>
> > +       ShuffleVector  Opcode = C.LLVMShuffleVector<br>
> > +       ExtractValue   Opcode = C.LLVMExtractValue<br>
> > +       InsertValue    Opcode = C.LLVMInsertValue<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.TypeKind<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       VoidTypeKind      TypeKind = C.LLVMVoidTypeKind<br>
> > +       FloatTypeKind     TypeKind = C.LLVMFloatTypeKind<br>
> > +       DoubleTypeKind    TypeKind = C.LLVMDoubleTypeKind<br>
> > +       X86_FP80TypeKind  TypeKind = C.LLVMX86_FP80TypeKind<br>
> > +       FP128TypeKind     TypeKind = C.LLVMFP128TypeKind<br>
> > +       PPC_FP128TypeKind TypeKind = C.LLVMPPC_FP128TypeKind<br>
> > +       LabelTypeKind     TypeKind = C.LLVMLabelTypeKind<br>
> > +       IntegerTypeKind   TypeKind = C.LLVMIntegerTypeKind<br>
> > +       FunctionTypeKind  TypeKind = C.LLVMFunctionTypeKind<br>
> > +       StructTypeKind    TypeKind = C.LLVMStructTypeKind<br>
> > +       ArrayTypeKind     TypeKind = C.LLVMArrayTypeKind<br>
> > +       PointerTypeKind   TypeKind = C.LLVMPointerTypeKind<br>
> > +       VectorTypeKind    TypeKind = C.LLVMVectorTypeKind<br>
> > +       MetadataTypeKind  TypeKind = C.LLVMMetadataTypeKind<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Linkage<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       ExternalLinkage            Linkage = C.LLVMExternalLinkage<br>
> > +       AvailableExternallyLinkage Linkage =<br>
> > C.LLVMAvailableExternallyLinkage<br>
> > +       LinkOnceAnyLinkage         Linkage = C.LLVMLinkOnceAnyLinkage<br>
> > +       LinkOnceODRLinkage         Linkage = C.LLVMLinkOnceODRLinkage<br>
> > +       WeakAnyLinkage             Linkage = C.LLVMWeakAnyLinkage<br>
> > +       WeakODRLinkage             Linkage = C.LLVMWeakODRLinkage<br>
> > +       AppendingLinkage           Linkage = C.LLVMAppendingLinkage<br>
> > +       InternalLinkage            Linkage = C.LLVMInternalLinkage<br>
> > +       PrivateLinkage             Linkage = C.LLVMPrivateLinkage<br>
> > +       ExternalWeakLinkage        Linkage = C.LLVMExternalWeakLinkage<br>
> > +       CommonLinkage              Linkage = C.LLVMCommonLinkage<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Visibility<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       DefaultVisibility   Visibility = C.LLVMDefaultVisibility<br>
> > +       HiddenVisibility    Visibility = C.LLVMHiddenVisibility<br>
> > +       ProtectedVisibility Visibility = C.LLVMProtectedVisibility<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.CallConv<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       CCallConv           CallConv = C.LLVMCCallConv<br>
> > +       FastCallConv        CallConv = C.LLVMFastCallConv<br>
> > +       ColdCallConv        CallConv = C.LLVMColdCallConv<br>
> > +       X86StdcallCallConv  CallConv = C.LLVMX86StdcallCallConv<br>
> > +       X86FastcallCallConv CallConv = C.LLVMX86FastcallCallConv<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.IntPredicate<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       IntEQ  IntPredicate = C.LLVMIntEQ<br>
> > +       IntNE  IntPredicate = C.LLVMIntNE<br>
> > +       IntUGT IntPredicate = C.LLVMIntUGT<br>
> > +       IntUGE IntPredicate = C.LLVMIntUGE<br>
> > +       IntULT IntPredicate = C.LLVMIntULT<br>
> > +       IntULE IntPredicate = C.LLVMIntULE<br>
> > +       IntSGT IntPredicate = C.LLVMIntSGT<br>
> > +       IntSGE IntPredicate = C.LLVMIntSGE<br>
> > +       IntSLT IntPredicate = C.LLVMIntSLT<br>
> > +       IntSLE IntPredicate = C.LLVMIntSLE<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.FloatPredicate<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       FloatPredicateFalse FloatPredicate = C.LLVMRealPredicateFalse<br>
> > +       FloatOEQ            FloatPredicate = C.LLVMRealOEQ<br>
> > +       FloatOGT            FloatPredicate = C.LLVMRealOGT<br>
> > +       FloatOGE            FloatPredicate = C.LLVMRealOGE<br>
> > +       FloatOLT            FloatPredicate = C.LLVMRealOLT<br>
> > +       FloatOLE            FloatPredicate = C.LLVMRealOLE<br>
> > +       FloatONE            FloatPredicate = C.LLVMRealONE<br>
> > +       FloatORD            FloatPredicate = C.LLVMRealORD<br>
> > +       FloatUNO            FloatPredicate = C.LLVMRealUNO<br>
> > +       FloatUEQ            FloatPredicate = C.LLVMRealUEQ<br>
> > +       FloatUGT            FloatPredicate = C.LLVMRealUGT<br>
> > +       FloatUGE            FloatPredicate = C.LLVMRealUGE<br>
> > +       FloatULT            FloatPredicate = C.LLVMRealULT<br>
> > +       FloatULE            FloatPredicate = C.LLVMRealULE<br>
> > +       FloatUNE            FloatPredicate = C.LLVMRealUNE<br>
> > +       FloatPredicateTrue  FloatPredicate = C.LLVMRealPredicateTrue<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.LandingPadClause<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +const (<br>
> > +       LandingPadCatch  LandingPadClause = C.LLVMLandingPadCatch<br>
> > +       LandingPadFilter LandingPadClause = C.LLVMLandingPadFilter<br>
> > +)<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Context<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +func NewContext() Context    { return Context{C.LLVMContextCreate()} }<br>
> > +func GlobalContext() Context { return Context{C.LLVMGetGlobalContext()} }<br>
> > +func (c Context) Dispose()   { C.LLVMContextDispose(c.C) }<br>
> > +<br>
> > +func (c Context) MDKindID(name string) (id int) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       id = int(C.LLVMGetMDKindIDInContext(c.C, cname,<br>
> > C.unsigned(len(name))))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func MDKindID(name string) (id int) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       id = int(C.LLVMGetMDKindID(cname, C.unsigned(len(name))))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Module<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// Create and destroy modules.<br>
> > +// See llvm::Module::Module.<br>
> > +func NewModule(name string) (m Module) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       m.C = C.LLVMModuleCreateWithName(cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (c Context) NewModule(name string) (m Module) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       m.C = C.LLVMModuleCreateWithNameInContext(cname, c.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// See llvm::Module::~Module<br>
> > +func (m Module) Dispose() { C.LLVMDisposeModule(m.C) }<br>
> > +<br>
> > +// Data layout. See Module::getDataLayout.<br>
> > +func (m Module) DataLayout() string {<br>
> > +       clayout := C.LLVMGetDataLayout(m.C)<br>
> > +       return C.GoString(clayout)<br>
> > +}<br>
> > +<br>
> > +func (m Module) SetDataLayout(layout string) {<br>
> > +       clayout := C.CString(layout)<br>
> > +       defer C.free(unsafe.Pointer(clayout))<br>
> > +       C.LLVMSetDataLayout(m.C, clayout)<br>
> > +}<br>
> > +<br>
> > +// Target triple. See Module::getTargetTriple.<br>
> > +func (m Module) Target() string {<br>
> > +       ctarget := C.LLVMGetTarget(m.C)<br>
> > +       return C.GoString(ctarget)<br>
> > +}<br>
> > +func (m Module) SetTarget(target string) {<br>
> > +       ctarget := C.CString(target)<br>
> > +       defer C.free(unsafe.Pointer(ctarget))<br>
> > +       C.LLVMSetTarget(m.C, ctarget)<br>
> > +}<br>
> > +<br>
> > +func (m Module) GetTypeByName(name string) (t Type) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       t.C = C.LLVMGetTypeByName(m.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// See Module::dump.<br>
> > +func (m Module) Dump() {<br>
> > +       C.LLVMDumpModule(m.C)<br>
> > +}<br>
> > +<br>
> > +func (m Module) String() string {<br>
> > +       cir := C.LLVMPrintModuleToString(m.C)<br>
> > +       defer C.free(unsafe.Pointer(cir))<br>
> > +       ir := C.GoString(cir)<br>
> > +       return ir<br>
> > +}<br>
> > +<br>
> > +// See Module::setModuleInlineAsm.<br>
> > +func (m Module) SetInlineAsm(asm string) {<br>
> > +       casm := C.CString(asm)<br>
> > +       defer C.free(unsafe.Pointer(casm))<br>
> > +       C.LLVMSetModuleInlineAsm(m.C, casm)<br>
> > +}<br>
> > +<br>
> > +func (m Module) AddNamedMetadataOperand(name string, operand Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       C.LLVMAddNamedMetadataOperand(m.C, cname, operand.C)<br>
> > +}<br>
> > +<br>
> > +func (m Module) Context() (c Context) {<br>
> > +       c.C = C.LLVMGetModuleContext(m.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Type<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// LLVM types conform to the following hierarchy:<br>
> > +//<br>
> > +//   types:<br>
> > +//     integer type<br>
> > +//     real type<br>
> > +//     function type<br>
> > +//     sequence types:<br>
> > +//       array type<br>
> > +//       pointer type<br>
> > +//       vector type<br>
> > +//     void type<br>
> > +//     label type<br>
> > +//     opaque type<br>
> > +<br>
> > +// See llvm::LLVMTypeKind::getTypeID.<br>
> > +func (t Type) TypeKind() TypeKind { return<br>
> > TypeKind(C.LLVMGetTypeKind(t.C)) }<br>
> > +<br>
> > +// See llvm::LLVMType::getContext.<br>
> > +func (t Type) Context() (c Context) {<br>
> > +       c.C = C.LLVMGetTypeContext(t.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Operations on integer types<br>
> > +func (c Context) Int1Type() (t Type)  { t.C =<br>
> > C.LLVMInt1TypeInContext(c.C); return }<br>
> > +func (c Context) Int8Type() (t Type)  { t.C =<br>
> > C.LLVMInt8TypeInContext(c.C); return }<br>
> > +func (c Context) Int16Type() (t Type) { t.C =<br>
> > C.LLVMInt16TypeInContext(c.C); return }<br>
> > +func (c Context) Int32Type() (t Type) { t.C =<br>
> > C.LLVMInt32TypeInContext(c.C); return }<br>
> > +func (c Context) Int64Type() (t Type) { t.C =<br>
> > C.LLVMInt64TypeInContext(c.C); return }<br>
> > +func (c Context) IntType(numbits int) (t Type) {<br>
> > +       t.C = C.LLVMIntTypeInContext(c.C, C.unsigned(numbits))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func Int1Type() (t Type)  { t.C = C.LLVMInt1Type(); return }<br>
> > +func Int8Type() (t Type)  { t.C = C.LLVMInt8Type(); return }<br>
> > +func Int16Type() (t Type) { t.C = C.LLVMInt16Type(); return }<br>
> > +func Int32Type() (t Type) { t.C = C.LLVMInt32Type(); return }<br>
> > +func Int64Type() (t Type) { t.C = C.LLVMInt64Type(); return }<br>
> > +<br>
> > +func IntType(numbits int) (t Type) {<br>
> > +       t.C = C.LLVMIntType(C.unsigned(numbits))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (t Type) IntTypeWidth() int {<br>
> > +       return int(C.LLVMGetIntTypeWidth(t.C))<br>
> > +}<br>
> > +<br>
> > +// Operations on real types<br>
> > +func (c Context) FloatType() (t Type)    { t.C =<br>
> > C.LLVMFloatTypeInContext(c.C); return }<br>
> > +func (c Context) DoubleType() (t Type)   { t.C =<br>
> > C.LLVMDoubleTypeInContext(c.C); return }<br>
> > +func (c Context) X86FP80Type() (t Type)  { t.C =<br>
> > C.LLVMX86FP80TypeInContext(c.C); return }<br>
> > +func (c Context) FP128Type() (t Type)    { t.C =<br>
> > C.LLVMFP128TypeInContext(c.C); return }<br>
> > +func (c Context) PPCFP128Type() (t Type) { t.C =<br>
> > C.LLVMPPCFP128TypeInContext(c.C); return }<br>
> > +<br>
> > +func FloatType() (t Type)    { t.C = C.LLVMFloatType(); return }<br>
> > +func DoubleType() (t Type)   { t.C = C.LLVMDoubleType(); return }<br>
> > +func X86FP80Type() (t Type)  { t.C = C.LLVMX86FP80Type(); return }<br>
> > +func FP128Type() (t Type)    { t.C = C.LLVMFP128Type(); return }<br>
> > +func PPCFP128Type() (t Type) { t.C = C.LLVMPPCFP128Type(); return }<br>
> > +<br>
> > +// Operations on function types<br>
> > +func FunctionType(returnType Type, paramTypes []Type, isVarArg bool) (t<br>
> > Type) {<br>
> > +       var pt *C.LLVMTypeRef<br>
> > +       var ptlen C.unsigned<br>
> > +       if len(paramTypes) > 0 {<br>
> > +               pt = llvmTypeRefPtr(&paramTypes[0])<br>
> > +               ptlen = C.unsigned(len(paramTypes))<br>
> > +       }<br>
> > +       t.C = C.LLVMFunctionType(returnType.C,<br>
> > +               pt,<br>
> > +               ptlen,<br>
> > +               boolToLLVMBool(isVarArg))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (t Type) IsFunctionVarArg() bool { return<br>
> > C.LLVMIsFunctionVarArg(t.C) != 0 }<br>
> > +func (t Type) ReturnType() (rt Type)  { rt.C = C.LLVMGetReturnType(t.C);<br>
> > return }<br>
> > +func (t Type) ParamTypesCount() int   { return<br>
> > int(C.LLVMCountParamTypes(t.C)) }<br>
> > +func (t Type) ParamTypes() []Type {<br>
> > +       count := t.ParamTypesCount()<br>
> > +       if count > 0 {<br>
> > +               out := make([]Type, count)<br>
> > +               C.LLVMGetParamTypes(t.C, llvmTypeRefPtr(&out[0]))<br>
> > +               return out<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +// Operations on struct types<br>
> > +func (c Context) StructType(elementTypes []Type, packed bool) (t Type) {<br>
> > +       var pt *C.LLVMTypeRef<br>
> > +       var ptlen C.unsigned<br>
> > +       if len(elementTypes) > 0 {<br>
> > +               pt = llvmTypeRefPtr(&elementTypes[0])<br>
> > +               ptlen = C.unsigned(len(elementTypes))<br>
> > +       }<br>
> > +       t.C = C.LLVMStructTypeInContext(c.C,<br>
> > +               pt,<br>
> > +               ptlen,<br>
> > +               boolToLLVMBool(packed))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func StructType(elementTypes []Type, packed bool) (t Type) {<br>
> > +       var pt *C.LLVMTypeRef<br>
> > +       var ptlen C.unsigned<br>
> > +       if len(elementTypes) > 0 {<br>
> > +               pt = llvmTypeRefPtr(&elementTypes[0])<br>
> > +               ptlen = C.unsigned(len(elementTypes))<br>
> > +       }<br>
> > +       t.C = C.LLVMStructType(pt, ptlen, boolToLLVMBool(packed))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (c Context) StructCreateNamed(name string) (t Type) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       t.C = C.LLVMStructCreateNamed(c.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (t Type) StructName() string {<br>
> > +       return C.GoString(C.LLVMGetStructName(t.C))<br>
> > +}<br>
> > +<br>
> > +func (t Type) StructSetBody(elementTypes []Type, packed bool) {<br>
> > +       var pt *C.LLVMTypeRef<br>
> > +       var ptlen C.unsigned<br>
> > +       if len(elementTypes) > 0 {<br>
> > +               pt = llvmTypeRefPtr(&elementTypes[0])<br>
> > +               ptlen = C.unsigned(len(elementTypes))<br>
> > +       }<br>
> > +       C.LLVMStructSetBody(t.C, pt, ptlen, boolToLLVMBool(packed))<br>
> > +}<br>
> > +<br>
> > +func (t Type) IsStructPacked() bool         { return<br>
> > C.LLVMIsPackedStruct(t.C) != 0 }<br>
> > +func (t Type) StructElementTypesCount() int { return<br>
> > int(C.LLVMCountStructElementTypes(t.C)) }<br>
> > +func (t Type) StructElementTypes() []Type {<br>
> > +       out := make([]Type, t.StructElementTypesCount())<br>
> > +       if len(out) > 0 {<br>
> > +               C.LLVMGetStructElementTypes(t.C, llvmTypeRefPtr(&out[0]))<br>
> > +       }<br>
> > +       return out<br>
> > +}<br>
> > +<br>
> > +// Operations on array, pointer, and vector types (sequence types)<br>
> > +func ArrayType(elementType Type, elementCount int) (t Type) {<br>
> > +       t.C = C.LLVMArrayType(elementType.C, C.unsigned(elementCount))<br>
> > +       return<br>
> > +}<br>
> > +func PointerType(elementType Type, addressSpace int) (t Type) {<br>
> > +       t.C = C.LLVMPointerType(elementType.C, C.unsigned(addressSpace))<br>
> > +       return<br>
> > +}<br>
> > +func VectorType(elementType Type, elementCount int) (t Type) {<br>
> > +       t.C = C.LLVMVectorType(elementType.C, C.unsigned(elementCount))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (t Type) ElementType() (rt Type)   { rt.C =<br>
> > C.LLVMGetElementType(t.C); return }<br>
> > +func (t Type) ArrayLength() int         { return<br>
> > int(C.LLVMGetArrayLength(t.C)) }<br>
> > +func (t Type) PointerAddressSpace() int { return<br>
> > int(C.LLVMGetPointerAddressSpace(t.C)) }<br>
> > +func (t Type) VectorSize() int          { return<br>
> > int(C.LLVMGetVectorSize(t.C)) }<br>
> > +<br>
> > +// Operations on other types<br>
> > +func (c Context) VoidType() (t Type)  { t.C =<br>
> > C.LLVMVoidTypeInContext(c.C); return }<br>
> > +func (c Context) LabelType() (t Type) { t.C =<br>
> > C.LLVMLabelTypeInContext(c.C); return }<br>
> > +<br>
> > +func VoidType() (t Type)  { t.C = C.LLVMVoidType(); return }<br>
> > +func LabelType() (t Type) { t.C = C.LLVMLabelType(); return }<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Value<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// Operations on all values<br>
> > +func (v Value) Type() (t Type) { t.C = C.LLVMTypeOf(v.C); return }<br>
> > +func (v Value) Name() string   { return<br>
> > C.GoString(C.LLVMGetValueName(v.C)) }<br>
> > +func (v Value) SetName(name string) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       C.LLVMSetValueName(v.C, cname)<br>
> > +}<br>
> > +func (v Value) Dump()                       { C.LLVMDumpValue(v.C) }<br>
> > +func (v Value) ReplaceAllUsesWith(nv Value) {<br>
> > C.LLVMReplaceAllUsesWith(v.C, nv.C) }<br>
> > +func (v Value) HasMetadata() bool           { return<br>
> > C.LLVMHasMetadata(v.C) != 0 }<br>
> > +func (v Value) Metadata(kind int) (rv Value) {<br>
> > +       rv.C = C.LLVMGetMetadata(v.C, C.unsigned(kind))<br>
> > +       return<br>
> > +}<br>
> > +func (v Value) SetMetadata(kind int, node Value) {<br>
> > +       C.LLVMSetMetadata(v.C, C.unsigned(kind), node.C)<br>
> > +}<br>
> > +<br>
> > +// Conversion functions.<br>
> > +// Return the input value if it is an instance of the specified class,<br>
> > otherwise NULL.<br>
> > +// See llvm::dyn_cast_or_null<>.<br>
> > +func (v Value) IsAArgument() (rv Value)   { rv.C =<br>
> > C.LLVMIsAArgument(v.C); return }<br>
> > +func (v Value) IsABasicBlock() (rv Value) { rv.C =<br>
> > C.LLVMIsABasicBlock(v.C); return }<br>
> > +func (v Value) IsAInlineAsm() (rv Value)  { rv.C =<br>
> > C.LLVMIsAInlineAsm(v.C); return }<br>
> > +func (v Value) IsAUser() (rv Value)       { rv.C = C.LLVMIsAUser(v.C);<br>
> > return }<br>
> > +func (v Value) IsAConstant() (rv Value)   { rv.C =<br>
> > C.LLVMIsAConstant(v.C); return }<br>
> > +func (v Value) IsAConstantAggregateZero() (rv Value) {<br>
> > +       rv.C = C.LLVMIsAConstantAggregateZero(v.C)<br>
> > +       return<br>
> > +}<br>
> > +func (v Value) IsAConstantArray() (rv Value)       { rv.C =<br>
> > C.LLVMIsAConstantArray(v.C); return }<br>
> > +func (v Value) IsAConstantExpr() (rv Value)        { rv.C =<br>
> > C.LLVMIsAConstantExpr(v.C); return }<br>
> > +func (v Value) IsAConstantFP() (rv Value)          { rv.C =<br>
> > C.LLVMIsAConstantFP(v.C); return }<br>
> > +func (v Value) IsAConstantInt() (rv Value)         { rv.C =<br>
> > C.LLVMIsAConstantInt(v.C); return }<br>
> > +func (v Value) IsAConstantPointerNull() (rv Value) { rv.C =<br>
> > C.LLVMIsAConstantPointerNull(v.C); return }<br>
> > +func (v Value) IsAConstantStruct() (rv Value)      { rv.C =<br>
> > C.LLVMIsAConstantStruct(v.C); return }<br>
> > +func (v Value) IsAConstantVector() (rv Value)      { rv.C =<br>
> > C.LLVMIsAConstantVector(v.C); return }<br>
> > +func (v Value) IsAGlobalValue() (rv Value)         { rv.C =<br>
> > C.LLVMIsAGlobalValue(v.C); return }<br>
> > +func (v Value) IsAFunction() (rv Value)            { rv.C =<br>
> > C.LLVMIsAFunction(v.C); return }<br>
> > +func (v Value) IsAGlobalAlias() (rv Value)         { rv.C =<br>
> > C.LLVMIsAGlobalAlias(v.C); return }<br>
> > +func (v Value) IsAGlobalVariable() (rv Value)      { rv.C =<br>
> > C.LLVMIsAGlobalVariable(v.C); return }<br>
> > +func (v Value) IsAUndefValue() (rv Value)          { rv.C =<br>
> > C.LLVMIsAUndefValue(v.C); return }<br>
> > +func (v Value) IsAInstruction() (rv Value)         { rv.C =<br>
> > C.LLVMIsAInstruction(v.C); return }<br>
> > +func (v Value) IsABinaryOperator() (rv Value)      { rv.C =<br>
> > C.LLVMIsABinaryOperator(v.C); return }<br>
> > +func (v Value) IsACallInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsACallInst(v.C); return }<br>
> > +func (v Value) IsAIntrinsicInst() (rv Value)       { rv.C =<br>
> > C.LLVMIsAIntrinsicInst(v.C); return }<br>
> > +func (v Value) IsADbgInfoIntrinsic() (rv Value)    { rv.C =<br>
> > C.LLVMIsADbgInfoIntrinsic(v.C); return }<br>
> > +func (v Value) IsADbgDeclareInst() (rv Value)      { rv.C =<br>
> > C.LLVMIsADbgDeclareInst(v.C); return }<br>
> > +func (v Value) IsAMemIntrinsic() (rv Value)        { rv.C =<br>
> > C.LLVMIsAMemIntrinsic(v.C); return }<br>
> > +func (v Value) IsAMemCpyInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAMemCpyInst(v.C); return }<br>
> > +func (v Value) IsAMemMoveInst() (rv Value)         { rv.C =<br>
> > C.LLVMIsAMemMoveInst(v.C); return }<br>
> > +func (v Value) IsAMemSetInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAMemSetInst(v.C); return }<br>
> > +func (v Value) IsACmpInst() (rv Value)             { rv.C =<br>
> > C.LLVMIsACmpInst(v.C); return }<br>
> > +func (v Value) IsAFCmpInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsAFCmpInst(v.C); return }<br>
> > +func (v Value) IsAICmpInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsAICmpInst(v.C); return }<br>
> > +func (v Value) IsAExtractElementInst() (rv Value)  { rv.C =<br>
> > C.LLVMIsAExtractElementInst(v.C); return }<br>
> > +func (v Value) IsAGetElementPtrInst() (rv Value)   { rv.C =<br>
> > C.LLVMIsAGetElementPtrInst(v.C); return }<br>
> > +func (v Value) IsAInsertElementInst() (rv Value)   { rv.C =<br>
> > C.LLVMIsAInsertElementInst(v.C); return }<br>
> > +func (v Value) IsAInsertValueInst() (rv Value)     { rv.C =<br>
> > C.LLVMIsAInsertValueInst(v.C); return }<br>
> > +func (v Value) IsAPHINode() (rv Value)             { rv.C =<br>
> > C.LLVMIsAPHINode(v.C); return }<br>
> > +func (v Value) IsASelectInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsASelectInst(v.C); return }<br>
> > +func (v Value) IsAShuffleVectorInst() (rv Value)   { rv.C =<br>
> > C.LLVMIsAShuffleVectorInst(v.C); return }<br>
> > +func (v Value) IsAStoreInst() (rv Value)           { rv.C =<br>
> > C.LLVMIsAStoreInst(v.C); return }<br>
> > +func (v Value) IsATerminatorInst() (rv Value)      { rv.C =<br>
> > C.LLVMIsATerminatorInst(v.C); return }<br>
> > +func (v Value) IsABranchInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsABranchInst(v.C); return }<br>
> > +func (v Value) IsAInvokeInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAInvokeInst(v.C); return }<br>
> > +func (v Value) IsAReturnInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAReturnInst(v.C); return }<br>
> > +func (v Value) IsASwitchInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsASwitchInst(v.C); return }<br>
> > +func (v Value) IsAUnreachableInst() (rv Value)     { rv.C =<br>
> > C.LLVMIsAUnreachableInst(v.C); return }<br>
> > +func (v Value) IsAUnaryInstruction() (rv Value)    { rv.C =<br>
> > C.LLVMIsAUnaryInstruction(v.C); return }<br>
> > +func (v Value) IsAAllocaInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAAllocaInst(v.C); return }<br>
> > +func (v Value) IsACastInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsACastInst(v.C); return }<br>
> > +func (v Value) IsABitCastInst() (rv Value)         { rv.C =<br>
> > C.LLVMIsABitCastInst(v.C); return }<br>
> > +func (v Value) IsAFPExtInst() (rv Value)           { rv.C =<br>
> > C.LLVMIsAFPExtInst(v.C); return }<br>
> > +func (v Value) IsAFPToSIInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAFPToSIInst(v.C); return }<br>
> > +func (v Value) IsAFPToUIInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAFPToUIInst(v.C); return }<br>
> > +func (v Value) IsAFPTruncInst() (rv Value)         { rv.C =<br>
> > C.LLVMIsAFPTruncInst(v.C); return }<br>
> > +func (v Value) IsAIntToPtrInst() (rv Value)        { rv.C =<br>
> > C.LLVMIsAIntToPtrInst(v.C); return }<br>
> > +func (v Value) IsAPtrToIntInst() (rv Value)        { rv.C =<br>
> > C.LLVMIsAPtrToIntInst(v.C); return }<br>
> > +func (v Value) IsASExtInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsASExtInst(v.C); return }<br>
> > +func (v Value) IsASIToFPInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsASIToFPInst(v.C); return }<br>
> > +func (v Value) IsATruncInst() (rv Value)           { rv.C =<br>
> > C.LLVMIsATruncInst(v.C); return }<br>
> > +func (v Value) IsAUIToFPInst() (rv Value)          { rv.C =<br>
> > C.LLVMIsAUIToFPInst(v.C); return }<br>
> > +func (v Value) IsAZExtInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsAZExtInst(v.C); return }<br>
> > +func (v Value) IsAExtractValueInst() (rv Value)    { rv.C =<br>
> > C.LLVMIsAExtractValueInst(v.C); return }<br>
> > +func (v Value) IsALoadInst() (rv Value)            { rv.C =<br>
> > C.LLVMIsALoadInst(v.C); return }<br>
> > +func (v Value) IsAVAArgInst() (rv Value)           { rv.C =<br>
> > C.LLVMIsAVAArgInst(v.C); return }<br>
> > +<br>
> > +// Operations on Uses<br>
> > +func (v Value) FirstUse() (u Use)  { u.C = C.LLVMGetFirstUse(v.C); return<br>
> > }<br>
> > +func (u Use) NextUse() (ru Use)    { ru.C = C.LLVMGetNextUse(u.C); return<br>
> > }<br>
> > +func (u Use) User() (v Value)      { v.C = C.LLVMGetUser(u.C); return }<br>
> > +func (u Use) UsedValue() (v Value) { v.C = C.LLVMGetUsedValue(u.C);<br>
> > return }<br>
> > +<br>
> > +// Operations on Users<br>
> > +func (v Value) Operand(i int) (rv Value)   { rv.C = C.LLVMGetOperand(v.C,<br>
> > C.unsigned(i)); return }<br>
> > +func (v Value) SetOperand(i int, op Value) { C.LLVMSetOperand(v.C,<br>
> > C.unsigned(i), op.C) }<br>
> > +func (v Value) OperandsCount() int         { return<br>
> > int(C.LLVMGetNumOperands(v.C)) }<br>
> > +<br>
> > +// Operations on constants of any type<br>
> > +func ConstNull(t Type) (v Value)        { v.C = C.LLVMConstNull(t.C);<br>
> > return }<br>
> > +func ConstAllOnes(t Type) (v Value)     { v.C = C.LLVMConstAllOnes(t.C);<br>
> > return }<br>
> > +func Undef(t Type) (v Value)            { v.C = C.LLVMGetUndef(t.C);<br>
> > return }<br>
> > +func (v Value) IsConstant() bool        { return C.LLVMIsConstant(v.C) !=<br>
> > 0 }<br>
> > +func (v Value) IsNull() bool            { return C.LLVMIsNull(v.C) != 0 }<br>
> > +func (v Value) IsUndef() bool           { return C.LLVMIsUndef(v.C) != 0 }<br>
> > +func ConstPointerNull(t Type) (v Value) { v.C =<br>
> > C.LLVMConstPointerNull(t.C); return }<br>
> > +<br>
> > +// Operations on metadata<br>
> > +func (c Context) MDString(str string) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMMDStringInContext(c.C, cstr, C.unsigned(len(str)))<br>
> > +       return<br>
> > +}<br>
> > +func MDString(str string) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMMDString(cstr, C.unsigned(len(str)))<br>
> > +       return<br>
> > +}<br>
> > +func (c Context) MDNode(vals []Value) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(vals)<br>
> > +       v.C = C.LLVMMDNodeInContext(c.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func MDNode(vals []Value) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(vals)<br>
> > +       v.C = C.LLVMMDNode(ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Operations on scalar constants<br>
> > +func ConstInt(t Type, n uint64, signExtend bool) (v Value) {<br>
> > +       v.C = C.LLVMConstInt(t.C,<br>
> > +               C.ulonglong(n),<br>
> > +               boolToLLVMBool(signExtend))<br>
> > +       return<br>
> > +}<br>
> > +func ConstIntFromString(t Type, str string, radix int) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMConstIntOfString(t.C, cstr, C.uint8_t(radix))<br>
> > +       return<br>
> > +}<br>
> > +func ConstFloat(t Type, n float64) (v Value) {<br>
> > +       v.C = C.LLVMConstReal(t.C, C.double(n))<br>
> > +       return<br>
> > +}<br>
> > +func ConstFloatFromString(t Type, str string) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMConstRealOfString(t.C, cstr)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (v Value) ZExtValue() uint64 { return<br>
> > uint64(C.LLVMConstIntGetZExtValue(v.C)) }<br>
> > +func (v Value) SExtValue() int64  { return<br>
> > int64(C.LLVMConstIntGetSExtValue(v.C)) }<br>
> > +<br>
> > +// Operations on composite constants<br>
> > +func (c Context) ConstString(str string, addnull bool) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMConstStringInContext(c.C, cstr,<br>
> > +               C.unsigned(len(str)), boolToLLVMBool(!addnull))<br>
> > +       return<br>
> > +}<br>
> > +func (c Context) ConstStruct(constVals []Value, packed bool) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(constVals)<br>
> > +       v.C = C.LLVMConstStructInContext(c.C, ptr, nvals,<br>
> > +               boolToLLVMBool(packed))<br>
> > +       return<br>
> > +}<br>
> > +func ConstNamedStruct(t Type, constVals []Value) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(constVals)<br>
> > +       v.C = C.LLVMConstNamedStruct(t.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func ConstString(str string, addnull bool) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       v.C = C.LLVMConstString(cstr,<br>
> > +               C.unsigned(len(str)), boolToLLVMBool(!addnull))<br>
> > +       return<br>
> > +}<br>
> > +func ConstArray(t Type, constVals []Value) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(constVals)<br>
> > +       v.C = C.LLVMConstArray(t.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func ConstStruct(constVals []Value, packed bool) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(constVals)<br>
> > +       v.C = C.LLVMConstStruct(ptr, nvals, boolToLLVMBool(packed))<br>
> > +       return<br>
> > +}<br>
> > +func ConstVector(scalarConstVals []Value, packed bool) (v Value) {<br>
> > +       ptr, nvals := llvmValueRefs(scalarConstVals)<br>
> > +       v.C = C.LLVMConstVector(ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Constant expressions<br>
> > +func (v Value) Opcode() Opcode                { return<br>
> > Opcode(C.LLVMGetConstOpcode(v.C)) }<br>
> > +func (v Value) InstructionOpcode() Opcode     { return<br>
> > Opcode(C.LLVMGetInstructionOpcode(v.C)) }<br>
> > +func AlignOf(t Type) (v Value)                { v.C = C.LLVMAlignOf(t.C);<br>
> > return }<br>
> > +func SizeOf(t Type) (v Value)                 { v.C = C.LLVMSizeOf(t.C);<br>
> > return }<br>
> > +func ConstNeg(v Value) (rv Value)             { rv.C =<br>
> > C.LLVMConstNeg(v.C); return }<br>
> > +func ConstNSWNeg(v Value) (rv Value)          { rv.C =<br>
> > C.LLVMConstNSWNeg(v.C); return }<br>
> > +func ConstNUWNeg(v Value) (rv Value)          { rv.C =<br>
> > C.LLVMConstNUWNeg(v.C); return }<br>
> > +func ConstFNeg(v Value) (rv Value)            { rv.C =<br>
> > C.LLVMConstFNeg(v.C); return }<br>
> > +func ConstNot(v Value) (rv Value)             { rv.C =<br>
> > C.LLVMConstNot(v.C); return }<br>
> > +func ConstAdd(lhs, rhs Value) (v Value)       { v.C =<br>
> > C.LLVMConstAdd(lhs.C, rhs.C); return }<br>
> > +func ConstNSWAdd(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNSWAdd(lhs.C, rhs.C); return }<br>
> > +func ConstNUWAdd(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNUWAdd(lhs.C, rhs.C); return }<br>
> > +func ConstFAdd(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstFAdd(lhs.C, rhs.C); return }<br>
> > +func ConstSub(lhs, rhs Value) (v Value)       { v.C =<br>
> > C.LLVMConstSub(lhs.C, rhs.C); return }<br>
> > +func ConstNSWSub(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNSWSub(lhs.C, rhs.C); return }<br>
> > +func ConstNUWSub(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNUWSub(lhs.C, rhs.C); return }<br>
> > +func ConstFSub(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstFSub(lhs.C, rhs.C); return }<br>
> > +func ConstMul(lhs, rhs Value) (v Value)       { v.C =<br>
> > C.LLVMConstMul(lhs.C, rhs.C); return }<br>
> > +func ConstNSWMul(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNSWMul(lhs.C, rhs.C); return }<br>
> > +func ConstNUWMul(lhs, rhs Value) (v Value)    { v.C =<br>
> > C.LLVMConstNUWMul(lhs.C, rhs.C); return }<br>
> > +func ConstFMul(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstFMul(lhs.C, rhs.C); return }<br>
> > +func ConstUDiv(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstUDiv(lhs.C, rhs.C); return }<br>
> > +func ConstSDiv(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstSDiv(lhs.C, rhs.C); return }<br>
> > +func ConstExactSDiv(lhs, rhs Value) (v Value) { v.C =<br>
> > C.LLVMConstExactSDiv(lhs.C, rhs.C); return }<br>
> > +func ConstFDiv(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstFDiv(lhs.C, rhs.C); return }<br>
> > +func ConstURem(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstURem(lhs.C, rhs.C); return }<br>
> > +func ConstSRem(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstSRem(lhs.C, rhs.C); return }<br>
> > +func ConstFRem(lhs, rhs Value) (v Value)      { v.C =<br>
> > C.LLVMConstFRem(lhs.C, rhs.C); return }<br>
> > +func ConstAnd(lhs, rhs Value) (v Value)       { v.C =<br>
> > C.LLVMConstAnd(lhs.C, rhs.C); return }<br>
> > +func ConstOr(lhs, rhs Value) (v Value)        { v.C =<br>
> > C.LLVMConstOr(lhs.C, rhs.C); return }<br>
> > +func ConstXor(lhs, rhs Value) (v Value)       { v.C =<br>
> > C.LLVMConstXor(lhs.C, rhs.C); return }<br>
> > +<br>
> > +func ConstICmp(pred IntPredicate, lhs, rhs Value) (v Value) {<br>
> > +       v.C = C.LLVMConstICmp(C.LLVMIntPredicate(pred), lhs.C, rhs.C)<br>
> > +       return<br>
> > +}<br>
> > +func ConstFCmp(pred FloatPredicate, lhs, rhs Value) (v Value) {<br>
> > +       v.C = C.LLVMConstFCmp(C.LLVMRealPredicate(pred), lhs.C, rhs.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func ConstShl(lhs, rhs Value) (v Value)  { v.C = C.LLVMConstShl(lhs.C,<br>
> > rhs.C); return }<br>
> > +func ConstLShr(lhs, rhs Value) (v Value) { v.C = C.LLVMConstLShr(lhs.C,<br>
> > rhs.C); return }<br>
> > +func ConstAShr(lhs, rhs Value) (v Value) { v.C = C.LLVMConstAShr(lhs.C,<br>
> > rhs.C); return }<br>
> > +<br>
> > +func ConstGEP(v Value, indices []Value) (rv Value) {<br>
> > +       ptr, nvals := llvmValueRefs(indices)<br>
> > +       rv.C = C.LLVMConstGEP(v.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func ConstInBoundsGEP(v Value, indices []Value) (rv Value) {<br>
> > +       ptr, nvals := llvmValueRefs(indices)<br>
> > +       rv.C = C.LLVMConstInBoundsGEP(v.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func ConstTrunc(v Value, t Type) (rv Value)         { rv.C =<br>
> > C.LLVMConstTrunc(v.C, t.C); return }<br>
> > +func ConstSExt(v Value, t Type) (rv Value)          { rv.C =<br>
> > C.LLVMConstSExt(v.C, t.C); return }<br>
> > +func ConstZExt(v Value, t Type) (rv Value)          { rv.C =<br>
> > C.LLVMConstZExt(v.C, t.C); return }<br>
> > +func ConstFPTrunc(v Value, t Type) (rv Value)       { rv.C =<br>
> > C.LLVMConstFPTrunc(v.C, t.C); return }<br>
> > +func ConstFPExt(v Value, t Type) (rv Value)         { rv.C =<br>
> > C.LLVMConstFPExt(v.C, t.C); return }<br>
> > +func ConstUIToFP(v Value, t Type) (rv Value)        { rv.C =<br>
> > C.LLVMConstUIToFP(v.C, t.C); return }<br>
> > +func ConstSIToFP(v Value, t Type) (rv Value)        { rv.C =<br>
> > C.LLVMConstSIToFP(v.C, t.C); return }<br>
> > +func ConstFPToUI(v Value, t Type) (rv Value)        { rv.C =<br>
> > C.LLVMConstFPToUI(v.C, t.C); return }<br>
> > +func ConstFPToSI(v Value, t Type) (rv Value)        { rv.C =<br>
> > C.LLVMConstFPToSI(v.C, t.C); return }<br>
> > +func ConstPtrToInt(v Value, t Type) (rv Value)      { rv.C =<br>
> > C.LLVMConstPtrToInt(v.C, t.C); return }<br>
> > +func ConstIntToPtr(v Value, t Type) (rv Value)      { rv.C =<br>
> > C.LLVMConstIntToPtr(v.C, t.C); return }<br>
> > +func ConstBitCast(v Value, t Type) (rv Value)       { rv.C =<br>
> > C.LLVMConstBitCast(v.C, t.C); return }<br>
> > +func ConstZExtOrBitCast(v Value, t Type) (rv Value) { rv.C =<br>
> > C.LLVMConstZExtOrBitCast(v.C, t.C); return }<br>
> > +func ConstSExtOrBitCast(v Value, t Type) (rv Value) { rv.C =<br>
> > C.LLVMConstSExtOrBitCast(v.C, t.C); return }<br>
> > +func ConstTruncOrBitCast(v Value, t Type) (rv Value) {<br>
> > +       rv.C = C.LLVMConstTruncOrBitCast(v.C, t.C)<br>
> > +       return<br>
> > +}<br>
> > +func ConstPointerCast(v Value, t Type) (rv Value) { rv.C =<br>
> > C.LLVMConstPointerCast(v.C, t.C); return }<br>
> > +func ConstIntCast(v Value, t Type, signed bool) (rv Value) {<br>
> > +       rv.C = C.LLVMConstIntCast(v.C, t.C, boolToLLVMBool(signed))<br>
> > +       return<br>
> > +}<br>
> > +func ConstFPCast(v Value, t Type) (rv Value) { rv.C =<br>
> > C.LLVMConstFPCast(v.C, t.C); return }<br>
> > +func ConstSelect(cond, iftrue, iffalse Value) (rv Value) {<br>
> > +       rv.C = C.LLVMConstSelect(cond.C, iftrue.C, iffalse.C)<br>
> > +       return<br>
> > +}<br>
> > +func ConstExtractElement(vec, i Value) (rv Value) {<br>
> > +       rv.C = C.LLVMConstExtractElement(vec.C, i.C)<br>
> > +       return<br>
> > +}<br>
> > +func ConstInsertElement(vec, elem, i Value) (rv Value) {<br>
> > +       rv.C = C.LLVMConstInsertElement(vec.C, elem.C, i.C)<br>
> > +       return<br>
> > +}<br>
> > +func ConstShuffleVector(veca, vecb, mask Value) (rv Value) {<br>
> > +       rv.C = C.LLVMConstShuffleVector(veca.C, vecb.C, mask.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +//TODO<br>
> > +//LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned<br>
> > *IdxList,<br>
> > +//                                   unsigned NumIdx);<br>
> > +<br>
> > +func ConstExtractValue(agg Value, indices []uint32) (rv Value) {<br>
> > +       n := len(indices)<br>
> > +       if n == 0 {<br>
> > +               panic("one or more indices are required")<br>
> > +       }<br>
> > +       ptr := (*C.unsigned)(&indices[0])<br>
> > +       rv.C = C.LLVMConstExtractValue(agg.C, ptr, C.unsigned(n))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func ConstInsertValue(agg, val Value, indices []uint32) (rv Value) {<br>
> > +       n := len(indices)<br>
> > +       if n == 0 {<br>
> > +               panic("one or more indices are required")<br>
> > +       }<br>
> > +       ptr := (*C.unsigned)(&indices[0])<br>
> > +       rv.C = C.LLVMConstInsertValue(agg.C, val.C, ptr, C.unsigned(n))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func BlockAddress(f Value, bb BasicBlock) (v Value) {<br>
> > +       v.C = C.LLVMBlockAddress(f.C, bb.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Operations on global variables, functions, and aliases (globals)<br>
> > +func (v Value) GlobalParent() (m Module) { m.C =<br>
> > C.LLVMGetGlobalParent(v.C); return }<br>
> > +func (v Value) IsDeclaration() bool      { return<br>
> > C.LLVMIsDeclaration(v.C) != 0 }<br>
> > +func (v Value) Linkage() Linkage         { return<br>
> > Linkage(C.LLVMGetLinkage(v.C)) }<br>
> > +func (v Value) SetLinkage(l Linkage)     { C.LLVMSetLinkage(v.C,<br>
> > C.LLVMLinkage(l)) }<br>
> > +func (v Value) Section() string          { return<br>
> > C.GoString(C.LLVMGetSection(v.C)) }<br>
> > +func (v Value) SetSection(str string) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       C.LLVMSetSection(v.C, cstr)<br>
> > +}<br>
> > +func (v Value) Visibility() Visibility      { return<br>
> > Visibility(C.LLVMGetVisibility(v.C)) }<br>
> > +func (v Value) SetVisibility(vi Visibility) { C.LLVMSetVisibility(v.C,<br>
> > C.LLVMVisibility(vi)) }<br>
> > +func (v Value) Alignment() int              { return<br>
> > int(C.LLVMGetAlignment(v.C)) }<br>
> > +func (v Value) SetAlignment(a int)          { C.LLVMSetAlignment(v.C,<br>
> > C.unsigned(a)) }<br>
> > +<br>
> > +// Operations on global variables<br>
> > +func AddGlobal(m Module, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMAddGlobal(m.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func AddGlobalInAddressSpace(m Module, t Type, name string, addressSpace<br>
> > int) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMAddGlobalInAddressSpace(m.C, t.C, cname,<br>
> > C.unsigned(addressSpace))<br>
> > +       return<br>
> > +}<br>
> > +func (m Module) NamedGlobal(name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMGetNamedGlobal(m.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (m Module) FirstGlobal() (v Value)   { v.C =<br>
> > C.LLVMGetFirstGlobal(m.C); return }<br>
> > +func (m Module) LastGlobal() (v Value)    { v.C =<br>
> > C.LLVMGetLastGlobal(m.C); return }<br>
> > +func NextGlobal(v Value) (rv Value)       { rv.C =<br>
> > C.LLVMGetNextGlobal(v.C); return }<br>
> > +func PrevGlobal(v Value) (rv Value)       { rv.C =<br>
> > C.LLVMGetPreviousGlobal(v.C); return }<br>
> > +func (v Value) EraseFromParentAsGlobal()  { C.LLVMDeleteGlobal(v.C) }<br>
> > +func (v Value) Initializer() (rv Value)   { rv.C =<br>
> > C.LLVMGetInitializer(v.C); return }<br>
> > +func (v Value) SetInitializer(cv Value)   { C.LLVMSetInitializer(v.C,<br>
> > cv.C) }<br>
> > +func (v Value) IsThreadLocal() bool       { return<br>
> > C.LLVMIsThreadLocal(v.C) != 0 }<br>
> > +func (v Value) SetThreadLocal(tl bool)    { C.LLVMSetThreadLocal(v.C,<br>
> > boolToLLVMBool(tl)) }<br>
> > +func (v Value) IsGlobalConstant() bool    { return<br>
> > C.LLVMIsGlobalConstant(v.C) != 0 }<br>
> > +func (v Value) SetGlobalConstant(gc bool) { C.LLVMSetGlobalConstant(v.C,<br>
> > boolToLLVMBool(gc)) }<br>
> > +<br>
> > +// Operations on aliases<br>
> > +func AddAlias(m Module, t Type, aliasee Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMAddAlias(m.C, t.C, aliasee.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Operations on functions<br>
> > +func AddFunction(m Module, name string, ft Type) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMAddFunction(m.C, cname, ft.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (m Module) NamedFunction(name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMGetNamedFunction(m.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (m Module) FirstFunction() (v Value)  { v.C =<br>
> > C.LLVMGetFirstFunction(m.C); return }<br>
> > +func (m Module) LastFunction() (v Value)   { v.C =<br>
> > C.LLVMGetLastFunction(m.C); return }<br>
> > +func NextFunction(v Value) (rv Value)      { rv.C =<br>
> > C.LLVMGetNextFunction(v.C); return }<br>
> > +func PrevFunction(v Value) (rv Value)      { rv.C =<br>
> > C.LLVMGetPreviousFunction(v.C); return }<br>
> > +func (v Value) EraseFromParentAsFunction() { C.LLVMDeleteFunction(v.C) }<br>
> > +func (v Value) IntrinsicID() int           { return<br>
> > int(C.LLVMGetIntrinsicID(v.C)) }<br>
> > +func (v Value) FunctionCallConv() CallConv {<br>
> > +       return CallConv(C.LLVMCallConv(C.LLVMGetFunctionCallConv(v.C)))<br>
> > +}<br>
> > +func (v Value) SetFunctionCallConv(cc CallConv) {<br>
> > C.LLVMSetFunctionCallConv(v.C, C.unsigned(cc)) }<br>
> > +func (v Value) GC() string                      { return<br>
> > C.GoString(C.LLVMGetGC(v.C)) }<br>
> > +func (v Value) SetGC(name string) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       C.LLVMSetGC(v.C, cname)<br>
> > +}<br>
> > +func (v Value) AddFunctionAttr(a Attribute)    {<br>
> > C.LLVMAddFunctionAttr2(v.C, C.uint64_t(a)) }<br>
> > +func (v Value) FunctionAttr() Attribute        { return<br>
> > Attribute(C.LLVMGetFunctionAttr2(v.C)) }<br>
> > +func (v Value) RemoveFunctionAttr(a Attribute) {<br>
> > C.LLVMRemoveFunctionAttr2(v.C, C.uint64_t(a)) }<br>
> > +func (v Value) AddTargetDependentFunctionAttr(attr, value string) {<br>
> > +       cattr := C.CString(attr)<br>
> > +       defer C.free(unsafe.Pointer(cattr))<br>
> > +       cvalue := C.CString(value)<br>
> > +       defer C.free(unsafe.Pointer(cvalue))<br>
> > +       C.LLVMAddTargetDependentFunctionAttr(v.C, cattr, cvalue)<br>
> > +}<br>
> > +<br>
> > +// Operations on parameters<br>
> > +func (v Value) ParamsCount() int { return int(C.LLVMCountParams(v.C)) }<br>
> > +func (v Value) Params() []Value {<br>
> > +       out := make([]Value, v.ParamsCount())<br>
> > +       if len(out) > 0 {<br>
> > +               C.LLVMGetParams(v.C, llvmValueRefPtr(&out[0]))<br>
> > +       }<br>
> > +       return out<br>
> > +}<br>
> > +func (v Value) Param(i int) (rv Value)  { rv.C = C.LLVMGetParam(v.C,<br>
> > C.unsigned(i)); return }<br>
> > +func (v Value) ParamParent() (rv Value) { rv.C =<br>
> > C.LLVMGetParamParent(v.C); return }<br>
> > +func (v Value) FirstParam() (rv Value)  { rv.C =<br>
> > C.LLVMGetFirstParam(v.C); return }<br>
> > +func (v Value) LastParam() (rv Value)   { rv.C = C.LLVMGetLastParam(v.C);<br>
> > return }<br>
> > +func NextParam(v Value) (rv Value)      { rv.C = C.LLVMGetNextParam(v.C);<br>
> > return }<br>
> > +func PrevParam(v Value) (rv Value)      { rv.C =<br>
> > C.LLVMGetPreviousParam(v.C); return }<br>
> > +func (v Value) AddAttribute(a Attribute) {<br>
> > +       if a >= 1<<32 {<br>
> > +               panic("attribute value currently unsupported")<br>
> > +       }<br>
> > +       C.LLVMAddAttribute(v.C, C.LLVMAttribute(a))<br>
> > +}<br>
> > +func (v Value) RemoveAttribute(a Attribute) {<br>
> > +       if a >= 1<<32 {<br>
> > +               panic("attribute value currently unsupported")<br>
> > +       }<br>
> > +       C.LLVMRemoveAttribute(v.C, C.LLVMAttribute(a))<br>
> > +}<br>
> > +func (v Value) Attribute() Attribute        { return<br>
> > Attribute(C.LLVMGetAttribute(v.C)) }<br>
> > +func (v Value) SetParamAlignment(align int) {<br>
> > C.LLVMSetParamAlignment(v.C, C.unsigned(align)) }<br>
> > +<br>
> > +// Operations on basic blocks<br>
> > +func (bb BasicBlock) AsValue() (v Value)      { v.C =<br>
> > C.LLVMBasicBlockAsValue(bb.C); return }<br>
> > +func (v Value) IsBasicBlock() bool            { return<br>
> > C.LLVMValueIsBasicBlock(v.C) != 0 }<br>
> > +func (v Value) AsBasicBlock() (bb BasicBlock) { bb.C =<br>
> > C.LLVMValueAsBasicBlock(v.C); return }<br>
> > +func (bb BasicBlock) Parent() (v Value)       { v.C =<br>
> > C.LLVMGetBasicBlockParent(bb.C); return }<br>
> > +func (v Value) BasicBlocksCount() int         { return<br>
> > int(C.LLVMCountBasicBlocks(v.C)) }<br>
> > +func (v Value) BasicBlocks() []BasicBlock {<br>
> > +       out := make([]BasicBlock, v.BasicBlocksCount())<br>
> > +       C.LLVMGetBasicBlocks(v.C, llvmBasicBlockRefPtr(&out[0]))<br>
> > +       return out<br>
> > +}<br>
> > +func (v Value) FirstBasicBlock() (bb BasicBlock)    { bb.C =<br>
> > C.LLVMGetFirstBasicBlock(v.C); return }<br>
> > +func (v Value) LastBasicBlock() (bb BasicBlock)     { bb.C =<br>
> > C.LLVMGetLastBasicBlock(v.C); return }<br>
> > +func NextBasicBlock(bb BasicBlock) (rbb BasicBlock) { rbb.C =<br>
> > C.LLVMGetNextBasicBlock(bb.C); return }<br>
> > +func PrevBasicBlock(bb BasicBlock) (rbb BasicBlock) { rbb.C =<br>
> > C.LLVMGetPreviousBasicBlock(bb.C); return }<br>
> > +func (v Value) EntryBasicBlock() (bb BasicBlock)    { bb.C =<br>
> > C.LLVMGetEntryBasicBlock(v.C); return }<br>
> > +func (c Context) AddBasicBlock(f Value, name string) (bb BasicBlock) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       bb.C = C.LLVMAppendBasicBlockInContext(c.C, f.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (c Context) InsertBasicBlock(ref BasicBlock, name string) (bb<br>
> > BasicBlock) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       bb.C = C.LLVMInsertBasicBlockInContext(c.C, ref.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func AddBasicBlock(f Value, name string) (bb BasicBlock) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       bb.C = C.LLVMAppendBasicBlock(f.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func InsertBasicBlock(ref BasicBlock, name string) (bb BasicBlock) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       bb.C = C.LLVMInsertBasicBlock(ref.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (bb BasicBlock) EraseFromParent()          {<br>
> > C.LLVMDeleteBasicBlock(bb.C) }<br>
> > +func (bb BasicBlock) MoveBefore(pos BasicBlock) {<br>
> > C.LLVMMoveBasicBlockBefore(bb.C, pos.C) }<br>
> > +func (bb BasicBlock) MoveAfter(pos BasicBlock)  {<br>
> > C.LLVMMoveBasicBlockAfter(bb.C, pos.C) }<br>
> > +<br>
> > +// Operations on instructions<br>
> > +func (v Value) InstructionParent() (bb BasicBlock) { bb.C =<br>
> > C.LLVMGetInstructionParent(v.C); return }<br>
> > +func (bb BasicBlock) FirstInstruction() (v Value)  { v.C =<br>
> > C.LLVMGetFirstInstruction(bb.C); return }<br>
> > +func (bb BasicBlock) LastInstruction() (v Value)   { v.C =<br>
> > C.LLVMGetLastInstruction(bb.C); return }<br>
> > +func NextInstruction(v Value) (rv Value)           { rv.C =<br>
> > C.LLVMGetNextInstruction(v.C); return }<br>
> > +func PrevInstruction(v Value) (rv Value)           { rv.C =<br>
> > C.LLVMGetPreviousInstruction(v.C); return }<br>
> > +<br>
> > +// Operations on call sites<br>
> > +func (v Value) SetInstructionCallConv(cc CallConv) {<br>
> > +       C.LLVMSetInstructionCallConv(v.C, C.unsigned(cc))<br>
> > +}<br>
> > +func (v Value) InstructionCallConv() CallConv {<br>
> > +       return CallConv(C.LLVMCallConv(C.LLVMGetInstructionCallConv(v.C)))<br>
> > +}<br>
> > +func (v Value) AddInstrAttribute(i int, a Attribute) {<br>
> > +       if a >= 1<<32 {<br>
> > +               panic("attribute value currently unsupported")<br>
> > +       }<br>
> > +       C.LLVMAddInstrAttribute(v.C, C.unsigned(i), C.LLVMAttribute(a))<br>
> > +}<br>
> > +func (v Value) RemoveInstrAttribute(i int, a Attribute) {<br>
> > +       if a >= 1<<32 {<br>
> > +               panic("attribute value currently unsupported")<br>
> > +       }<br>
> > +       C.LLVMRemoveInstrAttribute(v.C, C.unsigned(i), C.LLVMAttribute(a))<br>
> > +}<br>
> > +func (v Value) SetInstrParamAlignment(i int, align int) {<br>
> > +       C.LLVMSetInstrParamAlignment(v.C, C.unsigned(i), C.unsigned(align))<br>
> > +}<br>
> > +<br>
> > +// Operations on call instructions (only)<br>
> > +func (v Value) IsTailCall() bool    { return C.LLVMIsTailCall(v.C) != 0 }<br>
> > +func (v Value) SetTailCall(is bool) { C.LLVMSetTailCall(v.C,<br>
> > boolToLLVMBool(is)) }<br>
> > +<br>
> > +// Operations on phi nodes<br>
> > +func (v Value) AddIncoming(vals []Value, blocks []BasicBlock) {<br>
> > +       ptr, nvals := llvmValueRefs(vals)<br>
> > +       C.LLVMAddIncoming(v.C, ptr, llvmBasicBlockRefPtr(&blocks[0]),<br>
> > nvals)<br>
> > +}<br>
> > +func (v Value) IncomingCount() int { return int(C.LLVMCountIncoming(v.C))<br>
> > }<br>
> > +func (v Value) IncomingValue(i int) (rv Value) {<br>
> > +       rv.C = C.LLVMGetIncomingValue(v.C, C.unsigned(i))<br>
> > +       return<br>
> > +}<br>
> > +func (v Value) IncomingBlock(i int) (bb BasicBlock) {<br>
> > +       bb.C = C.LLVMGetIncomingBlock(v.C, C.unsigned(i))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Builder<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// An instruction builder represents a point within a basic block, and is<br>
> > the<br>
> > +// exclusive means of building instructions using the C interface.<br>
> > +<br>
> > +func (c Context) NewBuilder() (b Builder) { b.C =<br>
> > C.LLVMCreateBuilderInContext(c.C); return }<br>
> > +func NewBuilder() (b Builder)             { b.C = C.LLVMCreateBuilder();<br>
> > return }<br>
> > +func (b Builder) SetInsertPoint(block BasicBlock, instr Value) {<br>
> > +       C.LLVMPositionBuilder(b.C, block.C, instr.C)<br>
> > +}<br>
> > +func (b Builder) SetInsertPointBefore(instr Value)     {<br>
> > C.LLVMPositionBuilderBefore(b.C, instr.C) }<br>
> > +func (b Builder) SetInsertPointAtEnd(block BasicBlock) {<br>
> > C.LLVMPositionBuilderAtEnd(b.C, block.C) }<br>
> > +func (b Builder) GetInsertBlock() (bb BasicBlock)      { bb.C =<br>
> > C.LLVMGetInsertBlock(b.C); return }<br>
> > +func (b Builder) ClearInsertionPoint()                 {<br>
> > C.LLVMClearInsertionPosition(b.C) }<br>
> > +func (b Builder) Insert(instr Value)                   {<br>
> > C.LLVMInsertIntoBuilder(b.C, instr.C) }<br>
> > +func (b Builder) InsertWithName(instr Value, name string) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       C.LLVMInsertIntoBuilderWithName(b.C, instr.C, cname)<br>
> > +}<br>
> > +func (b Builder) Dispose() { C.LLVMDisposeBuilder(b.C) }<br>
> > +<br>
> > +// Metadata<br>
> > +func (b Builder) SetCurrentDebugLocation(v Value) {<br>
> > C.LLVMSetCurrentDebugLocation(b.C, v.C) }<br>
> > +func (b Builder) CurrentDebugLocation() (v Value) { v.C =<br>
> > C.LLVMGetCurrentDebugLocation(b.C); return }<br>
> > +func (b Builder) SetInstDebugLocation(v Value)    {<br>
> > C.LLVMSetInstDebugLocation(b.C, v.C) }<br>
> > +func (b Builder) InsertDeclare(module Module, storage Value, md Value)<br>
> > Value {<br>
> > +       f := module.NamedFunction("llvm.dbg.declare")<br>
> > +       if f.IsNil() {<br>
> > +               ftyp := FunctionType(VoidType(), []Type{storage.Type(),<br>
> > md.Type()}, false)<br>
> > +               f = AddFunction(module, "llvm.dbg.declare", ftyp)<br>
> > +       }<br>
> > +       return b.CreateCall(f, []Value{storage, md}, "")<br>
> > +}<br>
> > +<br>
> > +// Terminators<br>
> > +func (b Builder) CreateRetVoid() (rv Value)    { rv.C =<br>
> > C.LLVMBuildRetVoid(b.C); return }<br>
> > +func (b Builder) CreateRet(v Value) (rv Value) { rv.C =<br>
> > C.LLVMBuildRet(b.C, v.C); return }<br>
> > +func (b Builder) CreateAggregateRet(vs []Value) (rv Value) {<br>
> > +       ptr, nvals := llvmValueRefs(vs)<br>
> > +       rv.C = C.LLVMBuildAggregateRet(b.C, ptr, nvals)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateBr(bb BasicBlock) (rv Value) { rv.C =<br>
> > C.LLVMBuildBr(b.C, bb.C); return }<br>
> > +func (b Builder) CreateCondBr(ifv Value, thenb, elseb BasicBlock) (rv<br>
> > Value) {<br>
> > +       rv.C = C.LLVMBuildCondBr(b.C, ifv.C, thenb.C, elseb.C)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSwitch(v Value, elseb BasicBlock, numCases int)<br>
> > (rv Value) {<br>
> > +       rv.C = C.LLVMBuildSwitch(b.C, v.C, elseb.C, C.unsigned(numCases))<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateIndirectBr(addr Value, numDests int) (rv Value) {<br>
> > +       rv.C = C.LLVMBuildIndirectBr(b.C, addr.C, C.unsigned(numDests))<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateInvoke(fn Value, args []Value, then, catch<br>
> > BasicBlock, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       ptr, nvals := llvmValueRefs(args)<br>
> > +       rv.C = C.LLVMBuildInvoke(b.C, fn.C, ptr, nvals, then.C, catch.C,<br>
> > cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateUnreachable() (rv Value) { rv.C =<br>
> > C.LLVMBuildUnreachable(b.C); return }<br>
> > +<br>
> > +// Add a case to the switch instruction<br>
> > +func (v Value) AddCase(on Value, dest BasicBlock) { C.LLVMAddCase(v.C,<br>
> > on.C, dest.C) }<br>
> > +<br>
> > +// Add a destination to the indirectbr instruction<br>
> > +func (v Value) AddDest(dest BasicBlock) { C.LLVMAddDestination(v.C,<br>
> > dest.C) }<br>
> > +<br>
> > +// Arithmetic<br>
> > +func (b Builder) CreateAdd(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildAdd(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNSWAdd(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNSWAdd(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNUWAdd(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNUWAdd(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFAdd(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFAdd(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSub(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSub(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNSWSub(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNSWSub(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNUWSub(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNUWSub(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFSub(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       v.C = C.LLVMBuildFSub(b.C, lhs.C, rhs.C, cname)<br>
> > +       C.free(unsafe.Pointer(cname))<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateMul(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildMul(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNSWMul(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNSWMul(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNUWMul(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildNUWMul(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFMul(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFMul(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateUDiv(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildUDiv(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSDiv(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSDiv(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateExactSDiv(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildExactSDiv(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFDiv(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFDiv(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateURem(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildURem(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSRem(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSRem(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFRem(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFRem(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateShl(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildShl(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateLShr(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildLShr(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateAShr(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildAShr(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateAnd(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildAnd(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateOr(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildOr(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateXor(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildXor(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateBinOp(op Opcode, lhs, rhs Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildBinOp(b.C, C.LLVMOpcode(op), lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNeg(v Value, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       rv.C = C.LLVMBuildNeg(b.C, v.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNSWNeg(v Value, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       rv.C = C.LLVMBuildNSWNeg(b.C, v.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNUWNeg(v Value, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       rv.C = C.LLVMBuildNUWNeg(b.C, v.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFNeg(v Value, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       rv.C = C.LLVMBuildFNeg(b.C, v.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateNot(v Value, name string) (rv Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       rv.C = C.LLVMBuildNot(b.C, v.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Memory<br>
> > +<br>
> > +func (b Builder) CreateMalloc(t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildMalloc(b.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateArrayMalloc(t Type, val Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildArrayMalloc(b.C, t.C, val.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateAlloca(t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildAlloca(b.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateArrayAlloca(t Type, val Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildArrayAlloca(b.C, t.C, val.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFree(p Value) (v Value) {<br>
> > +       v.C = C.LLVMBuildFree(b.C, p.C)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateLoad(p Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildLoad(b.C, p.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateStore(val Value, p Value) (v Value) {<br>
> > +       v.C = C.LLVMBuildStore(b.C, val.C, p.C)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateGEP(p Value, indices []Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       ptr, nvals := llvmValueRefs(indices)<br>
> > +       v.C = C.LLVMBuildGEP(b.C, p.C, ptr, nvals, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateInBoundsGEP(p Value, indices []Value, name string)<br>
> > (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       ptr, nvals := llvmValueRefs(indices)<br>
> > +       v.C = C.LLVMBuildInBoundsGEP(b.C, p.C, ptr, nvals, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateStructGEP(p Value, i int, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildStructGEP(b.C, p.C, C.unsigned(i), cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateGlobalString(str, name string) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildGlobalString(b.C, cstr, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateGlobalStringPtr(str, name string) (v Value) {<br>
> > +       cstr := C.CString(str)<br>
> > +       defer C.free(unsafe.Pointer(cstr))<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildGlobalStringPtr(b.C, cstr, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Casts<br>
> > +func (b Builder) CreateTrunc(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildTrunc(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateZExt(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildZExt(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSExt(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSExt(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFPToUI(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFPToUI(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFPToSI(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFPToSI(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateUIToFP(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildUIToFP(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSIToFP(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSIToFP(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFPTrunc(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFPTrunc(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFPExt(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFPExt(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreatePtrToInt(val Value, t Type, name string) (v Value)<br>
> > {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildPtrToInt(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateIntToPtr(val Value, t Type, name string) (v Value)<br>
> > {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildIntToPtr(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateBitCast(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildBitCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateZExtOrBitCast(val Value, t Type, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildZExtOrBitCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateSExtOrBitCast(val Value, t Type, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSExtOrBitCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateTruncOrBitCast(val Value, t Type, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildTruncOrBitCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateCast(val Value, op Opcode, t Type, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildCast(b.C, C.LLVMOpcode(op), val.C, t.C, cname)<br>
> > +       return<br>
> > +} //<br>
> > +func (b Builder) CreatePointerCast(val Value, t Type, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildPointerCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateIntCast(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildIntCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFPCast(val Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFPCast(b.C, val.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Comparisons<br>
> > +func (b Builder) CreateICmp(pred IntPredicate, lhs, rhs Value, name<br>
> > string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildICmp(b.C, C.LLVMIntPredicate(pred), lhs.C, rhs.C,<br>
> > cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateFCmp(pred FloatPredicate, lhs, rhs Value, name<br>
> > string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildFCmp(b.C, C.LLVMRealPredicate(pred), lhs.C,<br>
> > rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Miscellaneous instructions<br>
> > +func (b Builder) CreatePHI(t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildPhi(b.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateCall(fn Value, args []Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       ptr, nvals := llvmValueRefs(args)<br>
> > +       v.C = C.LLVMBuildCall(b.C, fn.C, ptr, nvals, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (b Builder) CreateSelect(ifv, thenv, elsev Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildSelect(b.C, ifv.C, thenv.C, elsev.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (b Builder) CreateVAArg(list Value, t Type, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildVAArg(b.C, list.C, t.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateExtractElement(vec, i Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildExtractElement(b.C, vec.C, i.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateInsertElement(vec, elt, i Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildInsertElement(b.C, vec.C, elt.C, i.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateShuffleVector(v1, v2, mask Value, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildShuffleVector(b.C, v1.C, v2.C, mask.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateExtractValue(agg Value, i int, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildExtractValue(b.C, agg.C, C.unsigned(i), cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateInsertValue(agg, elt Value, i int, name string) (v<br>
> > Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildInsertValue(b.C, agg.C, elt.C, C.unsigned(i),<br>
> > cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (b Builder) CreateIsNull(val Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildIsNull(b.C, val.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreateIsNotNull(val Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildIsNotNull(b.C, val.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +func (b Builder) CreatePtrDiff(lhs, rhs Value, name string) (v Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       v.C = C.LLVMBuildPtrDiff(b.C, lhs.C, rhs.C, cname)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (b Builder) CreateLandingPad(t Type, personality Value, nclauses<br>
> > int, name string) (l Value) {<br>
> > +       cname := C.CString(name)<br>
> > +       defer C.free(unsafe.Pointer(cname))<br>
> > +       l.C = C.LLVMBuildLandingPad(b.C, t.C, personality.C,<br>
> > C.unsigned(nclauses), cname)<br>
> > +       return l<br>
> > +}<br>
> > +<br>
> > +func (l Value) AddClause(v Value) {<br>
> > +       C.LLVMAddClause(l.C, v.C)<br>
> > +}<br>
> > +<br>
> > +func (l Value) SetCleanup(cleanup bool) {<br>
> > +       C.LLVMSetCleanup(l.C, boolToLLVMBool(cleanup))<br>
> > +}<br>
> > +<br>
> > +func (b Builder) CreateResume(ex Value) (v Value) {<br>
> > +       v.C = C.LLVMBuildResume(b.C, ex.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.ModuleProvider<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// Changes the type of M so it can be passed to FunctionPassManagers and<br>
> > the<br>
> > +// JIT. They take ModuleProviders for historical reasons.<br>
> > +func NewModuleProviderForModule(m Module) (mp ModuleProvider) {<br>
> > +       mp.C = C.LLVMCreateModuleProviderForExistingModule(m.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Destroys the module M.<br>
> > +func (mp ModuleProvider) Dispose() { C.LLVMDisposeModuleProvider(mp.C) }<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.MemoryBuffer<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +func NewMemoryBufferFromFile(path string) (b MemoryBuffer, err error) {<br>
> > +       var cmsg *C.char<br>
> > +       cpath := C.CString(path)<br>
> > +       defer C.free(unsafe.Pointer(cpath))<br>
> > +       fail := C.LLVMCreateMemoryBufferWithContentsOfFile(cpath, &b.C,<br>
> > &cmsg)<br>
> > +       if fail != 0 {<br>
> > +               b.C = nil<br>
> > +               err = errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func NewMemoryBufferFromStdin() (b MemoryBuffer, err error) {<br>
> > +       var cmsg *C.char<br>
> > +       fail := C.LLVMCreateMemoryBufferWithSTDIN(&b.C, &cmsg)<br>
> > +       if fail != 0 {<br>
> > +               b.C = nil<br>
> > +               err = errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (b MemoryBuffer) Bytes() []byte {<br>
> > +       cstart := C.LLVMGetBufferStart(b.C)<br>
> > +       csize := C.LLVMGetBufferSize(b.C)<br>
> > +       return C.GoBytes(unsafe.Pointer(cstart), C.int(csize))<br>
> > +}<br>
> > +<br>
> > +func (b MemoryBuffer) Dispose() { C.LLVMDisposeMemoryBuffer(b.C) }<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.PassManager<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// Constructs a new whole-module pass pipeline. This type of pipeline is<br>
> > +// suitable for link-time optimization and whole-module transformations.<br>
> > +// See llvm::PassManager::PassManager.<br>
> > +func NewPassManager() (pm PassManager) { pm.C =<br>
> > C.LLVMCreatePassManager(); return }<br>
> > +<br>
> > +// Constructs a new function-by-function pass pipeline over the module<br>
> > +// provider. It does not take ownership of the module provider. This type<br>
> > of<br>
> > +// pipeline is suitable for code generation and JIT compilation tasks.<br>
> > +// See llvm::FunctionPassManager::FunctionPassManager.<br>
> > +func NewFunctionPassManagerForModule(m Module) (pm PassManager) {<br>
> > +       pm.C = C.LLVMCreateFunctionPassManagerForModule(m.C)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Initializes, executes on the provided module, and finalizes all of the<br>
> > +// passes scheduled in the pass manager. Returns 1 if any of the passes<br>
> > +// modified the module, 0 otherwise. See llvm::PassManager::run(Module&).<br>
> > +func (pm PassManager) Run(m Module) bool { return<br>
> > C.LLVMRunPassManager(pm.C, m.C) != 0 }<br>
> > +<br>
> > +// Initializes all of the function passes scheduled in the function pass<br>
> > +// manager. Returns 1 if any of the passes modified the module, 0<br>
> > otherwise.<br>
> > +// See llvm::FunctionPassManager::doInitialization.<br>
> > +func (pm PassManager) InitializeFunc() bool { return<br>
> > C.LLVMInitializeFunctionPassManager(pm.C) != 0 }<br>
> > +<br>
> > +// Executes all of the function passes scheduled in the function pass<br>
> > manager<br>
> > +// on the provided function. Returns 1 if any of the passes modified the<br>
> > +// function, false otherwise.<br>
> > +// See llvm::FunctionPassManager::run(Function&).<br>
> > +func (pm PassManager) RunFunc(f Value) bool { return<br>
> > C.LLVMRunFunctionPassManager(pm.C, f.C) != 0 }<br>
> > +<br>
> > +// Finalizes all of the function passes scheduled in in the function pass<br>
> > +// manager. Returns 1 if any of the passes modified the module, 0<br>
> > otherwise.<br>
> > +// See llvm::FunctionPassManager::doFinalization.<br>
> > +func (pm PassManager) FinalizeFunc() bool { return<br>
> > C.LLVMFinalizeFunctionPassManager(pm.C) != 0 }<br>
> > +<br>
> > +// Frees the memory of a pass pipeline. For function pipelines, does not<br>
> > free<br>
> > +// the module provider.<br>
> > +// See llvm::PassManagerBase::~PassManagerBase.<br>
> > +func (pm PassManager) Dispose() { C.LLVMDisposePassManager(pm.C) }<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/ir_test.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir_test.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir_test.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/ir_test.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/ir_test.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,95 @@<br>
> > +//===- ir_test.go - Tests for ir<br>
> > ------------------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file tests bindings for the ir component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +import (<br>
> > +       "strings"<br>
> > +       "testing"<br>
> > +)<br>
> > +<br>
> > +func testAttribute(t *testing.T, attr Attribute, name string) {<br>
> > +       mod := NewModule("")<br>
> > +       defer mod.Dispose()<br>
> > +<br>
> > +       ftyp := FunctionType(VoidType(), nil, false)<br>
> > +       fn := AddFunction(mod, "foo", ftyp)<br>
> > +<br>
> > +       fn.AddFunctionAttr(attr)<br>
> > +       newattr := fn.FunctionAttr()<br>
> > +       if attr != newattr {<br>
> > +               t.Errorf("got attribute mask %d, want %d", newattr, attr)<br>
> > +       }<br>
> > +<br>
> > +       text := mod.String()<br>
> > +       if !strings.Contains(text, " "+name+" ") {<br>
> > +               t.Errorf("expected attribute '%s', got:\n%s", name, text)<br>
> > +       }<br>
> > +<br>
> > +       fn.RemoveFunctionAttr(attr)<br>
> > +       newattr = fn.FunctionAttr()<br>
> > +       if newattr != 0 {<br>
> > +               t.Errorf("got attribute mask %d, want 0", newattr)<br>
> > +       }<br>
> > +}<br>
> > +<br>
> > +func TestAttributes(t *testing.T) {<br>
> > +       // Tests that our attribute constants haven't drifted from LLVM's.<br>
> > +       attrTests := []struct {<br>
> > +               attr Attribute<br>
> > +               name string<br>
> > +       }{<br>
> > +               {SanitizeAddressAttribute, "sanitize_address"},<br>
> > +               {AlwaysInlineAttribute, "alwaysinline"},<br>
> > +               {BuiltinAttribute, "builtin"},<br>
> > +               {ByValAttribute, "byval"},<br>
> > +               {InAllocaAttribute, "inalloca"},<br>
> > +               {InlineHintAttribute, "inlinehint"},<br>
> > +               {InRegAttribute, "inreg"},<br>
> > +               {JumpTableAttribute, "jumptable"},<br>
> > +               {MinSizeAttribute, "minsize"},<br>
> > +               {NakedAttribute, "naked"},<br>
> > +               {NestAttribute, "nest"},<br>
> > +               {NoAliasAttribute, "noalias"},<br>
> > +               {NoBuiltinAttribute, "nobuiltin"},<br>
> > +               {NoCaptureAttribute, "nocapture"},<br>
> > +               {NoDuplicateAttribute, "noduplicate"},<br>
> > +               {NoImplicitFloatAttribute, "noimplicitfloat"},<br>
> > +               {NoInlineAttribute, "noinline"},<br>
> > +               {NonLazyBindAttribute, "nonlazybind"},<br>
> > +               {NonNullAttribute, "nonnull"},<br>
> > +               {NoRedZoneAttribute, "noredzone"},<br>
> > +               {NoReturnAttribute, "noreturn"},<br>
> > +               {NoUnwindAttribute, "nounwind"},<br>
> > +               {OptimizeNoneAttribute, "optnone"},<br>
> > +               {OptimizeForSizeAttribute, "optsize"},<br>
> > +               {ReadNoneAttribute, "readnone"},<br>
> > +               {ReadOnlyAttribute, "readonly"},<br>
> > +               {ReturnedAttribute, "returned"},<br>
> > +               {ReturnsTwiceAttribute, "returns_twice"},<br>
> > +               {SExtAttribute, "signext"},<br>
> > +               {StackProtectAttribute, "ssp"},<br>
> > +               {StackProtectReqAttribute, "sspreq"},<br>
> > +               {StackProtectStrongAttribute, "sspstrong"},<br>
> > +               {StructRetAttribute, "sret"},<br>
> > +               {SanitizeThreadAttribute, "sanitize_thread"},<br>
> > +               {SanitizeMemoryAttribute, "sanitize_memory"},<br>
> > +               {UWTableAttribute, "uwtable"},<br>
> > +               {ZExtAttribute, "zeroext"},<br>
> > +               {ColdAttribute, "cold"},<br>
> > +       }<br>
> > +<br>
> > +       for _, a := range attrTests {<br>
> > +               testAttribute(t, a.attr, <a href="http://a.name" target="_blank">a.name</a>)<br>
> > +       }<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/linker.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/linker.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/linker.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/linker.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/linker.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,39 @@<br>
> > +//===- linker.go - Bindings for linker<br>
> > ------------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the linker component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Linker.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "errors"<br>
> > +<br>
> > +type LinkerMode C.LLVMLinkerMode<br>
> > +<br>
> > +const (<br>
> > +       LinkerDestroySource  = C.LLVMLinkerDestroySource<br>
> > +       LinkerPreserveSource = C.LLVMLinkerPreserveSource<br>
> > +)<br>
> > +<br>
> > +func LinkModules(Dest, Src Module, Mode LinkerMode) error {<br>
> > +       var cmsg *C.char<br>
> > +       failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerMode(Mode),<br>
> > &cmsg)<br>
> > +       if failed != 0 {<br>
> > +               err := errors.New(C.GoString(cmsg))<br>
> > +               C.LLVMDisposeMessage(cmsg)<br>
> > +               return err<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/<a href="http://llvm_config.go.in" target="_blank">llvm_config.go.in</a><br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/llvm_config.go.in?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/llvm_config.go.in?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/<a href="http://llvm_config.go.in" target="_blank">llvm_config.go.in</a> (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/<a href="http://llvm_config.go.in" target="_blank">llvm_config.go.in</a> Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,12 @@<br>
> > +// +build !byollvm<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#cgo CXXFLAGS: -std=c++11<br>
> > +#cgo CPPFLAGS: @LLVM_CFLAGS@<br>
> > +#cgo LDFLAGS: @LLVM_LDFLAGS@<br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +type (run_build_sh int)<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/llvm_dep.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/llvm_dep.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/llvm_dep.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/llvm_dep.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/llvm_dep.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,19 @@<br>
> > +//===- llvm_dep.go - creates LLVM dependency<br>
> > ------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file ensures that the LLVM libraries are built before using the<br>
> > +// bindings.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +// +build !byollvm<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +var _ run_build_sh<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/string.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/string.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/string.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/string.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/string.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,105 @@<br>
> > +//===- string.go - Stringer implementation for Type<br>
> > -----------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file implements the Stringer interface for the Type type.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +import "fmt"<br>
> > +<br>
> > +func (t TypeKind) String() string {<br>
> > +       switch t {<br>
> > +       case VoidTypeKind:<br>
> > +               return "VoidTypeKind"<br>
> > +       case FloatTypeKind:<br>
> > +               return "FloatTypeKind"<br>
> > +       case DoubleTypeKind:<br>
> > +               return "DoubleTypeKind"<br>
> > +       case X86_FP80TypeKind:<br>
> > +               return "X86_FP80TypeKind"<br>
> > +       case FP128TypeKind:<br>
> > +               return "FP128TypeKind"<br>
> > +       case PPC_FP128TypeKind:<br>
> > +               return "PPC_FP128TypeKind"<br>
> > +       case LabelTypeKind:<br>
> > +               return "LabelTypeKind"<br>
> > +       case IntegerTypeKind:<br>
> > +               return "IntegerTypeKind"<br>
> > +       case FunctionTypeKind:<br>
> > +               return "FunctionTypeKind"<br>
> > +       case StructTypeKind:<br>
> > +               return "StructTypeKind"<br>
> > +       case ArrayTypeKind:<br>
> > +               return "ArrayTypeKind"<br>
> > +       case PointerTypeKind:<br>
> > +               return "PointerTypeKind"<br>
> > +       case VectorTypeKind:<br>
> > +               return "VectorTypeKind"<br>
> > +       case MetadataTypeKind:<br>
> > +               return "MetadataTypeKind"<br>
> > +       }<br>
> > +       panic("unreachable")<br>
> > +}<br>
> > +<br>
> > +func (t Type) String() string {<br>
> > +       ts := typeStringer{s: make(map[Type]string)}<br>
> > +       return ts.typeString(t)<br>
> > +}<br>
> > +<br>
> > +type typeStringer struct {<br>
> > +       s map[Type]string<br>
> > +}<br>
> > +<br>
> > +func (ts *typeStringer) typeString(t Type) string {<br>
> > +       if s, ok := ts.s[t]; ok {<br>
> > +               return s<br>
> > +       }<br>
> > +<br>
> > +       k := t.TypeKind()<br>
> > +       s := k.String()<br>
> > +       s = s[:len(s)-len("Kind")]<br>
> > +<br>
> > +       switch k {<br>
> > +       case ArrayTypeKind:<br>
> > +               s += fmt.Sprintf("(%v[%v])",<br>
> > ts.typeString(t.ElementType()), t.ArrayLength())<br>
> > +       case PointerTypeKind:<br>
> > +               s += fmt.Sprintf("(%v)", ts.typeString(t.ElementType()))<br>
> > +       case FunctionTypeKind:<br>
> > +               params := t.ParamTypes()<br>
> > +               s += "("<br>
> > +               if len(params) > 0 {<br>
> > +                       s += fmt.Sprintf("%v", ts.typeString(params[0]))<br>
> > +                       for i := 1; i < len(params); i++ {<br>
> > +                               s += fmt.Sprintf(", %v",<br>
> > ts.typeString(params[i]))<br>
> > +                       }<br>
> > +               }<br>
> > +               s += fmt.Sprintf("):%v", ts.typeString(t.ReturnType()))<br>
> > +       case StructTypeKind:<br>
> > +               if name := t.StructName(); name != "" {<br>
> > +                       ts.s[t] = "%" + name<br>
> > +                       s = fmt.Sprintf("%%%s: %s", name, s)<br>
> > +               }<br>
> > +               etypes := t.StructElementTypes()<br>
> > +               s += "("<br>
> > +               if n := len(etypes); n > 0 {<br>
> > +                       s += ts.typeString(etypes[0])<br>
> > +                       for i := 1; i < n; i++ {<br>
> > +                               s += fmt.Sprintf(", %v",<br>
> > ts.typeString(etypes[i]))<br>
> > +                       }<br>
> > +               }<br>
> > +               s += ")"<br>
> > +       case IntegerTypeKind:<br>
> > +               s += fmt.Sprintf("(%d bits)", t.IntTypeWidth())<br>
> > +       }<br>
> > +<br>
> > +       ts.s[t] = s<br>
> > +       return s<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/string_test.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/string_test.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/string_test.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/string_test.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/string_test.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,28 @@<br>
> > +//===- string_test.go - test Stringer implementation for Type<br>
> > -------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file tests the Stringer interface for the Type type.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +import (<br>
> > +       "testing"<br>
> > +)<br>
> > +<br>
> > +func TestStringRecursiveType(t *testing.T) {<br>
> > +       ctx := NewContext()<br>
> > +       defer ctx.Dispose()<br>
> > +       s := ctx.StructCreateNamed("recursive")<br>
> > +       s.StructSetBody([]Type{s, s}, false)<br>
> > +       if str := s.String(); str != "%recursive: StructType(%recursive,<br>
> > %recursive)" {<br>
> > +               t.Errorf("incorrect string result %q", str)<br>
> > +       }<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/support.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/support.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/support.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/support.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/support.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,54 @@<br>
> > +//===- support.go - Bindings for support<br>
> > ----------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the support component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Support.h"<br>
> > +#include "SupportBindings.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +import (<br>
> > +       "errors"<br>
> > +       "unsafe"<br>
> > +)<br>
> > +<br>
> > +// Loads a dynamic library such that it may be used as an LLVM plugin.<br>
> > +// See llvm::sys::DynamicLibrary::LoadLibraryPermanently.<br>
> > +func LoadLibraryPermanently(lib string) error {<br>
> > +       var errstr *C.char<br>
> > +       libstr := C.CString(lib)<br>
> > +       defer C.free(unsafe.Pointer(libstr))<br>
> > +       C.LLVMLoadLibraryPermanently2(libstr, &errstr)<br>
> > +       if errstr != nil {<br>
> > +               err := errors.New(C.GoString(errstr))<br>
> > +               C.free(unsafe.Pointer(errstr))<br>
> > +               return err<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +// Parse the given arguments using the LLVM command line parser.<br>
> > +// See llvm::cl::ParseCommandLineOptions.<br>
> > +func ParseCommandLineOptions(args []string, overview string) {<br>
> > +       argstrs := make([]*C.char, len(args))<br>
> > +       for i, arg := range args {<br>
> > +               argstrs[i] = C.CString(arg)<br>
> > +               defer C.free(unsafe.Pointer(argstrs[i]))<br>
> > +       }<br>
> > +       overviewstr := C.CString(overview)<br>
> > +       defer C.free(unsafe.Pointer(overviewstr))<br>
> > +       C.LLVMParseCommandLineOptions(C.int(len(args)), &argstrs[0],<br>
> > overviewstr)<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/target.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/target.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/target.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/target.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/target.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,300 @@<br>
> > +//===- target.go - Bindings for target<br>
> > ------------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the target component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Target.h"<br>
> > +#include "llvm-c/TargetMachine.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "unsafe"<br>
> > +import "errors"<br>
> > +<br>
> > +type (<br>
> > +       TargetData struct {<br>
> > +               C C.LLVMTargetDataRef<br>
> > +       }<br>
> > +       Target struct {<br>
> > +               C C.LLVMTargetRef<br>
> > +       }<br>
> > +       TargetMachine struct {<br>
> > +               C C.LLVMTargetMachineRef<br>
> > +       }<br>
> > +       ByteOrdering    C.enum_LLVMByteOrdering<br>
> > +       RelocMode       C.LLVMRelocMode<br>
> > +       CodeGenOptLevel C.LLVMCodeGenOptLevel<br>
> > +       CodeGenFileType C.LLVMCodeGenFileType<br>
> > +       CodeModel       C.LLVMCodeModel<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       BigEndian    ByteOrdering = C.LLVMBigEndian<br>
> > +       LittleEndian ByteOrdering = C.LLVMLittleEndian<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       RelocDefault      RelocMode = C.LLVMRelocDefault<br>
> > +       RelocStatic       RelocMode = C.LLVMRelocStatic<br>
> > +       RelocPIC          RelocMode = C.LLVMRelocPIC<br>
> > +       RelocDynamicNoPic RelocMode = C.LLVMRelocDynamicNoPic<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       CodeGenLevelNone       CodeGenOptLevel = C.LLVMCodeGenLevelNone<br>
> > +       CodeGenLevelLess       CodeGenOptLevel = C.LLVMCodeGenLevelLess<br>
> > +       CodeGenLevelDefault    CodeGenOptLevel = C.LLVMCodeGenLevelDefault<br>
> > +       CodeGenLevelAggressive CodeGenOptLevel =<br>
> > C.LLVMCodeGenLevelAggressive<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       CodeModelDefault    CodeModel = C.LLVMCodeModelDefault<br>
> > +       CodeModelJITDefault CodeModel = C.LLVMCodeModelJITDefault<br>
> > +       CodeModelSmall      CodeModel = C.LLVMCodeModelSmall<br>
> > +       CodeModelKernel     CodeModel = C.LLVMCodeModelKernel<br>
> > +       CodeModelMedium     CodeModel = C.LLVMCodeModelMedium<br>
> > +       CodeModelLarge      CodeModel = C.LLVMCodeModelLarge<br>
> > +)<br>
> > +<br>
> > +const (<br>
> > +       AssemblyFile CodeGenFileType = C.LLVMAssemblyFile<br>
> > +       ObjectFile   CodeGenFileType = C.LLVMObjectFile<br>
> > +)<br>
> > +<br>
> > +// InitializeAllTargetInfos - The main program should call this function<br>
> > if it<br>
> > +// wants access to all available targets that LLVM is configured to<br>
> > support.<br>
> > +func InitializeAllTargetInfos() { C.LLVMInitializeAllTargetInfos() }<br>
> > +<br>
> > +// InitializeAllTargets - The main program should call this function if<br>
> > it wants<br>
> > +// to link in all available targets that LLVM is configured to support.<br>
> > +func InitializeAllTargets() { C.LLVMInitializeAllTargets() }<br>
> > +<br>
> > +func InitializeAllTargetMCs() { C.LLVMInitializeAllTargetMCs() }<br>
> > +<br>
> > +func InitializeAllAsmParsers() { C.LLVMInitializeAllAsmParsers() }<br>
> > +<br>
> > +func InitializeAllAsmPrinters() { C.LLVMInitializeAllAsmPrinters() }<br>
> > +<br>
> > +var initializeNativeTargetError = errors.New("Failed to initialize native<br>
> > target")<br>
> > +<br>
> > +// InitializeNativeTarget - The main program should call this function to<br>
> > +// initialize the native target corresponding to the host. This is useful<br>
> > +// for JIT applications to ensure that the target gets linked in<br>
> > correctly.<br>
> > +func InitializeNativeTarget() error {<br>
> > +       fail := C.LLVMInitializeNativeTarget()<br>
> > +       if fail != 0 {<br>
> > +               return initializeNativeTargetError<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> > +func InitializeNativeAsmPrinter() error {<br>
> > +       fail := C.LLVMInitializeNativeAsmPrinter()<br>
> > +       if fail != 0 {<br>
> > +               return initializeNativeTargetError<br>
> > +       }<br>
> > +       return nil<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.TargetData<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// Creates target data from a target layout string.<br>
> > +// See the constructor llvm::TargetData::TargetData.<br>
> > +func NewTargetData(rep string) (td TargetData) {<br>
> > +       crep := C.CString(rep)<br>
> > +       defer C.free(unsafe.Pointer(crep))<br>
> > +       td.C = C.LLVMCreateTargetData(crep)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Adds target data information to a pass manager. This does not take<br>
> > ownership<br>
> > +// of the target data.<br>
> > +// See the method llvm::PassManagerBase::add.<br>
> > +func (pm PassManager) Add(td TargetData) {<br>
> > +       C.LLVMAddTargetData(td.C, pm.C)<br>
> > +}<br>
> > +<br>
> > +// Converts target data to a target layout string. The string must be<br>
> > disposed<br>
> > +// with LLVMDisposeMessage.<br>
> > +// See the constructor llvm::TargetData::TargetData.<br>
> > +func (td TargetData) String() (s string) {<br>
> > +       cmsg := C.LLVMCopyStringRepOfTargetData(td.C)<br>
> > +       s = C.GoString(cmsg)<br>
> > +       C.LLVMDisposeMessage(cmsg)<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Returns the byte order of a target, either BigEndian or LittleEndian.<br>
> > +// See the method llvm::TargetData::isLittleEndian.<br>
> > +func (td TargetData) ByteOrder() ByteOrdering { return<br>
> > ByteOrdering(C.LLVMByteOrder(td.C)) }<br>
> > +<br>
> > +// Returns the pointer size in bytes for a target.<br>
> > +// See the method llvm::TargetData::getPointerSize.<br>
> > +func (td TargetData) PointerSize() int { return<br>
> > int(C.LLVMPointerSize(td.C)) }<br>
> > +<br>
> > +// Returns the integer type that is the same size as a pointer on a<br>
> > target.<br>
> > +// See the method llvm::TargetData::getIntPtrType.<br>
> > +func (td TargetData) IntPtrType() (t Type) { t.C =<br>
> > C.LLVMIntPtrType(td.C); return }<br>
> > +<br>
> > +// Computes the size of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getTypeSizeInBits.<br>
> > +func (td TargetData) TypeSizeInBits(t Type) uint64 {<br>
> > +       return uint64(C.LLVMSizeOfTypeInBits(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the storage size of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getTypeStoreSize.<br>
> > +func (td TargetData) TypeStoreSize(t Type) uint64 {<br>
> > +       return uint64(C.LLVMStoreSizeOfType(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the ABI size of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getTypeAllocSize.<br>
> > +func (td TargetData) TypeAllocSize(t Type) uint64 {<br>
> > +       return uint64(C.LLVMABISizeOfType(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the ABI alignment of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getABITypeAlignment.<br>
> > +func (td TargetData) ABITypeAlignment(t Type) int {<br>
> > +       return int(C.LLVMABIAlignmentOfType(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the call frame alignment of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getCallFrameTypeAlignment.<br>
> > +func (td TargetData) CallFrameTypeAlignment(t Type) int {<br>
> > +       return int(C.LLVMCallFrameAlignmentOfType(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the preferred alignment of a type in bytes for a target.<br>
> > +// See the method llvm::TargetData::getPrefTypeAlignment.<br>
> > +func (td TargetData) PrefTypeAlignment(t Type) int {<br>
> > +       return int(C.LLVMPreferredAlignmentOfType(td.C, t.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the preferred alignment of a global variable in bytes for a<br>
> > target.<br>
> > +// See the method llvm::TargetData::getPreferredAlignment.<br>
> > +func (td TargetData) PreferredAlignment(g Value) int {<br>
> > +       return int(C.LLVMPreferredAlignmentOfGlobal(td.C, g.C))<br>
> > +}<br>
> > +<br>
> > +// Computes the structure element that contains the byte offset for a<br>
> > target.<br>
> > +// See the method llvm::StructLayout::getElementContainingOffset.<br>
> > +func (td TargetData) ElementContainingOffset(t Type, offset uint64) int {<br>
> > +       return int(C.LLVMElementAtOffset(td.C, t.C, C.ulonglong(offset)))<br>
> > +}<br>
> > +<br>
> > +// Computes the byte offset of the indexed struct element for a target.<br>
> > +// See the method llvm::StructLayout::getElementOffset.<br>
> > +func (td TargetData) ElementOffset(t Type, element int) uint64 {<br>
> > +       return uint64(C.LLVMOffsetOfElement(td.C, t.C,<br>
> > C.unsigned(element)))<br>
> > +}<br>
> > +<br>
> > +// Deallocates a TargetData.<br>
> > +// See the destructor llvm::TargetData::~TargetData.<br>
> > +func (td TargetData) Dispose() { C.LLVMDisposeTargetData(td.C) }<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.Target<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +func FirstTarget() Target {<br>
> > +       return Target{C.LLVMGetFirstTarget()}<br>
> > +}<br>
> > +<br>
> > +func (t Target) NextTarget() Target {<br>
> > +       return Target{C.LLVMGetNextTarget(t.C)}<br>
> > +}<br>
> > +<br>
> > +func GetTargetFromTriple(triple string) (t Target, err error) {<br>
> > +       var errstr *C.char<br>
> > +       ctriple := C.CString(triple)<br>
> > +       defer C.free(unsafe.Pointer(ctriple))<br>
> > +       fail := C.LLVMGetTargetFromTriple(ctriple, &t.C, &errstr)<br>
> > +       if fail != 0 {<br>
> > +               err = errors.New(C.GoString(errstr))<br>
> > +               C.free(unsafe.Pointer(errstr))<br>
> > +       }<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (t Target) Name() string {<br>
> > +       return C.GoString(C.LLVMGetTargetName(t.C))<br>
> > +}<br>
> > +<br>
> > +func (t Target) Description() string {<br>
> > +       return C.GoString(C.LLVMGetTargetDescription(t.C))<br>
> > +}<br>
> > +<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +// llvm.TargetMachine<br>
> ><br>
> > +//-------------------------------------------------------------------------<br>
> > +<br>
> > +// CreateTargetMachine creates a new TargetMachine.<br>
> > +func (t Target) CreateTargetMachine(Triple string, CPU string, Features<br>
> > string,<br>
> > +       Level CodeGenOptLevel, Reloc RelocMode,<br>
> > +       CodeModel CodeModel) (tm TargetMachine) {<br>
> > +       cTriple := C.CString(Triple)<br>
> > +       defer C.free(unsafe.Pointer(cTriple))<br>
> > +       cCPU := C.CString(CPU)<br>
> > +       defer C.free(unsafe.Pointer(cCPU))<br>
> > +       cFeatures := C.CString(Features)<br>
> > +       defer C.free(unsafe.Pointer(cFeatures))<br>
> > +       tm.C = C.LLVMCreateTargetMachine(t.C, cTriple, cCPU, cFeatures,<br>
> > +               C.LLVMCodeGenOptLevel(Level),<br>
> > +               C.LLVMRelocMode(Reloc),<br>
> > +               C.LLVMCodeModel(CodeModel))<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +// Triple returns the triple describing the machine (arch-vendor-os).<br>
> > +func (tm TargetMachine) Triple() string {<br>
> > +       cstr := C.LLVMGetTargetMachineTriple(tm.C)<br>
> > +       return C.GoString(cstr)<br>
> > +}<br>
> > +<br>
> > +// TargetData returns the TargetData for the machine.<br>
> > +func (tm TargetMachine) TargetData() TargetData {<br>
> > +       return TargetData{C.LLVMGetTargetMachineData(tm.C)}<br>
> > +}<br>
> > +<br>
> > +func (tm TargetMachine) EmitToMemoryBuffer(m Module, ft CodeGenFileType)<br>
> > (MemoryBuffer, error) {<br>
> > +       var errstr *C.char<br>
> > +       var mb MemoryBuffer<br>
> > +       fail := C.LLVMTargetMachineEmitToMemoryBuffer(tm.C, m.C,<br>
> > C.LLVMCodeGenFileType(ft), &errstr, &mb.C)<br>
> > +       if fail != 0 {<br>
> > +               err := errors.New(C.GoString(errstr))<br>
> > +               C.free(unsafe.Pointer(errstr))<br>
> > +               return MemoryBuffer{}, err<br>
> > +       }<br>
> > +       return mb, nil<br>
> > +}<br>
> > +<br>
> > +func (tm TargetMachine) AddAnalysisPasses(pm PassManager) {<br>
> > +       C.LLVMAddAnalysisPasses(tm.C, pm.C)<br>
> > +}<br>
> > +<br>
> > +// Dispose releases resources related to the TargetMachine.<br>
> > +func (tm TargetMachine) Dispose() {<br>
> > +       C.LLVMDisposeTargetMachine(tm.C)<br>
> > +}<br>
> > +<br>
> > +func DefaultTargetTriple() (triple string) {<br>
> > +       cTriple := C.LLVMGetDefaultTargetTriple()<br>
> > +       defer C.free(unsafe.Pointer(cTriple))<br>
> > +       triple = C.GoString(cTriple)<br>
> > +       return<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/transforms_instrumentation.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_instrumentation.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_instrumentation.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/transforms_instrumentation.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/transforms_instrumentation.go Thu Oct 16<br>
> > 17:48:02 2014<br>
> > @@ -0,0 +1,43 @@<br>
> > +//===- transforms_instrumentation.go - Bindings for instrumentation<br>
> > -------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the instrumentation component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "InstrumentationBindings.h"<br>
> > +#include <stdlib.h><br>
> > +*/<br>
> > +import "C"<br>
> > +import "unsafe"<br>
> > +<br>
> > +func (pm PassManager) AddAddressSanitizerFunctionPass() {<br>
> > +       C.LLVMAddAddressSanitizerFunctionPass(pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pm PassManager) AddAddressSanitizerModulePass() {<br>
> > +       C.LLVMAddAddressSanitizerModulePass(pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pm PassManager) AddThreadSanitizerPass() {<br>
> > +       C.LLVMAddThreadSanitizerPass(pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pm PassManager) AddMemorySanitizerPass() {<br>
> > +       C.LLVMAddMemorySanitizerPass(pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pm PassManager) AddDataFlowSanitizerPass(abilist string) {<br>
> > +       cabilist := C.CString(abilist)<br>
> > +       defer C.free(unsafe.Pointer(cabilist))<br>
> > +       C.LLVMAddDataFlowSanitizerPass(pm.C, cabilist)<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/transforms_ipo.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_ipo.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_ipo.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/transforms_ipo.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/transforms_ipo.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,42 @@<br>
> > +//===- transforms_ipo.go - Bindings for ipo<br>
> > -------------------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the ipo component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Transforms/IPO.h"<br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +// helpers<br>
> > +func boolToUnsigned(b bool) C.unsigned {<br>
> > +       if b {<br>
> > +               return 1<br>
> > +       }<br>
> > +       return 0<br>
> > +}<br>
> > +<br>
> > +func (pm PassManager) AddArgumentPromotionPass()     {<br>
> > C.LLVMAddArgumentPromotionPass(pm.C) }<br>
> > +func (pm PassManager) AddConstantMergePass()         {<br>
> > C.LLVMAddConstantMergePass(pm.C) }<br>
> > +func (pm PassManager) AddDeadArgEliminationPass()    {<br>
> > C.LLVMAddDeadArgEliminationPass(pm.C) }<br>
> > +func (pm PassManager) AddFunctionAttrsPass()         {<br>
> > C.LLVMAddFunctionAttrsPass(pm.C) }<br>
> > +func (pm PassManager) AddFunctionInliningPass()      {<br>
> > C.LLVMAddFunctionInliningPass(pm.C) }<br>
> > +func (pm PassManager) AddGlobalDCEPass()             {<br>
> > C.LLVMAddGlobalDCEPass(pm.C) }<br>
> > +func (pm PassManager) AddGlobalOptimizerPass()       {<br>
> > C.LLVMAddGlobalOptimizerPass(pm.C) }<br>
> > +func (pm PassManager) AddIPConstantPropagationPass() {<br>
> > C.LLVMAddIPConstantPropagationPass(pm.C) }<br>
> > +func (pm PassManager) AddPruneEHPass()               {<br>
> > C.LLVMAddPruneEHPass(pm.C) }<br>
> > +func (pm PassManager) AddIPSCCPPass()                {<br>
> > C.LLVMAddIPSCCPPass(pm.C) }<br>
> > +func (pm PassManager) AddInternalizePass(allButMain bool) {<br>
> > +       C.LLVMAddInternalizePass(pm.C, boolToUnsigned(allButMain))<br>
> > +}<br>
> > +func (pm PassManager) AddStripDeadPrototypesPass() {<br>
> > C.LLVMAddStripDeadPrototypesPass(pm.C) }<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/transforms_pmbuilder.go Thu Oct 16<br>
> > 17:48:02 2014<br>
> > @@ -0,0 +1,48 @@<br>
> > +//===- transforms_pmbuilder.go - Bindings for PassManagerBuilder<br>
> > ----------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the PassManagerBuilder class.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Transforms/PassManagerBuilder.h"<br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +type PassManagerBuilder struct {<br>
> > +       C C.LLVMPassManagerBuilderRef<br>
> > +}<br>
> > +<br>
> > +func NewPassManagerBuilder() (pmb PassManagerBuilder) {<br>
> > +       pmb.C = C.LLVMPassManagerBuilderCreate()<br>
> > +       return<br>
> > +}<br>
> > +<br>
> > +func (pmb PassManagerBuilder) SetOptLevel(level int) {<br>
> > +       C.LLVMPassManagerBuilderSetOptLevel(pmb.C, C.uint(level))<br>
> > +}<br>
> > +<br>
> > +func (pmb PassManagerBuilder) SetSizeLevel(level int) {<br>
> > +       C.LLVMPassManagerBuilderSetSizeLevel(pmb.C, C.uint(level))<br>
> > +}<br>
> > +<br>
> > +func (pmb PassManagerBuilder) Populate(pm PassManager) {<br>
> > +       C.LLVMPassManagerBuilderPopulateModulePassManager(pmb.C, pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pmb PassManagerBuilder) PopulateFunc(pm PassManager) {<br>
> > +       C.LLVMPassManagerBuilderPopulateFunctionPassManager(pmb.C, pm.C)<br>
> > +}<br>
> > +<br>
> > +func (pmb PassManagerBuilder) Dispose() {<br>
> > +       C.LLVMPassManagerBuilderDispose(pmb.C)<br>
> > +}<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/transforms_scalar.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_scalar.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/transforms_scalar.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/transforms_scalar.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/transforms_scalar.go Thu Oct 16 17:48:02<br>
> > 2014<br>
> > @@ -0,0 +1,45 @@<br>
> > +//===- transforms_scalar.go - Bindings for scalaropts<br>
> > ---------------------===//<br>
> > +//<br>
> > +//                     The LLVM Compiler Infrastructure<br>
> > +//<br>
> > +// This file is distributed under the University of Illinois Open Source<br>
> > +// License. See LICENSE.TXT for details.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +//<br>
> > +// This file defines bindings for the scalaropts component.<br>
> > +//<br>
> ><br>
> > +//===----------------------------------------------------------------------===//<br>
> > +<br>
> > +package llvm<br>
> > +<br>
> > +/*<br>
> > +#include "llvm-c/Transforms/Scalar.h"<br>
> > +*/<br>
> > +import "C"<br>
> > +<br>
> > +func (pm PassManager) AddAggressiveDCEPass()           {<br>
> > C.LLVMAddAggressiveDCEPass(pm.C) }<br>
> > +func (pm PassManager) AddCFGSimplificationPass()       {<br>
> > C.LLVMAddCFGSimplificationPass(pm.C) }<br>
> > +func (pm PassManager) AddDeadStoreEliminationPass()    {<br>
> > C.LLVMAddDeadStoreEliminationPass(pm.C) }<br>
> > +func (pm PassManager) AddGVNPass()                     {<br>
> > C.LLVMAddGVNPass(pm.C) }<br>
> > +func (pm PassManager) AddIndVarSimplifyPass()          {<br>
> > C.LLVMAddIndVarSimplifyPass(pm.C) }<br>
> > +func (pm PassManager) AddInstructionCombiningPass()    {<br>
> > C.LLVMAddInstructionCombiningPass(pm.C) }<br>
> > +func (pm PassManager) AddJumpThreadingPass()           {<br>
> > C.LLVMAddJumpThreadingPass(pm.C) }<br>
> > +func (pm PassManager) AddLICMPass()                    {<br>
> > C.LLVMAddLICMPass(pm.C) }<br>
> > +func (pm PassManager) AddLoopDeletionPass()            {<br>
> > C.LLVMAddLoopDeletionPass(pm.C) }<br>
> > +func (pm PassManager) AddLoopRotatePass()              {<br>
> > C.LLVMAddLoopRotatePass(pm.C) }<br>
> > +func (pm PassManager) AddLoopUnrollPass()              {<br>
> > C.LLVMAddLoopUnrollPass(pm.C) }<br>
> > +func (pm PassManager) AddLoopUnswitchPass()            {<br>
> > C.LLVMAddLoopUnswitchPass(pm.C) }<br>
> > +func (pm PassManager) AddMemCpyOptPass()               {<br>
> > C.LLVMAddMemCpyOptPass(pm.C) }<br>
> > +func (pm PassManager) AddPromoteMemoryToRegisterPass() {<br>
> > C.LLVMAddPromoteMemoryToRegisterPass(pm.C) }<br>
> > +func (pm PassManager) AddReassociatePass()             {<br>
> > C.LLVMAddReassociatePass(pm.C) }<br>
> > +func (pm PassManager) AddSCCPPass()                    {<br>
> > C.LLVMAddSCCPPass(pm.C) }<br>
> > +func (pm PassManager) AddScalarReplAggregatesPass()    {<br>
> > C.LLVMAddScalarReplAggregatesPass(pm.C) }<br>
> > +func (pm PassManager) AddScalarReplAggregatesPassWithThreshold(threshold<br>
> > int) {<br>
> > +       C.LLVMAddScalarReplAggregatesPassWithThreshold(pm.C,<br>
> > C.int(threshold))<br>
> > +}<br>
> > +func (pm PassManager) AddSimplifyLibCallsPass()       {<br>
> > C.LLVMAddSimplifyLibCallsPass(pm.C) }<br>
> > +func (pm PassManager) AddTailCallEliminationPass()    {<br>
> > C.LLVMAddTailCallEliminationPass(pm.C) }<br>
> > +func (pm PassManager) AddConstantPropagationPass()    {<br>
> > C.LLVMAddConstantPropagationPass(pm.C) }<br>
> > +func (pm PassManager) AddDemoteMemoryToRegisterPass() {<br>
> > C.LLVMAddDemoteMemoryToRegisterPass(pm.C) }<br>
> > +func (pm PassManager) AddVerifierPass()               {<br>
> > C.LLVMAddVerifierPass(pm.C) }<br>
> ><br>
> > Added: llvm/trunk/bindings/go/llvm/version.go<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/version.go?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/version.go?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/bindings/go/llvm/version.go (added)<br>
> > +++ llvm/trunk/bindings/go/llvm/version.go Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,3 @@<br>
> > +package llvm<br>
> > +<br>
> > +const Version = "3.6.0svn"<br>
> ><br>
> > Modified: llvm/trunk/cmake/config-ix.cmake<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/cmake/config-ix.cmake (original)<br>
> > +++ llvm/trunk/cmake/config-ix.cmake Thu Oct 16 17:48:02 2014<br>
> > @@ -491,3 +491,18 @@ if (LLVM_ENABLE_SPHINX)<br>
> >  else()<br>
> >    message(STATUS "Sphinx disabled.")<br>
> >  endif()<br>
> > +<br>
> > +set(LLVM_BINDINGS "")<br>
> > +find_program(GO_EXECUTABLE NAMES go DOC "go executable")<br>
> > +if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND")<br>
> > +  message(STATUS "Go bindings disabled.")<br>
> > +else()<br>
> > +  execute_process(COMMAND ${GO_EXECUTABLE} run<br>
> > ${CMAKE_SOURCE_DIR}/bindings/go/conftest.go<br>
> > +                  RESULT_VARIABLE GO_CONFTEST)<br>
> > +  if(GO_CONFTEST STREQUAL "0")<br>
> > +    set(LLVM_BINDINGS "${LLVM_BINDINGS} go")<br>
> > +    message(STATUS "Go bindings enabled.")<br>
> > +  else()<br>
> > +    message(STATUS "Go bindings disabled, need at least Go 1.2.")<br>
> > +  endif()<br>
> > +endif()<br>
> ><br>
> > Modified: llvm/trunk/cmake/modules/AddLLVM.cmake<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/cmake/modules/AddLLVM.cmake (original)<br>
> > +++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Oct 16 17:48:02 2014<br>
> > @@ -651,6 +651,9 @@ function(configure_lit_site_cfg input ou<br>
> >    set(HOST_OS ${CMAKE_SYSTEM_NAME})<br>
> >    set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR})<br>
> ><br>
> > +  set(HOST_CC "${CMAKE_C_COMPILER}")<br>
> > +  set(HOST_CXX "${CMAKE_CXX_COMPILER}")<br>
> > +<br>
> >    configure_file(${input} ${output} @ONLY)<br>
> >  endfunction()<br>
> ><br>
> ><br>
> > Modified: llvm/trunk/configure<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/configure (original)<br>
> > +++ llvm/trunk/configure Thu Oct 16 17:48:02 2014<br>
> > @@ -752,6 +752,7 @@ GROFF<br>
> >  GZIPBIN<br>
> >  PDFROFF<br>
> >  ZIP<br>
> > +GO<br>
> >  OCAMLC<br>
> >  OCAMLOPT<br>
> >  OCAMLDEP<br>
> > @@ -6871,6 +6872,46 @@ echo "${ECHO_T}no" >&6; }<br>
> >  fi<br>
> ><br>
> ><br>
> > +# Extract the first word of "go", so it can be a program name with args.<br>
> > +set dummy go; ac_word=$2<br>
> > +{ echo "$as_me:$LINENO: checking for $ac_word" >&5<br>
> > +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }<br>
> > +if test "${ac_cv_path_GO+set}" = set; then<br>
> > +  echo $ECHO_N "(cached) $ECHO_C" >&6<br>
> > +else<br>
> > +  case $GO in<br>
> > +  [\\/]* | ?:[\\/]*)<br>
> > +  ac_cv_path_GO="$GO" # Let the user override the test with a path.<br>
> > +  ;;<br>
> > +  *)<br>
> > +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR<br>
> > +for as_dir in $PATH<br>
> > +do<br>
> > +  IFS=$as_save_IFS<br>
> > +  test -z "$as_dir" && as_dir=.<br>
> > +  for ac_exec_ext in '' $ac_executable_extensions; do<br>
> > +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p<br>
> > "$as_dir/$ac_word$ac_exec_ext"; }; then<br>
> > +    ac_cv_path_GO="$as_dir/$ac_word$ac_exec_ext"<br>
> > +    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5<br>
> > +    break 2<br>
> > +  fi<br>
> > +done<br>
> > +done<br>
> > +IFS=$as_save_IFS<br>
> > +<br>
> > +  ;;<br>
> > +esac<br>
> > +fi<br>
> > +GO=$ac_cv_path_GO<br>
> > +if test -n "$GO"; then<br>
> > +  { echo "$as_me:$LINENO: result: $GO" >&5<br>
> > +echo "${ECHO_T}$GO" >&6; }<br>
> > +else<br>
> > +  { echo "$as_me:$LINENO: result: no" >&5<br>
> > +echo "${ECHO_T}no" >&6; }<br>
> > +fi<br>
> > +<br>
> > +<br>
> >  for ac_prog in ocamlc<br>
> >  do<br>
> >    # Extract the first word of "$ac_prog", so it can be a program name<br>
> > with args.<br>
> > @@ -18613,6 +18654,11 @@ if test "$BINDINGS_TO_BUILD" = auto ; th<br>
> >    if test "x$OCAMLC" != x -a "x$OCAMLDEP" != x ; then<br>
> >      BINDINGS_TO_BUILD="ocaml $BINDINGS_TO_BUILD"<br>
> >    fi<br>
> > +  if test "x$GO" != x ; then<br>
> > +    if $GO run ${srcdir}/bindings/go/conftest.go ; then<br>
> > +      BINDINGS_TO_BUILD="go $BINDINGS_TO_BUILD"<br>
> > +    fi<br>
> > +  fi<br>
> >  fi<br>
> >  BINDINGS_TO_BUILD=$BINDINGS_TO_BUILD<br>
> ><br>
> > @@ -18652,6 +18698,21 @@ echo "$as_me: WARNING: --enable-bindings<br>
> >        fi<br>
> >      fi<br>
> >      ;;<br>
> > +  go)<br>
> > +    if test "x$GO" = x ; then<br>
> > +      { echo "$as_me:$LINENO: WARNING: --enable-bindings=go specified,<br>
> > but go not found. Try configure GO=/path/to/go" >&5<br>
> > +echo "$as_me: WARNING: --enable-bindings=go specified, but go not found.<br>
> > Try configure GO=/path/to/go" >&2;}<br>
> > +      binding_prereqs_failed=1<br>
> > +    else<br>
> > +      if $GO run ${srcdir}/bindings/go/conftest.go ; then<br>
> > +        :<br>
> > +      else<br>
> > +        { echo "$as_me:$LINENO: WARNING: --enable-bindings=go specified,<br>
> > but need at least Go 1.2. Try configure GO=/path/to/go" >&5<br>
> > +echo "$as_me: WARNING: --enable-bindings=go specified, but need at least<br>
> > Go 1.2. Try configure GO=/path/to/go" >&2;}<br>
> > +        binding_prereqs_failed=1<br>
> > +      fi<br>
> > +    fi<br>
> > +    ;;<br>
> >    esac<br>
> >  done<br>
> >  if test "$binding_prereqs_failed" = 1 ; then<br>
> > @@ -19679,6 +19740,7 @@ GROFF!$GROFF$ac_delim<br>
> >  GZIPBIN!$GZIPBIN$ac_delim<br>
> >  PDFROFF!$PDFROFF$ac_delim<br>
> >  ZIP!$ZIP$ac_delim<br>
> > +GO!$GO$ac_delim<br>
> >  OCAMLC!$OCAMLC$ac_delim<br>
> >  OCAMLOPT!$OCAMLOPT$ac_delim<br>
> >  OCAMLDEP!$OCAMLDEP$ac_delim<br>
> > @@ -19724,7 +19786,7 @@ LIBOBJS!$LIBOBJS$ac_delim<br>
> >  LTLIBOBJS!$LTLIBOBJS$ac_delim<br>
> >  _ACEOF<br>
> ><br>
> > -  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 96;<br>
> > then<br>
> > +  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97;<br>
> > then<br>
> >      break<br>
> >    elif $ac_last_try; then<br>
> >      { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5<br>
> ><br>
> > Added: llvm/trunk/test/Bindings/Go/go.test<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Go/go.test?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Go/go.test?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/Bindings/Go/go.test (added)<br>
> > +++ llvm/trunk/test/Bindings/Go/go.test Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,8 @@<br>
> > +; RUN: cd %S/../../../bindings/go/llvm && \<br>
> > +; RUN: env CGO_CPPFLAGS="$(llvm-config --cppflags)" \<br>
> > +; RUN:     CGO_CXXFLAGS=-std=c++11 \<br>
> > +; RUN:     CGO_LDFLAGS="$(llvm-config --ldflags --libs --system-libs \<br>
> > +; RUN:                                $(../build.sh --print-components))"<br>
> > \<br>
> > +; RUN:     %go test -tags byollvm .<br>
> > +<br>
> > +; REQUIRES: shell<br>
> ><br>
> > Added: llvm/trunk/test/Bindings/Go/lit.local.cfg<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Go/lit.local.cfg?rev=219976&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Go/lit.local.cfg?rev=219976&view=auto</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/Bindings/Go/lit.local.cfg (added)<br>
> > +++ llvm/trunk/test/Bindings/Go/lit.local.cfg Thu Oct 16 17:48:02 2014<br>
> > @@ -0,0 +1,33 @@<br>
> > +import distutils.spawn<br>
> > +import os<br>
> > +import pipes<br>
> > +import shlex<br>
> > +<br>
> > +if not 'go' in config.root.llvm_bindings:<br>
> > +    config.unsupported = True<br>
> > +<br>
> > +# Resolve certain symlinks in the first word of compiler.<br>
> > +#<br>
> > +# This is a Go-specific hack. cgo and other Go tools check $CC and $CXX<br>
> > for the<br>
> > +# substring 'clang' to determine if the compiler is Clang. This won't<br>
> > work if<br>
> > +# $CC is cc and cc is a symlink pointing to clang, as it is on Darwin.<br>
> > +def fixup_compiler_path(compiler):<br>
> > +    args = shlex.split(compiler)<br>
> > +    path = distutils.spawn.find_executable(args[0])<br>
> > +<br>
> > +    try:<br>
> > +        if path.endswith('/cc') and os.readlink(path) == 'clang':<br>
> > +            args[0] = path[:len(path)-2] + 'clang'<br>
> > +    except OSError:<br>
> > +        skip<br>
> > +<br>
> > +    try:<br>
> > +        if path.endswith('/c++') and os.readlink(path) == 'clang++':<br>
> > +            args[0] = path[:len(path)-3] + 'clang++'<br>
> > +    except OSError:<br>
> > +        skip<br>
> > +<br>
> > +    return ' '.join([pipes.quote(arg) for arg in args])<br>
> > +<br>
> > +config.environment['CC'] = fixup_compiler_path(config.host_cc)<br>
> > +config.environment['CXX'] = fixup_compiler_path(config.host_cxx)<br>
> ><br>
> > Modified: llvm/trunk/test/Bindings/Ocaml/lit.local.cfg<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/lit.local.cfg?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/lit.local.cfg?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/Bindings/Ocaml/lit.local.cfg (original)<br>
> > +++ llvm/trunk/test/Bindings/Ocaml/lit.local.cfg Thu Oct 16 17:48:02 2014<br>
> > @@ -1,5 +1,4 @@<br>
> >  config.suffixes = ['.ml']<br>
> ><br>
> > -bindings = set([s.strip() for s in config.root.llvm_bindings.split(',')])<br>
> > -if not 'ocaml' in bindings:<br>
> > +if not 'ocaml' in config.root.llvm_bindings:<br>
> >      config.unsupported = True<br>
> ><br>
> > Modified: llvm/trunk/test/Makefile<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Makefile?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Makefile?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/Makefile (original)<br>
> > +++ llvm/trunk/test/Makefile Thu Oct 16 17:48:02 2014<br>
> > @@ -133,6 +133,9 @@ lit.site.cfg: FORCE<br>
> >         @$(ECHOPATH) s=@EXEEXT@=$(EXEEXT)=g >> lit.tmp<br>
> >         @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp<br>
> >         @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc $(subst<br>
> > *,'\\\"',*$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))*) -cclib -L$(LibDir) -I<br>
> > $(LibDir)/ocaml=g >> lit.tmp<br>
> > +       @$(ECHOPATH) s=@GO_EXECUTABLE@=$(GO)=g >> lit.tmp<br>
> > +       @$(ECHOPATH) s!@HOST_CC@!$(CC)!g >> lit.tmp<br>
> > +       @$(ECHOPATH) s!@HOST_CXX@!$(CXX)!g >> lit.tmp<br>
> >         @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp<br>
> >         @$(ECHOPATH) s=@ENABLE_ASSERTIONS@=$(ENABLE_ASSERTIONS)=g >><br>
> > lit.tmp<br>
> >         @$(ECHOPATH) s=@TARGETS_TO_BUILD@=$(TARGETS_TO_BUILD)=g >> lit.tmp<br>
> ><br>
> > Modified: llvm/trunk/test/lit.cfg<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/lit.cfg (original)<br>
> > +++ llvm/trunk/test/lit.cfg Thu Oct 16 17:48:02 2014<br>
> > @@ -168,6 +168,7 @@ config.substitutions.append( ('%llc_dwar<br>
> ><br>
> >  # Add site-specific substitutions.<br>
> >  config.substitutions.append( ('%ocamlopt', config.ocamlopt_executable) )<br>
> > +config.substitutions.append( ('%go', config.go_executable) )<br>
> >  config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )<br>
> >  config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )<br>
> >  config.substitutions.append( ('%exeext', config.llvm_exe_ext) )<br>
> ><br>
> > Modified: llvm/trunk/test/<a href="http://lit.site.cfg.in" target="_blank">lit.site.cfg.in</a><br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.site.cfg.in?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.site.cfg.in?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/test/<a href="http://lit.site.cfg.in" target="_blank">lit.site.cfg.in</a> (original)<br>
> > +++ llvm/trunk/test/<a href="http://lit.site.cfg.in" target="_blank">lit.site.cfg.in</a> Thu Oct 16 17:48:02 2014<br>
> > @@ -13,12 +13,15 @@ config.llvm_exe_ext = "@EXEEXT@"<br>
> >  config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"<br>
> >  config.python_executable = "@PYTHON_EXECUTABLE@"<br>
> >  config.ocamlopt_executable = "@OCAMLOPT@"<br>
> > +config.go_executable = "@GO_EXECUTABLE@"<br>
> >  config.enable_shared = @ENABLE_SHARED@<br>
> >  config.enable_assertions = @ENABLE_ASSERTIONS@<br>
> >  config.targets_to_build = "@TARGETS_TO_BUILD@"<br>
> > -config.llvm_bindings = "@LLVM_BINDINGS@"<br>
> > +config.llvm_bindings = "@LLVM_BINDINGS@".split(' ')<br>
> >  config.host_os = "@HOST_OS@"<br>
> >  config.host_arch = "@HOST_ARCH@"<br>
> > +config.host_cc = "@HOST_CC@"<br>
> > +config.host_cxx = "@HOST_CXX@"<br>
> >  config.llvm_use_intel_jitevents = "@LLVM_USE_INTEL_JITEVENTS@"<br>
> >  config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"<br>
> >  config.have_zlib = "@HAVE_LIBZ@"<br>
> ><br>
> > Modified: llvm/trunk/utils/lit/lit/discovery.py<br>
> > URL:<br>
> > <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=219976&r1=219975&r2=219976&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=219976&r1=219975&r2=219976&view=diff</a><br>
> ><br>
> > ==============================================================================<br>
> > --- llvm/trunk/utils/lit/lit/discovery.py (original)<br>
> > +++ llvm/trunk/utils/lit/lit/discovery.py Thu Oct 16 17:48:02 2014<br>
> > @@ -91,7 +91,7 @@ def getLocalConfig(ts, path_in_suite, li<br>
> ><br>
> >          # Otherwise, copy the current config and load the local<br>
> > configuration<br>
> >          # file into it.<br>
> > -        config = copy.copy(parent)<br>
> > +        config = copy.deepcopy(parent)<br>
> >          if litConfig.debug:<br>
> >              litConfig.note('loading local config %r' % cfgpath)<br>
> >          config.load_from_path(cfgpath, litConfig)<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > llvm-commits mailing list<br>
> > <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
> ><br>
<span class=""><font color="#888888"><br>
--<br>
Peter<br>
</font></span></blockquote></div><br></div></div>