mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 05:32:25 +00:00
Moved these files to "SmallExamples" directory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e784fa40c5
commit
903990df33
@ -1,109 +0,0 @@
|
|||||||
//===--- HowToUseJIT.cpp - An example use of the JIT ----------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file was developed by Valery A. Khamenya and is distributed under the
|
|
||||||
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// This small program provides an example of how to quickly build a small
|
|
||||||
// module with two functions and execute it with the JIT.
|
|
||||||
//
|
|
||||||
// Goal:
|
|
||||||
// The goal of this snippet is to create in the memory
|
|
||||||
// the LLVM module consisting of two functions as follow:
|
|
||||||
//
|
|
||||||
// int add1(int x) {
|
|
||||||
// return x+1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int foo() {
|
|
||||||
// return add1(10);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// then compile the module via JIT, then execute the `foo'
|
|
||||||
// function and return result to a driver, i.e. to a "host program".
|
|
||||||
//
|
|
||||||
// Some remarks and questions:
|
|
||||||
//
|
|
||||||
// - could we invoke some code using noname functions too?
|
|
||||||
// e.g. evaluate "foo()+foo()" without fears to introduce
|
|
||||||
// conflict of temporary function name with some real
|
|
||||||
// existing function name?
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include "llvm/Module.h"
|
|
||||||
#include "llvm/Constants.h"
|
|
||||||
#include "llvm/Type.h"
|
|
||||||
#include "llvm/Instructions.h"
|
|
||||||
#include "llvm/ModuleProvider.h"
|
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
|
||||||
#include "llvm/ExecutionEngine/GenericValue.h"
|
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
// Create some module to put our function into it.
|
|
||||||
Module *M = new Module("test");
|
|
||||||
|
|
||||||
// Create the add1 function entry and insert this entry into module M. The
|
|
||||||
// function will have a return type of "int" and take an argument of "int".
|
|
||||||
// The '0' terminates the list of argument types.
|
|
||||||
Function *Add1F = M->getOrInsertFunction("add1", Type::IntTy, Type::IntTy, 0);
|
|
||||||
|
|
||||||
// Add a basic block to the function. As before, it automatically inserts
|
|
||||||
// because of the last argument.
|
|
||||||
BasicBlock *BB = new BasicBlock("EntryBlock", Add1F);
|
|
||||||
|
|
||||||
// Get pointers to the constant `1'.
|
|
||||||
Value *One = ConstantSInt::get(Type::IntTy, 1);
|
|
||||||
|
|
||||||
// Get pointers to the integer argument of the add1 function...
|
|
||||||
assert(Add1F->abegin() != Add1F->aend()); // Make sure there's an arg
|
|
||||||
Argument *ArgX = Add1F->abegin(); // Get the arg
|
|
||||||
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
|
|
||||||
|
|
||||||
// Create the add instruction, inserting it into the end of BB.
|
|
||||||
Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB);
|
|
||||||
|
|
||||||
// Create the return instruction and add it to the basic block
|
|
||||||
new ReturnInst(Add, BB);
|
|
||||||
|
|
||||||
// Now, function add1 is ready.
|
|
||||||
|
|
||||||
|
|
||||||
// Now we going to create function `foo', which returns an int and takes no
|
|
||||||
// arguments.
|
|
||||||
Function *FooF = M->getOrInsertFunction("foo", Type::IntTy, 0);
|
|
||||||
|
|
||||||
// Add a basic block to the FooF function.
|
|
||||||
BB = new BasicBlock("EntryBlock", FooF);
|
|
||||||
|
|
||||||
// Get pointers to the constant `10'.
|
|
||||||
Value *Ten = ConstantSInt::get(Type::IntTy, 10);
|
|
||||||
|
|
||||||
// Pass Ten to the call call:
|
|
||||||
std::vector<Value*> Params;
|
|
||||||
Params.push_back(Ten);
|
|
||||||
CallInst * Add1CallRes = new CallInst(Add1F, Params, "add1", BB);
|
|
||||||
|
|
||||||
// Create the return instruction and add it to the basic block.
|
|
||||||
new ReturnInst(Add1CallRes, BB);
|
|
||||||
|
|
||||||
// Now we create the JIT.
|
|
||||||
ExistingModuleProvider* MP = new ExistingModuleProvider(M);
|
|
||||||
ExecutionEngine* EE = ExecutionEngine::create(MP, false);
|
|
||||||
|
|
||||||
std::cout << "We just constructed this LLVM module:\n\n" << *M;
|
|
||||||
std::cout << "\n\nRunning foo: " << std::flush;
|
|
||||||
|
|
||||||
// Call the `foo' function with no arguments:
|
|
||||||
std::vector<GenericValue> noargs;
|
|
||||||
GenericValue gv = EE->runFunction(FooF, noargs);
|
|
||||||
|
|
||||||
// Import result of execution:
|
|
||||||
std::cout << "Result: " << gv.IntVal << "\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
##===- projects/HowToUseJIT/Makefile -----------------------*- Makefile -*-===##
|
|
||||||
#
|
|
||||||
# The LLVM Compiler Infrastructure
|
|
||||||
#
|
|
||||||
# This file was developed by Valery A. Khamenya and is distributed under
|
|
||||||
# the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
||||||
#
|
|
||||||
##===----------------------------------------------------------------------===##
|
|
||||||
LEVEL = ../..
|
|
||||||
TOOLNAME = HowToUseJIT
|
|
||||||
USEDLIBS = lli-jit lli-interpreter codegen executionengine x86 selectiondag \
|
|
||||||
scalaropts analysis.a transformutils.a bcreader target.a vmcore \
|
|
||||||
support.a
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
|
@ -1,27 +0,0 @@
|
|||||||
##===- projects/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.
|
|
||||||
#
|
|
||||||
##===----------------------------------------------------------------------===##
|
|
||||||
#
|
|
||||||
# This is a sample Makefile for a project that uses LLVM.
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
@ -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/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
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// ModuleMaker Sample project
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
This project is a extremely simple example of two things: building an LLVM
|
|
||||||
"project" and using some simple pieces of the LLVM API. The actual executable
|
|
||||||
generated by this project simply emits an LLVM bytecode file to standard output.
|
|
||||||
It is designed to show some basic usage of LLVM APIs, and how to link to LLVM
|
|
||||||
libraries.
|
|
@ -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.
|
|
||||||
|
|
6168
projects/ModuleMaker/autoconf/aclocal.m4
vendored
6168
projects/ModuleMaker/autoconf/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
1388
projects/ModuleMaker/autoconf/config.guess
vendored
1388
projects/ModuleMaker/autoconf/config.guess
vendored
File diff suppressed because it is too large
Load Diff
1489
projects/ModuleMaker/autoconf/config.sub
vendored
1489
projects/ModuleMaker/autoconf/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -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)
|
|
@ -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
@ -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
|
|
2210
projects/ModuleMaker/configure
vendored
2210
projects/ModuleMaker/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -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
|
|
@ -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
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user