This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
gcjx llvm backend
- From: Mike Emmel <mike dot emmel at gmail dot com>
- To: java at gcc dot gnu dot org
- Date: Thu, 8 Dec 2005 09:04:27 -0600
- Subject: gcjx llvm backend
Attached is a snapshot of my inital work on a llvm backend for gcjx.
I will not be able to check email agian till Sunday so please forgive
me if I don't respond quickly to questions.
once the patch is applied
run autoconf automake autoheader
autokitchensink :)
you should be able to configure with
./configure --with-llvm=../../llvm
Where llvm is the top dir of the llvm source.
Here is my little script for running
export LD_LIBRARY_PATH=../gcjx-branch/gcjx/.libs:../../llvm/Debug/libs
#(cd ../gcjx-branch/gcjx/gcjx; make)
prg=../gcjx-branch/gcjx/gcjx
rm Main.cgen
$prg -o llvm -bootclasspath ../gcjx-branch/libjava Main.java
And the test file... note I'm generating very little but I do get something.
public class Main {
public static void main( String[] args ) {
int res = add(2,2);
return;
}
static int add( int a, int b ) {
return a+b;
}
}
diff -Nur ../gcjx.original/configure.ac ./configure.ac
--- ../gcjx.original/configure.ac 2005-12-08 06:42:00.000000000 -0600
+++ ./configure.ac 2005-12-08 06:12:41.000000000 -0600
@@ -19,6 +19,30 @@
fi])
+# begin LLVM changed to llvmgen to differ from gcc llvm backend
+AC_ARG_WITH([llvm],
+AC_HELP_STRING([--with-llvm=PATH],[enable the LLVM backend installed in path]),
+ LLVMBASELIBPATH=$withval
+ LLVM_BUILDMODE=Debug
+ AC_DEFINE(ENABLE_LLVM_BACKEND, 1, [enable llvm])
+ AM_CONDITIONAL(ENABLE_LLVM, test xyes = xyes)
+)
+AC_SUBST(LLVMBASELIBPATH)
+AC_SUBST(LLVM_BUILDMODE)
+
+
+AC_ARG_ENABLE(llvmdebug,
+AS_HELP_STRING([--enable-llvmdebug],[use debug version of llvm ]),
+[case ${enableval} in
+ yes) LLVM_BUILDMODE=Debug;;
+ *) LLVM_BUILDMODE=Release;;
+esac])
+AC_SUBST(BUILDMODE)
+
+
+# end LLVM
+
+
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
diff -Nur ../gcjx.original/gcjx-config.h.in ./gcjx-config.h.in
--- ../gcjx.original/gcjx-config.h.in 2005-12-08 06:26:44.000000000 -0600
+++ ./gcjx-config.h.in 2005-12-08 06:55:02.000000000 -0600
@@ -3,6 +3,9 @@
/* Default -bootclasspath */
#undef BOOTCLASSPATH
+/* enable llvm */
+#undef ENABLE_LLVM_BACKEND
+
/* Define to 1 if you have the `iconv' library (-liconv). */
#undef HAVE_LIBICONV
diff -Nur ../gcjx.original/llvm/llvmgen.cc ./llvm/llvmgen.cc
--- ../gcjx.original/llvm/llvmgen.cc 1969-12-31 18:00:00.000000000 -0600
+++ ./llvm/llvmgen.cc 2005-12-08 06:20:25.000000000 -0600
@@ -0,0 +1,877 @@
+// Code generator for llvm.
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of GCC.
+//
+// gcjx is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// gcjx is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with gcjx; see the file COPYING.LIB. If
+// not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "typedefs.hh"
+#include "llvmgen.hh"
+#include "dump.hh"
+
+
+#include "llvm/SymbolTable.h"
+#include "llvm/Module.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/Instructions.h"
+#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
+#include "llvm/Bytecode/Writer.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/DepthFirstIterator.h"
+
+/** Generate C code**/
+#include "llvm/Bytecode/Reader.h"
+#include "llvm/Target/SubtargetFeature.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/Module.h"
+#include "llvm/PassManager.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/PassNameParser.h"
+#include "llvm/Analysis/Verifier.h"
+#include "llvm/System/Signals.h"
+#include "llvm/Config/config.h"
+/** End gnerate c code **/
+
+
+
+#include <list>
+#include <utility>
+#include <algorithm>
+#include <fstream>
+#include <iostream>
+#include <memory>
+
+
+using namespace std;
+using namespace llvm;
+
+// GetFileNameRoot - Helper function to get the basename of a filename.
+static inline string
+GetFileNameRoot(const string &InputFilename) {
+ string IFN = InputFilename;
+ string outputFilename;
+ int Len = IFN.length();
+ if ((Len > 2) &&
+ IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
+ outputFilename = string(IFN.begin(), IFN.end()-3); // s/.bc/.s/
+ } else {
+ outputFilename = IFN;
+ }
+ return outputFilename;
+}
+
+const Type * llvm_code_generator::convertType( model_type *type )
+{
+ if (typemap.find (type) == typemap.end ())
+ {
+ const Type *Ty;
+ assert (type->reference_p ());
+ model_class *klass = assert_cast<model_class *> (type);
+ Ty = OpaqueType::get();
+ module->addTypeName(klass->get_fully_qualified_name (),Ty);
+ //typemap[klass] = TypeDB.setType(type,PointerType::get(Ty));
+ typemap[klass] = PointerType::get(Ty);
+ return typemap[klass];
+ }
+ return typemap[type];
+}
+
+/// CastToType - Cast the specified value to the specified type if it is
+/// not already that type.
+Value *llvm_code_generator::castToType(Value *V, const Type *Ty) {
+ if (V->getType() == Ty) return V;
+ if (Constant *C = dyn_cast<Constant>(V))
+ return ConstantExpr::getCast(C, Ty);
+
+ // Handle cast (cast bool X to T2) to bool as X, because this occurs all over
+ // the place.
+ if (CastInst *CI = dyn_cast<CastInst>(V))
+ if (Ty == Type::BoolTy && CI->getOperand(0)->getType() == Type::BoolTy)
+ return CI->getOperand(0);
+ return new CastInst(V, Ty, V->getName(), currentBlock);
+}
+
+
+/// emitBlock - Add the specified basic block to the end of the function. If
+/// the previous block falls through into it, add an explicit branch. Also,
+/// manage fixups for EH info.
+void llvm_code_generator::emitBlock(BasicBlock *BB) {
+ // If the previous block falls through to BB, add an explicit branch.
+ if ( currentBlock->getTerminator() == 0) {
+ // If the previous block has no label and is empty, remove it: it is a
+ // post-terminator block.
+ if (currentBlock->getName().empty() && currentBlock->begin() == currentBlock->end())
+ currentBlock->eraseFromParent();
+ else {
+ // Otherwise, fall through to this block.
+ new BranchInst(BB, currentBlock);
+ }
+ }
+
+ // Add this block.
+ currentMethod->getBasicBlockList().push_back(BB);
+ currentBlock = BB; // It is now the current block.
+}
+
+
+
+
+llvm_code_generator::llvm_code_generator (compiler *comp,
+ directory_cache &dirs)
+: code_generator (dirs)
+{
+ // Set up all primitive types.
+ typemap[primitive_byte_type] = Type::SByteTy;
+ typemap[primitive_short_type] = Type::ShortTy;
+ typemap[primitive_int_type] = Type::IntTy;
+ typemap[primitive_long_type] = Type::LongTy;
+ typemap[primitive_float_type] = Type::FloatTy;
+ typemap[primitive_double_type] = Type::DoubleTy;
+ typemap[primitive_boolean_type] = Type::BoolTy;
+ typemap[primitive_char_type] = Type::UShortTy;
+ typemap[primitive_void_type] = Type::VoidTy;
+ typemap[null_type] = PointerType::get(OpaqueType::get());
+
+}
+
+ void
+llvm_code_generator::generate (model_class *klass)
+{
+ cout << "GENERATE CALLED\n";
+ cout << "Class " << klass->get_name() << "\n";
+ string FeaturesStr;
+ string OutputFilename;
+ ostream *Out = 0;
+ const TargetMachineRegistry::Entry * target = TargetMachineRegistry::getList();
+
+ module = new Module(klass->get_name());
+ OutputFilename=GetFileNameRoot(klass->get_name())+".cgen";
+ //while( target != NULL ) {
+ cout << "Target=" << target->Name << "\n";
+ //target = target->getNext();
+ //}
+ auto_ptr<TargetMachine> targetArch(target->CtorFn(*module, 0, FeaturesStr));
+ assert(targetArch.get() && "Could not allocate target machine!");
+ TargetMachine &Target = *targetArch.get();
+ const TargetData &TD = Target.getTargetData();
+ // Build up all of the passes that we want to do to the module...
+ PassManager Passes;
+ Passes.add(new TargetData(TD));
+ Out = new ofstream(OutputFilename.c_str());
+ if (!Out->good()) {
+ cerr << ": error opening " << OutputFilename << "!\n";
+ delete Out;
+ return ;
+ }
+ sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+ Target.addPassesToEmitFile(Passes,*Out,TargetMachine::AssemblyFile, true);
+
+
+
+
+
+ // First we generate code for the methods. Then we write the bytes
+ // for the fields and the methods in a separate step. We do this
+ // because code generation might require adding a new field.
+ list<ref_method> methods = klass->get_methods ();
+ for (list<ref_method>::const_iterator i = methods.begin ();
+ i != methods.end ();
+ ++i)
+ {
+ generate ((*i).get ());
+ }
+ // Output the bytecode file to stdout
+ //WriteBytecodeToFile(module, cout);
+ Passes.run(*module);
+ // Delete the ostream if it's not a stdout stream
+ if (Out != &cout) delete Out;
+ delete module;
+ //dump_tree(klass);
+}
+
+llvm_code_generator::~llvm_code_generator ()
+{
+ //XXX dunno about this is it enough ?
+ delete currentMethod;
+ delete this;
+}
+
+ void
+llvm_code_generator::generate( model_method *m)
+{
+ m->visit (this);
+}
+
+
+ void
+llvm_code_generator::visit_method (model_method * method,
+ const list<ref_variable_decl> & params,
+ const ref_block &block)
+{
+ cout << "Method " << method->get_name() << "\n";
+ vector<const Type*> llvm_params;
+ llvm_params.reserve(params.size());
+ // Create the function decl: first create the type
+ for (list<ref_variable_decl>::const_iterator i = params.begin ();
+ i != params.end (); ++i)
+ {
+
+ model_type *type = (*i)->type ();
+ const Type *Ty =convertType(type);
+ llvm_params.push_back(Ty);
+ }
+ const Type *result = convertType(method->get_return_type());
+
+ FunctionType *ftype = FunctionType::get(result,llvm_params,false/*not varg*/);
+ //By passing a module as the last parameter to the Function constructor,
+ // it automatically gets appended to the Module.
+ currentMethod = new Function(ftype,Function::ExternalLinkage,
+ method->get_name(), module);
+
+ // Add a basic block to the function... again, it automatically inserts
+ // because of the last argument.
+ if( !block ) {
+ //eeeak
+ assert(0);
+ currentBlock = NULL;
+ }
+ //create the return block but add it later
+ //we will branch ahead to here on returns
+ returnBlock = new BasicBlock("return");
+
+ //start walking
+ block->visit(this);
+
+ //finish return block make it the current block
+ emitBlock(returnBlock);
+
+ //If the function returns a value, get it into a register and return it now.
+ if (currentMethod->getReturnType() != Type::VoidTy) {
+ //Value *returnValue = new LoadInst(DECL_LLVM(DECL_RESULT(FnDecl)), "retval", currentBlock);
+ //returnValue = castToType(RV, currentMethod->getReturnType());
+ //new ReturnInst(RV, currentBlock);
+ new ReturnInst(currentBlock);
+ } else {
+ // Otherwise, just return.
+ new ReturnInst(currentBlock);
+ }
+
+}
+
+ void
+llvm_code_generator::visit_assert (model_assert *stmt,
+ const ref_expression &first,
+ const ref_expression &second)
+{
+}
+
+ void
+llvm_code_generator::visit_block (model_block *block,
+ const list<ref_stmt> &statements)
+{
+ if( currentBlock == NULL ) {
+ currentBlock = new BasicBlock("EntryBlock",currentMethod);
+ }else {
+ emitBlock(new BasicBlock(""));
+ }
+ ::visit(this,statements);
+}
+
+ void
+llvm_code_generator::visit_bytecode_block (model_bytecode_block *block,
+ int, int, int, const uint8 *)
+{
+}
+
+ void
+llvm_code_generator::visit_break (model_break *brk, const ref_stmt &target)
+{
+}
+
+ void
+llvm_code_generator::visit_catch (model_catch *stmt,
+ const ref_variable_decl &var,
+ const ref_block &body)
+{
+}
+
+void llvm_code_generator::visit_continue (model_continue *stmt,
+ const ref_stmt &target)
+{
+}
+
+ void
+llvm_code_generator::visit_class_decl_stmt (model_class_decl_stmt *stmt,
+ const ref_class &klass)
+{
+}
+
+void llvm_code_generator::visit_do (model_do *stmt, const ref_expression &cond,
+ const ref_stmt &body)
+{
+}
+
+void llvm_code_generator::visit_empty (model_empty *)
+{
+}
+
+void llvm_code_generator::visit_expression_stmt (model_expression_stmt *,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_for_enhanced (model_for_enhanced *,
+ const ref_stmt &, const ref_expression &,
+ const ref_variable_decl &)
+{
+}
+
+void llvm_code_generator::visit_for (model_for *, const ref_stmt &,
+ const ref_expression &, const ref_stmt &,
+ const ref_stmt &)
+{
+}
+
+void llvm_code_generator::visit_if (model_if *, const ref_expression &,
+ const ref_stmt &, const ref_stmt &)
+{
+}
+
+void llvm_code_generator::visit_label (model_label *, const ref_stmt &)
+{
+}
+
+void llvm_code_generator::visit_return (model_return *, const ref_expression &)
+{
+ cout << "VISIT RETURN !!! " << currentBlock << "\n";
+ new BranchInst(returnBlock,currentBlock);
+}
+
+void llvm_code_generator::visit_switch (model_switch *,
+ const ref_expression &,
+ const list<ref_switch_block> &)
+{
+}
+
+void llvm_code_generator::visit_switch_block (model_switch_block *,
+ const list<ref_stmt> &)
+{
+}
+
+void llvm_code_generator::visit_synchronized (model_synchronized *,
+ const ref_expression &,
+ const ref_stmt &)
+{
+}
+
+void llvm_code_generator::visit_throw (model_throw *, const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_try (model_try *, const ref_block &,
+ const list<ref_catch> &, const ref_block &)
+{
+}
+
+void llvm_code_generator::visit_variable_stmt (model_variable_stmt *,
+ const list<ref_variable_decl> &)
+{
+cout << "VISIT VARIABLE !!! STMT \n";
+#if 0
+ for (std::list<ref_variable_decl>::const_iterator i = decls.begin ();
+ i != decls.end ();
+ ++i)
+ {
+ int n = vars.request ((*i).get ());
+ class_writer::check_type ((*i).get (), (*i)->type ());
+ ref_expression init = (*i)->get_initializer ();
+ if (init)
+ {
+ push_expr_target where (this, ON_STACK);
+ init->visit (this);
+ emit_store ((*i)->type (), n);
+ }
+ }
+#endif
+}
+
+void llvm_code_generator::visit_while (model_while *, const ref_expression &,
+ const ref_stmt &)
+{
+}
+
+void llvm_code_generator::visit_array_initializer (model_array_initializer *,
+ const ref_forwarding_type &,
+ const list<ref_expression> &)
+{
+}
+
+void llvm_code_generator::visit_array_ref (model_array_ref *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_assignment (model_assignment *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_minus_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_mult_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_div_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_and_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_or_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_plus_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_xor_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_mod_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_ls_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_rs_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_op_assignment (model_urs_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_minus *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_mult *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_div *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_mod *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_and *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_or *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+void llvm_code_generator::visit_arith_binary (model_xor *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+ void
+llvm_code_generator::visit_arith_binary (model_plus *,
+ const ref_expression &,
+ const ref_expression &)
+{
+}
+
+ void
+llvm_code_generator::visit_arith_shift (model_left_shift *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_arith_shift (model_right_shift *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_arith_shift (model_unsigned_right_shift *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_cast (model_cast *, const ref_forwarding_type &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_class_ref (model_class_ref *,
+ const ref_forwarding_type &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_equal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_notequal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_lessthan *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_greaterthan *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_lessthanequal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_comparison (model_greaterthanequal *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_conditional (model_conditional *,
+ const ref_expression &,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_field_ref (model_field_ref *,
+ const ref_expression &,
+ model_field *)
+{
+
+}
+
+ void
+llvm_code_generator::visit_field_initializer (model_field_initializer *,
+ model_field *)
+{
+
+}
+
+ void
+llvm_code_generator::visit_instanceof (model_instanceof *,
+ const ref_expression &,
+ const ref_forwarding_type &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_logical_binary (model_lor *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_logical_binary (model_land *,
+ const ref_expression &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jboolean &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jbyte &val)
+{
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jchar &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jshort &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jint &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jlong &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jfloat &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_literal (model_literal_base *,
+ const jdouble &val)
+{
+
+}
+
+ void
+llvm_code_generator::visit_string_literal (model_string_literal *,
+ const string &val)
+{
+}
+
+ void
+llvm_code_generator::visit_method_invocation (model_method_invocation *,
+ model_method *,
+ const ref_expression &,
+ const list<ref_expression> &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_type_qualified_invocation (model_type_qualified_invocation *,
+ const model_method *,
+ const list<ref_expression> &,
+ bool)
+{
+
+}
+
+ void
+llvm_code_generator::visit_super_invocation (model_super_invocation *,
+ const model_method *,
+ const list<ref_expression> &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_this_invocation (model_this_invocation *,
+ const model_method *,
+ const list<ref_expression> &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_new (model_new *, const model_method *,
+ const ref_forwarding_type &,
+ const list<ref_expression> &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_new_array (model_new_array *,
+ const ref_forwarding_type &,
+ const list<ref_expression> &,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_null_literal (model_null_literal *)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_simple (model_prefix_plus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_simple (model_prefix_minus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_simple (model_bitwise_not *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_simple (model_logical_not *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_side_effect (model_prefix_plusplus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_prefix_side_effect (model_prefix_minusminus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_postfix_side_effect (model_postfix_plusplus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_postfix_side_effect (model_postfix_minusminus *,
+ const ref_expression &)
+{
+
+}
+
+ void
+llvm_code_generator::visit_this (model_this *)
+{
+
+}
+
+ void
+llvm_code_generator::visit_simple_variable_ref (model_simple_variable_ref *,
+ const model_variable_decl *)
+{
+
+}
+
+
diff -Nur ../gcjx.original/llvm/llvmgen.hh ./llvm/llvmgen.hh
--- ../gcjx.original/llvm/llvmgen.hh 1969-12-31 18:00:00.000000000 -0600
+++ ./llvm/llvmgen.hh 2005-12-08 07:54:46.000000000 -0600
@@ -0,0 +1,790 @@
+// Code generator for llvm.
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of GCC.
+//
+// gcjx is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// gcjx is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with gcjx; see the file COPYING.LIB. If
+// not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef GCJX_LLVM_GEN_HH
+#define GCJX_LLVM_GEN_HH
+
+#include "codegen.hh"
+#include "llvm/Module.h"
+
+using namespace llvm;
+
+/// This is the primary interface to bytecode generation.
+class llvm_code_generator : public visitor, public code_generator
+{
+public:
+
+ /// Construct a new bytecode code generator. Argument is the
+ /// compiler being used to generate code.
+ llvm_code_generator (compiler *, directory_cache &);
+ virtual ~llvm_code_generator();
+
+ /// This is called to generate code for a class and write it.
+ void generate (model_class *);
+ void generate (model_method *);
+
+ void visit_method (model_method *,
+ const std::list<ref_variable_decl> &,
+ const ref_block &);
+
+ void visit_assert (model_assert *, const ref_expression &,
+ const ref_expression &);
+
+ void visit_block (model_block *,
+ const std::list<ref_stmt> &);
+
+ void visit_bytecode_block (model_bytecode_block *, int, int, int,
+ const uint8 *);
+
+ void visit_break (model_break *, const ref_stmt &);
+
+ void visit_catch (model_catch *, const ref_variable_decl &,
+ const ref_block &);
+
+ void visit_continue (model_continue *, const ref_stmt &);
+
+ void visit_class_decl_stmt (model_class_decl_stmt *,
+ const ref_class &);
+
+ void visit_do (model_do *, const ref_expression &,
+ const ref_stmt &);
+
+ void visit_empty (model_empty *);
+
+ void visit_expression_stmt (model_expression_stmt *,
+ const ref_expression &);
+
+ void visit_for_enhanced (model_for_enhanced *,
+ const ref_stmt &, const ref_expression &,
+ const ref_variable_decl &);
+
+ void visit_for (model_for *, const ref_stmt &,
+ const ref_expression &, const ref_stmt &,
+ const ref_stmt &);
+
+ void visit_if (model_if *, const ref_expression &,
+ const ref_stmt &, const ref_stmt &);
+
+ void visit_label (model_label *, const ref_stmt &);
+
+ void visit_return (model_return *, const ref_expression &);
+
+ void visit_switch (model_switch *,
+ const ref_expression &,
+ const std::list<ref_switch_block> &);
+
+ void visit_switch_block (model_switch_block *,
+ const std::list<ref_stmt> &);
+
+ void visit_synchronized (model_synchronized *,
+ const ref_expression &,
+ const ref_stmt &);
+
+ void visit_throw (model_throw *, const ref_expression &);
+
+ void visit_try (model_try *, const ref_block &,
+ const std::list<ref_catch> &, const ref_block &);
+
+ void visit_variable_stmt (model_variable_stmt *,
+ const std::list<ref_variable_decl> &);
+
+ void visit_while (model_while *, const ref_expression &,
+ const ref_stmt &);
+
+
+ void visit_array_initializer (model_array_initializer *,
+ const ref_forwarding_type &,
+ const std::list<ref_expression> &);
+
+ void visit_array_ref (model_array_ref *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_assignment (model_assignment *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_method_invocation (model_method_invocation *,
+ model_method *,
+ const ref_expression &,
+ const std::list<ref_expression> &);
+
+ void visit_type_qualified_invocation (model_type_qualified_invocation *,
+ const model_method *,
+ const std::list<ref_expression> &,
+ bool);
+
+ void visit_super_invocation (model_super_invocation *,
+ const model_method *,
+ const std::list<ref_expression> &,
+ const ref_expression &);
+
+ void visit_this_invocation (model_this_invocation *,
+ const model_method *,
+ const std::list<ref_expression> &);
+
+ void visit_op_assignment (model_minus_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_mult_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_div_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_and_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_or_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_xor_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_mod_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_ls_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_rs_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_urs_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_op_assignment (model_plus_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_minus *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_mult *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_div *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_mod *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_and *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_or *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_xor *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_binary (model_plus *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_shift (model_left_shift *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_shift (model_right_shift *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_arith_shift (model_unsigned_right_shift *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_cast (model_cast *, const ref_forwarding_type &,
+ const ref_expression &);
+
+ void visit_class_ref (model_class_ref *,
+ const ref_forwarding_type &);
+
+ void visit_comparison (model_equal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_comparison (model_notequal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_comparison (model_lessthan *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_comparison (model_greaterthan *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_comparison (model_lessthanequal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_comparison (model_greaterthanequal *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_conditional (model_conditional *,
+ const ref_expression &,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_field_ref (model_field_ref *,
+ const ref_expression &,
+ model_field *);
+
+ void visit_field_initializer (model_field_initializer *,
+ model_field *);
+
+ void visit_field (model_field *)
+ {
+ // Nothing.
+ }
+
+ void visit_instanceof (model_instanceof *,
+ const ref_expression &,
+ const ref_forwarding_type &);
+
+ void visit_logical_binary (model_lor *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_logical_binary (model_land *,
+ const ref_expression &,
+ const ref_expression &);
+
+ void visit_simple_literal (model_literal_base *,
+ const jboolean &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jbyte &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jchar &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jshort &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jint &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jlong &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jfloat &val);
+
+ void visit_simple_literal (model_literal_base *,
+ const jdouble &val);
+
+ void visit_string_literal (model_string_literal *,
+ const std::string &val);
+
+ void visit_new (model_new *, const model_method *,
+ const ref_forwarding_type &,
+ const std::list<ref_expression> &);
+
+ void visit_new_array (model_new_array *,
+ const ref_forwarding_type &,
+ const std::list<ref_expression> &,
+ const ref_expression &);
+
+ void visit_null_literal (model_null_literal *);
+
+ void visit_prefix_simple (model_prefix_plus *,
+ const ref_expression &);
+
+ void visit_prefix_simple (model_prefix_minus *,
+ const ref_expression &);
+
+ void visit_prefix_simple (model_bitwise_not *,
+ const ref_expression &);
+
+ void visit_prefix_simple (model_logical_not *,
+ const ref_expression &);
+
+ void visit_prefix_side_effect (model_prefix_plusplus *,
+ const ref_expression &);
+
+ void visit_prefix_side_effect (model_prefix_minusminus *,
+ const ref_expression &);
+
+ void visit_postfix_side_effect (model_postfix_plusplus *,
+ const ref_expression &);
+
+ void visit_postfix_side_effect (model_postfix_minusminus *,
+ const ref_expression &);
+
+ void visit_this (model_this *);
+
+ void visit_simple_variable_ref (model_simple_variable_ref *,
+ const model_variable_decl *);
+
+ void visit_forwarding_type (model_forwarding_type *,
+ model_type *)
+ {
+ // Nothing.
+ }
+
+ void visit_forwarding_resolved (model_forwarding_resolved *,
+ model_type *)
+ {
+ // Nothing.
+ }
+
+ void visit_forwarding_owned (model_forwarding_owned *,
+ const ref_type &)
+ {
+ // Nothing.
+ }
+
+ void visit_forwarding_simple (model_forwarding_simple *,
+ const std::list<std::string> &)
+ {
+ // Nothing.
+ }
+
+ void
+ visit_forwarding_array (model_forwarding_array *,
+ const owner<model_forwarding_type> &)
+ {
+ // Nothing.
+ }
+
+ void
+ visit_forwarding_element (model_forwarding_element *,
+ const owner<model_forwarding_type> &)
+ {
+ // Nothing.
+ }
+
+ void visit_forwarding_full (model_forwarding_full *,
+ const std::string &)
+ {
+ // Nothing.
+ }
+
+ void
+ visit_forwarding_inner (model_forwarding_inner *,
+ const std::list<std::string> &,
+ const owner<model_forwarding_type> &)
+ {
+ // Nothing.
+ }
+
+ void
+ visit_forwarding_parameterized (model_forwarding_parameterized *,
+ const owner<model_forwarding_type> &,
+ const std::list< owner<model_forwarding_type> > &)
+ {
+ // Nothing.
+ }
+
+ void visit_variable_decl (model_variable_decl *,
+ const std::string &,
+ const ref_forwarding_type &,
+ const ref_expression &,
+ bool,
+ bool)
+ {
+ // Nothing.
+ }
+
+ void visit_parameter_decl (model_variable_decl *,
+ const std::string &,
+ const ref_forwarding_type &,
+ const ref_expression &,
+ bool,
+ bool)
+ {
+ // Nothing.
+ }
+
+ void visit_catch_decl (model_variable_decl *,
+ const std::string &,
+ const ref_forwarding_type &,
+ const ref_expression &,
+ bool,
+ bool)
+ {
+ // Nothing.
+ }
+
+ void visit_package (model_package *, const std::list<std::string> &)
+ {
+ // Nothing.
+ }
+
+ void visit_type (model_type *, const std::string &)
+ {
+ // Nothing.
+ }
+
+ void visit_identifier (model_identifier *, const std::string &)
+ {
+ // Nothing.
+ }
+
+ void visit_annotation_member (model_annotation_member *,
+ const ref_forwarding_type &)
+ {
+ // Nothing.
+ }
+
+ void visit_annotation_value (model_annotation_value *,
+ const std::string &, const ref_expression &)
+ {
+ // Nothing.
+ }
+
+ void visit_import_single (model_import_single *,
+ const std::list<std::string> &, model_class *)
+ {
+ // Nothing.
+ }
+
+ void visit_import_on_demand (model_import_on_demand *,
+ const std::list<std::string> &, Iname *, bool)
+ {
+ // Nothing.
+ }
+
+ void visit_static_import_single (model_static_import_single *,
+ const std::list<std::string> &,
+ model_class *, const std::string &)
+ {
+ // Nothing.
+ }
+
+ void visit_static_import_on_demand (model_static_import_on_demand *,
+ const std::list<std::string> &,
+ model_class *)
+ {
+ // Nothing.
+ }
+
+ void visit_unit_source (model_unit_source *, model_package *,
+ const std::list<ref_class> &,
+ const std::string &,
+ bool, const std::list<ref_import> &)
+ {
+ // Nothing.
+ }
+
+ void visit_unit_class (model_unit_class *, model_package *,
+ const std::list<ref_class> &,
+ const std::string &, bool)
+ {
+ // Nothing.
+ }
+
+ void visit_unit_fake (model_unit_fake *, model_package *,
+ const std::list<ref_class> &,
+ const std::string &, bool)
+ {
+ // Nothing.
+ }
+
+ void visit_abstract_method (model_abstract_method *am,
+ const std::list<ref_variable_decl> ¶ms,
+ const ref_block &body, model_method *)
+ {
+ visit_method (am, params, body);
+ }
+
+ void visit_annotation_type (model_annotation_type *at,
+ const std::string &descr,
+ const std::string &name)
+ {
+ visit_class (at, descr, name);
+ }
+
+ void visit_array_type (model_array_type *at, const std::string &descr,
+ const std::string &name, model_type *)
+ {
+ visit_class (at, descr, name);
+ }
+
+ void visit_class (model_class *c, const std::string &descr,
+ const std::string &)
+ {
+ visit_type (c, descr);
+ }
+
+ void visit_class_instance (model_class_instance *ci,
+ const std::string &descr,
+ const std::string &name, model_class *)
+ {
+ visit_class (ci, descr, name);
+ }
+
+ void visit_constructor (model_constructor *c,
+ const std::list<ref_variable_decl> ¶ms,
+ const ref_block &body)
+ {
+ visit_method (c, params, body);
+ }
+
+ void visit_enum (model_enum *e, const std::string &descr,
+ const std::string &name,
+ const std::list<ref_enum_constant> &)
+ {
+ visit_class (e, descr, name);
+ }
+
+ void visit_enum_constant (model_enum_constant *ec,
+ const std::string &descr,
+ const std::string &name,
+ const std::list<ref_expression> &)
+ {
+ visit_class (ec, descr, name);
+ }
+
+ void visit_fp_primitive (model_primitive_base *, char, jfloat)
+ {
+ // Nothing.
+ }
+
+ void visit_fp_primitive (model_primitive_base *, char, jdouble)
+ {
+ // Nothing.
+ }
+
+ void visit_int_primitive (model_primitive_base *, char,
+ long long, long long, jbyte)
+ {
+ // Nothing.
+ }
+
+ void visit_int_primitive (model_primitive_base *, char,
+ long long, long long, jchar)
+ {
+ // Nothing.
+ }
+
+ void visit_int_primitive (model_primitive_base *, char,
+ long long, long long, jshort)
+ {
+ // Nothing.
+ }
+
+ void visit_int_primitive (model_primitive_base *, char,
+ long long, long long, jint)
+ {
+ // Nothing.
+ }
+
+ void visit_int_primitive (model_primitive_base *, char,
+ long long, long long, jlong)
+ {
+ // Nothing.
+ }
+
+ void visit_primitive_boolean (model_primitive_boolean *)
+ {
+ // Nothing.
+ }
+
+ void visit_initializer_block (model_initializer_block *ib,
+ const std::list<ref_stmt> &stmts, bool)
+ {
+ visit_block (ib, stmts);
+ }
+
+ void visit_new_primary (model_new_primary *np, const model_method *meth,
+ const ref_forwarding_type &klass,
+ const std::list<ref_expression> &args,
+ const std::string &,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_new (np, meth, klass, args);
+ }
+
+ void visit_null_type (model_null_type *nt, const std::string &descr)
+ {
+ visit_type (nt, descr);
+ }
+
+ void visit_phony_block (model_phony_block *pb,
+ const std::list<ref_stmt> &stmts)
+ {
+ visit_block (pb, stmts);
+ }
+
+ void visit_primordial_package (model_primordial_package *pp,
+ const std::list<std::string> &name)
+ {
+ visit_package (pp, name);
+ }
+
+ void visit_unnamed_package (model_unnamed_package *up,
+ const std::list<std::string> &name)
+ {
+ visit_package (up, name);
+ }
+
+ void visit_synthetic_this (model_synthetic_this *st)
+ {
+ visit_this (st);
+ }
+
+ void visit_this_outer (model_this_outer *to)
+ {
+ visit_this (to);
+ }
+
+ void
+ visit_type_variable (model_type_variable *tv,
+ const std::string &descr, const std::string &name,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_class (tv, descr, name);
+ }
+
+ void visit_void_type (model_void_type *vt, const std::string &descr)
+ {
+ visit_type (vt, descr);
+ }
+
+ void visit_wildcard (model_wildcard *w, const std::string &descr,
+ const std::string &name, bool,
+ const ref_forwarding_type &)
+ {
+ visit_class (w, descr, name);
+ }
+
+ void visit_javadoc (model_javadoc *, bool)
+ {
+ // Nothing.
+ }
+
+ void
+ visit_generic_invocation (model_method_invocation *mi,
+ model_method *meth,
+ const ref_expression &qual,
+ const std::list<ref_expression> &args,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_method_invocation (mi, meth, qual, args);
+ }
+
+ void
+ visit_generic_invocation (model_type_qualified_invocation *tqi,
+ const model_method *meth,
+ const std::list<ref_expression> &args,
+ bool is_super,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_type_qualified_invocation (tqi, meth, args, is_super);
+ }
+
+ void
+ visit_generic_invocation (model_super_invocation *si,
+ const model_method *meth,
+ const std::list<ref_expression> &args,
+ const ref_expression &finit,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_super_invocation (si, meth, args, finit);
+ }
+
+ void
+ visit_generic_invocation (model_this_invocation *ti,
+ const model_method *meth,
+ const std::list<ref_expression> &args,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_this_invocation (ti, meth, args);
+ }
+
+ void
+ visit_generic_invocation (model_new *n, const model_method *meth,
+ const ref_forwarding_type &klass,
+ const std::list<ref_expression> &args,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_new (n, meth, klass, args);
+ }
+
+ void
+ visit_generic_invocation (model_new_primary *np, const model_method *meth,
+ const ref_forwarding_type &klass,
+ const std::list<ref_expression> &args,
+ const std::string &simple_name,
+ const std::list<ref_forwarding_type> &type_params,
+ const std::list<ref_forwarding_type> &)
+ {
+ visit_new_primary (np, meth, klass, args, simple_name, type_params);
+ }
+
+ void
+ visit_annotation (model_annotation *, const ref_forwarding_type &,
+ const std::list<ref_annotation_value> &)
+ {
+ abort ();
+ }
+
+ void
+ visit_annotation_initializer (model_annotation_initializer *,
+ const ref_forwarding_type &,
+ const std::list<ref_expression> &)
+ {
+ abort ();
+ }
+
+ void visit_memberref_enum (model_memberref_enum *,
+ const ref_forwarding_type &,
+ const std::string &)
+ {
+ abort ();
+ }
+
+private:
+ //void Type *convertType(
+ // This maps our types to llvm types.
+ std::map<model_type *,Type *> typemap;
+ Module* module;
+ Function *currentMethod;
+ BasicBlock *currentBlock;
+ BasicBlock *returnBlock;
+ const Type * convertType( model_type *type );
+ void emitBlock(BasicBlock *BB);
+ Value * castToType(Value *V, const Type *Ty);
+};
+
+#endif // GCJX_LLVM_GEN_HH
diff -Nur ../gcjx.original/main.cc ./main.cc
--- ../gcjx.original/main.cc 2005-12-08 06:26:44.000000000 -0600
+++ ./main.cc 2005-12-08 07:39:56.000000000 -0600
@@ -21,6 +21,9 @@
#include "typedefs.hh"
#include "bytecode/bytegen.hh"
+#ifdef ENABLE_LLVM_BACKEND
+#include "llvm/llvmgen.hh"
+#endif
#include "header/jni.hh"
#include "header/jnistub.hh"
#include "header/cni.hh"
@@ -447,14 +450,8 @@
comp->warnings_are_errors = true;
else if (arg == "-pedantic")
comp->pedantic = true;
- else if (arg.length () >= 2 && ! strncmp (arg.c_str (), "-g" , 2))
- {
- // The real form is -g:none, or
- // -g:{lines,vars,source}.
- // Currently we don't differentiate this in the back end,
- // so we just handle all-or-nothing.
- comp->target_debug = (arg != "-g:none");
- }
+ else if (arg == "-g")
+ comp->target_debug = true;
else if (arg == "-d")
output = get_next_arg (it, arg);
else if (is_form_of (it, "-bootclasspath"))
@@ -484,6 +481,11 @@
else if (otype == "jnistub")
comp->add_code_generator (new jni_stub_generator (comp,
comp->get_directory_cache ()));
+#ifdef ENABLE_LLVM_BACKEND
+ else if (otype == "llvm")
+ comp->add_code_generator (new llvm_code_generator (comp,
+ comp->get_directory_cache ()));
+#endif
else if (otype == "none")
{
// Nothing.
diff -Nur ../gcjx.original/Makefile.am ./Makefile.am
--- ../gcjx.original/Makefile.am 2005-12-08 06:42:27.000000000 -0600
+++ ./Makefile.am 2005-12-08 06:12:53.000000000 -0600
@@ -10,11 +10,19 @@
gcjx_SOURCES = main.cc
gcjx_LDADD = libgcjx.la -lpthread
+if ENABLE_LLVM
+gcjx_LDADD += $(llvm_libs)
+endif
+
libgcjx_la_SOURCES = $(dot_sources) $(model_sources) $(reader_sources) \
$(source_sources) $(format_sources) $(bytecode_sources) \
$(header_sources) $(fdlibm_c_sources) $(fdlibm_cc_sources) \
$(aot_sources)
+if ENABLE_LLVM
+libgcjx_la_SOURCES += $(llvm_sources)
+endif
+
BUILT_SOURCES = source/keyword.h source/chartables.h typedefs.hh.gch
EXTRA_DIST = source/keyword.gperf source/gen-table.pl
@@ -137,3 +145,27 @@
aot_sources = aot/aotclass.cc aot/aotfactory.cc aot/mangle.cc
+llvm_cppflags=-I$(LLVMBASELIBPATH)/include -D__STDC_LIMIT_MACROS
+LLVMLIBPATH = $(LLVMBASELIBPATH)/$(LLVM_BUILDMODE)/lib
+
+
+llvm_libs = -L$(LLVMLIBPATH) \
+ $(LLVMLIBPATH)/LLVMCBackend.o \
+ $(LLVMLIBPATH)/LLVMBCReader.o \
+ $(LLVMLIBPATH)/LLVMBCWriter.o \
+ $(LLVMLIBPATH)/LLVMbzip2.o \
+ -lLLVMipa \
+ -lLLVMTransforms \
+ -lLLVMScalarOpts \
+ -lLLVMTransformUtils \
+ -lLLVMAnalysis \
+ $(LLVMLIBPATH)/LLVMSelectionDAG.o \
+ $(LLVMLIBPATH)/LLVMCodeGen.o \
+ -lLLVMTarget \
+ $(LLVMLIBPATH)/LLVMCore.o \
+ -lLLVMSupport \
+ -lLLVMSystem \
+ -ldl
+
+llvm_sources = llvm/llvmgen.cc
+