Permalink
Browse files

Function.first_basic_block and .last_basic_block

  • Loading branch information...
1 parent 0004a71 commit 4ac7226425d0d7570afa1c8e7f814973cc47819a @bacek bacek committed Mar 26, 2011
Showing with 36 additions and 0 deletions.
  1. +18 −0 runtime/parrot/library/LLVM/Function.pm
  2. +18 −0 t/library/llvm/08-function.t
@@ -80,6 +80,24 @@ class LLVM::Function is LLVM::Value {
LLVM::call("GetPreviousFunction", self)
);
}
+
+ method entry_basic_block () {
+ LLVM::BasicBlock.create(
+ LLVM::call("GetEntryBasicBlock", self)
+ );
+ }
+
+ method first_basic_block () {
+ LLVM::BasicBlock.create(
+ LLVM::call("GetFirstBasicBlock", self)
+ );
+ }
+
+ method last_basic_block () {
+ LLVM::BasicBlock.create(
+ LLVM::call("GetLastBasicBlock", self)
+ );
+ }
};
# vim: ft=perl6
@@ -0,0 +1,18 @@
+#! parrot-nqp
+
+Q:PIR { .include "test_more.pir" };
+pir::load_bytecode("LLVM.pbc");
+
+# We need Module and Function to test Builder.
+my $m := LLVM::Module.create("Test");
+my $f := $m.add_function("hello", LLVM::Type::int32());
+
+my $bb1 := $f.append_basic_block();
+my $bb2 := $f.append_basic_block();
+
+ok( $bb1 ~~ $f.first_basic_block, "Got first BasicBlock");
+ok( $bb2 ~~ $f.last_basic_block, "Got first BasicBlock");
+
+done_testing();
+
+# vim: ft=perl6

0 comments on commit 4ac7226

Please sign in to comment.