Moved small examples from /projects/SmallExamples to /examples.

Made the "ModuleMaker" into an example since its just one source file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16003 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-08-23 19:29:54 +00:00
parent 157b956e42
commit 3a168a7d68
17 changed files with 10 additions and 18134 deletions

View File

@ -6,7 +6,7 @@
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LEVEL = ../..
TOOLNAME = Fibonacci
USEDLIBS = lli-jit lli-interpreter codegen executionengine x86 selectiondag \
scalaropts analysis.a transformutils.a bcreader target.a vmcore \

View File

@ -6,7 +6,7 @@
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LEVEL = ../..
TOOLNAME = HowToUseJIT
USEDLIBS = lli-jit lli-interpreter codegen executionengine x86 selectiondag \
scalaropts analysis.a transformutils.a bcreader target.a vmcore \

View File

@ -6,10 +6,11 @@
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL=../..
LEVEL=..
include $(LEVEL)/Makefile.config
DIRS:= $(patsubst %/Makefile,%,$(wildcard $(SourceDir)/*/Makefile))
#PARALLEL_DIRS:= $(patsubst %/Makefile,%,$(wildcard $(SourceDir)/*/Makefile))
PARALLEL_DIRS:= Fibonacci HowToUseJIT ModuleMaker
include $(BUILD_SRC_ROOT)/Makefile.rules
include $(LEVEL)/Makefile.common

View File

@ -1,4 +1,4 @@
##===- projects/ModuleMaker/Makefile -----------------------*- Makefile -*-===##
##===- examples/ModuleMaker --------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
@ -6,22 +6,8 @@
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is a sample Makefile for a project that uses LLVM.
#
LEVEL=../..
TOOLNAME=ModuleMaker
USEDLIBS= bcwriter vmcore support.a
#
# Indicates our relative path to the top of the project's root directory.
#
LEVEL = .
#
# Directories that needs to be built.
#
DIRS = tools
#
# Include the Master Makefile that knows how to build all.
#
include $(LEVEL)/Makefile.common

View File

@ -1,23 +0,0 @@
#
# Configure the location of the LLVM object root. We know it is two
# directories up. The source tree location we do not know; let the LLVM
# Makefiles find it for us.
#
LLVM_OBJ_ROOT=$(LEVEL)/../../..
#
# Grab the LLVM configuration file.
#
include $(LEVEL)/../../../Makefile.config
#
# Reconfigure the source directories
#
BUILD_SRC_ROOT:=$(LLVM_SRC_ROOT)/projects/SmallExamples/ModuleMaker
BUILD_SRC_DIR := $(subst //,/,$(BUILD_SRC_ROOT)/$(patsubst $(BUILD_OBJ_ROOT)%,%,$(BUILD_OBJ_DIR)))
#
# Include LLVM's build rules.
#
include $(LLVM_SRC_ROOT)/Makefile.rules

View File

@ -1,24 +0,0 @@
------------------------------------------------------------------------------
Autoconf Files
------------------------------------------------------------------------------
All autoconf files are licensed under the LLVM license with the following
additions:
llvm/autoconf/install-sh:
This script is licensed under the LLVM license, with the following
additional copyrights and restrictions:
Copyright 1991 by the Massachusetts Institute of Technology
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
Please see the source files for additional copyrights.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +0,0 @@
dnl **************************************************************************
dnl * Initialize
dnl **************************************************************************
AC_INIT([[[ModuleMaker]]],[[[x.xx]]],[bugs@yourdomain])
dnl Place all of the extra autoconf files into the config subdirectory
AC_CONFIG_AUX_DIR([autoconf])
dnl Configure a header file
dnl Configure Makefiles
dnl List every Makefile that exists within your source tree
AC_CONFIG_MAKEFILE(Makefile)
dnl **************************************************************************
dnl * Determine which system we are building on
dnl **************************************************************************
dnl **************************************************************************
dnl * Check for programs.
dnl **************************************************************************
dnl Verify that the source directory is valid
AC_CONFIG_SRCDIR(["Makefile.common.in"])
dnl **************************************************************************
dnl * Check for libraries.
dnl **************************************************************************
dnl **************************************************************************
dnl * Checks for header files.
dnl **************************************************************************
dnl **************************************************************************
dnl * Checks for typedefs, structures, and compiler characteristics.
dnl **************************************************************************
dnl **************************************************************************
dnl * Checks for library functions.
dnl **************************************************************************
dnl **************************************************************************
dnl * Enable various compile-time options
dnl **************************************************************************
dnl **************************************************************************
dnl * Set the location of various third-party software packages
dnl **************************************************************************
dnl Location of LLVM source code
AC_ARG_WITH(llvmsrc,AC_HELP_STRING([--with-llvmsrc],[Location of LLVM Source Code]),AC_SUBST(LLVM_SRC,[$withval]),AC_SUBST(LLVM_SRC,[`cd ${srcdir}/../..; pwd`]))
dnl Location of LLVM object code
AC_ARG_WITH(llvmobj,AC_HELP_STRING([--with-llvmobj],[Location of LLVM Object Code]),AC_SUBST(LLVM_OBJ,[$withval]),AC_SUBST(LLVM_OBJ,[`cd ../..; pwd`]))
dnl **************************************************************************
dnl * Create the output files
dnl **************************************************************************
AC_OUTPUT(Makefile.common)

View File

@ -1,251 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
:
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
:
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
:
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
:
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
:
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
:
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id$
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
# process command line arguments
while test $# -gt 0 ; do
case "${1}" in
-h | --help | --h* ) # -h for help
echo "${usage}" 1>&2; exit 0 ;;
-m ) # -m PERM arg
shift
test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
dirmode="${1}"
shift ;;
-- ) shift; break ;; # stop option processing
-* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
* ) break ;; # first non-opt arg
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
case $dirmode in
'')
if mkdir -p -- . 2>/dev/null; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
fi ;;
*)
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
fi ;;
esac
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=""
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 3
# End:
# mkinstalldirs ends here

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +0,0 @@
##===- projects/ModuleMaker/tools/Makefile -----------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by the LLVM research group and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# Relative path to the top of the source tree.
#
LEVEL=..
#
# List all of the subdirectories that we will compile.
#
DIRS=ModuleMaker
include $(LEVEL)/Makefile.common

View File

@ -1,33 +0,0 @@
##===- projects/ModuleMaker/tools/ModuleMaker/Makefile -----*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by the LLVM research group and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# LEVEL - Indicate where we are relative to the top of the source tree.
#
LEVEL=../..
#
# TOOLNAME = Give the name of the tool.
#
TOOLNAME=ModuleMaker
#
# LLVMLIBS - List LLVM libraries that we'll need
#
LLVMLIBS= bcwriter vmcore support.a
#
# USEDLIBS - List all project local libraries here
#
#USEDLIBS=
#
# Include Makefile.common so we know what to do.
#
include $(LEVEL)/Makefile.common

View File

@ -1,55 +0,0 @@
//===- ModuleMaker.cpp - Example project which creates modules --*- C++ -*-===//
//
// This programs is a simple example that creates an LLVM module "from scratch",
// emitting it as a bytecode file to standard out. This is just to show how
// LLVM projects work and to demonstrate some of the LLVM APIs.
//
//===----------------------------------------------------------------------===//
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/Bytecode/Writer.h"
#include <iostream>
using namespace llvm;
int main() {
// Create the "module" or "program" or "translation unit" to hold the
// function
Module *M = new Module("test");
// Create the main function: first create the type 'int ()'
FunctionType *FT = FunctionType::get(Type::IntTy, std::vector<const Type*>(),
/*not vararg*/false);
// By passing a module as the last parameter to the Function constructor,
// it automatically gets appended to the Module.
Function *F = new Function(FT, Function::ExternalLinkage, "main", M);
// Add a basic block to the function... again, it automatically inserts
// because of the last argument.
BasicBlock *BB = new BasicBlock("EntryBlock", F);
// Get pointers to the constant integers...
Value *Two = ConstantSInt::get(Type::IntTy, 2);
Value *Three = ConstantSInt::get(Type::IntTy, 3);
// Create the add instruction... does not insert...
Instruction *Add = BinaryOperator::create(Instruction::Add, Two, Three,
"addresult");
// explicitly insert it into the basic block...
BB->getInstList().push_back(Add);
// Create the return instruction and add it to the basic block
BB->getInstList().push_back(new ReturnInst(Add));
// Output the bytecode file to stdout
WriteBytecodeToFile(M, std::cout);
// Delete the module and all of its contents.
delete M;
return 0;
}