Skip to content

Commit 5e4637b

Browse files
committed
Add Rust definitions for new LLVM EH instructions
Issue #236
1 parent 4bced5e commit 5e4637b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/comp/lib/llvm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ native "cdecl" mod llvm = "rustllvm" {
572572
fn LLVMBuildInvoke(B: BuilderRef, Fn: ValueRef, Args: *ValueRef,
573573
NumArgs: uint, Then: BasicBlockRef,
574574
Catch: BasicBlockRef, Name: sbuf) -> ValueRef;
575+
fn LLVMBuildLandingPad(B: BuilderRef, Ty: TypeRef, PersFn: ValueRef,
576+
NumClauses: uint, Name: sbuf) -> ValueRef;
577+
fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
575578
fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
576579

577580
/* Add a case to the switch instruction */
@@ -580,6 +583,12 @@ native "cdecl" mod llvm = "rustllvm" {
580583
/* Add a destination to the indirectbr instruction */
581584
fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
582585

586+
/* Add a clause to the landing pad instruction */
587+
fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
588+
589+
/* Set the cleanup on a landing pad instruction */
590+
fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
591+
583592
/* Arithmetic */
584593
fn LLVMBuildAdd(B: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: sbuf)
585594
-> ValueRef;

src/comp/middle/trans_build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,22 @@ fn Trap(cx: &@block_ctxt) -> ValueRef {
545545
});
546546
}
547547

548+
fn LandingPad(cx: &@block_ctxt, Ty: TypeRef, PersFn: ValueRef,
549+
NumClauses: uint) -> ValueRef {
550+
ret str::as_buf("",
551+
{|buf|
552+
llvm::LLVMBuildLandingPad(B(cx),
553+
Ty,
554+
PersFn,
555+
NumClauses,
556+
buf)
557+
});
558+
}
559+
560+
fn SetCleanup(_cx: &@block_ctxt, LandingPad: ValueRef) {
561+
llvm::LLVMSetCleanup(LandingPad, lib::llvm::True);
562+
}
563+
548564
//
549565
// Local Variables:
550566
// mode: rust

src/rustllvm/rustllvm.def.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LLVMAddAttribute
2525
LLVMAddBasicAliasAnalysisPass
2626
LLVMAddCFGSimplificationPass
2727
LLVMAddCase
28+
LLVMAddClause
2829
LLVMAddConstantMergePass
2930
LLVMAddConstantPropagationPass
3031
LLVMAddCorrelatedValuePropagationPass
@@ -122,6 +123,7 @@ LLVMBuildIntToPtr
122123
LLVMBuildInvoke
123124
LLVMBuildIsNotNull
124125
LLVMBuildIsNull
126+
LLVMBuildLandingPad
125127
LLVMBuildLShr
126128
LLVMBuildLoad
127129
LLVMBuildMalloc
@@ -141,6 +143,7 @@ LLVMBuildPhi
141143
LLVMBuildPointerCast
142144
LLVMBuildPtrDiff
143145
LLVMBuildPtrToInt
146+
LLVMBuildResume
144147
LLVMBuildRet
145148
LLVMBuildRetVoid
146149
LLVMBuildSDiv
@@ -548,6 +551,7 @@ LLVMRunPassManager
548551
LLVMRunStaticConstructors
549552
LLVMRunStaticDestructors
550553
LLVMSetAlignment
554+
LLVMSetCleanup
551555
LLVMSetCurrentDebugLocation
552556
LLVMSetDataLayout
553557
LLVMSetFunctionCallConv

0 commit comments

Comments
 (0)