Skip to content

Commit

Permalink
First actual JITting - handle 'goto offset' in LLVM::Trans::JIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 21, 2011
1 parent 16a0448 commit 34472b3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion compilers/opsc/src/Ops/Trans/JIT.pm
Expand Up @@ -70,7 +70,34 @@ our method access_arg:type<kic> ($num, %ctx) {

method goto_offset($offset, %ctx) {
#"return (opcode_t *)cur_opcode + $offset";
'goto L' ~ (%ctx<cur_opcode> + $offset);
#'goto L' ~ (%ctx<cur_opcode> + $offset);
my $target := %ctx<cur_opcode> + $offset;
my $jump_to := %ctx<basic_blocks>{$target}<bb>;

pir::die("No target found") unless pir::defined($jump_to);
pir::die("Crappy target") unless $jump_to ~~ LLVM::BasicBlock;

# TODO Handle non-existing block.
my $builder := %ctx<builder>;
$builder.br($jump_to);

# Preserve interace contract.
'goto L' ~ $target;
}

method goto_address($address, %ctx) {
# XXX Actually handle goto
my $builder := %ctx<builder>;
my $retval := %ctx<retval>;
$builder.store(
LLVM::Constant::null(
LLVM::Type::pointer(LLVM::Type::int32())
),
$retval,
);
$builder.br(%ctx<leave>);

"";
}

=item opcode_at
Expand Down

0 comments on commit 34472b3

Please sign in to comment.