llvm-base-3.2.0.0/0000755000000000000000000000000012142503271011717 5ustar0000000000000000llvm-base-3.2.0.0/llvm-base.buildinfo.in0000644000000000000000000000050712142503271016105 0ustar0000000000000000cpp-options: @llvm_cppflags@ -DTARGET=@llvm_target@ -DHS_LLVM_VERSION=@llvm_num_version@ cc-options: @llvm_cflags@ ghc-options: -pgml @CXX@ extra-libraries: @llvm_extra_libs@ stdc++ extra-lib-dirs: @llvm_extra_libdirs@ x-extra-ghci-libraries: @llvm_extra_ghci_libs@ ld-options: @llvm_ldoptions@ include-dirs: @llvm_includedir@ llvm-base-3.2.0.0/configure0000755000000000000000000040645512142503271013644 0ustar0000000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for Haskell LLVM FFI bindings 3.2.0.0. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and bos@serpentine.com $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do $0: have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Haskell LLVM FFI bindings' PACKAGE_TARNAME='llvm-base' PACKAGE_VERSION='3.2.0.0' PACKAGE_STRING='Haskell LLVM FFI bindings 3.2.0.0' PACKAGE_BUGREPORT='bos@serpentine.com' PACKAGE_URL='' ac_unique_file="LLVM/FFI/Core.hsc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS llvm_ldoptions llvm_includedir llvm_target llvm_extra_ghci_libs llvm_extra_libdirs llvm_extra_libs llvm_cflags llvm_cppflags llvm_version llvm_num_version EGREP GREP CXXCPP llvm_config OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_compiler with_llvm_prefix with_llvm_bindir ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Haskell LLVM FFI bindings 3.2.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/llvm-base] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --target=TARGET configure for building compilers for TARGET [guessed] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Haskell LLVM FFI bindings 3.2.0.0:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-compiler use the given Haskell compiler --with-llvm-prefix use the version of LLVM at the given location --with-llvm-bindir use LLVM binaries at the given location Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Haskell LLVM FFI bindings configure 3.2.0.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## --------------------------------- ## ## Report this to bos@serpentine.com ## ## --------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Haskell LLVM FFI bindings $as_me 3.2.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_files="$ac_config_files llvm-base.buildinfo" ac_config_headers="$ac_config_headers include/hs_llvm_config.h" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # Check whether --with-compiler was given. if test "${with_compiler+set}" = set; then : withval=$with_compiler; compiler="$withval" else compiler=ghc fi # Check whether --with-llvm_prefix was given. if test "${with_llvm_prefix+set}" = set; then : withval=$with_llvm_prefix; llvm_prefix="$withval" else llvm_prefix="$prefix" fi # Check whether --with-llvm_bindir was given. if test "${with_llvm_bindir+set}" = set; then : withval=$with_llvm_bindir; llvm_bindir="$withval" else llvm_bindir="$llvm_prefix/bin" fi for ac_prog in llvm-config do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_llvm_config+:} false; then : $as_echo_n "(cached) " >&6 else case $llvm_config in [\\/]* | ?:[\\/]*) ac_cv_path_llvm_config="$llvm_config" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy=""$llvm_bindir:$PATH"" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_llvm_config="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi llvm_config=$ac_cv_path_llvm_config if test -n "$llvm_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $llvm_config" >&5 $as_echo "$llvm_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$llvm_config" && break done test -n "$llvm_config" || llvm_config="as_fn_error $? "could not find llvm-config in $llvm_bindir" "$LINENO" 5" if test "$target" = "" then if test "${compiler}" != "" then target=`${compiler} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` echo "Target platform inferred as: $target" else echo "Can't work out target platform" exit 1 fi fi case $target in i386-apple-darwin) TARGET_CPPFLAGS="-m32" TAGRET_LDFLAGS="-m32" ;; x86_64-apple-darwin) TARGET_CPPFLAGS="-m64" TAGRET_LDFLAGS="-m64" ;; esac llvm_version="`$llvm_config --version`" { $as_echo "$as_me:${as_lineno-$LINENO}: result: found LLVM version $llvm_version" >&5 $as_echo "found LLVM version $llvm_version" >&6; } llvm_cppflags="`$llvm_config --cppflags`" llvm_includedir="`$llvm_config --includedir`" llvm_ldflags="`$llvm_config --ldflags`" llvm_cflags="`$llvm_config --cflags` `$llvm_config --cxxflags`" llvm_all_libs="`$llvm_config --libs all`" llvm_target="`$llvm_config --libs engine | sed 's/.*LLVM\(.[^ ]*\)CodeGen.*/\1/'`" CPPFLAGS="$llvm_cppflags $CPPFLAGS $TARGET_CPPFLAGS" LDFLAGS="$llvm_ldflags $LDFLAGS $TARGET_LDFLAGS" llvm_extra_ghci_libs="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing LLVMModuleCreateWithName" >&5 $as_echo_n "checking for library containing LLVMModuleCreateWithName... " >&6; } if ${ac_cv_search_LLVMModuleCreateWithName+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char LLVMModuleCreateWithName (); int main () { return LLVMModuleCreateWithName (); ; return 0; } _ACEOF for ac_lib in '' LLVM-2.7 LLVM-2.8 LLVM-2.9 LLVM-3.0 LLVM-3.1 LLVM-3.2; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_LLVMModuleCreateWithName=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_LLVMModuleCreateWithName+:} false; then : break fi done if ${ac_cv_search_LLVMModuleCreateWithName+:} false; then : else ac_cv_search_LLVMModuleCreateWithName=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_LLVMModuleCreateWithName" >&5 $as_echo "$ac_cv_search_LLVMModuleCreateWithName" >&6; } ac_res=$ac_cv_search_LLVMModuleCreateWithName if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi if test "$ac_cv_search_LLVMModuleCreateWithName" = "no"; then llvm_all_libs="`$llvm_config --libs all`" else llvm_extra_ghci_libs="LLVM-$llvm_version" llvm_all_libs="$LIBS" fi llvm_extra_libs="" llvm_extra_libdirs="" llvm_ldoptions="" for opt in $llvm_all_libs $llvm_ldflags; do case $opt in -l*) llvm_extra_libs="$llvm_extra_libs `echo $opt | sed 's/^-l//'`";; -L*) llvm_extra_libdirs="$llvm_extra_libdirs `echo $opt | sed 's/^-L//'`";; *) llvm_ldoptions="$llvm_ldoptions $opt";; esac done ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in llvm-c/Core.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "llvm-c/Core.h" "ac_cv_header_llvm_c_Core_h" "$ac_includes_default" if test "x$ac_cv_header_llvm_c_Core_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LLVM_C_CORE_H 1 _ACEOF else as_fn_error $? "could not find LLVM C bindings" "$LINENO" 5 fi done for ac_header in llvm/ADT/StringRef.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "llvm/ADT/StringRef.h" "ac_cv_header_llvm_ADT_StringRef_h" "$ac_includes_default" if test "x$ac_cv_header_llvm_ADT_StringRef_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LLVM_ADT_STRINGREF_H 1 _ACEOF fi done for ac_header in llvm/Support/DynamicLibrary.h do : ac_fn_cxx_check_header_compile "$LINENO" "llvm/Support/DynamicLibrary.h" "ac_cv_header_llvm_Support_DynamicLibrary_h" "#ifdef HAVE_LLVM_ADT_STRINGREF_H # include #endif " if test "x$ac_cv_header_llvm_Support_DynamicLibrary_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LLVM_SUPPORT_DYNAMICLIBRARY_H 1 _ACEOF fi done save_LIBS="$LIBS" LIBS="-lLLVMSupport -lpthread -ldl $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LLVMModuleCreateWithName in -lLLVMCore" >&5 $as_echo_n "checking for LLVMModuleCreateWithName in -lLLVMCore... " >&6; } if ${ac_cv_lib_LLVMCore_LLVMModuleCreateWithName+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lLLVMCore $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char LLVMModuleCreateWithName (); int main () { return LLVMModuleCreateWithName (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_LLVMCore_LLVMModuleCreateWithName=yes else ac_cv_lib_LLVMCore_LLVMModuleCreateWithName=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" >&5 $as_echo "$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" >&6; } if test "x$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBLLVMCORE 1 _ACEOF LIBS="-lLLVMCore $LIBS" fi if test "$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" = "no"; then unset ac_cv_lib_LLVMCore_LLVMModuleCreateWithName LIBS="-lLLVMSupport $save_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LLVMModuleCreateWithName in -lLLVMCore" >&5 $as_echo_n "checking for LLVMModuleCreateWithName in -lLLVMCore... " >&6; } if ${ac_cv_lib_LLVMCore_LLVMModuleCreateWithName+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lLLVMCore $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char LLVMModuleCreateWithName (); int main () { return LLVMModuleCreateWithName (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_LLVMCore_LLVMModuleCreateWithName=yes else ac_cv_lib_LLVMCore_LLVMModuleCreateWithName=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" >&5 $as_echo "$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" >&6; } if test "x$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBLLVMCORE 1 _ACEOF LIBS="-lLLVMCore $LIBS" else as_fn_error $? "could not find LLVM C bindings" "$LINENO" 5 fi fi llvm_num_version="`echo $llvm_version | sed 's/svn$//' | tr . 0`" cat >>confdefs.h <<_ACEOF #define HS_LLVM_VERSION $llvm_num_version _ACEOF cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Haskell LLVM FFI bindings $as_me 3.2.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Haskell LLVM FFI bindings config.status 3.2.0.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "llvm-base.buildinfo") CONFIG_FILES="$CONFIG_FILES llvm-base.buildinfo" ;; "include/hs_llvm_config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/hs_llvm_config.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi llvm-base-3.2.0.0/INSTALL.md0000644000000000000000000000345312142503271013354 0ustar0000000000000000Build and installation instructions ----------------------------------- Please don't think of these as canonical build instructions yet, as this work is rather early along. Let me tell you what's working for *me*, and hopefully this information will be enough to get you going. Prerequisites ------------- Firstly, you'll need to have LLVM. I recommend installing LLVM version 2.9 (from [llvm.org](http://llvm.org/releases/)), which is what this package has mostly been tested with. We try to work with both the current and one previous release of LLVM. It's easy to install LLVM itself from source: cd llvm ./configure --prefix=$SOMEWHERE make make install It's a good idea to have `$SOMEWHERE/bin` in your path. Installing from source on Windows requires MinGW. Building -------- (*Note*: If you're building from a clone of the `git` repository rather than a release, you *must* run `autoreconf` before you can build!) This is a normal Haskell package, but needs a `configure` script to configure some system-specific details of LLVM. If you have LLVM installed in a fairly normal location (`/usr` or `/usr/local`), the usual install command should just work: cabal install On the other hand, if you've installed LLVM in an unusual place, you'll need some `--configure-option` magic to tell the build where to find it: cabal install --configure-option --with-llvm-prefix=$SOMEWHERE Building examples ----------------- In the `examples` directory are a few example programs. There's a GNU Makefile in there, so running `make` in that directory will build the examples, as will `make examples` in the top-level directory. Doing `make run` will build and run the examples. Note: On older versions of MacOS X you may see a lot of "atom sorting error" warnings. They seem to be harmless. llvm-base-3.2.0.0/LICENSE0000644000000000000000000000564412142503271012735 0ustar0000000000000000====================================================================== Haskell LLVM Bindings Release License ====================================================================== University of Illinois/NCSA Open Source License Copyright (c) 2007-2009 Bryan O'Sullivan All rights reserved. Developed by: Bryan O'Sullivan http://www.serpentine.com/blog/ Lennart Augustsson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of Bryan O'Sullivan, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. ====================================================================== Copyrights and Licenses for Third Party Software Distributed with Haskell LLVM Bindings: ====================================================================== The Haskell LLVM Bindings software may contain code written by third parties. Any such software will have its own individual license file in the directory in which it appears. This file will describe the copyrights, license, and restrictions which apply to that code. The disclaimer of warranty in the University of Illinois Open Source License applies to all code in the Haskell LLVM Bindings Distribution, and nothing in any of the other licenses gives permission to use the name of Bryan O'Sullivan or the University of Illinois to endorse or promote products derived from this Software. The following pieces of software have additional or alternate copyrights, licenses, and/or restrictions: Program Directory ------- --------- configure . llvm-base-3.2.0.0/README.md0000644000000000000000000000422612142503271013202 0ustar0000000000000000Haskell LLVM bindings --------------------- This package provides Haskell bindings for the popular [LLVM](http://llvm.org/) compiler infrastructure project. Compatibility ------------- We try to stay up to date with LLVM releases. The current version of this package is compatible with LLVM 2.9 and 2.8. Please understand that the package may or may not work against older LLVM releases; we don't have the time or resources to test across multiple releases. Configuration ------------- By default, when you run `cabal install`, the Haskell bindings will be configured to look for LLVM in `/usr/local`. If you have LLVM installed in a different location, e.g. `/usr`, you can tell the `configure` script where to find it as follows: cabal install --configure-option=--with-llvm-prefix=/usr Package status - what to expect ------------------------------- This package is still under development. The high level bindings are currently incomplete, so there are some limits on what you can do. Adding new functions is generally easy, though, so don't be afraid to get your hands dirty. The high level interface is mostly safe, but the type system cannot protect against everything that can go wrong, so take care. And, of course, there's no way to guarantee anything about the generated code. GHCi ---- llvm-base will not work under GHCi. It fails to resolve some symbols, however under GHC it works fine. It appears related to the bugs listed in: http://hackage.haskell.org/trac/ghc/ticket/3333 http://hackage.haskell.org/trac/ghc/ticket/3658 http://hackage.haskell.org/trac/ghc/ticket/5987 Staying in touch ---------------- There is a low-volume mailing list named [haskell-llvm@projects.haskellorg](http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-llvm). If you use the LLVM bindings, you should think about joining. If you want to contribute patches, please clone a copy of the [git repository](https://github.com/bos/llvm): git clone git://github.com/bos/llvm Patches are best submitted via the github "pull request" interface. To file a bug or a request for an enhancement, please use the [github issue tracker](https://github.com/bos/llvm/issues). llvm-base-3.2.0.0/configure.ac0000644000000000000000000001040412142503271014204 0ustar0000000000000000AC_INIT([Haskell LLVM FFI bindings], [3.2.0.0], [bos@serpentine.com], [llvm-base]) AC_CONFIG_SRCDIR([LLVM/FFI/Core.hsc]) AC_CONFIG_FILES([llvm-base.buildinfo]) AC_CONFIG_HEADERS([include/hs_llvm_config.h]) AC_PROG_CXX AC_LANG(C++) AC_ARG_WITH(compiler, [AS_HELP_STRING([--with-compiler], [use the given Haskell compiler])], compiler="$withval", compiler=ghc)dnl AC_ARG_WITH(llvm_prefix, [AS_HELP_STRING([--with-llvm-prefix], [use the version of LLVM at the given location])], llvm_prefix="$withval", llvm_prefix="$prefix")dnl AC_ARG_WITH(llvm_bindir, [AS_HELP_STRING([--with-llvm-bindir], [use LLVM binaries at the given location])], llvm_bindir="$withval", llvm_bindir="$llvm_prefix/bin")dnl AC_PATH_PROGS(llvm_config, [llvm-config], [AC_MSG_ERROR(could not find llvm-config in $llvm_bindir)], ["$llvm_bindir:$PATH"]) dnl * Choose target platform dnl dnl We don't use the standard autoconf macros for this, but instead dnl ask GHC what platform it is for. Why? We need to generate a library dnl matching the compiler. dnl NB: This code is from GHC's configure (where the corresponding code for dnl guessing host and build variables can be found, too) dnl Guess target platform if necessary. m4_divert_once([HELP_CANON], [[ System types: --target=TARGET configure for building compilers for TARGET [guessed]]])dnl if test "$target" = "" then if test "${compiler}" != "" then target=`${compiler} +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` echo "Target platform inferred as: $target" else echo "Can't work out target platform" exit 1 fi fi dnl Determine target-specific options dnl This is important as Snow Leopard (Mac OS X 10.6) defaults to generating dnl 64-bit code. case $target in i386-apple-darwin) TARGET_CPPFLAGS="-m32" TAGRET_LDFLAGS="-m32" ;; x86_64-apple-darwin) TARGET_CPPFLAGS="-m64" TAGRET_LDFLAGS="-m64" ;; esac llvm_version="`$llvm_config --version`" AC_MSG_RESULT(found LLVM version $llvm_version) llvm_cppflags="`$llvm_config --cppflags`" llvm_includedir="`$llvm_config --includedir`" llvm_ldflags="`$llvm_config --ldflags`" llvm_cflags="`$llvm_config --cflags` `$llvm_config --cxxflags`" llvm_all_libs="`$llvm_config --libs all`" llvm_target="`$llvm_config --libs engine | sed 's/.*LLVM\(.[[^ ]]*\)CodeGen.*/\1/'`" CPPFLAGS="$llvm_cppflags $CPPFLAGS $TARGET_CPPFLAGS" LDFLAGS="$llvm_ldflags $LDFLAGS $TARGET_LDFLAGS" llvm_extra_ghci_libs="" AC_SEARCH_LIBS([LLVMModuleCreateWithName],[LLVM-2.7 LLVM-2.8 LLVM-2.9 LLVM-3.0 LLVM-3.1 LLVM-3.2]) if test "$ac_cv_search_LLVMModuleCreateWithName" = "no"; then llvm_all_libs="`$llvm_config --libs all`" else llvm_extra_ghci_libs="LLVM-$llvm_version" llvm_all_libs="$LIBS" fi dnl We need to separate libraries that need to be linked from other linker options. llvm_extra_libs="" llvm_extra_libdirs="" llvm_ldoptions="" for opt in $llvm_all_libs $llvm_ldflags; do case $opt in -l*) llvm_extra_libs="$llvm_extra_libs `echo $opt | sed 's/^-l//'`";; -L*) llvm_extra_libdirs="$llvm_extra_libdirs `echo $opt | sed 's/^-L//'`";; *) llvm_ldoptions="$llvm_ldoptions $opt";; esac done AC_CHECK_HEADERS([llvm-c/Core.h], [], [AC_MSG_ERROR(could not find LLVM C bindings)]) AC_CHECK_HEADERS([llvm/ADT/StringRef.h]) AC_CHECK_HEADERS([llvm/Support/DynamicLibrary.h], [], [], [#ifdef HAVE_LLVM_ADT_STRINGREF_H # include #endif]) save_LIBS="$LIBS" LIBS="-lLLVMSupport -lpthread -ldl $LIBS" AC_CHECK_LIB(LLVMCore, LLVMModuleCreateWithName, [], []) if test "$ac_cv_lib_LLVMCore_LLVMModuleCreateWithName" = "no"; then unset ac_cv_lib_LLVMCore_LLVMModuleCreateWithName LIBS="-lLLVMSupport $save_LIBS" AC_CHECK_LIB(LLVMCore, LLVMModuleCreateWithName, [], [AC_MSG_ERROR(could not find LLVM C bindings)]) fi llvm_num_version="`echo $llvm_version | sed 's/svn$//' | tr . 0`" AC_DEFINE_UNQUOTED([HS_LLVM_VERSION], [$llvm_num_version], [Define to the version of LLVM, e.g. 209 for 2.9.]) AC_SUBST([llvm_num_version]) AC_SUBST([llvm_version]) AC_SUBST([llvm_cppflags]) AC_SUBST([llvm_cflags]) AC_SUBST([llvm_extra_libs]) AC_SUBST([llvm_extra_libdirs]) AC_SUBST([llvm_extra_ghci_libs]) AC_SUBST([llvm_target]) AC_SUBST([llvm_includedir]) AC_SUBST([llvm_ldoptions]) AC_OUTPUT llvm-base-3.2.0.0/llvm-base.cabal0000644000000000000000000000602612142503271014571 0ustar0000000000000000name: llvm-base version: 3.2.0.0 license: BSD3 license-file: LICENSE synopsis: FFI bindings to the LLVM compiler toolkit. description: FFI bindings to the LLVM compiler toolkit. . We try to stay up to date with LLVM releases. The current version of this package is compatible with LLVM 3.0 and 2.9. Please understand that the package may or may not work against older LLVM releases; we don't have the time or resources to test across multiple releases. . * New in 3.2: Builds against LLVM 3.2, new mid-level Wrapper interface and ST-based pure interface . * New in 3.0: Builds against LLVM 3.0. . * New in 0.9.1.1: Builds against LLVM 2.9. . * New in 0.9.1.0: Util.Memory for memory related intrinsics. . * New in 0.9.0.0: Adapted to LLVM 2.8 (removed support for Union types). author: Bryan O'Sullivan, Lennart Augustsson, Benjamin Saunders maintainer: Bryan O'Sullivan , Lennart Augustsson , Benjamin Saunders homepage: https://github.com/bos/llvm bug-reports: https://github.com/bos/llvm/issues stability: experimental category: Compilers/Interpreters, Code Generation tested-with: GHC == 6.12.3, GHC == 7.0.3, GHC == 7.2.2 cabal-version: >= 1.6 build-type: Custom extra-source-files: *.md configure.ac configure include/extra.h include/hs_llvm_config.h.in include/support.h llvm-base.buildinfo.in llvm-base.buildinfo.windows.in tools/*.hs tools/Makefile extra-tmp-files: autom4te.cache config.log config.status configure include/hs_llvm_config.h llvm-base.buildinfo flag developer description: operate in developer mode default: False library build-depends: base >= 3 && < 5, mtl >= 2.1 && < 3 ghc-options: -Wall if flag(developer) ghc-options: -Werror exposed-modules: LLVM.FFI.Analysis LLVM.FFI.BitReader LLVM.FFI.BitWriter LLVM.FFI.Core LLVM.FFI.ExecutionEngine LLVM.FFI.Support LLVM.FFI.Linker LLVM.FFI.Target LLVM.FFI.Transforms.IPO LLVM.FFI.Transforms.Scalar LLVM.FFI.Transforms.PassManagerBuilder LLVM.FFI.AssemblyReader LLVM.Target.Native LLVM.Wrapper.Core LLVM.Wrapper.BitReader LLVM.Wrapper.BitWriter LLVM.Wrapper.Analysis, LLVM.Wrapper.ExecutionEngine LLVM.Wrapper.Target LLVM.Wrapper.Linker LLVM.Wrapper.Transforms.PassManagerBuilder LLVM.ST other-modules: LLVM.Target.ARM LLVM.Target.CellSPU LLVM.Target.CppBackend LLVM.Target.MSP430 LLVM.Target.Mips LLVM.Target.PowerPC LLVM.Target.Sparc LLVM.Target.X86 LLVM.Target.XCore LLVM.Wrapper.Internal include-dirs: include C-Sources: cbits/extra.cpp cbits/free.c cbits/malloc.c cbits/support.cpp source-repository head type: git location: git://github.com/bos/llvm.git source-repository head type: mercurial location: https://bitbucket.org/bos/llvm/ llvm-base-3.2.0.0/Setup.hs0000644000000000000000000001260212142503271013354 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE PatternGuards #-} import System.Directory import System.Environment import System.FilePath import System.Info import Control.Monad import Data.Char ( isSpace ) import Data.List import Data.Maybe import Distribution.Simple import Distribution.Simple.Setup import Distribution.InstalledPackageInfo import Distribution.PackageDescription import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Install import Distribution.Simple.Register import Distribution.Simple.Utils import Distribution.Text ( display ) main = do let hooks = autoconfUserHooks { postConf = if os == "mingw32" then generateBuildInfo else postConf autoconfUserHooks , instHook = installHookWithExtraGhciLibraries , regHook = regHookWithExtraGhciLibraries } defaultMainWithHooks hooks -- On Windows we can't count on the configure script, so generate the -- llvm.buildinfo from a template. generateBuildInfo _ conf _ _ = do let args = configConfigureArgs conf let pref = "--with-llvm-prefix=" let path = case [ p | arg <- args, Just p <- [stripPrefix pref arg] ] of [p] -> p _ -> error $ "Use '--configure-option " ++ pref ++ "PATH' to give LLVM installation path" info <- readFile "llvm.buildinfo.windows.in" writeFile "llvm.buildinfo" $ subst "@llvm_path@" path info subst from to [] = [] subst from to xs | Just r <- stripPrefix from xs = to ++ subst from to r subst from to (x:xs) = x : subst from to xs {- To compensate for Cabal's current design, we need to replicate the default registration hook code here, to inject a value for extra-ghci-libraries into the package registration info. (Inspired by 'Gtk2HsSetup.hs'.) This only works for Cabal 1.10, thus we added an according constraint to llvm.cabal. We define an extension field 'x-extra-ghci-libraries' in the .buildinfo file in order to communicate the version information of the LLVM dynamic library from the configure script to the registration code. -} installHookWithExtraGhciLibraries :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO () installHookWithExtraGhciLibraries pkg_descr localbuildinfo _ flags = do let copyFlags = defaultCopyFlags { copyDistPref = installDistPref flags, copyDest = toFlag NoCopyDest, copyVerbosity = installVerbosity flags } install pkg_descr localbuildinfo copyFlags let registerFlags = defaultRegisterFlags { regDistPref = installDistPref flags, regInPlace = installInPlace flags, regPackageDB = installPackageDB flags, regVerbosity = installVerbosity flags } when (hasLibs pkg_descr) $ register' pkg_descr localbuildinfo registerFlags regHookWithExtraGhciLibraries :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO () regHookWithExtraGhciLibraries pkg_descr localbuildinfo _ flags = if hasLibs pkg_descr then register' pkg_descr localbuildinfo flags else setupMessage verbosity "Package contains no library to register:" (packageId pkg_descr) where verbosity = fromFlag (regVerbosity flags) register' :: PackageDescription -> LocalBuildInfo -> RegisterFlags -- ^Install in the user's database?; verbose -> IO () register' pkg@PackageDescription { library = Just lib } lbi@LocalBuildInfo { libraryConfig = Just clbi } regFlags = do installedPkgInfoRaw <- generateRegistrationInfo verbosity pkg lib lbi clbi inplace distPref let ghciLibraries = case lookup "x-extra-ghci-libraries" (customFieldsBI (libBuildInfo lib)) of Just s | not (all isSpace s) -> [s] _ -> [] installedPkgInfo = installedPkgInfoRaw { extraGHCiLibraries = ghciLibraries } -- Three different modes: case () of _ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo | modeGenerateRegScript -> die "Generate Reg Script not supported" | otherwise -> registerPackage verbosity installedPkgInfo pkg lbi inplace (withPackageDB lbi) where modeGenerateRegFile = isJust (flagToMaybe (regGenPkgConf regFlags)) modeGenerateRegScript = fromFlag (regGenScript regFlags) inplace = fromFlag (regInPlace regFlags) packageDb = nub $ withPackageDB lbi ++ maybeToList (flagToMaybe (regPackageDB regFlags)) distPref = fromFlag (regDistPref regFlags) verbosity = fromFlag (regVerbosity regFlags) regFile = fromMaybe (display (packageId pkg) <.> "conf") (fromFlag (regGenPkgConf regFlags)) writeRegistrationFile installedPkgInfo = do notice verbosity ("Creating package registration file: " ++ regFile) writeUTF8File regFile (showInstalledPackageInfo installedPkgInfo) register' _ _ regFlags = notice verbosity "No package to register" where verbosity = fromFlag (regVerbosity regFlags) llvm-base-3.2.0.0/llvm-base.buildinfo.windows.in0000644000000000000000000000254612142503271017603 0ustar0000000000000000cpp-options: -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -DTARGET=X86 ghc-options: -I@llvm_path@/include -pgml g++ ld-options: -L@llvm_path@/lib -lLLVMXCoreAsmPrinter -lLLVMXCoreCodeGen -lLLVMXCoreInfo -lLLVMSystemZAsmPrinter -lLLVMSystemZCodeGen -lLLVMSystemZInfo -lLLVMSparcAsmPrinter -lLLVMSparcCodeGen -lLLVMSparcInfo -lLLVMPowerPCAsmPrinter -lLLVMPowerPCCodeGen -lLLVMPowerPCInfo -lLLVMPIC16AsmPrinter -lLLVMPIC16CodeGen -lLLVMPIC16Info -lLLVMMSP430AsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Info -lLLVMMSIL -lLLVMMSILInfo -lLLVMMipsAsmPrinter -lLLVMMipsCodeGen -lLLVMMipsInfo -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMDebugger -lLLVMCppBackend -lLLVMCppBackendInfo -lLLVMCellSPUAsmPrinter -lLLVMCellSPUCodeGen -lLLVMCellSPUInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBlackfinAsmPrinter -lLLVMBlackfinCodeGen -lLLVMBlackfinInfo -lLLVMBitWriter -lLLVMX86AsmParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen -lLLVMX86Info -lLLVMAsmParser -lLLVMARMAsmPrinter -lLLVMARMCodeGen -lLLVMARMInfo -lLLVMArchive -lLLVMBitReader -lLLVMAlphaAsmPrinter -lLLVMAlphaCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMAlphaInfo -lLLVMSupport -lLLVMSystem -lpsapi -limagehlp -lstdc++ -lmingwex include-dirs: @llvm_path@/include llvm-base-3.2.0.0/LLVM/0000755000000000000000000000000012142503271012471 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/ST.hs0000644000000000000000000007712312142503271013365 0ustar0000000000000000{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, UndecidableInstances, RankNTypes, NoMonomorphismRestriction #-} {-# OPTIONS_GHC -fno-warn-unused-do-bind -fno-warn-missing-signatures #-} module LLVM.ST ( CUInt, CULLong , IntPredicate(..), FPPredicate(..) , LLVM, MonadLLVM , getContext, liftLL, liftST , MemoryBuffer , createMemoryBufferWithContentsOfFile , createMemoryBufferWithSTDIN , createMemoryBufferWithMemoryRange , createMemoryBufferWithMemoryRangeCopy , run, run2, runLLVM , Context , W.getGlobalContext , W.contextCreate , STPassManager , createPassManager , populateModulePassManager , populateLTOPassManager , runPassManager , ModuleGen, MonadMG , runModuleGen, liftMG , STModule , Module , unsafeFreeze, unsafeThaw , parseBitcode , writeBitcodeToFile , getModule , genModule , verifyModule , showModule , linkModules , STBasicBlock , appendBasicBlock , STValue , Linkage(..) , Attribute(..) , CallingConvention(..) , showValue , typeOf , findGlobal, findFunction , addFunction, genFunction, defineFunction, runCodeGen , getFuncCallConv, setFuncCallConv, setInstrCallConv , getFunctionParams , addParamAttrib, addFuncAttrib, removeAttrib , getLinkage, setLinkage , getTailCall, setTailCall , verifyFunction , getUndef , isConstant, isNull, isUndef, isUnreachable , constInt , constPtrNull , constString, constStruct , STType , TypeKind(..) , typeKind , showType , findType , sizeOf , intType, floatType, doubleType, voidType , functionType, structType, vectorType, arrayType , pointerTypeInSpace, pointerType , structCreateNamed, structSetBody , CodeGen, MonadCG , liftCG , position, positionAtEnd, positionBefore, positionAfter , getEntryBasicBlock, getNextBasicBlock , getFirstInstruction, getNextInstruction, getPreviousInstruction, getLastInstruction , getInsertBlock, getFunction, getParams , getValueName, setValueName , buildTrunc , buildZExt , buildSExt , buildFPToUI , buildFPToSI , buildUIToFP , buildSIToFP , buildFPTrunc , buildFPExt , buildPtrToInt , buildIntToPtr , buildBitCast , buildPointerCast , buildTruncOrBitCast , buildZExtOrBitCast , buildSExtOrBitCast , buildInBoundsGEP , buildAlloca , buildLoad, buildStore , buildCall , buildBr, buildCondBr , buildSwitch, addCase , buildPhi, addIncoming , buildCase, buildIf , buildRet, buildUnreachable , buildAdd , buildSub , buildMul , buildFAdd , buildFMul , buildFPCast , buildFSub , buildUDiv , buildSDiv , buildExactSDiv , buildFDiv , buildURem , buildSRem , buildFRem , buildShl , buildLShr , buildAShr , buildAnd , buildOr , buildXor , buildNeg , buildFNeg , buildNot , buildNSWAdd , buildNSWMul , buildNSWNeg , buildNSWSub , buildNUWAdd , buildNUWMul , buildNUWNeg , buildNUWSub , buildICmp, buildFCmp , buildGlobalString, buildGlobalStringPtr -- , constNeg -- , constNot , constAdd , constSub , constMul -- , constExactSDiv , constFAdd , constFMul -- , constFNeg , constFPCast , constFSub , constUDiv , constSDiv , constFDiv , constURem , constSRem , constFRem , constAnd , constOr , constXor -- , constICmp -- , constFCmp , constShl , constLShr , constAShr , constGEP , constTrunc , constSExt , constZExt , constFPTrunc , constFPExt , constUIToFP , constSIToFP , constFPToUI , constFPToSI , constPtrToInt , constIntToPtr , constBitCast -- , constSelect -- , constExtractElement -- , constInsertElement -- , constShuffleVector -- , constRealOfString -- , constNSWMul -- , constNSWNeg -- , constNSWSub -- , constNUWAdd -- , constNUWMul -- , constNUWNeg -- , constNUWSub ) where import Control.Applicative import Control.Monad.Reader import Control.Monad.ST.Safe import Control.Monad.ST.Unsafe (unsafeIOToST, unsafeSTToIO) import System.IO.Unsafe (unsafePerformIO) import qualified LLVM.Wrapper.Core as W import qualified LLVM.Wrapper.Linker as W import qualified LLVM.Wrapper.BitReader as W import qualified LLVM.Wrapper.BitWriter as W import qualified LLVM.Wrapper.Analysis as W import qualified LLVM.Wrapper.Transforms.PassManagerBuilder as W import LLVM.Wrapper.Core ( MemoryBuffer, Context, BasicBlock, Type, Value, Builder , CUInt, CULLong , TypeKind(..) , Linkage(..) , Attribute(..) , CallingConvention(..) , IntPredicate(..), FPPredicate(..) , createMemoryBufferWithContentsOfFile , createMemoryBufferWithSTDIN , createMemoryBufferWithMemoryRange , createMemoryBufferWithMemoryRangeCopy ) newtype STPassManager c s = STPM W.PassManager deriving Eq newtype Module = PM W.Module deriving Eq newtype STModule c s = STM { unSTM :: W.Module } deriving Eq newtype STBasicBlock c s = STB { unSTB :: BasicBlock } deriving Eq newtype STType c s = STT { unSTT :: Type } deriving Eq newtype STValue c s = STV { unSTV :: Value } deriving Eq writeBitcodeToFile :: Module -> FilePath -> IO () writeBitcodeToFile (PM m) = W.writeBitcodeToFile m -- Note: LLVM will sometimes call exit inside this. Probably not intended behavior. verifyModule :: Module -> Maybe String verifyModule (PM m) = unsafePerformIO (W.verifyModule m) instance Show Module where show (PM m) = unsafePerformIO $ W.dumpModuleToString m newtype LLVM c s a = LL (ReaderT Context (ST s) a) deriving (Functor, Applicative, Monad) class MonadLLVM m where getContext :: m c s Context liftLL :: LLVM c s a -> m c s a liftST :: ST s a -> m c s a instance MonadLLVM LLVM where getContext = LL ask liftLL = id liftST = LL . lift wrap :: MonadLLVM m => IO a -> m c s a wrap = liftLL . LL . lift . unsafeIOToST run :: Context -> (forall c s. LLVM c s (STModule c s)) -> Module run ctx action = runST $ runLLVM ctx (action >>= unsafeFreeze) run2 :: Context -> (forall c s. LLVM c s (STModule c s, a)) -> (Module, a) run2 ctx action = runST $ runLLVM ctx (do (m, x) <- action; m' <- unsafeFreeze m; return (m', x)) runLLVM :: Context -> (forall c. LLVM c s a) -> ST s a runLLVM ctx (LL lm) = runReaderT lm ctx unsafeFreeze :: (Monad (m c s), MonadLLVM m) => STModule c s -> m c s Module unsafeFreeze (STM m) = liftLL $ return (PM m) unsafeThaw :: (Monad (m c s), MonadLLVM m) => Module -> m c s (STModule c s) unsafeThaw (PM m) = liftLL $ return $ STM m showModule :: (Monad (m c s), MonadLLVM m) => STModule c s -> m c s String showModule (STM m) = wrap . W.dumpModuleToString $ m -- Source module is unusable after this linkModules :: (Monad (m c s), MonadLLVM m) => STModule c s -> STModule c s -> m c s (Maybe String) linkModules (STM dest) (STM src) = wrap $ W.linkModules dest src W.DestroySource parseBitcode :: (Functor (m c s), Monad (m c s), MonadLLVM m) => MemoryBuffer -> m c s (Either String (STModule c s)) parseBitcode buf = do ctx <- getContext (fmap . fmap) STM . wrap $ W.parseBitcodeInContext ctx buf sizeOf :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s (STValue c s) sizeOf (STT ty) = wrap . fmap STV $ W.sizeOf ty typeKind :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s TypeKind typeKind (STT t) = wrap $ W.getTypeKind t showType :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s String showType (STT t) = wrap . W.dumpTypeToString $ t showValue :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s String showValue (STV v) = wrap . W.dumpValueToString $ v functionType :: (Monad (m c s), MonadLLVM m) => STType c s -> [STType c s] -> Bool -> m c s (STType c s) functionType (STT ret) args variadic = liftLL $ return $ STT (W.functionType ret (map unSTT args) variadic) intType :: (Monad (m c s), MonadLLVM m) => CUInt -> m c s (STType c s) intType i = do ctx <- getContext wrap . fmap STT $ W.intTypeInContext ctx i doubleType :: (Monad (m c s), MonadLLVM m) => m c s (STType c s) doubleType = do ctx <- getContext wrap . fmap STT $ W.doubleTypeInContext ctx floatType :: (Monad (m c s), MonadLLVM m) => m c s (STType c s) floatType = do ctx <- getContext wrap . fmap STT $ W.floatTypeInContext ctx voidType :: (Monad (m c s), MonadLLVM m) => m c s (STType c s) voidType = do ctx <- getContext wrap . fmap STT $ W.voidTypeInContext ctx structType :: (Monad (m c s), MonadLLVM m) => [STType c s] -> Bool -> m c s (STType c s) structType types packed = do ctx <- getContext wrap . fmap STT $ W.structTypeInContext ctx (map unSTT types) packed structCreateNamed :: (Monad (m c s), MonadLLVM m) => String -> m c s (STType c s) structCreateNamed n = getContext >>= wrap . fmap STT . flip W.structCreateNamedInContext n structSetBody :: (Monad (m c s), MonadLLVM m) => STType c s -> [STType c s] -> Bool -> m c s () structSetBody (STT struct) body packed = wrap $ W.structSetBody struct (map unSTT body) packed vectorType :: (Monad (m c s), MonadLLVM m) => STType c s -> CUInt -> m c s (STType c s) vectorType (STT t) count = return $ STT (W.vectorType t count) arrayType :: (Monad (m c s), MonadLLVM m) => STType c s -> CUInt -> m c s (STType c s) arrayType (STT t) count = return $ STT (W.arrayType t count) pointerTypeInSpace :: (Monad (m c s), MonadLLVM m) => STType c s -> CUInt -> m c s (STType c s) pointerTypeInSpace (STT t) addrSpace = return $ STT (W.pointerType t addrSpace) pointerType :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s (STType c s) pointerType ty = pointerTypeInSpace ty 0 getValueName :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s String getValueName (STV v) = wrap $ W.getValueName v setValueName :: (Monad (m c s), MonadLLVM m) => STValue c s -> String -> m c s () setValueName (STV v) = wrap . W.setValueName v isUnreachable :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool isUnreachable (STV v) = wrap $ W.isUnreachable v isConstant :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool isConstant (STV v) = wrap $ W.isConstant v isNull :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool isNull (STV v) = wrap $ W.isNull v isUndef :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool isUndef (STV v) = wrap $ W.isUndef v getUndef :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s (STValue c s) getUndef = return . STV . W.getUndef . unSTT constInt :: (Monad (m c s), MonadLLVM m) => STType c s -> CULLong -> Bool -> m c s (STValue c s) constInt (STT intTy) value signExtend = return . STV $ W.constInt intTy value signExtend constPtrNull :: (Monad (m c s), MonadLLVM m) => STType c s -> m c s (STValue c s) constPtrNull (STT ty) = wrap . fmap STV $ W.constPointerNull ty constString :: (Monad (m c s), MonadLLVM m) => String -> Bool -> m c s (STValue c s) constString str nullTerminated = do ctx <- getContext wrap . fmap STV $ W.constStringInContext ctx str nullTerminated constStruct :: (Monad (m c s), MonadLLVM m) => [STValue c s] -> Bool -> m c s (STValue c s) constStruct values packed = do ctx <- getContext wrap . fmap STV $ W.constStructInContext ctx (map unSTV values) packed appendBasicBlock :: (Monad (m c s), MonadLLVM m) => String -> STValue c s -> m c s (STBasicBlock c s) appendBasicBlock name (STV func) = do ctx <- getContext wrap . fmap STB $ W.appendBasicBlockInContext ctx func name getFunctionParams :: (Functor (m c s), Monad (m c s), MonadLLVM m) => STValue c s -> m c s [STValue c s] getFunctionParams (STV func) = (fmap . fmap) STV . wrap $ W.getParams func addParamAttrib :: (Monad (m c s), MonadLLVM m) => STValue c s -> Attribute -> m c s () addParamAttrib (STV param) = wrap . W.addAttribute param addFuncAttrib :: (Monad (m c s), MonadLLVM m) => STValue c s -> Attribute -> m c s () addFuncAttrib (STV func) = wrap . W.addFunctionAttr func removeAttrib :: (Monad (m c s), MonadLLVM m) => STValue c s -> Attribute -> m c s () removeAttrib (STV val) = wrap . W.removeAttribute val typeOf :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s (STType c s) typeOf (STV v) = wrap . fmap STT $ W.typeOf v data MGS = MGS { mgModule :: W.Module, mgCtx :: Context } newtype ModuleGen c s a = MG (ReaderT MGS (ST s) a) deriving (Functor, Applicative, Monad) class MonadLLVM m => MonadMG m where liftMG :: ModuleGen c s a -> m c s a instance MonadReader (STModule c s) (ModuleGen c s) where ask = fmap (STM . mgModule) (MG ask) local f (MG mg) = MG (local (\(MGS m ctx) -> MGS (unSTM . f . STM $ m) ctx) mg) instance MonadLLVM ModuleGen where getContext = fmap mgCtx $ MG ask liftLL (LL s) = do ctx <- getContext MG (lift $ runReaderT s ctx) liftST = MG . lift instance MonadMG ModuleGen where liftMG = id -- Internal unsafeMod :: ModuleGen c s W.Module unsafeMod = fmap mgModule $ MG ask getModule :: MonadMG m => m c s (STModule c s) getModule = liftMG ask genModule :: (Monad (m c s), MonadLLVM m) => String -> ModuleGen c s a -> m c s a genModule name (MG mg) = do ctx <- getContext wrap $ do m <- W.moduleCreateWithNameInContext name ctx unsafeSTToIO . runReaderT mg $ MGS m ctx runModuleGen :: (Monad (m c s), MonadLLVM m) => STModule c s -> ModuleGen c s a -> m c s a runModuleGen (STM m) (MG mg) = do ctx <- getContext liftLL $ LL . lift . runReaderT mg $ MGS m ctx createPassManager :: (Functor (m c s), MonadLLVM m) => m c s (STPassManager c s) createPassManager = fmap STPM . wrap $ W.createPassManager populateModulePassManager :: MonadLLVM m => CUInt -> CUInt -> STPassManager c s -> m c s () populateModulePassManager optLevel optSizeLevel (STPM pm) = wrap $ do pmb <- W.passManagerBuilderCreate W.passManagerBuilderSetOptLevel pmb optLevel W.passManagerBuilderSetSizeLevel pmb optSizeLevel W.passManagerBuilderPopulateModulePassManager pmb pm populateLTOPassManager :: MonadLLVM m => CUInt -> CUInt -> Bool -> Bool -> STPassManager c s -> m c s () populateLTOPassManager optLevel optSizeLevel internalize inline (STPM pm) = wrap $ do pmb <- W.passManagerBuilderCreate W.passManagerBuilderSetOptLevel pmb optLevel W.passManagerBuilderSetSizeLevel pmb optSizeLevel W.passManagerBuilderPopulateLTOPassManager pmb pm internalize inline runPassManager :: MonadLLVM m => STPassManager c s -> STModule c s -> m c s Bool runPassManager (STPM pm) (STM m) = wrap $ W.runPassManager pm m findType :: MonadMG m => String -> m c s (Maybe (STType c s)) findType name = liftMG $ unsafeMod >>= ((fmap . fmap) STT . wrap . flip W.getTypeByName name) findGlobal :: MonadMG m => String -> m c s (Maybe (STValue c s)) findGlobal name = liftMG $ unsafeMod >>= ((fmap . fmap) STV . wrap . flip W.getNamedGlobal name) findFunction :: MonadMG m => String -> m c s (Maybe (STValue c s)) findFunction name = liftMG $ unsafeMod >>= ((fmap . fmap) STV . wrap . flip W.getNamedFunction name) addFunction :: MonadMG m => String -> STType c s -> m c s (STValue c s) addFunction name (STT ty) = liftMG $ unsafeMod >>= (\m -> fmap STV . wrap $ W.addFunction m name ty) getLinkage :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Linkage getLinkage (STV v) = wrap (W.getLinkage v) setLinkage :: (Monad (m c s), MonadLLVM m) => STValue c s -> Linkage -> m c s () setLinkage (STV v) = wrap . W.setLinkage v getTailCall :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool getTailCall (STV call) = wrap $ W.isTailCall call setTailCall :: (Monad (m c s), MonadLLVM m) => STValue c s -> Bool -> m c s () setTailCall (STV call) = wrap . W.setTailCall call setFuncCallConv :: (Monad (m c s), MonadLLVM m) => STValue c s -> CallingConvention -> m c s () setFuncCallConv (STV func) = wrap . W.setFunctionCallConv func getFuncCallConv :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s CallingConvention getFuncCallConv (STV func) = wrap $ W.getFunctionCallConv func setInstrCallConv :: (Monad (m c s), MonadLLVM m) => STValue c s -> CallingConvention -> m c s () setInstrCallConv (STV func) = wrap . W.setInstructionCallConv func data CGS = CGS { cgBuilder :: Builder, cgMGS :: MGS } newtype CodeGen c s a = CG { unCG :: ReaderT CGS (ST s) a } deriving (Functor, Applicative, Monad) class MonadMG m => MonadCG m where liftCG :: CodeGen c s a -> m c s a instance MonadLLVM CodeGen where getContext = fmap (mgCtx . cgMGS) $ CG ask liftLL (LL s) = do ctx <- getContext CG (lift $ runReaderT s ctx) liftST = CG . lift instance MonadMG CodeGen where liftMG (MG mg) = do r <- CG ask CG (lift $ runReaderT mg (cgMGS r)) instance MonadCG CodeGen where liftCG = id -- Declare, initialize, and define genFunction :: (Functor (m c s), Monad (m c s), MonadMG m) => String -> STType c s -> CodeGen c s a -> m c s a genFunction name ty cg = do f <- addFunction name ty bb <- appendBasicBlock "entry" f mgs <- liftMG $ MG ask wrap (do b <- W.createBuilderInContext (mgCtx mgs) unsafeSTToIO (runReaderT (unCG (positionAtEnd bb >> cg)) (CGS b mgs))) -- Initialize and define defineFunction :: (Functor (m c s), Monad (m c s), MonadMG m) => STValue c s -> CodeGen c s a -> m c s a defineFunction func cg = do bb <- appendBasicBlock "entry" func mgs <- liftMG $ MG ask wrap (do b <- W.createBuilderInContext (mgCtx mgs) unsafeSTToIO (runReaderT (unCG (positionAtEnd bb >> cg)) (CGS b mgs))) -- Just establish a context runCodeGen :: (Monad (m c s), MonadMG m) => STValue c s -> CodeGen c s a -> ModuleGen c s a runCodeGen (STV func) cg = do bbs <- wrap $ W.getBasicBlocks func let cg' = if null bbs then cg else positionAtEnd (STB (last bbs)) >> cg mgs <- MG ask wrap (do b <- W.createBuilderInContext (mgCtx mgs) unsafeSTToIO (runReaderT (unCG cg') (CGS b mgs))) verifyFunction :: (Monad (m c s), MonadLLVM m) => STValue c s -> m c s Bool verifyFunction (STV f) = wrap (W.verifyFunction f) position :: MonadCG m => STBasicBlock c s -> STValue c s -> m c s () position (STB block) (STV instr) = liftCG $ do b <- fmap cgBuilder $ CG ask wrap $ W.positionBuilder b block instr positionAtEnd :: MonadCG m => STBasicBlock c s -> m c s () positionAtEnd (STB block) = liftCG $ CG ask >>= wrap . flip W.positionAtEnd block . cgBuilder positionBefore :: MonadCG m => STValue c s -> m c s () positionBefore (STV v) = liftCG $ CG ask >>= wrap . flip W.positionBefore v . cgBuilder positionAfter :: MonadCG m => STValue c s -> m c s () positionAfter (STV v) = liftCG $ CG ask >>= (\builder -> wrap $ do block <- W.getInstructionParent v W.positionBuilder builder block v) . cgBuilder getFirstInstruction :: MonadLLVM m => STBasicBlock c s -> m c s (STValue c s) getFirstInstruction (STB b) = wrap . fmap STV . W.getFirstInstruction $ b getLastInstruction :: MonadLLVM m => STBasicBlock c s -> m c s (STValue c s) getLastInstruction (STB b) = wrap . fmap STV . W.getLastInstruction $ b getNextInstruction :: MonadLLVM m => STValue c s -> m c s (STValue c s) getNextInstruction (STV v) = wrap . fmap STV . W.getNextInstruction $ v getPreviousInstruction :: MonadLLVM m => STValue c s -> m c s (STValue c s) getPreviousInstruction (STV v) = wrap . fmap STV . W.getPreviousInstruction $ v getInsertBlock :: MonadCG m => m c s (STBasicBlock c s) getInsertBlock = liftCG $ CG ask >>= wrap . fmap STB . W.getInsertBlock . cgBuilder getEntryBasicBlock :: MonadLLVM m => STValue c s -> m c s (STBasicBlock c s) getEntryBasicBlock (STV f) = liftLL $ wrap . fmap STB . W.getEntryBasicBlock $ f getNextBasicBlock :: MonadLLVM m => STBasicBlock c s -> m c s (Maybe (STBasicBlock c s)) getNextBasicBlock (STB b) = liftLL $ wrap . (fmap . fmap) STB . W.getNextBasicBlock $ b getFunction :: MonadCG m => m c s (STValue c s) getFunction = liftCG $ getInsertBlock >>= (\(STB b) -> wrap . fmap STV $ W.getBasicBlockParent b) getParams :: MonadCG m => m c s [STValue c s] getParams = liftCG $ getFunction >>= getFunctionParams buildInBoundsGEP :: (Monad (m c s), MonadCG m) => String -> STValue c s -> [STValue c s] -> m c s (STValue c s) buildInBoundsGEP name (STV aggPtr) indices = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildInBoundsGEP b aggPtr (map unSTV indices) name constGEP :: (Monad (m c s), MonadCG m) => STValue c s -> [STValue c s] -> m c s (STValue c s) constGEP (STV aggPtr) indices = wrap . fmap STV $ W.constGEP aggPtr (map unSTV indices) buildAlloca :: (Monad (m c s), MonadCG m) => String -> STType c s -> m c s (STValue c s) buildAlloca name (STT ty) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildAlloca b ty name buildLoad :: (Monad (m c s), MonadCG m) => String -> STValue c s -> m c s (STValue c s) buildLoad name (STV ptr) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildLoad b ptr name buildStore :: (Monad (m c s), MonadCG m) => STValue c s -> STValue c s -> m c s (STValue c s) buildStore (STV value) (STV ptr) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildStore b value ptr buildCall :: (Monad (m c s), MonadCG m) => String -> STValue c s -> [STValue c s] -> m c s (STValue c s) buildCall name (STV func) args = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildCall b func (map unSTV args) name buildRet :: (Monad (m c s), MonadCG m) => STValue c s -> m c s (STValue c s) buildRet (STV x) = do b <- liftCG $ CG ask; wrap . fmap STV $ W.buildRet (cgBuilder b) x buildBr :: (Monad (m c s), MonadCG m) => STBasicBlock c s -> m c s (STValue c s) buildBr (STB block) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildBr b block buildCondBr :: (Monad (m c s), MonadCG m) => STValue c s -> STBasicBlock c s -> STBasicBlock c s -> m c s (STValue c s) buildCondBr (STV cond) (STB trueBlock) (STB falseBlock) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildCondBr b cond trueBlock falseBlock buildSwitch :: (Monad (m c s), MonadCG m) => STValue c s -> STBasicBlock c s -> CUInt -> m c s (STValue c s) buildSwitch (STV val) (STB defaultBlock) count = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildSwitch b val defaultBlock count addCase :: (Monad (m c s), MonadCG m) => STValue c s -> STValue c s -> STBasicBlock c b -> m c s () addCase (STV switch) (STV val) (STB block) = wrap $ W.addCase switch val block buildCase :: (Functor (m c s), Monad (m c s), MonadCG m) => STValue c s -> m c s (STValue c s) -> [(STValue c s, m c s (STValue c s))] -> m c s (STValue c s) buildCase value defaultCode alts = do func <- getFunction defBlock <- appendBasicBlock "caseDefault" func switch <- buildSwitch value defBlock (fromIntegral (length alts)) positionAtEnd defBlock defResult <- defaultCode defExit <- getInsertBlock results <- forM alts $ \(val, cg) -> do inBlock <- appendBasicBlock "caseAlt" func addCase switch val inBlock positionAtEnd inBlock result <- cg outBlock <- getInsertBlock return (result, inBlock, outBlock) end <- appendBasicBlock "caseExit" func positionAtEnd defBlock isUnreachable defResult >>= flip unless (void $ buildBr end) forM_ results $ \(result, _, outBlock) -> do unreachable <- isUnreachable result unless unreachable $ void $ positionAtEnd outBlock >> buildBr end positionAtEnd end case results of [] -> return defResult (result, _, _):_ -> do ty <- typeOf result phi <- buildPhi "caseResult" ty inputs <- filterM (\(r, _, _) -> fmap not $ isUnreachable r) ((defResult, defBlock, defExit):results) addIncoming phi (map (\(outVal, _, outBlock) -> (outVal, outBlock)) inputs) return phi buildIf :: (Monad (m c s), MonadCG m) => STType c s -> STValue c s -> m c s (STValue c s) -> m c s (STValue c s) -> m c s (STValue c s) buildIf ty cond whenTrue whenFalse = do func <- getFunction initialBlock <- getInsertBlock trueBlock <- appendBasicBlock "ifTrue" func positionAtEnd trueBlock trueResult <- whenTrue trueExit <- getInsertBlock falseBlock <- appendBasicBlock "ifFalse" func positionAtEnd falseBlock falseResult <- whenFalse falseExit <- getInsertBlock positionAtEnd initialBlock buildCondBr cond trueBlock falseBlock exitBlock <- appendBasicBlock "ifExit" func positionAtEnd trueExit buildBr exitBlock positionAtEnd falseExit buildBr exitBlock positionAtEnd exitBlock phi <- buildPhi "ifResult" ty addIncoming phi [ (trueResult, trueExit) , (falseResult, falseExit)] return phi buildPhi :: (Monad (m c s), MonadCG m) => String -> STType c s -> m c s (STValue c s) buildPhi name (STT ty) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildPhi b ty name addIncoming :: (Monad (m c s), MonadCG m) => STValue c s -> [(STValue c s, STBasicBlock c s)] -> m c s () addIncoming (STV phi) incoming = wrap $ W.addIncoming phi (map (\(a, b) -> (unSTV a, unSTB b)) incoming) buildUnreachable :: (Monad (m c s), MonadCG m) => m c s (STValue c s) buildUnreachable = do b <- liftCG $ CG ask; wrap . fmap STV $ W.buildUnreachable (cgBuilder b) wrapCast :: (Monad (m c s), MonadCG m) => (Builder -> Value -> Type -> String -> IO Value) -> String -> STValue c s -> STType c s -> m c s (STValue c s) wrapCast f n (STV v) (STT t) = do b <- liftCG $ CG ask; wrap . fmap STV $ f (cgBuilder b) v t n buildTrunc = wrapCast W.buildTrunc buildZExt = wrapCast W.buildZExt buildSExt = wrapCast W.buildSExt buildFPToUI = wrapCast W.buildFPToUI buildFPToSI = wrapCast W.buildFPToSI buildUIToFP = wrapCast W.buildUIToFP buildSIToFP = wrapCast W.buildSIToFP buildFPTrunc = wrapCast W.buildFPTrunc buildFPExt = wrapCast W.buildFPExt buildPtrToInt = wrapCast W.buildPtrToInt buildIntToPtr = wrapCast W.buildIntToPtr buildBitCast = wrapCast W.buildBitCast buildPointerCast = wrapCast W.buildPointerCast buildTruncOrBitCast = wrapCast W.buildTruncOrBitCast buildZExtOrBitCast = wrapCast W.buildZExtOrBitCast buildSExtOrBitCast = wrapCast W.buildSExtOrBitCast buildFPCast = wrapCast W.buildFPCast wrapUn :: (Monad (m c s), MonadCG m) => (Builder -> Value -> String -> IO Value) -> String -> STValue c s -> m c s (STValue c s) wrapUn f n (STV x) = do b <- liftCG $ CG ask; wrap . fmap STV $ f (cgBuilder b) x n buildNeg = wrapUn W.buildNeg buildFNeg = wrapUn W.buildFNeg buildNot = wrapUn W.buildNot buildNSWNeg = wrapUn W.buildNSWNeg buildNUWNeg = wrapUn W.buildNUWNeg wrapBin :: (Monad (m c s), MonadCG m) => (Builder -> Value -> Value -> String -> IO Value) -> String -> STValue c s -> STValue c s -> m c s (STValue c s) wrapBin f n (STV l) (STV r) = do b <- liftCG $ CG ask; wrap . fmap STV $ f (cgBuilder b) l r n buildAdd = wrapBin W.buildAdd buildSub = wrapBin W.buildSub buildMul = wrapBin W.buildMul buildNSWAdd = wrapBin W.buildNSWAdd buildNSWSub = wrapBin W.buildNSWSub buildNSWMul = wrapBin W.buildNSWMul buildNUWAdd = wrapBin W.buildNUWAdd buildNUWSub = wrapBin W.buildNUWSub buildNUWMul = wrapBin W.buildNUWMul buildUDiv = wrapBin W.buildUDiv buildSDiv = wrapBin W.buildSDiv buildExactSDiv = wrapBin W.buildExactSDiv buildURem = wrapBin W.buildURem buildSRem = wrapBin W.buildSRem buildFAdd = wrapBin W.buildFAdd buildFSub = wrapBin W.buildFSub buildFMul = wrapBin W.buildFMul buildFDiv = wrapBin W.buildFDiv buildFRem = wrapBin W.buildFRem buildShl = wrapBin W.buildShl buildLShr = wrapBin W.buildLShr buildAShr = wrapBin W.buildAShr buildAnd = wrapBin W.buildAnd buildOr = wrapBin W.buildOr buildXor = wrapBin W.buildXor buildICmp :: (Monad (m c s), MonadCG m) => String -> IntPredicate -> STValue c s -> STValue c s -> m c s (STValue c s) buildICmp name f (STV l) (STV r) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildICmp b f l r name buildFCmp :: (Monad (m c s), MonadCG m) => String -> FPPredicate -> STValue c s -> STValue c s -> m c s (STValue c s) buildFCmp name f (STV l) (STV r) = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildFCmp b f l r name wrapConstBin :: (Monad (m c s), MonadLLVM m) => (Value -> Value -> Value) -> STValue c s -> STValue c s -> m c s (STValue c s) wrapConstBin f (STV l) (STV r) = return . STV $ f l r constAdd = wrapConstBin W.constAdd constSub = wrapConstBin W.constSub constMul = wrapConstBin W.constMul -- constNSWAdd = wrapConstBin W.constNSWAdd -- constNSWSub = wrapConstBin W.constNSWSub -- constNSWMul = wrapConstBin W.constNSWMul -- constNUWAdd = wrapConstBin W.constNUWAdd -- constNUWSub = wrapConstBin W.constNUWSub -- constNUWMul = wrapConstBin W.constNUWMul constUDiv = wrapConstBin W.constUDiv constSDiv = wrapConstBin W.constSDiv --constExactSDiv = wrapConstBin W.constExactSDiv constURem = wrapConstBin W.constURem constSRem = wrapConstBin W.constSRem constFAdd = wrapConstBin W.constFAdd constFSub = wrapConstBin W.constFSub constFMul = wrapConstBin W.constFMul constFDiv = wrapConstBin W.constFDiv constFRem = wrapConstBin W.constFRem constShl = wrapConstBin W.constShl constLShr = wrapConstBin W.constLShr constAShr = wrapConstBin W.constAShr constAnd = wrapConstBin W.constAnd constOr = wrapConstBin W.constOr constXor = wrapConstBin W.constXor buildGlobalString :: (Monad (m c s), MonadCG m) => String -> String -> m c s (STValue c s) buildGlobalString name value = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildGlobalString b value name buildGlobalStringPtr :: (Monad (m c s), MonadCG m) => String -> String -> m c s (STValue c s) buildGlobalStringPtr name value = do b <- liftCG $ fmap cgBuilder (CG ask) wrap . fmap STV $ W.buildGlobalStringPtr b value name wrapConstCast :: (Monad (m c s), MonadLLVM m) => (Value -> Type -> Value) -> STValue c s -> STType c s -> m c s (STValue c s) wrapConstCast f (STV v) (STT t) = liftLL $ return . STV $ f v t constTrunc = wrapConstCast W.constTrunc constZExt = wrapConstCast W.constZExt constSExt = wrapConstCast W.constSExt constFPToUI = wrapConstCast W.constFPToUI constFPToSI = wrapConstCast W.constFPToSI constUIToFP = wrapConstCast W.constUIToFP constSIToFP = wrapConstCast W.constSIToFP constFPTrunc = wrapConstCast W.constFPTrunc constFPExt = wrapConstCast W.constFPExt constPtrToInt = wrapConstCast W.constPtrToInt constIntToPtr = wrapConstCast W.constIntToPtr constBitCast = wrapConstCast W.constBitCast -- constPointerCast = wrapConstCast W.constPointerCast -- constTruncOrBitCast = wrapConstCast W.constTruncOrBitCast -- constZExtOrBitCast = wrapConstCast W.constZExtOrBitCast -- constSExtOrBitCast = wrapConstCast W.constSExtOrBitCast constFPCast = wrapConstCast W.constFPCast llvm-base-3.2.0.0/LLVM/Target/0000755000000000000000000000000012142503271013717 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/Target/ARM.hs0000644000000000000000000000055512142503271014677 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.ARM(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeARMTargetInfo initializeARMTarget foreign import ccall unsafe "LLVMInitializeARMTargetInfo" initializeARMTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeARMTarget" initializeARMTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/CellSPU.hs0000644000000000000000000000061112142503271015520 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.CellSPU(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeCellSPUTargetInfo initializeCellSPUTarget foreign import ccall unsafe "LLVMInitializeCellSPUTargetInfo" initializeCellSPUTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeCellSPUTarget" initializeCellSPUTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/Native.hs0000644000000000000000000000143612142503271015505 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface #-} module LLVM.Target.Native(initializeNativeTarget) where import Control.Monad import Control.Concurrent.MVar import System.IO.Unsafe import Foreign.C.Types -- TARGET is expanded by CPP to the native target architecture. import LLVM.Target.TARGET foreign import ccall unsafe "LLVMInitNativeTarget" llvmInitializeNativeTarget :: IO CUInt -- | Initialize jitter to the native target. -- The operation is idempotent. initializeNativeTarget :: IO () initializeNativeTarget = do done <- takeMVar refDone when (not done) (llvmInitializeNativeTarget >> return ()) -- initializeTarget putMVar refDone True -- UNSAFE: global variable to keep track of initialization state. refDone :: MVar Bool refDone = unsafePerformIO $ newMVar False llvm-base-3.2.0.0/LLVM/Target/CppBackend.hs0000644000000000000000000000063612142503271016252 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.CppBackend(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeCppBackendTargetInfo initializeCppBackendTarget foreign import ccall unsafe "LLVMInitializeCppBackendTargetInfo" initializeCppBackendTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeCppBackendTarget" initializeCppBackendTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/PowerPC.hs0000644000000000000000000000061112142503271015570 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.PowerPC(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializePowerPCTargetInfo initializePowerPCTarget foreign import ccall unsafe "LLVMInitializePowerPCTargetInfo" initializePowerPCTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializePowerPCTarget" initializePowerPCTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/XCore.hs0000644000000000000000000000057312142503271015300 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.XCore(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeXCoreTargetInfo initializeXCoreTarget foreign import ccall unsafe "LLVMInitializeXCoreTargetInfo" initializeXCoreTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeXCoreTarget" initializeXCoreTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/Mips.hs0000644000000000000000000000056412142503271015170 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.Mips(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeMipsTargetInfo initializeMipsTarget foreign import ccall unsafe "LLVMInitializeMipsTargetInfo" initializeMipsTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeMipsTarget" initializeMipsTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/MSP430.hs0000644000000000000000000000060212142503271015137 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.MSP430(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeMSP430TargetInfo initializeMSP430Target foreign import ccall unsafe "LLVMInitializeMSP430TargetInfo" initializeMSP430TargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeMSP430Target" initializeMSP430Target :: IO () llvm-base-3.2.0.0/LLVM/Target/Sparc.hs0000644000000000000000000000057312142503271015330 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.Sparc(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeSparcTargetInfo initializeSparcTarget foreign import ccall unsafe "LLVMInitializeSparcTargetInfo" initializeSparcTargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeSparcTarget" initializeSparcTarget :: IO () llvm-base-3.2.0.0/LLVM/Target/X86.hs0000644000000000000000000000055512142503271014645 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface #-} module LLVM.Target.X86(initializeTarget) where initializeTarget :: IO () initializeTarget = do initializeX86TargetInfo initializeX86Target foreign import ccall unsafe "LLVMInitializeX86TargetInfo" initializeX86TargetInfo :: IO () foreign import ccall unsafe "LLVMInitializeX86Target" initializeX86Target :: IO () llvm-base-3.2.0.0/LLVM/FFI/0000755000000000000000000000000012142503271013075 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/FFI/Support.hsc0000644000000000000000000000176312142503271015257 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface #-} module LLVM.FFI.Support ( createStandardModulePasses , createStandardFunctionPasses #if HS_LLVM_VERSION >= 300 , addEmitObjectPass #endif , disablePrettyStackTrace ) where #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types (CInt(..), CUInt(..)) #else import Foreign.C.Types (CInt, CUInt) #endif import Foreign.C.String (CString) import LLVM.FFI.Core (PassManagerRef, ModuleRef) foreign import ccall unsafe "LLVMCreateStandardFunctionPasses" createStandardFunctionPasses :: PassManagerRef -> CUInt -> IO () foreign import ccall unsafe "LLVMCreateStandardModulePasses" createStandardModulePasses :: PassManagerRef -> CUInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> IO () #if HS_LLVM_VERSION >= 300 foreign import ccall unsafe "LLVMAddEmitObjectPass" addEmitObjectPass :: ModuleRef -> CString -> IO CUInt #endif foreign import ccall unsafe "LLVMDisablePrettyStackTrace" disablePrettyStackTrace :: IO () llvm-base-3.2.0.0/LLVM/FFI/Core.hsc0000644000000000000000000020646412142503271014500 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls, DeriveDataTypeable, CPP #-} -- | -- Module: LLVM.FFI.Core -- Copyright: Bryan O'Sullivan 2007, 2008 -- License: BSD-style (see the file LICENSE) -- -- Maintainer: bos@serpentine.com -- Stability: experimental -- Portability: requires GHC 6.8, LLVM -- -- This module provides direct access to the LLVM C bindings. module LLVM.FFI.Core ( -- * Modules Module , ModuleRef , moduleCreateWithName , disposeModule , ptrDisposeModule , getDataLayout , setDataLayout , getTarget , setTarget -- * Module providers , ModuleProvider , ModuleProviderRef , createModuleProviderForExistingModule , ptrDisposeModuleProvider -- * Types , Type , TypeRef #if HS_LLVM_VERSION < 300 , addTypeName , deleteTypeName #endif , getTypeKind , TypeKind(..) -- ** Integer types , int1Type , int8Type , int16Type , int32Type , int64Type , integerType , getIntTypeWidth -- ** Real types , floatType , doubleType , x86FP80Type , fp128Type , ppcFP128Type -- ** Function types , functionType , isFunctionVarArg , getReturnType , countParamTypes , getParamTypes -- ** Other types , voidType , labelType #if HS_LLVM_VERSION < 300 , opaqueType #endif -- ** Array, pointer, and vector types , arrayType , pointerType , vectorType , getElementType , getArrayLength , getPointerAddressSpace , getVectorSize -- ** Struct types , structType , countStructElementTypes , getStructElementTypes , isPackedStruct #if HS_LLVM_VERSION >= 300 , structCreateNamed , getStructName , structSetBody #endif -- * Type handles #if HS_LLVM_VERSION < 300 , TypeHandleRef , createTypeHandle , refineType , resolveTypeHandle , disposeTypeHandle #endif -- * Values , Value , ValueRef , typeOf , getValueName , setValueName , dumpValue -- ** Constants , constNull , constAllOnes , getUndef , isConstant , isNull , isUndef -- ** Global variables, functions, and aliases (globals) , Linkage(..) , fromLinkage , toLinkage , getLinkage , setLinkage , Visibility(..) , fromVisibility , toVisibility , getVisibility , setVisibility , isDeclaration , getSection , setSection , getAlignment , setAlignment -- ** Global variables , addGlobal , getNamedGlobal , deleteGlobal , getInitializer , setInitializer , isThreadLocal , setThreadLocal , isGlobalConstant , setGlobalConstant , getFirstGlobal , getNextGlobal , getPreviousGlobal , getLastGlobal , getGlobalParent -- ** Functions , addFunction , getNamedFunction , deleteFunction , countParams , getParams , getParam , getIntrinsicID , getGC , setGC , getFirstFunction , getNextFunction , getPreviousFunction , getLastFunction , getFirstParam , getNextParam , getPreviousParam , getLastParam , getParamParent , isTailCall , setTailCall -- ** Phi nodes , addIncoming , countIncoming , getIncomingValue , getIncomingBlock -- ** Calling conventions , CallingConvention(..) , fromCallingConvention , toCallingConvention , getFunctionCallConv , setFunctionCallConv , getInstructionCallConv , setInstructionCallConv -- * Constants -- ** Scalar constants , constInt , constReal -- ** Composite constants , constArray , constString , constStruct , constVector -- ** Constant expressions , sizeOf , constNeg , constNot , constAdd , constSub , constMul , constExactSDiv , constFAdd , constFMul , constFNeg , constFPCast , constFSub , constUDiv , constSDiv , constFDiv , constURem , constSRem , constFRem , constAnd , constOr , constXor , constICmp , constFCmp , constShl , constLShr , constAShr , constGEP , constTrunc , constSExt , constZExt , constFPTrunc , constFPExt , constUIToFP , constSIToFP , constFPToUI , constFPToSI , constPtrToInt , constIntToPtr , constBitCast , constSelect , constExtractElement , constInsertElement , constShuffleVector , constRealOfString , constNSWMul , constNSWNeg , constNSWSub , constNUWAdd , constNUWMul , constNUWNeg , constNUWSub -- * Basic blocks , BasicBlock , BasicBlockRef , basicBlockAsValue , valueIsBasicBlock , valueAsBasicBlock , countBasicBlocks , getBasicBlocks , getEntryBasicBlock , appendBasicBlock , insertBasicBlock , deleteBasicBlock , getFirstBasicBlock , getNextBasicBlock , getPreviousBasicBlock , getLastBasicBlock , getInsertBlock , getBasicBlockParent -- * Instruction field accessors , instGetOpcode, getInstructionOpcode, cmpInstGetPredicate -- * Instruction building , Builder , BuilderRef , createBuilder , disposeBuilder , ptrDisposeBuilder , positionBuilder , positionBefore , positionAtEnd , getFirstInstruction , getNextInstruction , getPreviousInstruction , getLastInstruction , getInstructionParent -- ** Terminators , buildRetVoid , buildRet , buildBr , buildIndirectBr , buildCondBr , buildSwitch , buildInvoke #if HS_LLVM_VERSION < 300 , buildUnwind #endif , buildUnreachable #if HS_LLVM_VERSION >= 300 -- ** Landing pad , buildLandingPad , addClause , setCleanup #endif -- ** Arithmetic , buildAdd , buildSub , buildMul , buildFAdd , buildFMul , buildFPCast , buildFSub , buildUDiv , buildSDiv , buildExactSDiv , buildFDiv , buildURem , buildSRem , buildFRem , buildShl , buildLShr , buildAShr , buildAnd , buildOr , buildXor , buildNeg , buildFNeg , buildNot , buildNSWMul , buildNSWNeg , buildNSWSub , buildNUWAdd , buildNUWMul , buildNUWNeg , buildNUWSub -- ** Memory , buildMalloc , buildArrayMalloc , buildAlloca , buildArrayAlloca , buildFree , buildLoad , buildStore , buildGEP -- ** Casts , buildTrunc , buildZExt , buildSExt , buildFPToUI , buildFPToSI , buildUIToFP , buildSIToFP , buildFPTrunc , buildFPExt , buildPtrToInt , buildIntToPtr , buildBitCast , buildPointerCast , buildTruncOrBitCast , buildZExtOrBitCast , buildSExtOrBitCast , buildPtrDiff -- * Misc , buildAggregateRet , buildGlobalString , buildGlobalStringPtr , buildInBoundsGEP , buildIsNotNull , buildIsNull , buildNSWAdd , buildStructGEP -- ** Comparisons , IntPredicate(..) , toIntPredicate , fromIntPredicate , FPPredicate(..) , toFPPredicate , fromFPPredicate , buildICmp , buildFCmp -- ** Miscellaneous instructions , buildPhi , buildCall , buildSelect , buildVAArg , buildExtractElement , buildInsertElement , buildShuffleVector -- ** Other helpers , addCase -- * Memory buffers , MemoryBuffer , MemoryBufferRef , createMemoryBufferWithContentsOfFile , createMemoryBufferWithSTDIN , createMemoryBufferWithMemoryRange , createMemoryBufferWithMemoryRangeCopy , disposeMemoryBuffer , ptrDisposeMemoryBuffer -- * Error handling , disposeMessage -- * Parameter passing , addAttribute , setInstrParamAlignment , setParamAlignment , Attribute(..) , fromAttribute , toAttribute , addInstrAttribute , removeFunctionAttr , removeAttribute , removeInstrAttribute , addFunctionAttr -- * Pass manager , PassManager , PassManagerRef , createFunctionPassManager , createPassManager , disposePassManager , ptrDisposePassManager , finalizeFunctionPassManager , initializeFunctionPassManager , runFunctionPassManager , runPassManager -- * Context functions , Context , ContextRef -- * Debug , dumpModule , printModuleToFile , dumpModuleToString , dumpValueToString , dumpTypeToString -- * Misc , alignOf , constInBoundsGEP , constIntCast , constIntOfString , constIntOfStringAndSize , constNSWAdd , constPointerCast , constPointerNull , constRealOfStringAndSize , constSExtOrBitCast , getTypeByName , insertIntoBuilderWithName -- * Context functions , moduleCreateWithNameInContext , appendBasicBlockInContext , insertBasicBlockInContext , createBuilderInContext , contextDispose , ptrContextDispose , constStringInContext , constStructInContext , constTruncOrBitCast , constZExtOrBitCast , doubleTypeInContext , fP128TypeInContext , floatTypeInContext , int16TypeInContext , int1TypeInContext , int32TypeInContext , int64TypeInContext , int8TypeInContext , intTypeInContext , labelTypeInContext #if HS_LLVM_VERSION < 300 , opaqueTypeInContext #endif , pPCFP128TypeInContext , structTypeInContext , voidTypeInContext , x86FP80TypeInContext , getTypeContext , addAlias , addDestination , addGlobalInAddressSpace , blockAddress , clearInsertionPosition , constExtractValue , constInlineAsm , constInsertValue , constIntGetSExtValue , constIntGetZExtValue -- , constUnion , contextCreate -- , countUnionElementTypes , createFunctionPassManagerForModule , getAttribute , getCurrentDebugLocation , getFunctionAttr , getGlobalContext , getMDKindID , getMDKindIDInContext , getMetadata , getOperand , getNumOperands -- , getUnionElementTypes , hasMetadata , insertIntoBuilder , mdNode , mdNodeInContext , mdString , mdStringInContext , replaceAllUsesWith , setCurrentDebugLocation , setInstDebugLocation , debugVersion , setMetadata , MetadataKind(..) , fromMetadataKind , toMetadataKind , getNamedMetadataNumOperands , getNamedMetadataOperands , addNamedMetadataOperand -- , unionType -- , unionTypeInContext -- ** Build instruction from opcode , buildBinOp , getConstOpcode , buildCast , buildExtractValue , buildInsertValue -- ** Use , OpaqueUse , UseRef , getFirstUse , getNextUse , getNumUses , getUsedValue , getUser , isUsedInBasicBlock ) where import Data.Typeable(Typeable) import Foreign.C.String (CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types (CDouble(..), CInt(..), CUInt(..), CLLong(..), CULLong(..), CSize(..)) #else import Foreign.C.Types (CDouble, CInt, CUInt, CLLong, CULLong) #endif import Foreign.Ptr (Ptr, FunPtr) #include data Module deriving (Typeable) type ModuleRef = Ptr Module foreign import ccall unsafe "LLVMModuleCreateWithName" moduleCreateWithName :: CString -> IO ModuleRef foreign import ccall unsafe "LLVMDisposeModule" disposeModule :: ModuleRef -> IO () foreign import ccall unsafe "&LLVMDisposeModule" ptrDisposeModule :: FunPtr (ModuleRef -> IO ()) foreign import ccall unsafe "LLVMGetDataLayout" getDataLayout :: ModuleRef -> IO CString foreign import ccall unsafe "LLVMSetDataLayout" setDataLayout :: ModuleRef -> CString -> IO () data ModuleProvider deriving (Typeable) type ModuleProviderRef = Ptr ModuleProvider foreign import ccall unsafe "LLVMCreateModuleProviderForExistingModule" createModuleProviderForExistingModule :: ModuleRef -> IO ModuleProviderRef foreign import ccall unsafe "&LLVMDisposeModuleProvider" ptrDisposeModuleProvider :: FunPtr (ModuleProviderRef -> IO ()) data Type deriving (Typeable) type TypeRef = Ptr Type foreign import ccall unsafe "LLVMInt1Type" int1Type :: TypeRef foreign import ccall unsafe "LLVMInt8Type" int8Type :: TypeRef foreign import ccall unsafe "LLVMInt16Type" int16Type :: TypeRef foreign import ccall unsafe "LLVMInt32Type" int32Type :: TypeRef foreign import ccall unsafe "LLVMInt64Type" int64Type :: TypeRef -- | An integer type of the given width. foreign import ccall unsafe "LLVMIntType" integerType :: CUInt -- ^ width in bits -> TypeRef foreign import ccall unsafe "LLVMFloatType" floatType :: TypeRef foreign import ccall unsafe "LLVMDoubleType" doubleType :: TypeRef foreign import ccall unsafe "LLVMX86FP80Type" x86FP80Type :: TypeRef foreign import ccall unsafe "LLVMFP128Type" fp128Type :: TypeRef foreign import ccall unsafe "LLVMPPCFP128Type" ppcFP128Type :: TypeRef foreign import ccall unsafe "LLVMVoidType" voidType :: TypeRef -- | Create a function type. foreign import ccall unsafe "LLVMFunctionType" functionType :: TypeRef -- ^ return type -> Ptr TypeRef -- ^ array of argument types -> CUInt -- ^ number of elements in array -> Bool -- ^ non-zero if function is varargs -> TypeRef -- | Indicate whether a function takes varargs. foreign import ccall unsafe "LLVMIsFunctionVarArg" isFunctionVarArg :: TypeRef -> IO Bool -- | Give a function's return type. foreign import ccall unsafe "LLVMGetReturnType" getReturnType :: TypeRef -> IO TypeRef -- | Give the number of fixed parameters that a function takes. foreign import ccall unsafe "LLVMCountParamTypes" countParamTypes :: TypeRef -> IO CUInt -- | Fill out an array with the types of a function's fixed -- parameters. foreign import ccall unsafe "LLVMGetParamTypes" getParamTypes :: TypeRef -> Ptr TypeRef -> IO () foreign import ccall unsafe "LLVMArrayType" arrayType :: TypeRef -- ^ element type -> CUInt -- ^ element count -> TypeRef foreign import ccall unsafe "LLVMPointerType" pointerType :: TypeRef -- ^ pointed-to type -> CUInt -- ^ address space -> TypeRef foreign import ccall unsafe "LLVMVectorType" vectorType :: TypeRef -- ^ element type -> CUInt -- ^ element count -> TypeRef #if HS_LLVM_VERSION < 300 foreign import ccall unsafe "LLVMAddTypeName" addTypeName :: ModuleRef -> CString -> TypeRef -> IO Bool foreign import ccall unsafe "LLVMDeleteTypeName" deleteTypeName :: ModuleRef -> CString -> IO () #endif -- | Get the type of a sequential type's elements. foreign import ccall unsafe "LLVMGetElementType" getElementType :: TypeRef -> IO TypeRef data Value deriving (Typeable) type ValueRef = Ptr Value foreign import ccall unsafe "LLVMAddGlobal" addGlobal :: ModuleRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMDeleteGlobal" deleteGlobal :: ValueRef -> IO () foreign import ccall unsafe "LLVMSetInitializer" setInitializer :: ValueRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMGetNamedGlobal" getNamedGlobal :: ModuleRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMGetInitializer" getInitializer :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMIsThreadLocal" isThreadLocal :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMSetThreadLocal" setThreadLocal :: ValueRef -> Bool -> IO () foreign import ccall unsafe "LLVMIsGlobalConstant" isGlobalConstant :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMSetGlobalConstant" setGlobalConstant :: ValueRef -> Bool -> IO () foreign import ccall unsafe "LLVMTypeOf" typeOf :: ValueRef -> IO TypeRef foreign import ccall unsafe "LLVMGetValueName" getValueName :: ValueRef -> IO CString foreign import ccall unsafe "LLVMSetValueName" setValueName :: ValueRef -> CString -> IO () foreign import ccall unsafe "LLVMDumpValue" dumpValue :: ValueRef -> IO () foreign import ccall unsafe "LLVMConstAllOnes" constAllOnes :: TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstArray" constArray :: TypeRef -> Ptr ValueRef -> CUInt -> ValueRef foreign import ccall unsafe "LLVMConstNull" constNull :: TypeRef -> ValueRef foreign import ccall unsafe "LLVMIsConstant" isConstant :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMGetUndef" getUndef :: TypeRef -> ValueRef foreign import ccall unsafe "LLVMIsNull" isNull :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMIsUndef" isUndef :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMGetNamedFunction" getNamedFunction :: ModuleRef -- ^ module -> CString -- ^ name -> IO ValueRef -- ^ function (@nullPtr@ if not found) foreign import ccall unsafe "LLVMAddFunction" addFunction :: ModuleRef -- ^ module -> CString -- ^ name -> TypeRef -- ^ type -> IO ValueRef foreign import ccall unsafe "LLVMDeleteFunction" deleteFunction :: ValueRef -- ^ function -> IO () foreign import ccall unsafe "LLVMCountParams" countParams :: ValueRef -- ^ function -> CUInt foreign import ccall unsafe "LLVMGetParam" getParam :: ValueRef -- ^ function -> CUInt -- ^ offset into array -> ValueRef foreign import ccall unsafe "LLVMGetParams" getParams :: ValueRef -- ^ function -> Ptr ValueRef -- ^ array to fill out -> IO () foreign import ccall unsafe "LLVMGetIntrinsicID" getIntrinsicID :: ValueRef -- ^ function -> CUInt data CallingConvention = C | Fast | Cold | X86StdCall | X86FastCall | GHC deriving (Show, Eq, Ord, Enum, Bounded, Typeable) fromCallingConvention :: CallingConvention -> CUInt fromCallingConvention C = (#const LLVMCCallConv) fromCallingConvention Fast = (#const LLVMFastCallConv) fromCallingConvention Cold = (#const LLVMColdCallConv) fromCallingConvention X86StdCall = (#const LLVMX86FastcallCallConv) fromCallingConvention X86FastCall = (#const LLVMX86StdcallCallConv) fromCallingConvention GHC = 10 toCallingConvention :: CUInt -> CallingConvention toCallingConvention c | c == (#const LLVMCCallConv) = C toCallingConvention c | c == (#const LLVMFastCallConv) = Fast toCallingConvention c | c == (#const LLVMColdCallConv) = Cold toCallingConvention c | c == (#const LLVMX86StdcallCallConv) = X86StdCall toCallingConvention c | c == (#const LLVMX86FastcallCallConv) = X86FastCall toCallingConvention c | c == 10 = GHC toCallingConvention c = error $ "LLVM.Core.FFI.toCallingConvention: " ++ "unsupported calling convention" ++ show c foreign import ccall unsafe "LLVMGetFunctionCallConv" getFunctionCallConv :: ValueRef -- ^ function -> IO CUInt foreign import ccall unsafe "LLVMSetFunctionCallConv" setFunctionCallConv :: ValueRef -- ^ function -> CUInt -> IO () foreign import ccall unsafe "LLVMGetGC" getGC :: ValueRef -> IO CString foreign import ccall unsafe "LLVMSetGC" setGC :: ValueRef -> CString -> IO () foreign import ccall unsafe "LLVMIsDeclaration" isDeclaration :: ValueRef -> IO Bool -- |An enumeration for the kinds of linkage for global values. data Linkage = ExternalLinkage -- ^Externally visible function | AvailableExternallyLinkage | LinkOnceAnyLinkage -- ^Keep one copy of function when linking (inline) | LinkOnceODRLinkage -- ^Same, but only replaced by something equivalent. | WeakAnyLinkage -- ^Keep one copy of named function when linking (weak) | WeakODRLinkage -- ^Same, but only replaced by something equivalent. | AppendingLinkage -- ^Special purpose, only applies to global arrays | InternalLinkage -- ^Rename collisions when linking (static functions) | PrivateLinkage -- ^Like Internal, but omit from symbol table | DLLImportLinkage -- ^Function to be imported from DLL | DLLExportLinkage -- ^Function to be accessible from DLL | ExternalWeakLinkage -- ^ExternalWeak linkage description | GhostLinkage -- ^Stand-in functions for streaming fns from BC files | CommonLinkage -- ^Tentative definitions | LinkerPrivateLinkage -- ^Like Private, but linker removes. deriving (Show, Eq, Ord, Enum, Typeable) fromLinkage :: Linkage -> CUInt fromLinkage ExternalLinkage = (#const LLVMExternalLinkage) fromLinkage AvailableExternallyLinkage = (#const LLVMAvailableExternallyLinkage ) fromLinkage LinkOnceAnyLinkage = (#const LLVMLinkOnceAnyLinkage) fromLinkage LinkOnceODRLinkage = (#const LLVMLinkOnceODRLinkage) fromLinkage WeakAnyLinkage = (#const LLVMWeakAnyLinkage) fromLinkage WeakODRLinkage = (#const LLVMWeakODRLinkage) fromLinkage AppendingLinkage = (#const LLVMAppendingLinkage) fromLinkage InternalLinkage = (#const LLVMInternalLinkage) fromLinkage PrivateLinkage = (#const LLVMPrivateLinkage) fromLinkage DLLImportLinkage = (#const LLVMDLLImportLinkage) fromLinkage DLLExportLinkage = (#const LLVMDLLExportLinkage) fromLinkage ExternalWeakLinkage = (#const LLVMExternalWeakLinkage) fromLinkage GhostLinkage = (#const LLVMGhostLinkage) fromLinkage CommonLinkage = (#const LLVMCommonLinkage) fromLinkage LinkerPrivateLinkage = (#const LLVMLinkerPrivateLinkage) toLinkage :: CUInt -> Linkage toLinkage c | c == (#const LLVMExternalLinkage) = ExternalLinkage toLinkage c | c == (#const LLVMAvailableExternallyLinkage) = AvailableExternallyLinkage toLinkage c | c == (#const LLVMLinkOnceAnyLinkage) = LinkOnceAnyLinkage toLinkage c | c == (#const LLVMLinkOnceODRLinkage) = LinkOnceODRLinkage toLinkage c | c == (#const LLVMWeakAnyLinkage) = WeakAnyLinkage toLinkage c | c == (#const LLVMWeakODRLinkage) = WeakODRLinkage toLinkage c | c == (#const LLVMAppendingLinkage) = AppendingLinkage toLinkage c | c == (#const LLVMInternalLinkage) = InternalLinkage toLinkage c | c == (#const LLVMPrivateLinkage) = PrivateLinkage toLinkage c | c == (#const LLVMDLLImportLinkage) = DLLImportLinkage toLinkage c | c == (#const LLVMDLLExportLinkage) = DLLExportLinkage toLinkage c | c == (#const LLVMExternalWeakLinkage) = ExternalWeakLinkage toLinkage c | c == (#const LLVMGhostLinkage) = GhostLinkage toLinkage c | c == (#const LLVMCommonLinkage) = CommonLinkage toLinkage c | c == (#const LLVMLinkerPrivateLinkage) = LinkerPrivateLinkage toLinkage _ = error "toLinkage: bad value" foreign import ccall unsafe "LLVMGetLinkage" getLinkage :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMSetLinkage" setLinkage :: ValueRef -> CUInt -> IO () foreign import ccall unsafe "LLVMGetSection" getSection :: ValueRef -> IO CString foreign import ccall unsafe "LLVMSetSection" setSection :: ValueRef -> CString -> IO () -- |An enumeration for the kinds of visibility of global values. data Visibility = DefaultVisibility -- ^The GV is visible | HiddenVisibility -- ^The GV is hidden | ProtectedVisibility -- ^The GV is protected deriving (Show, Eq, Ord, Enum) fromVisibility :: Visibility -> CUInt fromVisibility DefaultVisibility = (#const LLVMDefaultVisibility) fromVisibility HiddenVisibility = (#const LLVMHiddenVisibility) fromVisibility ProtectedVisibility = (#const LLVMProtectedVisibility) toVisibility :: CUInt -> Visibility toVisibility c | c == (#const LLVMDefaultVisibility) = DefaultVisibility toVisibility c | c == (#const LLVMHiddenVisibility) = HiddenVisibility toVisibility c | c == (#const LLVMProtectedVisibility) = ProtectedVisibility toVisibility _ = error "toVisibility: bad value" foreign import ccall unsafe "LLVMGetVisibility" getVisibility :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMSetVisibility" setVisibility :: ValueRef -> CUInt -> IO () foreign import ccall unsafe "LLVMGetAlignment" getAlignment :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMSetAlignment" setAlignment :: ValueRef -> CUInt -> IO () foreign import ccall unsafe "LLVMConstInt" constInt :: TypeRef -> CULLong -> Bool -> ValueRef foreign import ccall unsafe "LLVMConstReal" constReal :: TypeRef -> CDouble -> ValueRef foreign import ccall unsafe "LLVMConstString" constString :: CString -> CUInt -> Bool -> ValueRef foreign import ccall unsafe "LLVMConstStruct" constStruct :: Ptr ValueRef -> CUInt -> Bool -> ValueRef foreign import ccall unsafe "LLVMConstVector" constVector :: Ptr ValueRef -> CUInt -> ValueRef foreign import ccall unsafe "LLVMConstNeg" constNeg :: ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstNot" constNot :: ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstAdd" constAdd :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstSub" constSub :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstMul" constMul :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstUDiv" constUDiv :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstSDiv" constSDiv :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFDiv" constFDiv :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstURem" constURem :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstSRem" constSRem :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFRem" constFRem :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstAnd" constAnd :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstOr" constOr :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstXor" constXor :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstICmp" constICmp :: CInt -> ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFCmp" constFCmp :: CInt -> ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstShl" constShl :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstLShr" constLShr :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstAShr" constAShr :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstGEP" constGEP :: ValueRef -> Ptr ValueRef -> CUInt -> ValueRef foreign import ccall unsafe "LLVMConstTrunc" constTrunc :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstSExt" constSExt :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstZExt" constZExt :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstFPTrunc" constFPTrunc :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstFPExt" constFPExt :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstUIToFP" constUIToFP :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstSIToFP" constSIToFP :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstFPToUI" constFPToUI :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstFPToSI" constFPToSI :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstPtrToInt" constPtrToInt :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstIntToPtr" constIntToPtr :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstBitCast" constBitCast :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstSelect" constSelect :: ValueRef -> ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstExtractElement" constExtractElement :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstInsertElement" constInsertElement :: ValueRef -> ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstShuffleVector" constShuffleVector :: ValueRef -> ValueRef -> ValueRef -> ValueRef type BasicBlock = Value type BasicBlockRef = Ptr BasicBlock foreign import ccall unsafe "LLVMBasicBlockAsValue" basicBlockAsValue :: BasicBlockRef -> ValueRef foreign import ccall unsafe "LLVMValueIsBasicBlock" valueIsBasicBlock :: ValueRef -> Bool foreign import ccall unsafe "LLVMValueAsBasicBlock" valueAsBasicBlock :: ValueRef -- ^ basic block -> BasicBlockRef foreign import ccall unsafe "LLVMCountBasicBlocks" countBasicBlocks :: ValueRef -- ^ function -> IO CUInt foreign import ccall unsafe "LLVMGetBasicBlocks" getBasicBlocks :: ValueRef -- ^ function -> Ptr BasicBlockRef -- ^ array to fill out -> IO () foreign import ccall unsafe "LLVMGetEntryBasicBlock" getEntryBasicBlock :: ValueRef -- ^ function -> IO BasicBlockRef foreign import ccall unsafe "LLVMAppendBasicBlock" appendBasicBlock :: ValueRef -- ^ function -> CString -- ^ name for label -> IO BasicBlockRef foreign import ccall unsafe "LLVMInsertBasicBlock" insertBasicBlock :: BasicBlockRef -- ^ insert before this one -> CString -- ^ name for label -> IO BasicBlockRef foreign import ccall unsafe "LLVMDeleteBasicBlock" deleteBasicBlock :: BasicBlockRef -> IO () #if HS_LLVM_VERSION < 301 foreign import ccall unsafe "LLVMInstGetOpcode" instGetOpcode :: ValueRef -> IO Int getInstructionOpcode :: ValueRef -> IO Int getInstructionOpcode = instGetOpcode #else foreign import ccall unsafe "LLVMGetInstructionOpcode" getInstructionOpcode :: ValueRef -> IO Int instGetOpcode :: ValueRef -> IO Int instGetOpcode = getInstructionOpcode #endif foreign import ccall unsafe "LLVMCmpInstGetPredicate" cmpInstGetPredicate :: ValueRef -> IO Int data Builder deriving (Typeable) type BuilderRef = Ptr Builder foreign import ccall unsafe "LLVMCreateBuilder" createBuilder :: IO BuilderRef foreign import ccall unsafe "LLVMDisposeBuilder" disposeBuilder :: BuilderRef -> IO () foreign import ccall unsafe "&LLVMDisposeBuilder" ptrDisposeBuilder :: FunPtr (BuilderRef -> IO ()) foreign import ccall unsafe "LLVMPositionBuilderBefore" positionBefore :: BuilderRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMPositionBuilderAtEnd" positionAtEnd :: BuilderRef -> BasicBlockRef -> IO () foreign import ccall unsafe "LLVMBuildRetVoid" buildRetVoid :: BuilderRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildRet" buildRet :: BuilderRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildBr" buildBr :: BuilderRef -> BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildCondBr" buildCondBr :: BuilderRef -> ValueRef -> BasicBlockRef -> BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildSwitch" buildSwitch :: BuilderRef -> ValueRef -> BasicBlockRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMBuildInvoke" buildInvoke :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> BasicBlockRef -> BasicBlockRef -> CString -> IO ValueRef #if HS_LLVM_VERSION < 300 foreign import ccall unsafe "LLVMBuildUnwind" buildUnwind :: BuilderRef -> IO ValueRef #endif foreign import ccall unsafe "LLVMBuildUnreachable" buildUnreachable :: BuilderRef -> IO ValueRef #if HS_LLVM_VERSION >= 300 -- New landing pad instructions for LLVM 3.0 foreign import ccall unsafe "LLVMBuildLandingPad" buildLandingPad :: BuilderRef -> TypeRef -> ValueRef -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMAddClause" addClause :: ValueRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMSetCleanup" setCleanup :: ValueRef -> CUInt -> IO () #endif foreign import ccall unsafe "LLVMBuildAdd" buildAdd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSub" buildSub :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildMul" buildMul :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildUDiv" buildUDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSDiv" buildSDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFDiv" buildFDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildURem" buildURem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSRem" buildSRem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFRem" buildFRem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildShl" buildShl :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildLShr" buildLShr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildAShr" buildAShr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildAnd" buildAnd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildOr" buildOr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildXor" buildXor :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNeg" buildNeg :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNot" buildNot :: BuilderRef -> ValueRef -> CString -> IO ValueRef -- Memory foreign import ccall unsafe "LLVMBuildMalloc" buildMalloc :: BuilderRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildArrayMalloc" buildArrayMalloc :: BuilderRef -> TypeRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildAlloca" buildAlloca :: BuilderRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildArrayAlloca" buildArrayAlloca :: BuilderRef -> TypeRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFree" buildFree :: BuilderRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildLoad" buildLoad :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildStore" buildStore :: BuilderRef -> ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildGEP" buildGEP :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> CString -> IO ValueRef -- Casts foreign import ccall unsafe "LLVMBuildTrunc" buildTrunc :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildZExt" buildZExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSExt" buildSExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFPToUI" buildFPToUI :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFPToSI" buildFPToSI :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildUIToFP" buildUIToFP :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSIToFP" buildSIToFP :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFPTrunc" buildFPTrunc :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFPExt" buildFPExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildPtrToInt" buildPtrToInt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildIntToPtr" buildIntToPtr :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildBitCast" buildBitCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef -- Comparisons data IntPredicate = IntEQ -- ^ equal | IntNE -- ^ not equal | IntUGT -- ^ unsigned greater than | IntUGE -- ^ unsigned greater or equal | IntULT -- ^ unsigned less than | IntULE -- ^ unsigned less or equal | IntSGT -- ^ signed greater than | IntSGE -- ^ signed greater or equal | IntSLT -- ^ signed less than | IntSLE -- ^ signed less or equal deriving (Eq, Ord, Enum, Show, Typeable) fromIntPredicate :: IntPredicate -> CInt fromIntPredicate p = fromIntegral (fromEnum p + 32) toIntPredicate :: Int -> IntPredicate toIntPredicate p = toEnum $ fromIntegral p - 32 data FPPredicate = FPFalse -- ^ Always false (always folded) | FPOEQ -- ^ True if ordered and equal | FPOGT -- ^ True if ordered and greater than | FPOGE -- ^ True if ordered and greater than or equal | FPOLT -- ^ True if ordered and less than | FPOLE -- ^ True if ordered and less than or equal | FPONE -- ^ True if ordered and operands are unequal | FPORD -- ^ True if ordered (no nans) | FPUNO -- ^ True if unordered: isnan(X) | isnan(Y) | FPUEQ -- ^ True if unordered or equal | FPUGT -- ^ True if unordered or greater than | FPUGE -- ^ True if unordered, greater than, or equal | FPULT -- ^ True if unordered or less than | FPULE -- ^ True if unordered, less than, or equal | FPUNE -- ^ True if unordered or not equal | FPT -- ^ Always true (always folded) deriving (Eq, Ord, Enum, Show, Typeable) fromFPPredicate :: FPPredicate -> CInt fromFPPredicate p = fromIntegral (fromEnum p) toFPPredicate :: Int -> FPPredicate toFPPredicate p = toEnum $ fromIntegral p foreign import ccall unsafe "LLVMBuildICmp" buildICmp :: BuilderRef -> CInt -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFCmp" buildFCmp :: BuilderRef -> CInt -> ValueRef -> ValueRef -> CString -> IO ValueRef -- Miscellaneous instructions foreign import ccall unsafe "LLVMBuildPhi" buildPhi :: BuilderRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildCall" buildCall :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSelect" buildSelect :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildVAArg" buildVAArg :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildExtractElement" buildExtractElement :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildInsertElement" buildInsertElement :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildShuffleVector" buildShuffleVector :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMAddCase" addCase :: ValueRef -> ValueRef -> BasicBlockRef -> IO () foreign import ccall unsafe "LLVMCountIncoming" countIncoming :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMAddIncoming" addIncoming :: ValueRef -> Ptr ValueRef -> Ptr ValueRef -> CUInt -> IO () foreign import ccall unsafe "LLVMGetIncomingValue" getIncomingValue :: ValueRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMGetIncomingBlock" getIncomingBlock :: ValueRef -> CUInt -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetInstructionCallConv" getInstructionCallConv :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMSetInstructionCallConv" setInstructionCallConv :: ValueRef -> CUInt -> IO () foreign import ccall unsafe "LLVMStructType" structType :: Ptr TypeRef -> CUInt -> Bool -> TypeRef foreign import ccall unsafe "LLVMCountStructElementTypes" countStructElementTypes :: TypeRef -> CUInt foreign import ccall unsafe "LLVMGetStructElementTypes" getStructElementTypes :: TypeRef -> Ptr TypeRef -> IO () foreign import ccall unsafe "LLVMIsPackedStruct" isPackedStruct :: TypeRef -> Bool data MemoryBuffer deriving (Typeable) type MemoryBufferRef = Ptr MemoryBuffer #if HS_LLVM_VERSION < 300 data TypeHandle deriving (Typeable) type TypeHandleRef = Ptr TypeHandle #endif data TypeKind = VoidTypeKind | HalfTypeKind | FloatTypeKind | DoubleTypeKind | X86_FP80TypeKind | FP128TypeKind | PPC_FP128TypeKind | LabelTypeKind | IntegerTypeKind | FunctionTypeKind | StructTypeKind | ArrayTypeKind | PointerTypeKind | VectorTypeKind | MetadataTypeKind | X86_MMXTypeKind deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable) getTypeKind :: TypeRef -> IO TypeKind getTypeKind = fmap (toEnum . fromIntegral) . getTypeKindCUInt foreign import ccall unsafe "LLVMCreateMemoryBufferWithContentsOfFile" createMemoryBufferWithContentsOfFile :: CString -> Ptr MemoryBufferRef -> Ptr CString -> IO Bool foreign import ccall unsafe "LLVMCreateMemoryBufferWithSTDIN" createMemoryBufferWithSTDIN :: Ptr MemoryBufferRef -> Ptr CString -> IO Bool foreign import ccall unsafe "LLVMCreateMemoryBufferWithMemoryRange" createMemoryBufferWithMemoryRange :: Ptr a -> CSize -> CString -> Bool -> IO MemoryBufferRef foreign import ccall unsafe "LLVMCreateMemoryBufferWithMemoryRangeCopy" createMemoryBufferWithMemoryRangeCopy :: Ptr a -> CSize -> CString -> IO MemoryBufferRef foreign import ccall unsafe "LLVMDisposeMemoryBuffer" disposeMemoryBuffer :: MemoryBufferRef -> IO () foreign import ccall unsafe "&LLVMDisposeMemoryBuffer" ptrDisposeMemoryBuffer :: FunPtr (MemoryBufferRef -> IO ()) foreign import ccall unsafe "LLVMDisposeMessage" disposeMessage :: CString -> IO () foreign import ccall unsafe "LLVMGetArrayLength" getArrayLength :: TypeRef -> IO CUInt foreign import ccall unsafe "LLVMGetIntTypeWidth" getIntTypeWidth :: TypeRef -> IO CUInt foreign import ccall unsafe "LLVMGetPointerAddressSpace" getPointerAddressSpace :: TypeRef -> IO CUInt foreign import ccall unsafe "LLVMGetTarget" getTarget :: ModuleRef -> IO CString foreign import ccall unsafe "LLVMGetTypeKind" getTypeKindCUInt :: TypeRef -> IO CUInt foreign import ccall unsafe "LLVMGetVectorSize" getVectorSize :: TypeRef -> IO CUInt foreign import ccall unsafe "LLVMSetTarget" setTarget :: ModuleRef -> CString -> IO () foreign import ccall unsafe "LLVMSizeOf" sizeOf :: TypeRef -> IO ValueRef #if HS_LLVM_VERSION < 300 foreign import ccall unsafe "LLVMCreateTypeHandle" createTypeHandle :: TypeRef -> IO TypeHandleRef foreign import ccall unsafe "LLVMDisposeTypeHandle" disposeTypeHandle :: TypeHandleRef -> IO () foreign import ccall unsafe "LLVMRefineType" refineType :: TypeRef -> TypeRef -> IO () foreign import ccall unsafe "LLVMResolveTypeHandle" resolveTypeHandle :: TypeHandleRef -> IO TypeRef #else foreign import ccall unsafe "LLVMStructCreateNamed" structCreateNamed :: ContextRef -> CString -> IO TypeRef foreign import ccall unsafe "LLVMGetStructName" getStructName :: TypeRef -> IO CString foreign import ccall unsafe "LLVMStructSetBody" structSetBody :: TypeRef -> Ptr TypeRef -> CUInt -> Bool -> IO () #endif data Attribute = ZExtAttribute | SExtAttribute | NoReturnAttribute | InRegAttribute | StructRetAttribute | NoUnwindAttribute | NoAliasAttribute | ByValAttribute | NestAttribute | ReadNoneAttribute | ReadOnlyAttribute | NoInlineAttribute | AlwaysInlineAttribute | OptimizeForSizeAttribute | StackProtectAttribute | StackProtectReqAttribute | NoCaptureAttribute | NoRedZoneAttribute | NoImplicitFloatAttribute | NakedAttribute deriving (Show, Eq, Ord, Enum, Bounded, Typeable) fromAttribute :: Attribute -> CAttribute fromAttribute ZExtAttribute = (#const LLVMZExtAttribute) fromAttribute SExtAttribute = (#const LLVMSExtAttribute) fromAttribute NoReturnAttribute = (#const LLVMNoReturnAttribute) fromAttribute InRegAttribute = (#const LLVMInRegAttribute) fromAttribute StructRetAttribute = (#const LLVMStructRetAttribute) fromAttribute NoUnwindAttribute = (#const LLVMNoUnwindAttribute) fromAttribute NoAliasAttribute = (#const LLVMNoAliasAttribute) fromAttribute ByValAttribute = (#const LLVMByValAttribute) fromAttribute NestAttribute = (#const LLVMNestAttribute) fromAttribute ReadNoneAttribute = (#const LLVMReadNoneAttribute) fromAttribute ReadOnlyAttribute = (#const LLVMReadOnlyAttribute) fromAttribute NoInlineAttribute = (#const LLVMNoInlineAttribute) fromAttribute AlwaysInlineAttribute = (#const LLVMAlwaysInlineAttribute) fromAttribute OptimizeForSizeAttribute = (#const LLVMOptimizeForSizeAttribute) fromAttribute StackProtectAttribute = (#const LLVMStackProtectAttribute) fromAttribute StackProtectReqAttribute = (#const LLVMStackProtectReqAttribute) fromAttribute NoCaptureAttribute = (#const LLVMNoCaptureAttribute) fromAttribute NoRedZoneAttribute = (#const LLVMNoRedZoneAttribute) fromAttribute NoImplicitFloatAttribute = (#const LLVMNoImplicitFloatAttribute) fromAttribute NakedAttribute = (#const LLVMNakedAttribute) toAttribute :: CAttribute -> Attribute toAttribute c | c == (#const LLVMZExtAttribute) = ZExtAttribute toAttribute c | c == (#const LLVMSExtAttribute) = SExtAttribute toAttribute c | c == (#const LLVMNoReturnAttribute) = NoReturnAttribute toAttribute c | c == (#const LLVMInRegAttribute) = InRegAttribute toAttribute c | c == (#const LLVMStructRetAttribute) = StructRetAttribute toAttribute c | c == (#const LLVMNoUnwindAttribute) = NoUnwindAttribute toAttribute c | c == (#const LLVMNoAliasAttribute) = NoAliasAttribute toAttribute c | c == (#const LLVMByValAttribute) = ByValAttribute toAttribute c | c == (#const LLVMNestAttribute) = NestAttribute toAttribute c | c == (#const LLVMReadNoneAttribute) = ReadNoneAttribute toAttribute c | c == (#const LLVMReadOnlyAttribute) = ReadOnlyAttribute toAttribute c | c == (#const LLVMNoInlineAttribute) = NoInlineAttribute toAttribute c | c == (#const LLVMAlwaysInlineAttribute) = AlwaysInlineAttribute toAttribute c | c == (#const LLVMOptimizeForSizeAttribute) = OptimizeForSizeAttribute toAttribute c | c == (#const LLVMStackProtectAttribute) = StackProtectAttribute toAttribute c | c == (#const LLVMStackProtectReqAttribute) = StackProtectReqAttribute toAttribute c | c == (#const LLVMNoCaptureAttribute) = NoCaptureAttribute toAttribute c | c == (#const LLVMNoRedZoneAttribute) = NoRedZoneAttribute toAttribute c | c == (#const LLVMNoImplicitFloatAttribute) = NoImplicitFloatAttribute toAttribute c | c == (#const LLVMNakedAttribute) = NakedAttribute toAttribute _ = error "toAttribute: bad value" type CAttribute = CInt data PassManager deriving (Typeable) type PassManagerRef = Ptr PassManager data OpaqueUse deriving (Typeable) type UseRef = Ptr OpaqueUse foreign import ccall unsafe "LLVMConstRealOfString" constRealOfString :: TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMCreateFunctionPassManager" createFunctionPassManager :: ModuleProviderRef -> IO PassManagerRef foreign import ccall unsafe "LLVMCreatePassManager" createPassManager :: IO PassManagerRef foreign import ccall unsafe "LLVMDisposePassManager" disposePassManager :: PassManagerRef -> IO () foreign import ccall unsafe "&LLVMDisposePassManager" ptrDisposePassManager :: FunPtr (PassManagerRef -> IO ()) foreign import ccall unsafe "LLVMDumpModule" dumpModule :: ModuleRef -> IO () foreign import ccall unsafe "LLVMDumpModuleToString" dumpModuleToString :: ModuleRef -> IO CString foreign import ccall unsafe "LLVMDumpTypeToString" dumpTypeToString :: TypeRef -> IO CString foreign import ccall unsafe "LLVMDumpValueToString" dumpValueToString :: ValueRef -> IO CString foreign import ccall unsafe "LLVMPrintModuleToFile" printModuleToFile :: ModuleRef -> CString -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMFinalizeFunctionPassManager" finalizeFunctionPassManager :: PassManagerRef -> IO Bool foreign import ccall unsafe "LLVMGetBasicBlockParent" getBasicBlockParent :: BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMGetFirstBasicBlock" getFirstBasicBlock :: ValueRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetFirstFunction" getFirstFunction :: ModuleRef -> IO ValueRef foreign import ccall unsafe "LLVMGetFirstGlobal" getFirstGlobal :: ModuleRef -> IO ValueRef foreign import ccall unsafe "LLVMGetFirstInstruction" getFirstInstruction :: BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMGetFirstParam" getFirstParam :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetGlobalParent" getGlobalParent :: ValueRef -> IO ModuleRef foreign import ccall unsafe "LLVMGetInsertBlock" getInsertBlock :: BuilderRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetInstructionParent" getInstructionParent :: ValueRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetLastBasicBlock" getLastBasicBlock :: ValueRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetLastFunction" getLastFunction :: ModuleRef -> IO ValueRef foreign import ccall unsafe "LLVMGetLastGlobal" getLastGlobal :: ModuleRef -> IO ValueRef foreign import ccall unsafe "LLVMGetLastInstruction" getLastInstruction :: BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMGetLastParam" getLastParam :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetNextBasicBlock" getNextBasicBlock :: BasicBlockRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetNextFunction" getNextFunction :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetNextGlobal" getNextGlobal :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetNextInstruction" getNextInstruction :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetNextParam" getNextParam :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetParamParent" getParamParent :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetPreviousBasicBlock" getPreviousBasicBlock :: BasicBlockRef -> IO BasicBlockRef foreign import ccall unsafe "LLVMGetPreviousFunction" getPreviousFunction :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetPreviousGlobal" getPreviousGlobal :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetPreviousInstruction" getPreviousInstruction :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMGetPreviousParam" getPreviousParam :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMInitializeFunctionPassManager" initializeFunctionPassManager :: PassManagerRef -> IO Bool foreign import ccall unsafe "LLVMLabelType" labelType :: TypeRef foreign import ccall unsafe "LLVMPositionBuilder" positionBuilder :: BuilderRef -> BasicBlockRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMRunFunctionPassManager" runFunctionPassManager :: PassManagerRef -> ValueRef -> IO Bool foreign import ccall unsafe "LLVMRunPassManager" runPassManager :: PassManagerRef -> ModuleRef -> IO Bool foreign import ccall unsafe "LLVMSetInstrParamAlignment" setInstrParamAlignment :: ValueRef -> CUInt -> CUInt -> IO () foreign import ccall unsafe "LLVMSetParamAlignment" setParamAlignment :: ValueRef -> CUInt -> IO () #if HS_LLVM_VERSION < 300 foreign import ccall unsafe "LLVMOpaqueType" opaqueType :: TypeRef foreign import ccall unsafe "LLVMOpaqueTypeInContext" opaqueTypeInContext :: ContextRef -> IO TypeRef #endif data Context deriving (Typeable) type ContextRef = Ptr Context foreign import ccall unsafe "LLVMAddAttribute" addAttribute :: ValueRef -> CAttribute -> IO () foreign import ccall unsafe "LLVMAddInstrAttribute" addInstrAttribute :: ValueRef -> CUInt -> CAttribute -> IO () foreign import ccall unsafe "LLVMIsTailCall" isTailCall :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMRemoveAttribute" removeAttribute :: ValueRef -> CAttribute -> IO () foreign import ccall unsafe "LLVMRemoveInstrAttribute" removeInstrAttribute :: ValueRef -> CUInt -> CAttribute -> IO () foreign import ccall unsafe "LLVMSetTailCall" setTailCall :: ValueRef -> Bool -> IO () foreign import ccall unsafe "LLVMAddFunctionAttr" addFunctionAttr :: ValueRef -> CAttribute -> IO () foreign import ccall unsafe "LLVMAlignOf" alignOf :: TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMAppendBasicBlockInContext" appendBasicBlockInContext :: ContextRef -> ValueRef -> CString -> IO BasicBlockRef foreign import ccall unsafe "LLVMBuildAggregateRet" buildAggregateRet :: BuilderRef -> (Ptr ValueRef) -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMBuildExactSDiv" buildExactSDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFAdd" buildFAdd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFMul" buildFMul :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFPCast" buildFPCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFSub" buildFSub :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildFNeg" buildFNeg :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildGlobalString" buildGlobalString :: BuilderRef -> CString -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildGlobalStringPtr" buildGlobalStringPtr :: BuilderRef -> CString -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildInBoundsGEP" buildInBoundsGEP :: BuilderRef -> ValueRef -> (Ptr ValueRef) -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildIsNotNull" buildIsNotNull :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildIsNull" buildIsNull :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNSWAdd" buildNSWAdd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildPointerCast" buildPointerCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildPtrDiff" buildPtrDiff :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildSExtOrBitCast" buildSExtOrBitCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildStructGEP" buildStructGEP :: BuilderRef -> ValueRef -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildTruncOrBitCast" buildTruncOrBitCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildZExtOrBitCast" buildZExtOrBitCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMConstExactSDiv" constExactSDiv :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstFAdd" constFAdd :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFMul" constFMul :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFNeg" constFNeg :: ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstFPCast" constFPCast :: ValueRef -> TypeRef -> ValueRef foreign import ccall unsafe "LLVMConstFSub" constFSub :: ValueRef -> ValueRef -> ValueRef foreign import ccall unsafe "LLVMConstInBoundsGEP" constInBoundsGEP :: ValueRef -> (Ptr ValueRef) -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstIntCast" constIntCast :: ValueRef -> TypeRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstIntOfString" constIntOfString :: TypeRef -> CString -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstIntOfStringAndSize" constIntOfStringAndSize :: TypeRef -> CString -> CUInt -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstNSWAdd" constNSWAdd :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstPointerCast" constPointerCast :: ValueRef -> TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMConstPointerNull" constPointerNull :: TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMConstRealOfStringAndSize" constRealOfStringAndSize :: TypeRef -> CString -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstSExtOrBitCast" constSExtOrBitCast :: ValueRef -> TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMConstStringInContext" constStringInContext :: ContextRef -> CString -> CUInt -> Bool -> IO ValueRef foreign import ccall unsafe "LLVMConstStructInContext" constStructInContext :: ContextRef -> (Ptr ValueRef) -> CUInt -> Bool -> IO ValueRef foreign import ccall unsafe "LLVMConstTruncOrBitCast" constTruncOrBitCast :: ValueRef -> TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMConstZExtOrBitCast" constZExtOrBitCast :: ValueRef -> TypeRef -> IO ValueRef foreign import ccall unsafe "LLVMContextDispose" contextDispose :: ContextRef -> IO () foreign import ccall unsafe "&LLVMContextDispose" ptrContextDispose :: FunPtr (ContextRef -> IO ()) foreign import ccall unsafe "LLVMCreateBuilderInContext" createBuilderInContext :: ContextRef -> IO BuilderRef foreign import ccall unsafe "LLVMDoubleTypeInContext" doubleTypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMFP128TypeInContext" fP128TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMFloatTypeInContext" floatTypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMGetTypeByName" getTypeByName :: ModuleRef -> CString -> IO TypeRef foreign import ccall unsafe "LLVMGetNamedMetadataNumOperands" getNamedMetadataNumOperands :: ModuleRef -> CString -> IO CUInt foreign import ccall unsafe "LLVMGetNamedMetadataOperands" getNamedMetadataOperands :: ModuleRef -> CString -> (Ptr ValueRef) -> IO () foreign import ccall unsafe "LLVMAddNamedMetadataOperand" addNamedMetadataOperand :: ModuleRef -> CString -> ValueRef -> IO () foreign import ccall unsafe "LLVMGetTypeContext" getTypeContext :: TypeRef -> IO ContextRef foreign import ccall unsafe "LLVMInsertBasicBlockInContext" insertBasicBlockInContext :: ContextRef -> BasicBlockRef -> CString -> IO BasicBlockRef foreign import ccall unsafe "LLVMInsertIntoBuilderWithName" insertIntoBuilderWithName :: BuilderRef -> ValueRef -> CString -> IO () foreign import ccall unsafe "LLVMInt16TypeInContext" int16TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMInt1TypeInContext" int1TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMInt32TypeInContext" int32TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMInt64TypeInContext" int64TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMInt8TypeInContext" int8TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMIntTypeInContext" intTypeInContext :: ContextRef -> CUInt -> IO TypeRef foreign import ccall unsafe "LLVMLabelTypeInContext" labelTypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMModuleCreateWithNameInContext" moduleCreateWithNameInContext :: CString -> ContextRef -> IO ModuleRef foreign import ccall unsafe "LLVMPPCFP128TypeInContext" pPCFP128TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMRemoveFunctionAttr" removeFunctionAttr :: ValueRef -> CAttribute -> IO () foreign import ccall unsafe "LLVMStructTypeInContext" structTypeInContext :: ContextRef -> (Ptr TypeRef) -> CUInt -> Bool -> IO TypeRef foreign import ccall unsafe "LLVMVoidTypeInContext" voidTypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMX86FP80TypeInContext" x86FP80TypeInContext :: ContextRef -> IO TypeRef foreign import ccall unsafe "LLVMAddAlias" addAlias :: ModuleRef -> TypeRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMAddDestination" addDestination :: ValueRef -> BasicBlockRef -> IO () foreign import ccall unsafe "LLVMAddGlobalInAddressSpace" addGlobalInAddressSpace :: ModuleRef -> TypeRef -> CString -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMBlockAddress" blockAddress :: ValueRef -> BasicBlockRef -> IO ValueRef foreign import ccall unsafe "LLVMBuildBinOp" buildBinOp :: BuilderRef -> CUInt{-Opcode-} -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildCast" buildCast :: BuilderRef -> CUInt{-Opcode-} -> ValueRef -> TypeRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildExtractValue" buildExtractValue :: BuilderRef -> ValueRef -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildIndirectBr" buildIndirectBr :: BuilderRef -> ValueRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMBuildInsertValue" buildInsertValue :: BuilderRef -> ValueRef -> ValueRef -> CUInt -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNSWMul" buildNSWMul :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNSWNeg" buildNSWNeg :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNSWSub" buildNSWSub :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNUWAdd" buildNUWAdd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNUWMul" buildNUWMul :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNUWNeg" buildNUWNeg :: BuilderRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMBuildNUWSub" buildNUWSub :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef foreign import ccall unsafe "LLVMClearInsertionPosition" clearInsertionPosition :: BuilderRef -> IO () foreign import ccall unsafe "LLVMConstExtractValue" constExtractValue :: ValueRef -> Ptr CUInt -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstInlineAsm" constInlineAsm :: TypeRef -> CString -> CString -> Bool -> Bool -> IO ValueRef foreign import ccall unsafe "LLVMConstInsertValue" constInsertValue :: ValueRef -> ValueRef -> Ptr CUInt -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMConstIntGetSExtValue" constIntGetSExtValue :: ValueRef -> IO CLLong foreign import ccall unsafe "LLVMConstIntGetZExtValue" constIntGetZExtValue :: ValueRef -> IO CULLong foreign import ccall unsafe "LLVMConstNSWMul" constNSWMul :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNSWNeg" constNSWNeg :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNSWSub" constNSWSub :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNUWAdd" constNUWAdd :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNUWMul" constNUWMul :: ValueRef -> ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNUWNeg" constNUWNeg :: ValueRef -> IO ValueRef foreign import ccall unsafe "LLVMConstNUWSub" constNUWSub :: ValueRef -> ValueRef -> IO ValueRef {- foreign import ccall unsafe "LLVMConstUnion" constUnion :: TypeRef -> ValueRef -> IO ValueRef -} foreign import ccall unsafe "LLVMContextCreate" contextCreate :: IO ContextRef {- foreign import ccall unsafe "LLVMCountUnionElementTypes" countUnionElementTypes :: TypeRef -> IO CUInt -} foreign import ccall unsafe "LLVMCreateFunctionPassManagerForModule" createFunctionPassManagerForModule :: ModuleRef -> IO PassManagerRef foreign import ccall unsafe "LLVMGetAttribute" getAttribute :: ValueRef -> IO CUInt{-Attribute-} foreign import ccall unsafe "LLVMGetConstOpcode" getConstOpcode :: ValueRef -> IO CUInt {-Opcode-} foreign import ccall unsafe "LLVMGetCurrentDebugLocation" getCurrentDebugLocation :: BuilderRef -> IO ValueRef foreign import ccall unsafe "LLVMGetFirstUse" getFirstUse :: ValueRef -> IO UseRef foreign import ccall unsafe "LLVMGetFunctionAttr" getFunctionAttr :: ValueRef -> IO CUInt {-Attribute-} foreign import ccall unsafe "LLVMGetGlobalContext" getGlobalContext :: IO ContextRef foreign import ccall unsafe "LLVMGetMDKindID" getMDKindID :: CString -> CUInt -> IO CUInt foreign import ccall unsafe "LLVMGetMDKindIDInContext" getMDKindIDInContext :: ContextRef -> CString -> CUInt -> IO CUInt foreign import ccall unsafe "LLVMGetMetadata" getMetadata :: ValueRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMGetNextUse" getNextUse :: UseRef -> IO UseRef foreign import ccall unsafe "LLVMGetOperand" getOperand :: ValueRef -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMGetNumOperands" getNumOperands :: ValueRef -> IO CUInt {- foreign import ccall unsafe "LLVMGetUnionElementTypes" getUnionElementTypes :: TypeRef -> (Ptr TypeRef) -> IO () -} foreign import ccall unsafe "LLVMValueIsUsedInBasicBlock" isUsedInBasicBlock :: BasicBlockRef -> ValueRef -> IO Bool foreign import ccall unsafe "LLVMValueGetNumUses" getNumUses :: ValueRef -> IO CUInt foreign import ccall unsafe "LLVMGetUsedValue" getUsedValue :: UseRef -> IO ValueRef foreign import ccall unsafe "LLVMGetUser" getUser :: UseRef -> IO ValueRef foreign import ccall unsafe "LLVMHasMetadata" hasMetadata :: ValueRef -> IO Bool foreign import ccall unsafe "LLVMInsertIntoBuilder" insertIntoBuilder :: BuilderRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMMDNode" mdNode :: (Ptr ValueRef) -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMMDNodeInContext" mdNodeInContext :: ContextRef -> (Ptr ValueRef) -> CUInt -> IO ValueRef foreign import ccall unsafe "LLVMMDString" mdString :: CString -> CUInt -> ValueRef foreign import ccall unsafe "LLVMMDStringInContext" mdStringInContext :: ContextRef -> CString -> CUInt -> ValueRef foreign import ccall unsafe "LLVMReplaceAllUsesWith" replaceAllUsesWith :: ValueRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMSetCurrentDebugLocation" setCurrentDebugLocation :: BuilderRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMSetInstDebugLocation" setInstDebugLocation :: BuilderRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMSetMetadata" setMetadata :: ValueRef -> CUInt -> ValueRef -> IO () data MetadataKind = Dbg | TBAA | Prof | FPMath | Range | TBAAStruct deriving (Show, Eq, Enum) toMetadataKind :: CUInt -> MetadataKind toMetadataKind c = toEnum $ fromIntegral c fromMetadataKind :: MetadataKind -> CUInt fromMetadataKind k = fromIntegral $ fromEnum k debugVersion :: (Integral a) => a debugVersion = 786432 -- 12 << 16 {- foreign import ccall unsafe "LLVMUnionType" unionType :: (Ptr TypeRef) -> CUInt -> IO TypeRef foreign import ccall unsafe "LLVMUnionTypeInContext" unionTypeInContext :: ContextRef -> (Ptr TypeRef) -> CUInt -> IO TypeRef -} llvm-base-3.2.0.0/LLVM/FFI/BitWriter.hsc0000644000000000000000000000114112142503271015504 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.BitWriter where import Foreign.C.String(CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types(CInt(..)) #else import Foreign.C.Types(CInt) #endif import LLVM.FFI.Core foreign import ccall unsafe "LLVMWriteBitcodeToFile" writeBitcodeToFile :: ModuleRef -> CString -> IO Bool foreign import ccall unsafe "LLVMWriteBitcodeToFileHandle" writeBitcodeToFileHandle :: ModuleRef -> CInt -> IO Bool foreign import ccall unsafe "LLVMWriteBitcodeToFD" writeBitcodeToFD :: ModuleRef -> CInt -> Bool -> Bool -> IO Bool llvm-base-3.2.0.0/LLVM/FFI/Linker.hsc0000644000000000000000000000154512142503271015025 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface #-} module LLVM.FFI.Linker where import LLVM.FFI.Core import Foreign.C.String(CString) import Foreign.C.Types(CUInt(..)) import Foreign.Ptr(Ptr) #include data LinkerMode = DestroySource | PreserveSource deriving (Show, Eq) fromLinkerMode :: LinkerMode -> CUInt fromLinkerMode DestroySource = (#const LLVMLinkerDestroySource) fromLinkerMode PreserveSource = (#const LLVMLinkerDestroySource) toLinkerMode :: CUInt -> LinkerMode toLinkerMode c | c == (#const LLVMLinkerDestroySource) = DestroySource toLinkerMode c | c == (#const LLVMLinkerPreserveSource) = PreserveSource toLinkerMode c = error $ "LLVM.FFI.Linker.toLinkerMode: unrecognized linker mode" ++ show c foreign import ccall unsafe "LLVMLinkModules" linkModules :: ModuleRef -> ModuleRef -> CUInt -> Ptr CString -> IO Boolllvm-base-3.2.0.0/LLVM/FFI/Analysis.hsc0000644000000000000000000000136012142503271015357 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.Analysis where import Foreign.C.String(CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types(CInt(..)) #else import Foreign.C.Types(CInt) #endif import Foreign.Ptr(Ptr) import LLVM.FFI.Core type VerifierFailureAction = CInt foreign import ccall unsafe "LLVMVerifyFunction" verifyFunction :: ValueRef -> VerifierFailureAction -> IO Bool foreign import ccall unsafe "LLVMVerifyModule" verifyModule :: ModuleRef -> VerifierFailureAction -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMViewFunctionCFG" viewFunctionCFG :: ValueRef -> IO () foreign import ccall unsafe "LLVMViewFunctionCFGOnly" viewFunctionCFGOnly :: ValueRef -> IO () llvm-base-3.2.0.0/LLVM/FFI/Target.hsc0000644000000000000000000000456412142503271015033 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls, DeriveDataTypeable #-} module LLVM.FFI.Target where import Data.Typeable import Foreign.C.String (CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types (CInt(..), CUInt(..), CULLong(..)) #else import Foreign.C.Types (CInt, CUInt, CULLong) #endif import Foreign.Ptr (Ptr) import LLVM.FFI.Core -- enum { LLVMBigEndian, LLVMLittleEndian }; type ByteOrdering = CInt data TargetData deriving (Typeable) type TargetDataRef = Ptr TargetData foreign import ccall unsafe "LLVMABIAlignmentOfType" aBIAlignmentOfType :: TargetDataRef -> TypeRef -> CUInt foreign import ccall unsafe "LLVMABISizeOfType" aBISizeOfType :: TargetDataRef -> TypeRef -> CULLong foreign import ccall unsafe "LLVMAddTargetData" addTargetData :: TargetDataRef -> PassManagerRef -> IO () foreign import ccall unsafe "LLVMByteOrder" byteOrder :: TargetDataRef -> ByteOrdering foreign import ccall unsafe "LLVMCallFrameAlignmentOfType" callFrameAlignmentOfType :: TargetDataRef -> TypeRef -> CUInt foreign import ccall unsafe "LLVMCopyStringRepOfTargetData" copyStringRepOfTargetData :: TargetDataRef -> IO CString foreign import ccall unsafe "LLVMCreateTargetData" createTargetData :: CString -> IO TargetDataRef foreign import ccall unsafe "LLVMDisposeTargetData" disposeTargetData :: TargetDataRef -> IO () foreign import ccall unsafe "LLVMElementAtOffset" elementAtOffset :: TargetDataRef -> TypeRef -> CULLong -> CUInt foreign import ccall unsafe "LLVMIntPtrType" intPtrType :: TargetDataRef -> TypeRef -- Removed in LLVM_3.0 ? -- foreign import ccall unsafe "LLVMInvalidateStructLayout" invalidateStructLayout -- :: TargetDataRef -> TypeRef -> IO () foreign import ccall unsafe "LLVMOffsetOfElement" offsetOfElement :: TargetDataRef -> TypeRef -> CUInt -> CULLong foreign import ccall unsafe "LLVMPointerSize" pointerSize :: TargetDataRef -> CUInt foreign import ccall unsafe "LLVMPreferredAlignmentOfGlobal" preferredAlignmentOfGlobal :: TargetDataRef -> ValueRef -> CUInt foreign import ccall unsafe "LLVMPreferredAlignmentOfType" preferredAlignmentOfType :: TargetDataRef -> TypeRef -> CUInt foreign import ccall unsafe "LLVMSizeOfTypeInBits" sizeOfTypeInBits :: TargetDataRef -> TypeRef -> CULLong foreign import ccall unsafe "LLVMStoreSizeOfType" storeSizeOfType :: TargetDataRef -> TypeRef -> CULLong llvm-base-3.2.0.0/LLVM/FFI/ExecutionEngine.hsc0000644000000000000000000001414412142503271016671 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls, DeriveDataTypeable #-} module LLVM.FFI.ExecutionEngine ( -- * Execution engines ExecutionEngine , createExecutionEngine , ptrDisposeExecutionEngine , createInterpreter , createJITCompiler , addModuleProvider , removeModuleProvider , findFunction , freeMachineCodeForFunction , runStaticConstructors , runStaticDestructors , runFunction , runFunctionAsMain , getExecutionEngineTargetData , addGlobalMapping , getPointerToGlobal , addModule , createExecutionEngineForModule , createInterpreterForModule , createJITCompilerForModule , disposeExecutionEngine , removeModule -- * Generic values , GenericValue , GenericValueRef , createGenericValueOfInt , genericValueToInt , genericValueIntWidth , createGenericValueOfFloat , genericValueToFloat , createGenericValueOfPointer , genericValueToPointer , ptrDisposeGenericValue -- * Linking -- , linkInInterpreter , linkInJIT ) where import Data.Typeable import Foreign.C.String (CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types (CDouble(..), CInt(..), CUInt(..), CULLong(..)) #else import Foreign.C.Types (CDouble, CInt, CUInt, CULLong) #endif import Foreign.Ptr (Ptr, FunPtr) import LLVM.FFI.Core (ModuleRef, ModuleProviderRef, TypeRef, ValueRef) import LLVM.FFI.Target(TargetDataRef) data ExecutionEngine deriving (Typeable) type ExecutionEngineRef = Ptr ExecutionEngine foreign import ccall unsafe "LLVMCreateExecutionEngine" createExecutionEngine :: Ptr ExecutionEngineRef -> ModuleProviderRef -> Ptr CString -> IO CInt foreign import ccall unsafe "&LLVMDisposeExecutionEngine" ptrDisposeExecutionEngine :: FunPtr (ExecutionEngineRef -> IO ()) foreign import ccall unsafe "LLVMRunStaticConstructors" runStaticConstructors :: ExecutionEngineRef -> IO () foreign import ccall unsafe "LLVMRunStaticDestructors" runStaticDestructors :: ExecutionEngineRef -> IO () data GenericValue deriving (Typeable) type GenericValueRef = Ptr GenericValue foreign import ccall unsafe "LLVMCreateGenericValueOfInt" createGenericValueOfInt :: TypeRef -> CULLong -> CInt -> IO GenericValueRef foreign import ccall unsafe "LLVMGenericValueToInt" genericValueToInt :: GenericValueRef -> CInt -> CULLong foreign import ccall unsafe "LLVMCreateGenericValueOfFloat" createGenericValueOfFloat :: TypeRef -> CDouble -> IO GenericValueRef foreign import ccall unsafe "LLVMGenericValueToFloat" genericValueToFloat :: TypeRef -> GenericValueRef -> CDouble foreign import ccall unsafe "&LLVMDisposeGenericValue" ptrDisposeGenericValue :: FunPtr (GenericValueRef -> IO ()) {- safe call is important, since the running LLVM code may call back into Haskell code See http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3 says: "Optionally, an import declaration can specify, after the calling convention, the safety level that should be used when invoking an external entity. ..." -} foreign import ccall safe "LLVMRunFunction" runFunction :: ExecutionEngineRef -> ValueRef -> CUInt -> Ptr GenericValueRef -> IO GenericValueRef foreign import ccall unsafe "LLVMAddModuleProvider" addModuleProvider :: ExecutionEngineRef -> ModuleProviderRef -> IO () foreign import ccall unsafe "LLVMCreateGenericValueOfPointer" createGenericValueOfPointer :: Ptr a -> IO GenericValueRef foreign import ccall unsafe "LLVMCreateInterpreter" createInterpreter :: Ptr ExecutionEngineRef -> ModuleProviderRef -> Ptr CString -> IO CInt foreign import ccall unsafe "LLVMCreateJITCompiler" createJITCompiler :: Ptr ExecutionEngineRef -> ModuleProviderRef -> CUInt -> Ptr CString -> IO CInt foreign import ccall unsafe "LLVMFindFunction" findFunction :: ExecutionEngineRef -> CString -> Ptr ValueRef -> IO CInt foreign import ccall unsafe "LLVMFreeMachineCodeForFunction" freeMachineCodeForFunction :: ExecutionEngineRef -> ValueRef -> IO () foreign import ccall unsafe "LLVMGenericValueIntWidth" genericValueIntWidth :: GenericValueRef -> IO CUInt foreign import ccall unsafe "LLVMGenericValueToPointer" genericValueToPointer :: GenericValueRef -> IO (Ptr a) foreign import ccall unsafe "LLVMRemoveModuleProvider" removeModuleProvider :: ExecutionEngineRef -> ModuleProviderRef -> Ptr ModuleRef -> Ptr CString -> IO CInt foreign import ccall safe "LLVMRunFunctionAsMain" runFunctionAsMain :: ExecutionEngineRef -> ValueRef -> CUInt -> Ptr CString -- ^ argv -> Ptr CString -- ^ envp -> IO CInt foreign import ccall unsafe "LLVMGetExecutionEngineTargetData" getExecutionEngineTargetData :: ExecutionEngineRef -> IO TargetDataRef foreign import ccall unsafe "LLVMAddGlobalMapping" addGlobalMapping :: ExecutionEngineRef -> ValueRef -> Ptr () -> IO () foreign import ccall unsafe "LLVMGetPointerToGlobal" getPointerToGlobal :: ExecutionEngineRef -> ValueRef -> IO (FunPtr a) {- foreign import ccall unsafe "LLVMLinkInInterpreter" linkInInterpreter :: IO () -} foreign import ccall unsafe "LLVMLinkInJIT" linkInJIT :: IO () foreign import ccall unsafe "LLVMAddModule" addModule :: ExecutionEngineRef -> ModuleRef -> IO () foreign import ccall unsafe "LLVMCreateExecutionEngineForModule" createExecutionEngineForModule :: (Ptr ExecutionEngineRef) -> ModuleRef -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMCreateInterpreterForModule" createInterpreterForModule :: (Ptr ExecutionEngineRef) -> ModuleRef -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMCreateJITCompilerForModule" createJITCompilerForModule :: (Ptr ExecutionEngineRef) -> ModuleRef -> CUInt -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMDisposeExecutionEngine" disposeExecutionEngine :: ExecutionEngineRef -> IO () {- foreign import ccall unsafe "LLVMDisposeGenericValue" disposeGenericValue :: GenericValueRef -> IO () -} foreign import ccall unsafe "LLVMRemoveModule" removeModule :: ExecutionEngineRef -> ModuleRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO Bool llvm-base-3.2.0.0/LLVM/FFI/BitReader.hsc0000644000000000000000000000232612142503271015440 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.BitReader where import Foreign.C.String(CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types(CInt(..)) #else import Foreign.C.Types(CInt) #endif import Foreign.Ptr(Ptr) import LLVM.FFI.Core foreign import ccall unsafe "LLVMGetBitcodeModuleProvider" getBitcodeModuleProvider :: MemoryBufferRef -> (Ptr ModuleProviderRef) -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMParseBitcode" parseBitcode :: MemoryBufferRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMGetBitcodeModuleProviderInContext" getBitcodeModuleProviderInContext :: ContextRef -> MemoryBufferRef -> (Ptr ModuleProviderRef) -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMParseBitcodeInContext" parseBitcodeInContext :: ContextRef -> MemoryBufferRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMGetBitcodeModule" getBitcodeModule :: MemoryBufferRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO Bool foreign import ccall unsafe "LLVMGetBitcodeModuleInContext" getBitcodeModuleInContext :: ContextRef -> MemoryBufferRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO Bool llvm-base-3.2.0.0/LLVM/FFI/AssemblyReader.hsc0000644000000000000000000000064312142503271016501 0ustar0000000000000000{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.AssemblyReader where import Foreign.C.String(CString) #if __GLASGOW_HASKELL__ >= 704 import Foreign.C.Types(CInt(..)) #else import Foreign.C.Types(CInt) #endif import Foreign.Ptr(Ptr) import LLVM.FFI.Core foreign import ccall unsafe "LLVMGetModuleFromAssembly" getModuleFromAssembly :: CString -> CInt -> Ptr CString -> IO ModuleRef llvm-base-3.2.0.0/LLVM/FFI/Transforms/0000755000000000000000000000000012142503271015233 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/FFI/Transforms/IPO.hsc0000644000000000000000000000314112142503271016360 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.Transforms.IPO where import LLVM.FFI.Core foreign import ccall unsafe "LLVMAddArgumentPromotionPass" addArgumentPromotionPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddConstantMergePass" addConstantMergePass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddDeadArgEliminationPass" addDeadArgEliminationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddFunctionAttrsPass" addFunctionAttrsPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddFunctionInliningPass" addFunctionInliningPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddGlobalDCEPass" addGlobalDCEPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddGlobalOptimizerPass" addGlobalOptimizerPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddIPConstantPropagationPass" addIPConstantPropagationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddPruneEHPass" addPruneEHPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddIPSCCPPass" addIPSCCPPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddStripDeadPrototypesPass" addStripDeadPrototypesPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddStripSymbolsPass" addStripSymbolsPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddAlwaysInlinerPass" addAlwaysInlinerPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddInternalizePass" addInternalizePass :: PassManagerRef -> IO () llvm-base-3.2.0.0/LLVM/FFI/Transforms/Scalar.hsc0000644000000000000000000000661412142503271017146 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-} module LLVM.FFI.Transforms.Scalar where import LLVM.FFI.Core foreign import ccall unsafe "LLVMAddCFGSimplificationPass" addCFGSimplificationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddConstantPropagationPass" addConstantPropagationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddDemoteMemoryToRegisterPass" addDemoteMemoryToRegisterPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddGVNPass" addGVNPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddInstructionCombiningPass" addInstructionCombiningPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddPromoteMemoryToRegisterPass" addPromoteMemoryToRegisterPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddReassociatePass" addReassociatePass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddAggressiveDCEPass" addAggressiveDCEPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddDeadStoreEliminationPass" addDeadStoreEliminationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddIndVarSimplifyPass" addIndVarSimplifyPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddJumpThreadingPass" addJumpThreadingPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLICMPass" addLICMPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLoopDeletionPass" addLoopDeletionPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLoopRotatePass" addLoopRotatePass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLoopUnrollPass" addLoopUnrollPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLoopUnswitchPass" addLoopUnswitchPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddMemCpyOptPass" addMemCpyOptPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddSCCPPass" addSCCPPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddScalarReplAggregatesPass" addScalarReplAggregatesPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddSimplifyLibCallsPass" addSimplifyLibCallsPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddTailCallEliminationPass" addTailCallEliminationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddVerifierPass" addVerifierPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLoopIdiomPass" addLoopIdiomPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddScalarReplAggregatesPassSSA" addScalarReplAggregatesPassSSA :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddScalarReplAggregatesPassWithThreshold" addScalarReplAggregatesPassWithThreshold :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddCorrelatedValuePropagationPass" addCorrelatedValuePropagationPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddEarlyCSEPass" addEarlyCSEPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddLowerExpectIntrinsicPass" addLowerExpectIntrinsicPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddTypeBasedAliasAnalysisPass" addTypeBasedAliasAnalysisPass :: PassManagerRef -> IO () foreign import ccall unsafe "LLVMAddBasicAliasAnalysisPass" addBasicAliasAnalysisPass :: PassManagerRef -> IO () llvm-base-3.2.0.0/LLVM/FFI/Transforms/PassManagerBuilder.hsc0000644000000000000000000000302612142503271021443 0ustar0000000000000000{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls, DeriveDataTypeable #-} module LLVM.FFI.Transforms.PassManagerBuilder where import Foreign.C.Types import Foreign.Ptr (Ptr, FunPtr) import Data.Typeable(Typeable) import LLVM.FFI.Core data PassManagerBuilder deriving (Typeable) type PassManagerBuilderRef = Ptr PassManagerBuilder foreign import ccall unsafe "LLVMPassManagerBuilderCreate" passManagerBuilderCreate :: IO PassManagerBuilderRef foreign import ccall unsafe "LLVMPassManagerBuilderDispose" passManagerBuilderDispose :: PassManagerBuilderRef -> IO () foreign import ccall unsafe "&LLVMPassManagerBuilderDispose" ptrPassManagerBuilderDispose :: FunPtr (PassManagerBuilderRef -> IO ()) foreign import ccall unsafe "LLVMPassManagerBuilderSetOptLevel" passManagerBuilderSetOptLevel :: PassManagerBuilderRef -> CUInt -> IO () foreign import ccall unsafe "LLVMPassManagerBuilderSetSizeLevel" passManagerBuilderSetSizeLevel :: PassManagerBuilderRef -> CUInt -> IO () foreign import ccall unsafe "LLVMPassManagerBuilderPopulateFunctionPassManager" passManagerBuilderPopulateFunctionPassManager :: PassManagerBuilderRef -> PassManagerRef -> IO () foreign import ccall unsafe "LLVMPassManagerBuilderPopulateModulePassManager" passManagerBuilderPopulateModulePassManager :: PassManagerBuilderRef -> PassManagerRef -> IO () foreign import ccall unsafe "LLVMPassManagerBuilderPopulateLTOPassManager" passManagerBuilderPopulateLTOPassManager :: PassManagerBuilderRef -> PassManagerRef -> Bool -> Bool -> IO () llvm-base-3.2.0.0/LLVM/Wrapper/0000755000000000000000000000000012142503271014111 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/Wrapper/Target.hs0000644000000000000000000000251312142503271015674 0ustar0000000000000000module LLVM.Wrapper.Target ( module LLVM.FFI.Target , TargetData , ByteOrdering(..) , byteOrder , copyStringRepOfTargetData , createTargetData , withTargetData ) where import LLVM.FFI.Target ( addTargetData , disposeTargetData , intPtrType , callFrameAlignmentOfType , aBIAlignmentOfType , aBISizeOfType , pointerSize , preferredAlignmentOfGlobal , preferredAlignmentOfType , sizeOfTypeInBits , storeSizeOfType , elementAtOffset , offsetOfElement ) import qualified LLVM.FFI.Target as FFI.T import Foreign.C.String (peekCString, withCString) import Control.Exception (finally) type TargetData = FFI.T.TargetDataRef data ByteOrdering = BigEndian | LittleEndian deriving Eq byteOrder :: TargetData -> ByteOrdering byteOrder td = if FFI.T.byteOrder td == 0 then BigEndian else LittleEndian copyStringRepOfTargetData :: TargetData -> IO String copyStringRepOfTargetData td = do s <- FFI.T.copyStringRepOfTargetData td peekCString s createTargetData :: String -> IO TargetData createTargetData str = withCString str $ \p -> FFI.T.createTargetData p withTargetData :: String -> (TargetData -> IO a) -> IO a withTargetData str f = do t <- createTargetData str finally (f t) (FFI.T.disposeTargetData t) llvm-base-3.2.0.0/LLVM/Wrapper/Linker.hs0000644000000000000000000000200612142503271015667 0ustar0000000000000000module LLVM.Wrapper.Linker ( LinkerMode(..) , linkModules ) where import qualified LLVM.FFI.Linker as FFI import LLVM.FFI.Linker (LinkerMode(..)) import qualified LLVM.FFI.Core as FFI import LLVM.Wrapper.Core import LLVM.Wrapper.Internal import Foreign.C.String (peekCString) import Foreign.Marshal.Alloc (alloca) import Foreign.Storable (peek) import Foreign.ForeignPtr.Safe (withForeignPtr) import Data.IORef linkModules :: Module -> Module -> LinkerMode -> IO (Maybe String) linkModules (MkModule dest _) (MkModule src srcOurs) mode = withForeignPtr dest $ \dest' -> withForeignPtr src $ \src' -> alloca $ \msgPtr -> do result <- FFI.linkModules dest' src' (FFI.fromLinkerMode mode) msgPtr writeIORef srcOurs False msg <- peek msgPtr if not result then return Nothing else do str <- peekCString msg FFI.disposeMessage msg return (Just str) llvm-base-3.2.0.0/LLVM/Wrapper/Core.hs0000644000000000000000000005736312142503271015353 0ustar0000000000000000{-# OPTIONS_GHC -fno-warn-missing-signatures #-} module LLVM.Wrapper.Core ( module LLVM.FFI.Core , Context , getGlobalContext , contextCreate , MemoryBuffer , createMemoryBufferWithContentsOfFile , createMemoryBufferWithSTDIN , createMemoryBufferWithMemoryRange , createMemoryBufferWithMemoryRangeCopy -- ** Modules , Module , moduleCreateWithName , moduleCreateWithNameInContext , printModuleToFile , dumpModule -- * Types , Type , intTypeInContext , floatTypeInContext , doubleTypeInContext , x86FP80TypeInContext , voidTypeInContext -- ** Function types , functionType -- ** Struct types , structType , structTypeInContext , structCreateNamed , structCreateNamedInContext , structSetBody -- ** Misc , getTypeByName -- * Values , Value , getValueName , setValueName , getGC , setGC , getLinkage , setLinkage , constStructInContext -- ** Scalar constants , constRealOfString , constString , constStringInContext -- ** Globals , addGlobal , getNamedGlobal , buildGlobalString , buildGlobalStringPtr -- ** Pass Manager , PassManager , createPassManager , runPassManager , createFunctionPassManagerForModule , initializeFunctionPassManager , runFunctionPassManager , finalizeFunctionPassManager -- ** Functions , addFunction , getNamedFunction , getParams , getFunctionCallConv , setFunctionCallConv , getInstructionCallConv , setInstructionCallConv , addAttribute , removeAttribute , addFunctionAttr -- ** Metadata , setMetadata , getMetadata , getNamedMetadataOperands , addNamedMetadataOperand , mdNode , mdString -- * Basic blocks , BasicBlock , appendBasicBlock , appendBasicBlockInContext , getBasicBlocks , getNextBasicBlock -- * Instruction building , Builder , createBuilder , createBuilderInContext , getCurrentDebugLocation , setCurrentDebugLocation , setInstDebugLocation , getInsertBlock , positionBuilder , positionBefore , positionAtEnd -- ** Control , buildRetVoid , buildRet , buildBr , buildIndirectBr , buildCondBr , buildSwitch , buildUnreachable -- ** Arithmetic , buildAdd , buildSub , buildMul , buildFAdd , buildFMul , buildFPCast , buildFSub , buildUDiv , buildSDiv , buildExactSDiv , buildFDiv , buildURem , buildSRem , buildFRem , buildShl , buildLShr , buildAShr , buildAnd , buildOr , buildXor , buildNeg , buildFNeg , buildNot , buildNSWAdd , buildNSWMul , buildNSWNeg , buildNSWSub , buildNUWAdd , buildNUWMul , buildNUWNeg , buildNUWSub , buildFCmp , buildICmp -- ** Memory , buildAlloca , buildLoad , buildStructGEP , buildInBoundsGEP , constGEP , buildStore -- ** Casts , buildTrunc , buildZExt , buildSExt , buildFPToUI , buildFPToSI , buildUIToFP , buildSIToFP , buildFPTrunc , buildFPExt , buildPtrToInt , buildIntToPtr , buildBitCast , buildPointerCast , buildTruncOrBitCast , buildZExtOrBitCast , buildSExtOrBitCast -- ** Misc , CUInt , CULLong , CSize , buildPhi , addIncoming , buildCall , buildSelect , isUnreachable -- * Debug , dumpModuleToString , dumpValueToString , dumpTypeToString ) where import Foreign.Ptr (Ptr, nullPtr) import Foreign.C.String import Foreign.C.Types import Foreign.Marshal.Array import Foreign.Marshal.Alloc (alloca) import Foreign.Storable (peek) import Foreign.ForeignPtr.Safe (ForeignPtr, withForeignPtr, newForeignPtr, newForeignPtr_) import System.IO.Unsafe (unsafePerformIO) import Control.Monad import LLVM.Wrapper.Internal import LLVM.FFI.Core ( TypeKind(..) , getTypeKind , int1Type , int8Type , int16Type , int32Type , int64Type , integerType , getIntTypeWidth , floatType , doubleType , x86FP80Type , fp128Type , ppcFP128Type , arrayType , pointerType , vectorType , voidType , typeOf , dumpValue , constNull , constPointerNull , getUndef , constInt , constReal , isConstant, isNull, isUndef , constInBoundsGEP , constIntCast , constIntOfString , constIntOfStringAndSize , constNSWAdd , constPointerCast , constPointerNull , constRealOfStringAndSize , constSExtOrBitCast , constZExtOrBitCast , constTruncOrBitCast , Linkage(..) , IntPredicate(..) , FPPredicate(..) , sizeOf , constNeg , constNot , constAdd , constSub , constMul , constExactSDiv , constFAdd , constFMul , constFNeg , constFPCast , constFSub , constUDiv , constSDiv , constFDiv , constURem , constSRem , constFRem , constAnd , constOr , constXor , constICmp , constFCmp , constShl , constLShr , constAShr , constTrunc , constSExt , constZExt , constFPTrunc , constFPExt , constUIToFP , constSIToFP , constFPToUI , constFPToSI , constPtrToInt , constIntToPtr , constBitCast , constSelect , constExtractElement , constInsertElement , constShuffleVector , constNSWMul , constNSWNeg , constNSWSub , constNUWAdd , constNUWMul , constNUWNeg , constNUWSub , isTailCall , setTailCall , deleteFunction , createModuleProviderForExistingModule , getEntryBasicBlock , getPreviousBasicBlock , getBasicBlockParent , setInstrParamAlignment , setParamAlignment , Attribute(..) , getFirstInstruction , getNextInstruction , getPreviousInstruction , getLastInstruction , getInstructionParent , CallingConvention(..) , addCase , MetadataKind(..) , debugVersion ) import qualified LLVM.FFI.Core as FFI type Type = FFI.TypeRef type Value = FFI.ValueRef type Builder = ForeignPtr FFI.Builder type BasicBlock = FFI.BasicBlockRef type Context = ForeignPtr FFI.Context type MemoryBuffer = ForeignPtr FFI.MemoryBuffer contextCreate :: IO Context contextCreate = FFI.contextCreate >>= newForeignPtr FFI.ptrContextDispose getGlobalContext :: IO Context getGlobalContext = FFI.getGlobalContext >>= newForeignPtr_ createMemoryBufferWithContentsOfFile :: FilePath -> IO MemoryBuffer createMemoryBufferWithContentsOfFile path = alloca $ \bufPtr -> alloca $ \msgPtr -> do errOccurred <- withCString path $ \cpath -> FFI.createMemoryBufferWithContentsOfFile cpath bufPtr msgPtr if errOccurred then peek msgPtr >>= peekCString >>= fail else peek bufPtr >>= newForeignPtr FFI.ptrDisposeMemoryBuffer createMemoryBufferWithSTDIN :: IO MemoryBuffer createMemoryBufferWithSTDIN = alloca $ \bufPtr -> alloca $ \msgPtr -> do errOccurred <- FFI.createMemoryBufferWithSTDIN bufPtr msgPtr if errOccurred then peek msgPtr >>= peekCString >>= fail else peek bufPtr >>= newForeignPtr FFI.ptrDisposeMemoryBuffer createMemoryBufferWithMemoryRange :: Ptr a -> CSize -> String -> Bool -> IO MemoryBuffer createMemoryBufferWithMemoryRange p len name nullTerm = withCString name (\cname -> FFI.createMemoryBufferWithMemoryRange p len cname nullTerm) >>= newForeignPtr FFI.ptrDisposeMemoryBuffer createMemoryBufferWithMemoryRangeCopy :: Ptr a -> CSize -> String -> IO MemoryBuffer createMemoryBufferWithMemoryRangeCopy p len name = withCString name (FFI.createMemoryBufferWithMemoryRangeCopy p len) >>= newForeignPtr FFI.ptrDisposeMemoryBuffer moduleCreateWithName :: String -> IO Module moduleCreateWithName name = initModule =<< withCString name FFI.moduleCreateWithName moduleCreateWithNameInContext :: String -> Context -> IO Module moduleCreateWithNameInContext name ctx = withForeignPtr ctx $ \ctx' -> initModule =<< withCString name (`FFI.moduleCreateWithNameInContext` ctx') printModuleToFile :: Module -> FilePath -> IO () printModuleToFile (MkModule m _) file = withCString file (\f -> alloca (\msgPtr -> do result <- withForeignPtr m (\modPtr -> FFI.printModuleToFile modPtr f msgPtr) msg <- peek msgPtr when result $ do str <- peekCString msg FFI.disposeMessage msg fail str)) dumpModule :: Module -> IO () dumpModule (MkModule m _) = withForeignPtr m FFI.dumpModule getTypeByName :: Module -> String -> IO (Maybe Type) getTypeByName (MkModule m _) name = fmap nullableToMaybe $ withForeignPtr m (withCString name . FFI.getTypeByName) getValueName :: Value -> IO String getValueName v = FFI.getValueName v >>= peekCString setValueName :: Value -> String -> IO () setValueName v name = withCString name $ FFI.setValueName v addGlobal :: Module -> Type -> String -> IO Value addGlobal (MkModule m _) ty name = withForeignPtr m (\mPtr -> withCString name $ FFI.addGlobal mPtr ty) nullableToMaybe :: Ptr a -> Maybe (Ptr a) nullableToMaybe p = if p == nullPtr then Nothing else Just p getNamedGlobal :: Module -> String -> IO (Maybe Value) getNamedGlobal (MkModule m _) name = fmap nullableToMaybe $ withForeignPtr m (withCString name . FFI.getNamedGlobal) buildGlobalString :: Builder -> String -> String -> IO Value buildGlobalString b string name = withForeignPtr b $ \b' -> withCString name (\n -> withCString string (\s -> FFI.buildGlobalString b' s n)) buildGlobalStringPtr :: Builder -> String -> String -> IO Value buildGlobalStringPtr b string name = withForeignPtr b $ \b' -> withCString name (\n -> withCString string (\s -> FFI.buildGlobalStringPtr b' s n)) createPassManager :: IO PassManager createPassManager = initPassManager =<< FFI.createPassManager runPassManager :: PassManager -> Module -> IO Bool runPassManager (MkPassManager p) (MkModule m _) = withForeignPtr m $ \mptr -> withForeignPtr p $ \pptr -> FFI.runPassManager pptr mptr createFunctionPassManagerForModule :: Module -> IO PassManager createFunctionPassManagerForModule (MkModule m _) = initPassManager =<< withForeignPtr m FFI.createFunctionPassManagerForModule initializeFunctionPassManager :: PassManager -> IO Bool initializeFunctionPassManager (MkPassManager p) = withForeignPtr p FFI.initializeFunctionPassManager runFunctionPassManager :: PassManager -> Value -> IO Bool runFunctionPassManager (MkPassManager p) f = withForeignPtr p (`FFI.runFunctionPassManager` f) finalizeFunctionPassManager :: PassManager -> IO Bool finalizeFunctionPassManager (MkPassManager p) = withForeignPtr p FFI.finalizeFunctionPassManager addFunction :: Module -> String -> Type -> IO Value addFunction (MkModule m _) name ty = withForeignPtr m (\mPtr -> withCString name (\n -> FFI.addFunction mPtr n ty)) getNamedFunction :: Module -> String -> IO (Maybe Value) getNamedFunction (MkModule m _) name = fmap nullableToMaybe $ withForeignPtr m (withCString name . FFI.getNamedFunction) getParams :: Value -> IO [Value] getParams f = let count = fromIntegral $ FFI.countParams f in allocaArray count $ \ptr -> FFI.getParams f ptr >> peekArray count ptr getFunctionCallConv :: Value -> IO CallingConvention getFunctionCallConv f = fmap FFI.toCallingConvention $ FFI.getFunctionCallConv f setFunctionCallConv :: Value -> CallingConvention -> IO () setFunctionCallConv f c = FFI.setFunctionCallConv f $ FFI.fromCallingConvention c getInstructionCallConv :: Value -> IO CallingConvention getInstructionCallConv f = fmap FFI.toCallingConvention $ FFI.getInstructionCallConv f setInstructionCallConv :: Value -> CallingConvention -> IO () setInstructionCallConv f c = FFI.setInstructionCallConv f $ FFI.fromCallingConvention c intTypeInContext :: Context -> CUInt -> IO Type intTypeInContext ctx width = withForeignPtr ctx $ \ctx' -> FFI.intTypeInContext ctx' width floatTypeInContext :: Context -> IO Type floatTypeInContext ctx = withForeignPtr ctx FFI.floatTypeInContext doubleTypeInContext :: Context -> IO Type doubleTypeInContext ctx = withForeignPtr ctx FFI.doubleTypeInContext x86FP80TypeInContext :: Context -> IO Type x86FP80TypeInContext ctx = withForeignPtr ctx FFI.x86FP80TypeInContext voidTypeInContext :: Context -> IO Type voidTypeInContext ctx = withForeignPtr ctx FFI.voidTypeInContext -- unsafePerformIO just to wrap the non-effecting withArrayLen call functionType :: Type -> [Type] -> Bool -> Type functionType returnTy argTys isVarArg = unsafePerformIO $ withArrayLen argTys $ \len ptr -> return $ FFI.functionType returnTy ptr (fromIntegral len) isVarArg -- unsafePerformIO just to wrap the non-effecting withArrayLen call structType :: [Type] -> Bool -> Type structType types packed = unsafePerformIO $ withArrayLen types $ \ len ptr -> return $ FFI.structType ptr (fromIntegral len) packed structTypeInContext :: Context -> [Type] -> Bool -> IO Type structTypeInContext ctx types packed = withForeignPtr ctx $ \ctx' -> withArrayLen types $ \ len ptr -> FFI.structTypeInContext ctx' ptr (fromIntegral len) packed structCreateNamed :: String -> IO Type structCreateNamed name = do ctx <- getGlobalContext structCreateNamedInContext ctx name structCreateNamedInContext :: Context -> String -> IO Type structCreateNamedInContext ctx name = withForeignPtr ctx $ \ctx' -> withCString name $ FFI.structCreateNamed ctx' structSetBody :: Type -> [Type] -> Bool -> IO () structSetBody struct body packed = withArrayLen body $ \len ptr -> FFI.structSetBody struct ptr (fromIntegral len) packed appendBasicBlock :: Value -> String -> IO BasicBlock appendBasicBlock function name = withCString name $ FFI.appendBasicBlock function appendBasicBlockInContext :: Context -> Value -> String -> IO BasicBlock appendBasicBlockInContext ctx function name = withForeignPtr ctx $ \ctx' -> withCString name $ FFI.appendBasicBlockInContext ctx' function getBasicBlocks :: Value -> IO [BasicBlock] getBasicBlocks v = do count <- liftM fromIntegral (FFI.countBasicBlocks v) allocaArray count $ \ptr -> do FFI.getBasicBlocks v ptr peekArray count ptr getNextBasicBlock :: BasicBlock -> IO (Maybe BasicBlock) getNextBasicBlock bb = fmap nullableToMaybe $ FFI.getNextBasicBlock bb getGC :: Value -> IO String getGC f = FFI.getGC f >>= peekCString setGC :: Value -> String -> IO () setGC f name = withCString name $ FFI.setGC f getLinkage :: Value -> IO Linkage getLinkage v = fmap FFI.toLinkage $ FFI.getLinkage v setLinkage :: Value -> Linkage -> IO () setLinkage v l = FFI.setLinkage v (FFI.fromLinkage l) constStructInContext :: Context -> [Value] -> Bool -> IO Value constStructInContext ctx values packed = withForeignPtr ctx $ \ctx' -> withArrayLen values $ \ len ptr -> FFI.constStructInContext ctx' ptr (fromIntegral len) packed -- unsafePerformIO just to wrap the non-effecting withCString call constRealOfString :: Type -> String -> Value constRealOfString ty str = unsafePerformIO $ withCString str $ \s -> FFI.constRealOfString ty s -- unsafePerformIO just to wrap the non-effecting withCStringLen call constString :: String -> Bool -> Value constString str dontNullTerminate = unsafePerformIO $ withCStringLen str $ \(ptr, len) -> return $ FFI.constString ptr (fromIntegral len) dontNullTerminate constStringInContext :: Context -> String -> Bool -> IO Value constStringInContext ctx str dontNullTerminate = withForeignPtr ctx $ \ctx' -> withCStringLen str $ \(ptr, len) -> FFI.constStringInContext ctx' ptr (fromIntegral len) dontNullTerminate createBuilder :: IO Builder createBuilder = FFI.createBuilder >>= newForeignPtr FFI.ptrDisposeBuilder createBuilderInContext :: Context -> IO Builder createBuilderInContext ctx = withForeignPtr ctx $ FFI.createBuilderInContext >=> newForeignPtr FFI.ptrDisposeBuilder getCurrentDebugLocation b = withForeignPtr b FFI.getCurrentDebugLocation setCurrentDebugLocation b v = withForeignPtr b $ \b' -> FFI.setCurrentDebugLocation b' v setInstDebugLocation b v = withForeignPtr b $ \b' -> FFI.setInstDebugLocation b' v getInsertBlock b = withForeignPtr b FFI.getInsertBlock positionBuilder b bb v = withForeignPtr b $ \b' -> FFI.positionBuilder b' bb v positionBefore b v = withForeignPtr b $ \b' -> FFI.positionBefore b' v positionAtEnd b bb = withForeignPtr b $ \b' -> FFI.positionAtEnd b' bb buildRetVoid b = withForeignPtr b FFI.buildRetVoid buildRet b v = withForeignPtr b (`FFI.buildRet` v) buildBr b t = withForeignPtr b (`FFI.buildBr` t) buildIndirectBr b addr ndests = withForeignPtr b (\b' -> FFI.buildIndirectBr b' addr ndests) buildCondBr b c t f = withForeignPtr b (\b' -> FFI.buildCondBr b' c t f) buildSwitch b v d cnt = withForeignPtr b (\b' -> FFI.buildSwitch b' v d cnt) buildUnreachable b = withForeignPtr b FFI.buildUnreachable buildStore b v ptr = withForeignPtr b (\b' -> FFI.buildStore b' v ptr) wrapBin :: (FFI.BuilderRef -> Value -> Value -> CString -> IO Value) -> Builder -> Value -> Value -> String -> IO Value wrapBin f b x y name = withForeignPtr b (\b' -> withCString name $ f b' x y) buildAdd = wrapBin FFI.buildAdd buildSub = wrapBin FFI.buildSub buildMul = wrapBin FFI.buildMul buildNSWAdd = wrapBin FFI.buildNSWAdd buildNSWSub = wrapBin FFI.buildNSWSub buildNSWMul = wrapBin FFI.buildNSWMul buildNUWAdd = wrapBin FFI.buildNUWAdd buildNUWSub = wrapBin FFI.buildNUWSub buildNUWMul = wrapBin FFI.buildNUWMul buildUDiv = wrapBin FFI.buildUDiv buildSDiv = wrapBin FFI.buildSDiv buildExactSDiv = wrapBin FFI.buildExactSDiv buildURem = wrapBin FFI.buildURem buildSRem = wrapBin FFI.buildSRem buildFAdd = wrapBin FFI.buildFAdd buildFSub = wrapBin FFI.buildFSub buildFMul = wrapBin FFI.buildFMul buildFDiv = wrapBin FFI.buildFDiv buildFRem = wrapBin FFI.buildFRem buildShl = wrapBin FFI.buildShl buildLShr = wrapBin FFI.buildLShr buildAShr = wrapBin FFI.buildAShr buildAnd = wrapBin FFI.buildAnd buildOr = wrapBin FFI.buildOr buildXor = wrapBin FFI.buildXor wrapUn :: (FFI.BuilderRef -> Value -> CString -> IO Value) -> Builder -> Value -> String -> IO Value wrapUn f b v name = withForeignPtr b (\b' -> withCString name $ f b' v) buildNeg = wrapUn FFI.buildNeg buildFNeg = wrapUn FFI.buildFNeg buildNot = wrapUn FFI.buildNot buildNSWNeg = wrapUn FFI.buildNSWNeg buildNUWNeg = wrapUn FFI.buildNUWNeg buildICmp :: Builder -> IntPredicate -> Value -> Value -> String -> IO Value buildICmp b p l r n = withForeignPtr b $ \b' -> withCString n $ FFI.buildICmp b' (FFI.fromIntPredicate p) l r buildFCmp :: Builder -> FPPredicate -> Value -> Value -> String -> IO Value buildFCmp b p l r n = withForeignPtr b $ \b' -> withCString n $ FFI.buildFCmp b' (FFI.fromFPPredicate p) l r buildAlloca :: Builder -> Type -> String -> IO Value buildAlloca b ty name = withForeignPtr b $ \b' -> withCString name $ FFI.buildAlloca b' ty buildLoad :: Builder -> Value -> String -> IO Value buildLoad b ptr name = withForeignPtr b $ \b' -> withCString name $ FFI.buildLoad b' ptr buildStructGEP :: Builder -> Value -> CUInt -> String -> IO Value buildStructGEP b s idx name = withForeignPtr b $ \b' -> withCString name $ FFI.buildStructGEP b' s idx buildInBoundsGEP :: Builder -> Value -> [Value] -> String -> IO Value buildInBoundsGEP b ptr indices name = withArrayLen indices $ \len indicesPtr -> withForeignPtr b $ \b' -> withCString name $ FFI.buildInBoundsGEP b' ptr indicesPtr $ fromIntegral len constGEP :: Value -> [Value] -> IO Value constGEP ptr indices = withArrayLen indices $ \len indicesPtr -> return $ FFI.constGEP ptr indicesPtr $ fromIntegral len wrapCast :: (FFI.BuilderRef -> Value -> Type -> CString -> IO Value) -> Builder -> Value -> Type -> String -> IO Value wrapCast f b v t name = withForeignPtr b (\b' -> withCString name $ f b' v t) buildTrunc = wrapCast FFI.buildTrunc buildZExt = wrapCast FFI.buildZExt buildSExt = wrapCast FFI.buildSExt buildFPToUI = wrapCast FFI.buildFPToUI buildFPToSI = wrapCast FFI.buildFPToSI buildUIToFP = wrapCast FFI.buildUIToFP buildSIToFP = wrapCast FFI.buildSIToFP buildFPTrunc = wrapCast FFI.buildFPTrunc buildFPExt = wrapCast FFI.buildFPExt buildPtrToInt = wrapCast FFI.buildPtrToInt buildIntToPtr = wrapCast FFI.buildIntToPtr buildBitCast = wrapCast FFI.buildBitCast buildPointerCast = wrapCast FFI.buildPointerCast buildTruncOrBitCast = wrapCast FFI.buildTruncOrBitCast buildZExtOrBitCast = wrapCast FFI.buildZExtOrBitCast buildSExtOrBitCast = wrapCast FFI.buildSExtOrBitCast buildFPCast = wrapCast FFI.buildFPCast buildPhi :: Builder -> Type -> String -> IO Value buildPhi b ty name = withForeignPtr b (\b' -> withCString name $ FFI.buildPhi b' ty) addIncoming :: Value -> [(Value, BasicBlock)] -> IO () addIncoming phi incoming = withArrayLen (map fst incoming) $ \len valPtr -> withArray (map snd incoming) $ \blockPtr -> FFI.addIncoming phi valPtr blockPtr (fromIntegral len) buildCall :: Builder -> Value -> [Value] -> String -> IO Value buildCall b f args name = withArrayLen args $ \len ptr -> withForeignPtr b (\b' -> withCString name $ FFI.buildCall b' f ptr (fromIntegral len)) buildSelect :: Builder -> Value -> Value -> Value -> String -> IO Value buildSelect b cond t f name = withForeignPtr b (\b' -> withCString name $ FFI.buildSelect b' cond t f) -- See LLVMOpcode in llvm-c/Core.h isUnreachable :: Value -> IO Bool isUnreachable v = fmap (== 7) $ FFI.getInstructionOpcode v addAttribute :: Value -> Attribute -> IO () addAttribute v a = FFI.addAttribute v $ FFI.fromAttribute a removeAttribute :: Value -> Attribute -> IO () removeAttribute v a = FFI.removeAttribute v $ FFI.fromAttribute a addFunctionAttr :: Value -> Attribute -> IO () addFunctionAttr v a = FFI.addFunctionAttr v $ FFI.fromAttribute a setMetadata :: Value -> MetadataKind -> Value -> IO () setMetadata instruction kind = FFI.setMetadata instruction (FFI.fromMetadataKind kind) getMetadata :: Value -> MetadataKind -> IO Value getMetadata instruction kind = FFI.getMetadata instruction (FFI.fromMetadataKind kind) mdNode :: [Value] -> IO Value mdNode children = withArrayLen children $ \len ptr -> FFI.mdNode ptr $ fromIntegral len -- unsafePerformIO just to wrap the non-effecting withCString call mdString :: String -> Value mdString s = unsafePerformIO $ withCStringLen s $ \(ptr, len) -> return $ FFI.mdString ptr $ fromIntegral len getNamedMetadataOperands :: Module -> String -> IO [Value] getNamedMetadataOperands (MkModule m _) name = withCString name $ \namePtr -> do count <- liftM fromIntegral (withForeignPtr m (`FFI.getNamedMetadataNumOperands` namePtr)) allocaArray count $ \ptr -> do withForeignPtr m (\m' -> FFI.getNamedMetadataOperands m' namePtr ptr) peekArray count ptr addNamedMetadataOperand :: Module -> String -> Value -> IO () addNamedMetadataOperand (MkModule m _) name value = withForeignPtr m $ \m' -> withCString name $ \n -> FFI.addNamedMetadataOperand m' n value dumpModuleToString :: Module -> IO String dumpModuleToString (MkModule m _)= do cstr <- withForeignPtr m FFI.dumpModuleToString hstr <- peekCString cstr FFI.disposeMessage cstr return hstr dumpTypeToString :: Type -> IO String dumpTypeToString t = do cstr <- FFI.dumpTypeToString t hstr <- peekCString cstr FFI.disposeMessage cstr return hstr dumpValueToString :: Value -> IO String dumpValueToString v = do cstr <- FFI.dumpValueToString v hstr <- peekCString cstr FFI.disposeMessage cstr return hstr llvm-base-3.2.0.0/LLVM/Wrapper/Analysis.hs0000644000000000000000000000155112142503271016232 0ustar0000000000000000module LLVM.Wrapper.Analysis where import qualified LLVM.FFI.Analysis as FFI import qualified LLVM.FFI.Core as FFI import LLVM.Wrapper.Core import LLVM.Wrapper.Internal import Foreign.C.String (peekCString) import Foreign.Marshal.Alloc (alloca) import Foreign.Storable (peek) import Foreign.ForeignPtr.Safe (withForeignPtr) -- VerifierFailureAction 2 is 'no side effects' verifyFunction :: Value -> IO Bool verifyFunction f = FFI.verifyFunction f 2 verifyModule :: Module -> IO (Maybe String) verifyModule (MkModule m _) = alloca $ \msgPtr -> do result <- withForeignPtr m (\m' -> FFI.verifyModule m' 2 msgPtr) msg <- peek msgPtr if not result then return Nothing else do str <- peekCString msg FFI.disposeMessage msg return $ Just str llvm-base-3.2.0.0/LLVM/Wrapper/ExecutionEngine.hs0000644000000000000000000000661312142503271017544 0ustar0000000000000000module LLVM.Wrapper.ExecutionEngine ( module LLVM.FFI.ExecutionEngine -- * Execution engines , ExecutionEngine , findFunction , runFunction , runFunctionAsMain , createExecutionEngineForModule , createInterpreterForModule , createJITCompilerForModule -- * Generic values , createGenericValueOfInt , genericValueToInt ) where import LLVM.FFI.ExecutionEngine ( runStaticConstructors , runStaticDestructors , genericValueToFloat , createGenericValueOfFloat , disposeExecutionEngine , addModuleProvider , getExecutionEngineTargetData , freeMachineCodeForFunction , genericValueIntWidth , linkInJIT , addModule ) import qualified LLVM.FFI.ExecutionEngine as FFI.EE import qualified LLVM.FFI.Core as FFI import Control.Monad import Foreign.Ptr (Ptr) import Foreign.C.String import Foreign.C.Types import Foreign.Marshal.Array import Foreign.Marshal.Alloc import Foreign.Marshal.Utils import Foreign.Storable type ExecutionEngine = Ptr FFI.EE.ExecutionEngine -- FFI.EE.ExecutionEngineRef type GenericValue = Ptr FFI.EE.GenericValue -- FFI.EE.GenericValueRef type Type = FFI.TypeRef type Module = FFI.ModuleRef type Value = FFI.ValueRef createGenericValueOfInt :: Type -> CULLong -> Bool -> IO GenericValue createGenericValueOfInt ty n isSigned = FFI.EE.createGenericValueOfInt ty n (fromBool isSigned) genericValueToInt :: GenericValue -> Bool -> CULLong genericValueToInt genVal isSigned = FFI.EE.genericValueToInt genVal (fromBool isSigned) runFunction :: ExecutionEngine -> Value -> CUInt -> [GenericValue] -> IO GenericValue runFunction ee f numArgs args = withArray args $ \ptr -> FFI.EE.runFunction ee f numArgs ptr findFunction :: ExecutionEngine -> String -> IO (Maybe Value) findFunction ee name = alloca $ \funPtr -> withCString name $ \s -> do r <- liftM toBool (FFI.EE.findFunction ee s funPtr) if r then return Nothing else liftM Just (peek funPtr) runFunctionAsMain :: ExecutionEngine -> Value -> [String] -> [String] -> IO Bool runFunctionAsMain ee val argv envp = do argcstrs <- argcstrings envcstrs <- envcstrings withArray argcstrs $ \args -> withArray envcstrs $ \env -> liftM toBool (FFI.EE.runFunctionAsMain ee val (fromIntegral $ length argv) args env) where argcstrings = mapM newCString argv envcstrings = mapM newCString envp createJITCompilerForModule :: Module -> CUInt -> IO ExecutionEngine createJITCompilerForModule m optlvl = alloca $ \msgPtr -> alloca $ \eeref -> do r <- FFI.EE.createJITCompilerForModule eeref m optlvl msgPtr if r then peek msgPtr >>= peekCString >>= fail else peek eeref createInterpreterForModule :: Module -> IO ExecutionEngine createInterpreterForModule m = alloca $ \msgPtr -> alloca $ \eeref -> do r <- FFI.EE.createInterpreterForModule eeref m msgPtr if r then peek msgPtr >>= peekCString >>= fail else peek eeref createExecutionEngineForModule :: Module -> IO ExecutionEngine createExecutionEngineForModule m = alloca $ \msgPtr -> alloca $ \eeref -> do r <- FFI.EE.createExecutionEngineForModule eeref m msgPtr if r then peek msgPtr >>= peekCString >>= fail else peek eeref llvm-base-3.2.0.0/LLVM/Wrapper/BitWriter.hs0000644000000000000000000000071112142503271016357 0ustar0000000000000000module LLVM.Wrapper.BitWriter where import Foreign.C.String import Foreign.ForeignPtr.Safe (withForeignPtr) import Control.Monad import qualified LLVM.FFI.BitWriter as FFI import LLVM.Wrapper.Core import LLVM.Wrapper.Internal writeBitcodeToFile :: Module -> FilePath -> IO () writeBitcodeToFile (MkModule m _) p = do result <- withForeignPtr m (withCString p . FFI.writeBitcodeToFile) when result $ fail $ "Failed to write bitcode to " ++ p llvm-base-3.2.0.0/LLVM/Wrapper/Internal.hs0000644000000000000000000000237312142503271016226 0ustar0000000000000000module LLVM.Wrapper.Internal where import Foreign.ForeignPtr.Safe (ForeignPtr, newForeignPtr) import qualified Foreign.Concurrent as FC (newForeignPtr) import Foreign.Ptr (Ptr) import Control.Monad import Data.IORef import qualified LLVM.FFI.Core as FFI import qualified LLVM.FFI.Transforms.PassManagerBuilder as FFI data Module = MkModule (ForeignPtr FFI.Module) (IORef Bool) deriving Eq data PassManager = MkPassManager (ForeignPtr FFI.PassManager) deriving Eq data PassManagerBuilder = MkPassManagerBuilder (ForeignPtr FFI.PassManagerBuilder) deriving Eq moduleFinalizer :: Ptr FFI.Module -> IORef Bool -> IO () moduleFinalizer m ours = do isOurs <- readIORef ours when isOurs $ FFI.disposeModule m initModule :: Ptr FFI.Module -> IO Module initModule ptr = do ours <- newIORef True fptr <- FC.newForeignPtr ptr (moduleFinalizer ptr ours) return $ MkModule fptr ours initPassManager :: Ptr FFI.PassManager -> IO PassManager initPassManager ptr = fmap MkPassManager (newForeignPtr FFI.ptrDisposePassManager ptr) initPassManagerBuilder :: Ptr FFI.PassManagerBuilder -> IO PassManagerBuilder initPassManagerBuilder ptr = fmap MkPassManagerBuilder (newForeignPtr FFI.ptrPassManagerBuilderDispose ptr) llvm-base-3.2.0.0/LLVM/Wrapper/BitReader.hs0000644000000000000000000000231512142503271016307 0ustar0000000000000000module LLVM.Wrapper.BitReader (parseBitcodeInContext) where import Foreign.Marshal.Alloc (alloca) import Foreign.C.String (peekCString) import Foreign.Storable (peek) import Foreign.ForeignPtr.Safe (withForeignPtr) import qualified LLVM.FFI.BitReader as FFI import LLVM.Wrapper.Internal import LLVM.Wrapper.Core parseBitcodeInContext :: Context -> MemoryBuffer -> IO (Either String Module) parseBitcodeInContext ctx buf = alloca $ \msgPtr -> alloca $ \modPtr -> withForeignPtr ctx $ \ctx' -> withForeignPtr buf $ \buf' -> do errOccurred <- FFI.parseBitcodeInContext ctx' buf' modPtr msgPtr if errOccurred then fmap Left $ peek msgPtr >>= peekCString else fmap Right $ peek modPtr >>= initModule -- TODO: Work out the memory dynamics of this getBitcodeModuleInContext :: Context -> MemoryBuffer -> IO (Either String Module) getBitcodeModuleInContext ctx buf = alloca $ \msgPtr -> alloca $ \modPtr -> withForeignPtr ctx $ \ctx' -> withForeignPtr buf $ \buf' -> do errOccurred <- FFI.getBitcodeModuleInContext ctx' buf' modPtr msgPtr if errOccurred then fmap Left $ peek msgPtr >>= peekCString else fmap Right $ peek modPtr >>= initModule llvm-base-3.2.0.0/LLVM/Wrapper/Transforms/0000755000000000000000000000000012142503271016247 5ustar0000000000000000llvm-base-3.2.0.0/LLVM/Wrapper/Transforms/PassManagerBuilder.hs0000644000000000000000000000331212142503271022312 0ustar0000000000000000module LLVM.Wrapper.Transforms.PassManagerBuilder where import Foreign.C.Types import Foreign.ForeignPtr.Safe (withForeignPtr) import qualified LLVM.FFI.Transforms.PassManagerBuilder as FFI import LLVM.Wrapper.Internal passManagerBuilderCreate :: IO PassManagerBuilder passManagerBuilderCreate = initPassManagerBuilder =<< FFI.passManagerBuilderCreate passManagerBuilderSetOptLevel :: PassManagerBuilder -> CUInt -> IO () passManagerBuilderSetOptLevel (MkPassManagerBuilder p) level = withForeignPtr p (`FFI.passManagerBuilderSetOptLevel` level) passManagerBuilderSetSizeLevel :: PassManagerBuilder -> CUInt -> IO () passManagerBuilderSetSizeLevel (MkPassManagerBuilder p) level = withForeignPtr p (`FFI.passManagerBuilderSetSizeLevel` level) passManagerBuilderPopulateFunctionPassManager :: PassManagerBuilder -> PassManager -> IO () passManagerBuilderPopulateFunctionPassManager (MkPassManagerBuilder b) (MkPassManager m) = withForeignPtr b $ \bptr -> withForeignPtr m $ \mptr -> FFI.passManagerBuilderPopulateFunctionPassManager bptr mptr passManagerBuilderPopulateModulePassManager :: PassManagerBuilder -> PassManager -> IO () passManagerBuilderPopulateModulePassManager (MkPassManagerBuilder b) (MkPassManager m) = withForeignPtr b $ \bptr -> withForeignPtr m $ \mptr -> FFI.passManagerBuilderPopulateModulePassManager bptr mptr passManagerBuilderPopulateLTOPassManager :: PassManagerBuilder -> PassManager -> Bool -> Bool -> IO () passManagerBuilderPopulateLTOPassManager (MkPassManagerBuilder b) (MkPassManager m) internalize inline = withForeignPtr b $ \bptr -> withForeignPtr m $ \mptr -> FFI.passManagerBuilderPopulateLTOPassManager bptr mptr internalize inline llvm-base-3.2.0.0/cbits/0000755000000000000000000000000012142503271013023 5ustar0000000000000000llvm-base-3.2.0.0/cbits/support.cpp0000644000000000000000000000500012142503271015236 0ustar0000000000000000#define __STDC_LIMIT_MACROS #define __STDC_CONSTANT_MACROS #include "hs_llvm_config.h" #include "llvm-c/Core.h" #include "llvm/PassManager.h" #include "llvm/Support/PrettyStackTrace.h" #if HS_LLVM_VERSION >= 300 # if HS_LLVM_VERSION < 303 # include "llvm/DefaultPasses.h" # else # include "llvm/CodeGen/Passes.h" # endif # include "llvm/Transforms/IPO/PassManagerBuilder.h" # include "llvm/Transforms/IPO.h" #else # include "llvm/Support/StandardPasses.h" #endif #include "support.h" using namespace llvm; void LLVMCreateStandardFunctionPasses(LLVMPassManagerRef PM, unsigned OptimizationLevel) { #if HS_LLVM_VERSION >= 300 llvm::PassManagerBuilder Builder; Builder.OptLevel = OptimizationLevel; llvm::PassManagerBase *pass_man = unwrap(PM); llvm::FunctionPassManager *func_man = static_cast (pass_man); if (func_man) { Builder.populateFunctionPassManager (*func_man); } else { // printf ("Cannot create function passes for module pass manager\n"); } #else createStandardFunctionPasses(unwrap(PM), OptimizationLevel); #endif } void LLVMCreateStandardModulePasses(LLVMPassManagerRef PM, unsigned OptLevel, int OptimizeSize, int UnitAtATime, int UnrollLoops, int SimplifyLibCalls, int HaveExceptions, int DisableInline) { #if HS_LLVM_VERSION >= 300 llvm::PassManagerBuilder Builder; Builder.OptLevel = OptLevel; Builder.SizeLevel = OptimizeSize; Builder.DisableUnrollLoops = !UnrollLoops; Builder.DisableSimplifyLibCalls = !SimplifyLibCalls; Builder.DisableUnitAtATime = !UnitAtATime; Pass *InliningPass = 0; if (DisableInline) { // No inlining pass } else if (OptLevel) { unsigned Threshold = 225; if (OptLevel > 2) Threshold = 275; Builder.Inliner = createFunctionInliningPass(Threshold); } else { Builder.Inliner = createAlwaysInlinerPass(); } Builder.populateModulePassManager (*unwrap(PM)); #else Pass *InliningPass = 0; if (DisableInline) { // No inlining pass } else if (OptLevel) { unsigned Threshold = 225; if (OptLevel > 2) Threshold = 275; InliningPass = createFunctionInliningPass(Threshold); } else { InliningPass = createAlwaysInlinerPass(); } createStandardModulePasses(unwrap(PM), OptLevel, OptimizeSize, UnitAtATime, UnrollLoops, SimplifyLibCalls, HaveExceptions, InliningPass); #endif } void LLVMDisablePrettyStackTrace() { llvm::DisablePrettyStackTrace = true; } llvm-base-3.2.0.0/cbits/free.c0000644000000000000000000000100112142503271014100 0ustar0000000000000000#define __STDC_LIMIT_MACROS #define __STDC_CONSTANT_MACROS #include #include /* C function to free function object resources. Can be called from a finalizer. */ void c_freeFunctionObject(LLVMExecutionEngineRef execEngine, LLVMModuleProviderRef moduleProvider, LLVMValueRef f) { LLVMModuleRef mod; LLVMFreeMachineCodeForFunction(execEngine, f); if (!LLVMRemoveModuleProvider(execEngine, moduleProvider, &mod, 0)) { LLVMDisposeModule(mod); } } llvm-base-3.2.0.0/cbits/malloc.c0000644000000000000000000001035712142503271014444 0ustar0000000000000000#include #include #ifdef DEBUG #include #endif #ifdef TEST #include #endif size_t gcd(size_t x, size_t y) { while (x!=0) { size_t tmp = y%x; y = x; x = tmp; } return y; }; __inline__ size_t lcm(size_t x, size_t y) { return x*(y/gcd(x,y)); }; __inline__ size_t round_down_multiple(size_t x, size_t y) { return x - (x%y); }; /* This is the alignment that malloc always warrants. If smaller alignments are requested, then we do not need to pad. FIXME: This was only tested on ix86-linux. How to get the right number for every platform? */ const size_t default_align = 8; /* We have to waste a lot of memory, since we need an aligned address and before that space for a pointer. Less memory can be wasted if 'free' also gets size and align information. In this case we could omit padding in some cases and in the other cases we could put the pointer after the memory chunk, which allows us to use less padding. */ void *aligned_malloc(size_t size, size_t requested_align) { const size_t ptrsize = sizeof(void *); /* Ensure that alignment always allows to store a pointer (to the whole allocated block). */ const size_t align = lcm(requested_align, ptrsize); const size_t pad = align; void *ptr = malloc(pad+ptrsize+size); if (ptr) { void **alignedptr = (void **) round_down_multiple((size_t)(ptr+pad+ptrsize), align); *(alignedptr-1) = ptr; #ifdef DEBUG printf("allocated size %x with alignment %x at %08x %08x \n", size, align, (size_t) ptr, (size_t) alignedptr); #endif return alignedptr; } else { return NULL; } }; /* align must be a power of two */ void *power2_aligned_malloc(size_t size, size_t align) { const size_t ptrsize = sizeof(void *); size_t pad = align>=default_align ? align-default_align : 0; void *ptr = malloc(pad+ptrsize+size); if (ptr) { void **alignedptr = (void **)((size_t)(ptr+pad+ptrsize) & (-align)); *(alignedptr-1) = ptr; #ifdef DEBUG printf("allocated size 0x%x with alignment 0x%x at %08x %08x \n", size, align, (size_t) ptr, (size_t) alignedptr); #endif return alignedptr; } else { return NULL; } }; void aligned_free(void *alignedptr) { if (alignedptr) { void **sptr = (void **) alignedptr; void *ptr = *(sptr - 1); #ifdef DEBUG printf("freed %08x %08x \n", (size_t) ptr, (size_t) alignedptr); #endif free(ptr); } else { /* What shall we do about NULL pointers? Crash immediately? Make an official crash by 'free'? */ free(alignedptr); } }; /* Abuse a pointer type as a size_t compatible type and choose a name that will hopefully not clash with names an llvm user already uses (such as 'malloc'). */ void *aligned_malloc_sizeptr(void *size, void *align) { return aligned_malloc((size_t) size, (size_t) align); } const int prepadsize = 1024, postpadsize = 1024; void *padded_aligned_malloc(size_t size, size_t align) { void *ptr = aligned_malloc(prepadsize+size+postpadsize, align); return ptr ? ptr+prepadsize : NULL; }; void padded_aligned_free(void *ptr) { aligned_free(ptr ? ptr-prepadsize : NULL); }; #ifdef TEST void test_gcd (size_t x, size_t y) { printf("gcd(%d,%d) = %d\n", x, y, gcd (x,y)); } void test_malloc (size_t size, size_t align) { uint8_t *ptr = aligned_malloc (size, align); if (ptr) { if (((size_t) ptr) % align) { printf ("ptr %08x not correctly aligned\n", (size_t) ptr); } size_t k; for (k = 0; k #include #include #include #define __STDC_LIMIT_MACROS #define __STDC_CONSTANT_MACROS // LLVM includes #if HS_LLVM_VERSION < 303 #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" #include "llvm/IntrinsicInst.h" #else #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/IntrinsicInst.h" #endif #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Casting.h" #if HS_LLVM_VERSION < 300 #include "llvm/TypeSymbolTable.h" #endif #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/CallSite.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/Parser.h" #ifdef HAVE_LLVM_SUPPORT_DYNAMICLIBRARY_H # include "llvm/Support/DynamicLibrary.h" #else # include "llvm/System/DynamicLibrary.h" #endif #include "llvm/PassManager.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/DomPrinter.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Linker.h" #include "llvm/Support/SourceMgr.h" #if HS_LLVM_VERSION >= 300 // Imports for direct object emission // Target selection #if HS_LLVM_VERSION < 302 #include "llvm/Target/TargetData.h" #elif HS_LLVM_VERSION < 303 #include "llvm/DataLayout.h" #else #include "llvm/IR/DataLayout.h" #endif #include "llvm/Target/TargetMachine.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/Host.h" #include "llvm/ADT/SmallVector.h" // File output #include "llvm/Support/raw_ostream.h" #include "llvm/Support/FormattedStream.h" #endif // LLVM-C includes #include "llvm-c/Core.h" #include "llvm-c/ExecutionEngine.h" #include "llvm-c/Target.h" // our includes #include "extra.h" //using namespace llvm; unsigned LLVMInitNativeTarget() { return LLVMInitializeNativeTarget(); } char *LLVMDumpModuleToString(LLVMModuleRef module) { std::string s; llvm::raw_string_ostream buf(s); llvm::Module *p = llvm::unwrap(module); assert(p); p->print(buf, NULL); return strdup(buf.str().c_str()); } char *LLVMDumpTypeToString(LLVMTypeRef type) { std::string s; llvm::raw_string_ostream buf(s); llvm::Type *p = llvm::unwrap(type); assert(p); p->print(buf); return strdup(buf.str().c_str()); } char *LLVMDumpValueToString(LLVMValueRef value) { std::string s; llvm::raw_string_ostream buf(s); llvm::Value *p = llvm::unwrap(value); assert(p); p->print(buf); return strdup(buf.str().c_str()); } unsigned LLVMModuleGetPointerSize(LLVMModuleRef module) { llvm::Module *modulep = llvm::unwrap(module); assert(modulep); llvm::Module::PointerSize p = modulep->getPointerSize(); if (p == llvm::Module::Pointer32) return 32; else if (p == llvm::Module::Pointer64) return 64; return 0; } LLVMValueRef LLVMModuleGetOrInsertFunction(LLVMModuleRef module, const char *name, LLVMTypeRef function_type) { assert(name); llvm::Module *modulep = llvm::unwrap(module); assert(modulep); llvm::FunctionType *ftp = llvm::unwrap(function_type); assert(ftp); llvm::Constant *f = modulep->getOrInsertFunction(name, ftp); return wrap(f); } int LLVMHasInitializer(LLVMValueRef global_var) { llvm::GlobalVariable *gvp = llvm::unwrap(global_var); assert(gvp); return gvp->hasInitializer(); } #define inst_checkfn(ourfn, llvmfn) \ unsigned ourfn (LLVMValueRef v) { \ llvm::Instruction *ip = llvm::unwrap(v); \ assert(ip); \ return ip-> llvmfn () ? 1 : 0; \ } inst_checkfn(LLVMInstIsTerminator, isTerminator) inst_checkfn(LLVMInstIsBinaryOp, isBinaryOp) inst_checkfn(LLVMInstIsShift, isShift) inst_checkfn(LLVMInstIsCast, isCast) inst_checkfn(LLVMInstIsLogicalShift, isLogicalShift) inst_checkfn(LLVMInstIsArithmeticShift, isArithmeticShift) inst_checkfn(LLVMInstIsAssociative, isAssociative) inst_checkfn(LLVMInstIsCommutative, isCommutative) unsigned LLVMInstIsVolatile(LLVMValueRef v) { using namespace llvm; Instruction *ip = unwrap(v); assert(ip); return ((isa(*ip) && cast(*ip).isVolatile()) || (isa(*ip) && cast(*ip).isVolatile()) ); } const char *LLVMInstGetOpcodeName(LLVMValueRef inst) { llvm::Instruction *instp = llvm::unwrap(inst); assert(instp); return instp->getOpcodeName(); } #if HS_LLVM_VERSION < 301 unsigned LLVMInstGetOpcode(LLVMValueRef inst) { llvm::Instruction *instp = llvm::unwrap(inst); assert(instp); return instp->getOpcode(); } #endif unsigned LLVMCmpInstGetPredicate(LLVMValueRef cmpinst) { llvm::CmpInst *instp = llvm::unwrap(cmpinst); assert(instp); return instp->getPredicate(); } /* llvm::unwrap a set of `n' wrapped objects starting at `values', * into a vector of pointers to llvm::unwrapped objects `out'. */ template void unwrap_vec(W *values, unsigned n, std::vector& out) { out.clear(); while (n--) { UW *p = llvm::unwrap(*values); assert(p); out.push_back(p); ++values; } } /* Same as llvm::unwrap_vec, but use a vector of const pointers. */ template void unwrap_cvec(W *values, unsigned n, std::vector& out) { out.clear(); while (n--) { UW *p = llvm::unwrap(*values); assert(p); out.push_back(p); ++values; } } LLVMValueRef LLVMBuildRetMultiple(LLVMBuilderRef builder, LLVMValueRef *values, unsigned n_values) { assert(values); std::vector values_vec; unwrap_vec(values, n_values, values_vec); llvm::IRBuilder<> *builderp = llvm::unwrap(builder); assert(builderp); return llvm::wrap(builderp->CreateAggregateRet(&values_vec[0], values_vec.size())); } LLVMValueRef LLVMBuildGetResult(LLVMBuilderRef builder, LLVMValueRef value, unsigned index, const char *name) { assert(name); llvm::IRBuilder<> *builderp = llvm::unwrap(builder); assert(builderp); return llvm::wrap(builderp->CreateExtractValue(llvm::unwrap(value), index, name)); } unsigned LLVMValueGetID(LLVMValueRef value) { llvm::Value *valuep = llvm::unwrap(value); assert(valuep); return valuep->getValueID(); } unsigned LLVMValueGetNumUses(LLVMValueRef value) { llvm::Value *valuep = llvm::unwrap(value); assert(valuep); return valuep->getNumUses(); } unsigned LLVMValueGetUses(LLVMValueRef value, LLVMValueRef **refs) { llvm::Value *valuep = llvm::unwrap(value); assert(valuep); unsigned n = valuep->getNumUses(); if (n == 0) return 0; assert(refs); LLVMValueRef *out = (LLVMValueRef *)malloc(sizeof(LLVMValueRef) * n); if (!out) return 0; *refs = out; memset(out, 0, sizeof(LLVMValueRef) * n); llvm::Value::use_iterator it = valuep->use_begin(); while (it != valuep->use_end()) { *out++ = llvm::wrap(*it); ++it; } return n; } unsigned LLVMValueIsUsedInBasicBlock(LLVMValueRef value, LLVMBasicBlockRef bb) { llvm::Value *valuep = llvm::unwrap(value); assert(valuep); llvm::BasicBlock *bbp = llvm::unwrap(bb); assert(bbp); return valuep->isUsedInBasicBlock(bbp); } void LLVMDisposeValueRefArray(LLVMValueRef *refs) { assert(refs); free(refs); } unsigned LLVMUserGetNumOperands(LLVMValueRef user) { llvm::User *userp = llvm::unwrap(user); assert(userp); return userp->getNumOperands(); } LLVMValueRef LLVMUserGetOperand(LLVMValueRef user, unsigned idx) { llvm::User *userp = llvm::unwrap(user); assert(userp); llvm::Value *operand = userp->getOperand(idx); return llvm::wrap(operand); } unsigned LLVMGetDoesNotThrow(LLVMValueRef fn) { llvm::Function *fnp = llvm::unwrap(fn); assert(fnp); return fnp->doesNotThrow(); } void LLVMSetDoesNotThrow(LLVMValueRef fn) { llvm::Function *fnp = llvm::unwrap(fn); assert(fnp); return fnp->setDoesNotThrow(); } LLVMValueRef LLVMGetIntrinsic(LLVMModuleRef module, int id, LLVMTypeRef *types, unsigned n_types) { assert(types); #if HS_LLVM_VERSION >= 300 std::vector types_vec; unwrap_vec(types, n_types, types_vec); #else std::vector types_vec; unwrap_cvec(types, n_types, types_vec); #endif llvm::Module *modulep = llvm::unwrap(module); assert(modulep); #if HS_LLVM_VERSION >= 300 llvm::Function *intfunc = llvm::Intrinsic::getDeclaration(modulep, llvm::Intrinsic::ID(id), types_vec); #else llvm::Function *intfunc = llvm::Intrinsic::getDeclaration(modulep, llvm::Intrinsic::ID(id), &types_vec[0], types_vec.size()); #endif return wrap(intfunc); } LLVMModuleRef LLVMGetModuleFromAssembly(const char *asmtext, unsigned txtlen, char **out) { assert(asmtext); assert(out); llvm::Module *modulep; llvm::SMDiagnostic error; if (!(modulep = llvm::ParseAssemblyString(asmtext, NULL, error, llvm::getGlobalContext()))) { std::string s; llvm::raw_string_ostream buf(s); error.print("llvm-py", buf); *out = strdup(buf.str().c_str()); return NULL; } return wrap(modulep); } LLVMModuleRef LLVMGetModuleFromBitcode(const char *bitcode, unsigned bclen, char **out) { assert(bitcode); assert(out); llvm::StringRef as_str(bitcode, bclen); llvm::MemoryBuffer *mbp; if (!(mbp = llvm::MemoryBuffer::getMemBufferCopy(as_str))) return NULL; std::string msg; llvm::Module *modulep; if (!(modulep = llvm::ParseBitcodeFile(mbp, llvm::getGlobalContext(), &msg))) *out = strdup(msg.c_str()); delete mbp; return wrap(modulep); } #if HS_LLVM_VERSION < 302 unsigned LLVMLinkModules(LLVMModuleRef dest, LLVMModuleRef src, unsigned mode, char **out) { llvm::Module *sourcep = llvm::unwrap(src); assert(sourcep); llvm::Module *destinationp = llvm::unwrap(dest); assert(destinationp); std::string msg; bool err; #if HS_LLVM_VERSION >= 300 err = llvm::Linker::LinkModules(destinationp, sourcep, mode, &msg); #else err = llvm::Linker::LinkModules(destinationp, sourcep, &msg); #endif if (err) { *out = strdup(msg.c_str()); return 0; } return 1; } #endif unsigned char *LLVMGetBitcodeFromModule(LLVMModuleRef module, unsigned *lenp) { assert(lenp); llvm::Module *modulep = llvm::unwrap(module); assert(modulep); /* get bc into a string */ std::string s; llvm::raw_string_ostream buf(s); llvm::WriteBitcodeToFile(modulep, buf); const std::string& bc = buf.str(); /* and then into a malloc()-ed block */ size_t bclen = bc.size(); unsigned char *bytes = (unsigned char *)malloc(bclen); if (!bytes) return NULL; memcpy(bytes, bc.data(), bclen); /* return */ *lenp = bclen; return bytes; } /* Return 0 on failure (with errmsg filled in), 1 on success. */ unsigned LLVMLoadLibraryPermanently(const char* filename, char **errmsg) { assert(filename); assert(errmsg); /* Note: the LLVM API returns true on failure. Don't ask why. */ std::string msg; if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(filename, &msg)) { *errmsg = strdup(msg.c_str()); return 0; } return 1; } void *LLVMGetPointerToFunction(LLVMExecutionEngineRef ee, LLVMValueRef fn) { llvm::ExecutionEngine *eep = llvm::unwrap(ee); assert(eep); llvm::Function *fnp = llvm::unwrap(fn); assert(fnp); return eep->getPointerToFunction(fnp); } int LLVMInlineFunction(LLVMValueRef call) { llvm::Value *callp = llvm::unwrap(call); assert(callp); llvm::CallSite cs = llvm::CallSite(callp); llvm::InlineFunctionInfo unused; return llvm::InlineFunction(cs, unused); } #if HS_LLVM_VERSION >= 300 // Emits an object file based on the host system's machine specification. // The object is emitted to the filename given as an argument. bool LLVMAddEmitObjectPass (LLVMModuleRef modRef, const char* filename) { llvm::InitializeAllTargetInfos (); llvm::InitializeAllTargets (); llvm::InitializeAllTargetMCs (); llvm::InitializeNativeTarget (); llvm::InitializeAllAsmPrinters (); // will be true post 3.0 I think std::string triple = llvm::sys::getDefaultTargetTriple (); // std::string triple = llvm::sys::getHostTriple (); std::string err; const llvm::Target* Target = llvm::TargetRegistry::lookupTarget (triple, err); std::string cpu = llvm::sys::getHostCPUName (); std::string features = ""; // llvm::StringMap featureMap (10); // // this returns false at the moment, but it appears to not make a huge difference // // as the next iteration just doesn't do anything. // llvm::sys::getHostCPUFeatures (featureMap); // for ( llvm::StringMap ::const_iterator it = featureMap.begin (); // it != featureMap.end (); // ++it) { // if (it->second) { // features += it->first.str() + " "; // } // } llvm::TargetMachine *machine = Target->createTargetMachine (triple, cpu, features, llvm::TargetOptions()); llvm::PassManager pass_manager; pass_manager.add(new llvm::DataLayout (*machine->getDataLayout())); std::string outfile_err; llvm::raw_fd_ostream raw_out (filename, outfile_err); llvm::formatted_raw_ostream out (raw_out); if (machine->addPassesToEmitFile (pass_manager, out, llvm::TargetMachine::CGFT_ObjectFile, false)) return false; llvm::Module *mod = llvm::unwrap (modRef); pass_manager.run (*mod); return true; } #endif /* Passes. A few passes (listed below) are used directly from LLVM-C, * rest are defined here. */ #define define_pass(P) \ void LLVMAdd ## P ## Pass (LLVMPassManagerRef passmgr) { \ using namespace llvm; \ llvm::PassManagerBase *pmp = llvm::unwrap(passmgr); \ assert(pmp); \ pmp->add( create ## P ## Pass ()); \ } define_pass( AAEval ) define_pass( AliasAnalysisCounter ) define_pass( AlwaysInliner ) // Name conflicts with those in LLVM proper, have a safer prefix? // define_pass( BasicAliasAnalysis ) define_pass( BlockPlacement ) define_pass( BreakCriticalEdges ) define_pass( CodeGenPrepare ) #if HS_LLVM_VERSION < 303 define_pass( DbgInfoPrinter ) #endif define_pass( DeadCodeElimination ) define_pass( DeadInstElimination ) define_pass( DemoteRegisterToMemory ) define_pass( DomOnlyPrinter ) define_pass( DomOnlyViewer ) define_pass( DomPrinter ) define_pass( DomViewer ) define_pass( DependenceAnalysis ) define_pass( EdgeProfiler ) define_pass( GlobalsModRef ) define_pass( InstCount ) define_pass( InstructionNamer ) define_pass( LazyValueInfo ) define_pass( LCSSA ) define_pass( LoopExtractor ) define_pass( LoopSimplify ) define_pass( LoopStrengthReduce ) define_pass( LowerInvoke ) define_pass( LowerSwitch ) define_pass( MergeFunctions ) define_pass( NoAA ) define_pass( NoProfileInfo ) define_pass( OptimalEdgeProfiler ) define_pass( PartialInlining ) define_pass( PostDomOnlyPrinter ) define_pass( PostDomOnlyViewer ) define_pass( PostDomPrinter ) define_pass( PostDomViewer ) define_pass( ProfileEstimator ) define_pass( ProfileLoader ) define_pass( ProfileVerifier ) define_pass( ScalarEvolutionAliasAnalysis ) define_pass( SingleLoopExtractor ) define_pass( StripNonDebugSymbols ) define_pass( UnifyFunctionExitNodes ) define_pass( Internalize ) /* we support only internalize(true) */ llvm::ModulePass *createInternalize2Pass() { return llvm::createInternalizePass(); } define_pass( Internalize2 ) #if HS_LLVM_VERSION < 302 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage) { std::string error; llvm::raw_fd_ostream dest(Filename, error); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; } llvm::unwrap(M)->print(dest, NULL); if (!error.empty()) { *ErrorMessage = strdup(error.c_str()); return true; } dest.flush(); return false; } #endif #if HS_LLVM_VERSION < 303 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange( const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator) { return wrap(llvm::MemoryBuffer::getMemBuffer( llvm::StringRef(InputData, InputDataLength), llvm::StringRef(BufferName), RequiresNullTerminator)); } LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy( const char *InputData, size_t InputDataLength, const char *BufferName) { return wrap(llvm::MemoryBuffer::getMemBufferCopy( llvm::StringRef(InputData, InputDataLength), llvm::StringRef(BufferName))); } #endif llvm-base-3.2.0.0/tools/0000755000000000000000000000000012142503271013057 5ustar0000000000000000llvm-base-3.2.0.0/tools/FunctionMangulation.hs0000644000000000000000000000420212142503271017375 0ustar0000000000000000module FunctionMangulation ( pattern , rewrite , rewriteFunction ) where import Control.Monad (forM) import Data.Char (isSpace, toLower) import Data.List (intercalate, isPrefixOf, isSuffixOf) import Text.Regex.Posix ((=~), (=~~)) pattern :: String pattern = "^([A-Za-z0-9_ ]+ ?\\*?)[ \t\n]*" ++ "LLVM([A-Za-z0-9_]+)\\(([a-zA-Z0-9_*, \t\n]+)\\);" dropSpace :: String -> String dropSpace = dropWhile isSpace renameType :: String -> String renameType t | "LLVM" `isPrefixOf` t = rename' (drop 4 t) | otherwise = rename' t where rename' "int" = "CInt" rename' "unsigned" = "CUInt" rename' "long long" = "CLLong" rename' "unsigned long long" = "CULLong" rename' "void" = "()" rename' "const char *" = "CString" rename' "char *" = "CString" rename' s | "*" `isSuffixOf` s = pointer s | otherwise = strip s pointer p = case reverse p of ('*':ps) -> "(Ptr " ++ rename' (reverse ps) ++ ")" _ -> p split :: (a -> Bool) -> [a] -> [[a]] split p xs = case break p xs of (h,(_:t)) -> h : split p t (s,_) -> [s] strip :: String -> String strip = reverse . dropWhile isSpace . reverse . dropSpace dropName :: String -> String dropName s = case s =~ "^((const )?[A-Za-z0-9_]+( \\*+)?) ?[A-Za-z0-9]*$" of ((_:typ:_):_) -> typ _ -> "{- oops! -} " ++ s rewriteFunction :: String -> String -> String -> String rewriteFunction cret cname cparams = let ret = "IO " ++ renameType (strip cret) params = map renameParam . split (==',') $ cparams params' = if params == ["()"] then [] else params name = let (n:ame) = cname in toLower n : ame in foreign ++ "\"LLVM" ++ cname ++ "\" " ++ name ++ "\n :: " ++ intercalate " -> " (params' ++ [ret]) where renameParam = renameType . dropName . strip foreign = "foreign import ccall unsafe " rewrite :: Monad m => String -> m [String] rewrite s = do matches <- s =~~ pattern forM matches $ \(_:cret:cname:cparams:_) -> return (rewriteFunction cret cname cparams) llvm-base-3.2.0.0/tools/DiffFFI.hs0000644000000000000000000000243712142503271014616 0ustar0000000000000000module DiffFFI (main) where import Control.Monad (forM_) import Data.List (foldl') import qualified Data.Map as M import System.Environment (getArgs) import System.Exit (exitFailure) import System.IO (hPutStrLn, stderr) import Text.Regex.Posix ((=~)) import FunctionMangulation (pattern, rewriteFunction) cFunctions :: String -> M.Map String String cFunctions s = foldl' go M.empty (s =~ pattern) where go m (_:ret:name:params:_) = M.insert ("LLVM" ++ name) (rewriteFunction ret name params) m go m _ = m hsFunctions :: String -> M.Map String String hsFunctions s = foldl' go M.empty (s =~ pat) where pat = "\"([a-zA-Z0-9_]+)\"[ \t\n]+([a-zA-Z0-9_']+)" go m (_:cname:hsname:_) = M.insert cname hsname m go m _ = m main :: IO () main = do args <- getArgs case args of [cFile, hsFile] -> do c <- cFunctions `fmap` readFile cFile hs <- hsFunctions `fmap` readFile hsFile putStrLn "In C, not Haskell:" forM_ (M.toAscList $ M.difference c hs) $ \(_, hsfunc) -> putStrLn hsfunc putStrLn "In Haskell, not C:" forM_ (M.keys $ M.difference hs c) $ putStrLn . (" "++) _ -> do hPutStrLn stderr "Usage: DiffFFI cFile hsFile" exitFailure llvm-base-3.2.0.0/tools/FunctionMangler.hs0000644000000000000000000000030012142503271016477 0ustar0000000000000000module FunctionMangler (main) where import Data.List (intercalate) import FunctionMangulation (rewrite) main :: IO () main = interact (intercalate "\n\n" . concat . rewrite) >> putStr "\n" llvm-base-3.2.0.0/tools/Makefile0000644000000000000000000000033312142503271014516 0ustar0000000000000000ghc := ghc ghcflags := -O -Wall -Werror tools := DiffFFI FunctionMangler IntrinsicMangler all: $(tools) %: %.hs $(ghc) $(ghcflags) --make -o $@ -main-is $(basename $<).main $< clean: -rm -f *.o *.hi $(tools) *.exe llvm-base-3.2.0.0/tools/IntrinsicMangler.hs0000644000000000000000000000131612142503271016664 0ustar0000000000000000module IntrinsicMangler (main) where import Control.Monad (forM_) import qualified Data.ByteString.Char8 as C import Data.Maybe (catMaybes) import Text.Regex.Posix ((=~~)) maybeName :: C.ByteString -> Maybe C.ByteString maybeName line = do ((_:name:_):_) <- line =~~ "^[ \t]*([a-z0-9_]+),[ \t]*//[ \t]*llvm\\." return name main :: IO () main = do input <- (catMaybes . map maybeName . C.lines) `fmap` C.getContents putStrLn "-- automatically generated file - do not edit!" putStrLn "module LLVM.Core.Intrinsics (Intrinsic(..)) where" putStrLn "data Intrinsic =" putStrLn " NotIntrinsic" forM_ input $ C.putStrLn . (C.append (C.pack " | I_")) putStrLn " deriving (Eq, Ord, Enum, Show)" llvm-base-3.2.0.0/include/0000755000000000000000000000000012142503271013342 5ustar0000000000000000llvm-base-3.2.0.0/include/hs_llvm_config.h.in0000644000000000000000000000347612142503271017123 0ustar0000000000000000/* include/hs_llvm_config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `LLVMCore' library (-lLLVMCore). */ #undef HAVE_LIBLLVMCORE /* Define to 1 if you have the header file. */ #undef HAVE_LLVM_ADT_STRINGREF_H /* Define to 1 if you have the header file. */ #undef HAVE_LLVM_C_CORE_H /* Define to 1 if you have the header file. */ #undef HAVE_LLVM_SUPPORT_DYNAMICLIBRARY_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the version of LLVM, e.g. 209 for 2.9. */ #undef HS_LLVM_VERSION /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS llvm-base-3.2.0.0/include/extra.h0000644000000000000000000002373312142503271014646 0ustar0000000000000000/* * Copyright (c) 2008-10, Mahadevan R All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of this software, nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * These are some "extra" functions not available in the standard LLVM-C * bindings, but are required / good-to-have inorder to implement the * Python bindings. */ #ifndef LLVM_PY_EXTRA_H #define LLVM_PY_EXTRA_H #ifdef __cplusplus extern "C" { #endif /* Notes: * - Some returned strings must be disposed of by LLVMDisposeMessage. These are * indicated in the comments. Where it is not indicated, DO NOT call dispose. */ /* Wraps the LLVMInitializeTarget macro from Target.h */ unsigned LLVMInitNativeTarget(void); /* Wraps llvm::Module::print(). Dispose the returned string after use, via * LLVMDisposeMessage(). */ char *LLVMDumpModuleToString(LLVMModuleRef module); /* Wraps llvm::Type::print(). Dispose the returned string after use, via * LLVMDisposeMessage(). */ char *LLVMDumpTypeToString(LLVMTypeRef type); /* Wraps llvm::Value::print(). Dispose the returned string after use, via * LLVMDisposeMessage(). */ char *LLVMDumpValueToString(LLVMValueRef Val); /* Wraps llvm::IRBuilder::CreateRet(). */ LLVMValueRef LLVMBuildRetMultiple(LLVMBuilderRef bulder, LLVMValueRef *values, unsigned n_values); /* Wraps llvm::IRBuilder::CreateGetResult(). */ LLVMValueRef LLVMBuildGetResult(LLVMBuilderRef builder, LLVMValueRef value, unsigned index, const char *name); /* Wraps llvm::Value::getValueID(). */ unsigned LLVMValueGetID(LLVMValueRef value); /* Wraps llvm::Value::getNumUses(). */ unsigned LLVMValueGetNumUses(LLVMValueRef value); /* Wraps llvm::Value::use_{begin,end}. Allocates LLVMValueRef's as * required. Number of objects are returned as return value. If that is * greater than zero, the pointer given out must be freed by a * subsequent call to LLVMDisposeValueRefArray(). */ unsigned LLVMValueGetUses(LLVMValueRef value, LLVMValueRef **refs); /* Wraps llvm::Value::isUsedInBasicBlock(). */ unsigned LLVMValueIsUsedInBasicBlock(LLVMValueRef value, LLVMBasicBlockRef bb); /* See above. */ void LLVMDisposeValueRefArray(LLVMValueRef *refs); /* Wraps llvm:User::getNumOperands(). */ unsigned LLVMUserGetNumOperands(LLVMValueRef user); /* Wraps llvm:User::getOperand(). */ LLVMValueRef LLVMUserGetOperand(LLVMValueRef user, unsigned idx); /* Wraps llvm::ConstantExpr::getVICmp(). */ LLVMValueRef LLVMConstVICmp(LLVMIntPredicate predicate, LLVMValueRef lhs, LLVMValueRef rhs); /* Wraps llvm::ConstantExpr::getVFCmp(). */ LLVMValueRef LLVMConstVFCmp(LLVMRealPredicate predicate, LLVMValueRef lhs, LLVMValueRef rhs); /* Wraps llvm::IRBuilder::CreateVICmp(). */ LLVMValueRef LLVMBuildVICmp(LLVMBuilderRef builder, LLVMIntPredicate predicate, LLVMValueRef lhs, LLVMValueRef rhs, const char *name); /* Wraps llvm::IRBuilder::CreateVFCmp(). */ LLVMValueRef LLVMBuildVFCmp(LLVMBuilderRef builder, LLVMRealPredicate predicate, LLVMValueRef lhs, LLVMValueRef rhs, const char *name); /* Wraps llvm::Intrinsic::getDeclaration(). */ LLVMValueRef LLVMGetIntrinsic(LLVMModuleRef builder, int id, LLVMTypeRef *types, unsigned n_types); /* Wraps llvm::Module::getPointerSize(). */ unsigned LLVMModuleGetPointerSize(LLVMModuleRef module); /* Wraps llvm::Module::getOrInsertFunction(). */ LLVMValueRef LLVMModuleGetOrInsertFunction(LLVMModuleRef module, const char *name, LLVMTypeRef function_type); /* Wraps llvm::GlobalVariable::hasInitializer(). */ int LLVMHasInitializer(LLVMValueRef global_var); /* The following functions wrap various llvm::Instruction::isXXX() functions. * All of them take an instruction and return 0 (isXXX returned false) or 1 * (isXXX returned false). */ unsigned LLVMInstIsTerminator (LLVMValueRef inst); unsigned LLVMInstIsBinaryOp (LLVMValueRef inst); unsigned LLVMInstIsShift (LLVMValueRef inst); unsigned LLVMInstIsCast (LLVMValueRef inst); unsigned LLVMInstIsLogicalShift (LLVMValueRef inst); unsigned LLVMInstIsArithmeticShift (LLVMValueRef inst); unsigned LLVMInstIsAssociative (LLVMValueRef inst); unsigned LLVMInstIsCommutative (LLVMValueRef inst); unsigned LLVMInstIsTrapping (LLVMValueRef inst); /* As above, but these are wrap methods from subclasses of Instruction. */ unsigned LLVMInstIsVolatile (LLVMValueRef inst); /* Wraps llvm::Instruction::getOpcodeName(). */ const char *LLVMInstGetOpcodeName(LLVMValueRef inst); /* Wraps llvm::Instruction::getOpcode(). */ unsigned LLVMInstGetOpcode(LLVMValueRef inst); /* Wraps llvm::CmpInst::getPredicate(). */ unsigned LLVMCmpInstGetPredicate(LLVMValueRef cmpinst); /* Wraps llvm::ParseAssemblyString(). Returns a module reference or NULL (with * `out' pointing to an error message). Dispose error message after use, via * LLVMDisposeMessage(). */ LLVMModuleRef LLVMGetModuleFromAssembly(const char *asmtxt, unsigned txten, char **out); /* Wraps llvm::ParseBitcodeFile(). Returns a module reference or NULL (with * `out' pointing to an error message). Dispose error message after use, via * LLVMDisposeMessage(). */ LLVMModuleRef LLVMGetModuleFromBitcode(const char *bc, unsigned bclen, char **out); #if HS_LLVM_VERSION < 302 /* Wraps llvm::Linker::LinkModules(). Returns 0 on failure (with errmsg * filled in) and 1 on success. Dispose error message after use with * LLVMDisposeMessage(). */ unsigned LLVMLinkModules(LLVMModuleRef dest, LLVMModuleRef src, unsigned mode, char **errmsg); #endif /* Returns pointer to a heap-allocated block of `*len' bytes containing bit code * for the given module. NULL on error. */ unsigned char *LLVMGetBitcodeFromModule(LLVMModuleRef module, unsigned *len); /* Wraps llvm::sys::DynamicLibrary::LoadLibraryPermanently(). Returns 0 on * failure (with errmsg filled in) and 1 on success. Dispose error message after * use, via LLVMDisposeMessage(). */ unsigned LLVMLoadLibraryPermanently(const char* filename, char **errmsg); /* Wraps llvm::ExecutionEngine::getPointerToFunction(). Returns a pointer * to the JITted function. */ void *LLVMGetPointerToFunction(LLVMExecutionEngineRef ee, LLVMValueRef fn); /* Wraps llvm::InlineFunction(). Inlines a function. C is the call * instruction, created by LLVMBuildCall. Even if it fails, the Function * containing the call is still in a proper state (not changed). */ int LLVMInlineFunction(LLVMValueRef call); #if HS_LLVM_VERSION >= 300 bool LLVMAddEmitObjectPass (LLVMModuleRef modRef, const char* filename); #endif /* Passes. Some passes are used directly from LLVM-C, rest are declared * here. */ #define declare_pass(P) \ void LLVMAdd ## P ## Pass (LLVMPassManagerRef PM); declare_pass( AAEval ) declare_pass( AliasAnalysisCounter ) declare_pass( AlwaysInliner ) // Name conflicts with those in LLVM proper, have a safer prefix? // declare_pass( BasicAliasAnalysis ) declare_pass( BlockPlacement ) declare_pass( BreakCriticalEdges ) declare_pass( CodeGenPrepare ) declare_pass( DbgInfoPrinter ) declare_pass( DeadCodeElimination ) declare_pass( DeadInstElimination ) declare_pass( DemoteRegisterToMemory ) declare_pass( DomOnlyPrinter ) declare_pass( DomOnlyViewer ) declare_pass( DomPrinter ) declare_pass( DomViewer ) declare_pass( EdgeProfiler ) declare_pass( GlobalsModRef ) declare_pass( InstCount ) declare_pass( InstructionNamer ) declare_pass( LazyValueInfo ) declare_pass( LCSSA ) declare_pass( LoopDependenceAnalysis ) declare_pass( LoopExtractor ) declare_pass( LoopSimplify ) declare_pass( LoopStrengthReduce ) declare_pass( LowerInvoke ) declare_pass( LowerSwitch ) declare_pass( MergeFunctions ) declare_pass( NoAA ) declare_pass( NoProfileInfo ) declare_pass( OptimalEdgeProfiler ) declare_pass( PartialInlining ) declare_pass( PostDomOnlyPrinter ) declare_pass( PostDomOnlyViewer ) declare_pass( PostDomPrinter ) declare_pass( PostDomViewer ) declare_pass( ProfileEstimator ) declare_pass( ProfileLoader ) declare_pass( ProfileVerifier ) declare_pass( ScalarEvolutionAliasAnalysis ) declare_pass( SingleLoopExtractor ) declare_pass( StripNonDebugSymbols ) declare_pass( StructRetPromotion ) declare_pass( TailDuplication ) declare_pass( UnifyFunctionExitNodes ) declare_pass( Internalize2 ) #if HS_LLVM_VERSION < 302 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage); #endif #if HS_LLVM_VERSION < 303 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange( const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator); LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy( const char *InputData, size_t InputDataLength, const char *BufferName); #endif #ifdef __cplusplus } /* extern "C" */ #endif #endif /* LLVM_PY_EXTRA_H */ llvm-base-3.2.0.0/include/support.h0000644000000000000000000000107012142503271015225 0ustar0000000000000000#ifndef LLVM_HS_SUPPORT_H #define LLVM_HS_SUPPORT_H #ifdef __cplusplus extern "C" { #endif void LLVMCreateStandardFunctionPasses(LLVMPassManagerRef PM, unsigned OptimizationLevel); void LLVMCreateStandardModulePasses(LLVMPassManagerRef PM, unsigned OptimizationLevel, int OptimizeSize, int UnitAtATime, int UnrollLoops, int SimplifyLibCalls, int HaveExceptions, int DisableInlining); void LLVMDisablePrettyStackTrace(); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* LLVM_HS_SUPPORT_H */