Skip to content

Commit

Permalink
Add LLVM::BasicBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 6, 2011
1 parent 9b35f82 commit d473cea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions runtime/parrot/library/LLVM/BasicBlock.pm
@@ -0,0 +1,9 @@
class LLVM::BasicBlock {
has $!ref;

method BUILD($ref) { $!ref := $ref; self };


};

# vim: ft=perl6
4 changes: 3 additions & 1 deletion runtime/parrot/library/LLVM/Function.pm
Expand Up @@ -5,7 +5,9 @@ class LLVM::Function {
method BUILD($ptr) { $!ptr := $ptr; self };

method append_basic_block($name?) {
%LLVM::F<LLVMAppendBasicBlock>($!ptr, $name ?? $name !! "block" ~~ $counter++);
LLVM::BasicBlock.new.BUILD(
%LLVM::F<LLVMAppendBasicBlock>($!ptr, $name ?? $name !! "block" ~~ $counter++)
);
}

method _get_ptr() { $!ptr };
Expand Down
5 changes: 5 additions & 0 deletions runtime/parrot/library/Rules.mak
Expand Up @@ -25,6 +25,8 @@ $(LIBRARY_DIR)/P6Object.pbc : \
$(LIBRARY_DIR)/LLVM.pbc : \
$(LIBRARY_DIR)/llvm_lib.pir \
$(LIBRARY_DIR)/LLVM.pir \
$(LIBRARY_DIR)/LLVM/BasicBlock.pir \
$(LIBRARY_DIR)/LLVM/Builder.pir \
$(LIBRARY_DIR)/LLVM/Function.pir \
$(LIBRARY_DIR)/LLVM/Module.pir \
$(LIBRARY_DIR)/LLVM/Type.pir
Expand All @@ -33,6 +35,9 @@ $(LIBRARY_DIR)/LLVM.pbc : \
$(LIBRARY_DIR)/LLVM.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM.pm
$(NQP_RX) --target=pir --output=$@ $(LIBRARY_DIR)/LLVM.pm

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

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

Expand Down
2 changes: 2 additions & 0 deletions runtime/parrot/library/llvm_lib.pir
@@ -1,5 +1,7 @@

.include "runtime/parrot/library/LLVM.pir"
.include "runtime/parrot/library/LLVM/BasicBlock.pir"
.include "runtime/parrot/library/LLVM/Builder.pir"
.include "runtime/parrot/library/LLVM/Function.pir"
.include "runtime/parrot/library/LLVM/Type.pir"
.include "runtime/parrot/library/LLVM/Module.pir"
1 change: 1 addition & 0 deletions t/library/llvm.t
Expand Up @@ -19,6 +19,7 @@ ok( $function ~~ LLVM::Function, ".. with proper type");

my $bb := $function.append_basic_block("the_block");
ok( pir::defined($bb), "BasicBlock appended");
ok( $bb ~~ LLVM::BasicBlock, ".. with proper type");

# This will dump to stderr.
$module.dump();
Expand Down

0 comments on commit d473cea

Please sign in to comment.