@@ -56,7 +56,7 @@ pub use self::DiagnosticSeverity::*;
5656pub use self :: Linkage :: * ;
5757pub use self :: DLLStorageClassTypes :: * ;
5858
59- use std:: ffi:: CString ;
59+ use std:: ffi:: { CString , CStr } ;
6060use std:: cell:: RefCell ;
6161use std:: slice;
6262use libc:: { c_uint, c_ushort, uint64_t, c_int, size_t, c_char} ;
@@ -544,6 +544,9 @@ pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
544544#[ allow( missing_copy_implementations) ]
545545pub enum RustArchiveMember_opaque { }
546546pub type RustArchiveMemberRef = * mut RustArchiveMember_opaque ;
547+ #[ allow( missing_copy_implementations) ]
548+ pub enum OperandBundleDef_opaque { }
549+ pub type OperandBundleDefRef = * mut OperandBundleDef_opaque ;
547550
548551pub type DiagnosticHandler = unsafe extern "C" fn ( DiagnosticInfoRef , * mut c_void ) ;
549552pub type InlineAsmDiagHandler = unsafe extern "C" fn ( SMDiagnosticRef , * const c_void , c_uint ) ;
@@ -1149,14 +1152,15 @@ extern {
11491152 Addr : ValueRef ,
11501153 NumDests : c_uint )
11511154 -> ValueRef ;
1152- pub fn LLVMBuildInvoke ( B : BuilderRef ,
1153- Fn : ValueRef ,
1154- Args : * const ValueRef ,
1155- NumArgs : c_uint ,
1156- Then : BasicBlockRef ,
1157- Catch : BasicBlockRef ,
1158- Name : * const c_char )
1159- -> ValueRef ;
1155+ pub fn LLVMRustBuildInvoke ( B : BuilderRef ,
1156+ Fn : ValueRef ,
1157+ Args : * const ValueRef ,
1158+ NumArgs : c_uint ,
1159+ Then : BasicBlockRef ,
1160+ Catch : BasicBlockRef ,
1161+ Bundle : OperandBundleDefRef ,
1162+ Name : * const c_char )
1163+ -> ValueRef ;
11601164 pub fn LLVMRustBuildLandingPad ( B : BuilderRef ,
11611165 Ty : TypeRef ,
11621166 PersFn : ValueRef ,
@@ -1167,6 +1171,31 @@ extern {
11671171 pub fn LLVMBuildResume ( B : BuilderRef , Exn : ValueRef ) -> ValueRef ;
11681172 pub fn LLVMBuildUnreachable ( B : BuilderRef ) -> ValueRef ;
11691173
1174+ pub fn LLVMRustBuildCleanupPad ( B : BuilderRef ,
1175+ ParentPad : ValueRef ,
1176+ ArgCnt : c_uint ,
1177+ Args : * const ValueRef ,
1178+ Name : * const c_char ) -> ValueRef ;
1179+ pub fn LLVMRustBuildCleanupRet ( B : BuilderRef ,
1180+ CleanupPad : ValueRef ,
1181+ UnwindBB : BasicBlockRef ) -> ValueRef ;
1182+ pub fn LLVMRustBuildCatchPad ( B : BuilderRef ,
1183+ ParentPad : ValueRef ,
1184+ ArgCnt : c_uint ,
1185+ Args : * const ValueRef ,
1186+ Name : * const c_char ) -> ValueRef ;
1187+ pub fn LLVMRustBuildCatchRet ( B : BuilderRef ,
1188+ Pad : ValueRef ,
1189+ BB : BasicBlockRef ) -> ValueRef ;
1190+ pub fn LLVMRustBuildCatchSwitch ( Builder : BuilderRef ,
1191+ ParentPad : ValueRef ,
1192+ BB : BasicBlockRef ,
1193+ NumHandlers : c_uint ,
1194+ Name : * const c_char ) -> ValueRef ;
1195+ pub fn LLVMRustAddHandler ( CatchSwitch : ValueRef ,
1196+ Handler : BasicBlockRef ) ;
1197+ pub fn LLVMRustSetPersonalityFn ( B : BuilderRef , Pers : ValueRef ) ;
1198+
11701199 /* Add a case to the switch instruction */
11711200 pub fn LLVMAddCase ( Switch : ValueRef ,
11721201 OnVal : ValueRef ,
@@ -1476,12 +1505,13 @@ extern {
14761505 /* Miscellaneous instructions */
14771506 pub fn LLVMBuildPhi ( B : BuilderRef , Ty : TypeRef , Name : * const c_char )
14781507 -> ValueRef ;
1479- pub fn LLVMBuildCall ( B : BuilderRef ,
1480- Fn : ValueRef ,
1481- Args : * const ValueRef ,
1482- NumArgs : c_uint ,
1483- Name : * const c_char )
1484- -> ValueRef ;
1508+ pub fn LLVMRustBuildCall ( B : BuilderRef ,
1509+ Fn : ValueRef ,
1510+ Args : * const ValueRef ,
1511+ NumArgs : c_uint ,
1512+ Bundle : OperandBundleDefRef ,
1513+ Name : * const c_char )
1514+ -> ValueRef ;
14851515 pub fn LLVMBuildSelect ( B : BuilderRef ,
14861516 If : ValueRef ,
14871517 Then : ValueRef ,
@@ -2126,6 +2156,12 @@ extern {
21262156 pub fn LLVMRustSetDataLayoutFromTargetMachine ( M : ModuleRef ,
21272157 TM : TargetMachineRef ) ;
21282158 pub fn LLVMRustGetModuleDataLayout ( M : ModuleRef ) -> TargetDataRef ;
2159+
2160+ pub fn LLVMRustBuildOperandBundleDef ( Name : * const c_char ,
2161+ Inputs : * const ValueRef ,
2162+ NumInputs : c_uint )
2163+ -> OperandBundleDefRef ;
2164+ pub fn LLVMRustFreeOperandBundleDef ( Bundle : OperandBundleDefRef ) ;
21292165}
21302166
21312167#[ cfg( have_component_x86) ]
@@ -2404,6 +2440,48 @@ pub fn initialize_available_targets() {
24042440 init_pnacl ( ) ;
24052441}
24062442
2443+ pub fn last_error ( ) -> Option < String > {
2444+ unsafe {
2445+ let cstr = LLVMRustGetLastError ( ) ;
2446+ if cstr. is_null ( ) {
2447+ None
2448+ } else {
2449+ let err = CStr :: from_ptr ( cstr) . to_bytes ( ) ;
2450+ let err = String :: from_utf8_lossy ( err) . to_string ( ) ;
2451+ libc:: free ( cstr as * mut _ ) ;
2452+ Some ( err)
2453+ }
2454+ }
2455+ }
2456+
2457+ pub struct OperandBundleDef {
2458+ inner : OperandBundleDefRef ,
2459+ }
2460+
2461+ impl OperandBundleDef {
2462+ pub fn new ( name : & str , vals : & [ ValueRef ] ) -> OperandBundleDef {
2463+ let name = CString :: new ( name) . unwrap ( ) ;
2464+ let def = unsafe {
2465+ LLVMRustBuildOperandBundleDef ( name. as_ptr ( ) ,
2466+ vals. as_ptr ( ) ,
2467+ vals. len ( ) as c_uint )
2468+ } ;
2469+ OperandBundleDef { inner : def }
2470+ }
2471+
2472+ pub fn raw ( & self ) -> OperandBundleDefRef {
2473+ self . inner
2474+ }
2475+ }
2476+
2477+ impl Drop for OperandBundleDef {
2478+ fn drop ( & mut self ) {
2479+ unsafe {
2480+ LLVMRustFreeOperandBundleDef ( self . inner ) ;
2481+ }
2482+ }
2483+ }
2484+
24072485// The module containing the native LLVM dependencies, generated by the build system
24082486// Note that this must come after the rustllvm extern declaration so that
24092487// parts of LLVM that rustllvm depends on aren't thrown away by the linker.
0 commit comments