summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in39
-rw-r--r--README6
-rwxr-xr-xconfigure14
-rw-r--r--src/grt/Makefile.inc2
4 files changed, 48 insertions, 13 deletions
diff --git a/Makefile.in b/Makefile.in
index 753fb79..900b380 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -24,6 +24,7 @@ backend=@backend@
libdirsuffix=@libdirsuffix@
libdirreverse=@libdirreverse@
gcc_src_dir=@gcc_src_dir@
+llvm_prefix=@llvm_prefix@
INSTALL_PROGRAM=install -m 755
INSTALL_DATA=install -m 644
@@ -38,7 +39,7 @@ GRT_RANLIB=ranlib
VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)
ADAC=$(CC)
-GNATFLAGS=-gnaty3befhkmr -gnatwael -aO. -g -gnatf -gnat05
+GNATFLAGS=-gnaty3befhkmr -gnata -gnatwael -aO. -g -gnatf -gnat05
GRT_FLAGS=-g
LIB_CFLAGS=-g -O2
@@ -62,8 +63,6 @@ target=$(build)
#target=x86_64-apple-darwin
#target=i386-pc-mingw32
-LLVM_CONFIG=llvm-config
-
all: Makefile all.$(backend)
install: install.$(backend)
@@ -82,7 +81,9 @@ all.mcode: ghdl.mcode libs.vhdl.mcode
GRTSRCDIR=$(srcdir)/src/grt
include $(GRTSRCDIR)/Makefile.inc
-GHDL_MCODE_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/vhdl/translate -aI$(srcdir)/src/ortho/mcode -aI$(srcdir)/src/ortho
+GHDL_COMMON_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/vhdl/translate -aI$(srcdir)/src/ortho
+
+GHDL_MCODE_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho/mcode
ghdl.mcode: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl.mcode: $(GRT_ADD_OBJS) $(ORTHO_DEPS) memsegs_c.o chkstk.o force
@@ -145,19 +146,34 @@ grt.links:
#################### For llvm backend ##############################
+LLVM_CONFIG=$(llvm_prefix)/bin/llvm-config
+
+GHDL_LLVM_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho/llvm
+
+all.llvm: ghdl_llvm_jit
+
ghdl_llvm_jit: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl_llvm_jit: $(GRT_ADD_OBJS) $(ORTHO_DEPS) llvm-cbindings.o force
- $(GNATMAKE) -o $@ -aI../../ortho/llvm -aI../../ortho $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) `$(LLVM_CONFIG) --ldflags --libs --system-libs` -lc++
+ $(GNATMAKE) -o $@ $(GHDL_LLVM_INCFLAGS) $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) `$(LLVM_CONFIG) --ldflags --libs --system-libs` -lc++
-llvm-cbindings.o: ../../ortho/llvm/llvm-cbindings.cpp
+llvm-cbindings.o: $(srcdir)/src/ortho/llvm/llvm-cbindings.cpp
$(CXX) -c -m64 `$(LLVM_CONFIG) --includedir --cxxflags` -g -o $@ $<
+ghdl_llvm: force
+ $(GNATMAKE) $(GHDL_LLVM_INCFLAGS) -aI$(srcdir)/src/ghdldrv $(GNATFLAGS)\
+ ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS)
+
+ghdl1-llvm: force
+ $(MAKE) -f $(srcdir)/src/ortho/llvm/Makefile \
+ ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
+ GNAT_FLAGS="$(GHDL_LLVM_INCFLAGS) $(GNATFLAGS)" \
+ LLVM_CONFIG="$(LLVM_CONFIG)" all
+
+################ For simul (no code generation, interpretation) ##########
+
ghdl_simul: $(GRT_ADD_OBJS) force
$(GNATMAKE) -aI../../simulate $(GNATFLAGS) ghdl_simul $(GNAT_BARGS) -largs $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
-ghdl_llvm: force
- $(GNATMAKE) $(GNATFLAGS) ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS)
-
################ Libraries ###############################################
LIB87_DIR:=$(libdirsuffix)/v87
@@ -224,9 +240,12 @@ libs.vhdl.mcode: libs.vhdl.all
libs.vhdl.simul:
$(MAKE) GHDL=ghdl_simul libs.vhdl.all
+libs.vhdl.llvmjit:
+ $(MAKE) GHDL=ghdl_llvm_jit libs.vhdl.all
+
libs.vhdl.llvm:
$(MAKE) GHDL=ghdl_llvm libs.vhdl.all
- $(MAKE) GHDL1=./ghdl1-llvm lib.vhdl.standard
+ $(MAKE) GHDL1=./ghdl1-llvm libs.vhdl.standard
install.dirs:
[ -d $(DESTDIR)$(prefix) ] || $(MKDIR) -p $(DESTDIR)$(prefix)
diff --git a/README b/README
index b02f1ff..4c34319 100644
--- a/README
+++ b/README
@@ -78,7 +78,11 @@ The configure gcc following the gcc instructions and also enable vhdl
languages (you can use --enable-languages=c,vhdl --disable-bootstrap)
* Building with the llvm backend
-TODO
+You need llvm 3.5
+
+First configure ghdl and specify where llvm is installed
+$ ./configure --with-llvm=PREFIX
+ where PREFIX/bin/llvm-config is present
Notes for developpers
*********************
diff --git a/configure b/configure
index e869495..ca9baa0 100755
--- a/configure
+++ b/configure
@@ -12,12 +12,13 @@ libdirsuffix=lib/ghdl
libdirreverse=../..
gcc_src_dir=
gcc_version=unknown
+llvm_prefix=
build=
show_help=no
progname=$0
-subst_vars="CC GNATMAKE CFLAGS build srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir"
+subst_vars="CC GNATMAKE CFLAGS build srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir llvm_prefix"
# Find srcdir
srcdir=`dirname $progname`
@@ -49,6 +50,7 @@ for opt do
--prefix=*) prefix="$optarg";;
--srcdir=*) srcdir="$optarg";;
--with-gcc=*) gcc_src_dir="$optarg"; backend=gcc;;
+ --with-llvm=*) llvm_prefix="$optarg"; backend=llvm;;
-h|-help|--help) show_help=yes;;
*) echo "$0: unknown option $opt; try $0 --help"
exit 1
@@ -65,6 +67,7 @@ Options [defaults in brackets]:
--prefix=PREFIX install in PREFIX [$prefix]
--srcdir=SRCDIR source code path [$srcdir]
--with-gcc=DIR use gcc backend from DIR (needs gcc $gcc_version)
+ --with-llvm=DIR use llvm installed in DIR
EOF
exit 0
fi
@@ -105,6 +108,15 @@ if test $backend = gcc; then
fi
fi
+# For llvm backend, check llvm-config
+if test $backend = llvm; then
+ llvm_cmd="$llvm_prefix/bin/llvm-config --version"
+ if ! $llvm_cmd 2> /dev/null; then
+ echo "cannot run $llvm_cmd"
+ exit 1
+ fi
+fi
+
# Compute build machine
if test x$build = x; then
build=`$CC $CFLAGS -dumpmachine`
diff --git a/src/grt/Makefile.inc b/src/grt/Makefile.inc
index ec1b0df..bc59bb5 100644
--- a/src/grt/Makefile.inc
+++ b/src/grt/Makefile.inc
@@ -123,7 +123,7 @@ libgrt.a: $(GRT_ADD_OBJS) run-bind.o main.o grt-files # grt-arch.ads
$(GRT_RANLIB) $@
run-bind.adb: grt-force
- gnatmake -c $(GNATFLAGS) -aI$(GRTSRCDIR) $(GRT_PRAGMA_FLAG) \
+ gnatmake -c -aI$(GRTSRCDIR) $(GRT_PRAGMA_FLAG) \
ghdl_main $(GRT_ADAFLAGS) -cargs $(GRT_FLAGS)
gnatbind -Lgrt_ -o run-bind.adb -n ghdl_main.ali