Skip to content

Commit

Permalink
Skeleton for LLVM bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek authored and Reini Urban committed Oct 2, 2012
1 parent bd6851e commit df587e8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtime/parrot/library/LLVM.pir
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.include "runtime/parrot/library/LLVM/Module.pir"
33 changes: 33 additions & 0 deletions runtime/parrot/library/LLVM/Module.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! nqp
=begin Description
LLVM Module.
=end Description


class LLVM::Module {
our %FUNCTIONS;

has $!ref;

method createWithName($name) {
$!ref := %FUNCTIONS<CreateWithName>($name);
self;
}

method dump() {
%FUNCTIONS<Dump>($!ref);
}


INIT {
pir::load_bytecode("nqp-setting.pbc");

# Vivify
my $lib := pir::loadlib("/usr/lib/libLLVM-2.7.so.1");
%FUNCTIONS<CreateWithName> := pir::dlfunc__ppss($lib, "LLVMModuleCreateWithName", "pt");
%FUNCTIONS<Dump> := pir::dlfunc__ppss($lib, "LLVMDumpModule", "vp");
}

};

# vim: ft=perl6
10 changes: 10 additions & 0 deletions runtime/parrot/library/Rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ $(LIBRARY_DIR)/Tcl/Glob.pbc : \

$(LIBRARY_DIR)/P6Object.pbc : \
$(LIBRARY_DIR)/dumper.pbc

$(LIBRARY_DIR)/LLVM.pbc : \
$(LIBRARY_DIR)/LLVM.pir \
$(LIBRARY_DIR)/LLVM/Module.pir
$(PARROT) -o $@ $(LIBRARY_DIR)/LLVM.pir

$(LIBRARY_DIR)/LLVM/Module.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM/Module.pm
$(NQP_RX) --target=pir --output=$@ $(LIBRARY_DIR)/LLVM/Module.pm


14 changes: 14 additions & 0 deletions t/library/llvm.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! parrot-nqp

pir::load_bytecode("LLVM.pbc");

Q:PIR {
# We want Test::More features for testing. Not NQP's builtin.
.include "test_more.pir"
load_bytecode "dumper.pbc"
};

my $module := LLVM::Module.new.createWithName("HELLO");
$module.dump();

# vim: ft=perl6

0 comments on commit df587e8

Please sign in to comment.