@@ -516,3 +516,47 @@ macro_rules! impl_unsafe_fn {
516
516
}
517
517
518
518
impl_unsafe_fn ! ( A , B , C , D , E , F , G , H , I , J , K , L , M ) ;
519
+
520
+ #[ cfg( all( feature = "experimental" , not( any( feature = "llvm3-6" , feature = "llvm3-7" ) ) ) ) ]
521
+ pub mod experimental {
522
+ #[ llvm_versions( 3.8 ..=latest) ]
523
+ use llvm_sys:: orc:: { LLVMOrcCreateInstance , LLVMOrcDisposeInstance , LLVMOrcJITStackRef , LLVMOrcAddEagerlyCompiledIR , LLVMOrcAddLazilyCompiledIR } ;
524
+ use crate :: module:: Module ;
525
+ use crate :: targets:: TargetMachine ;
526
+ use std:: mem:: MaybeUninit ;
527
+
528
+ // TODO
529
+ #[ derive( Debug ) ]
530
+ pub struct Orc ( LLVMOrcJITStackRef ) ;
531
+
532
+ impl Orc {
533
+ pub fn create ( target_machine : TargetMachine ) -> Self {
534
+ let stack_ref = unsafe {
535
+ LLVMOrcCreateInstance ( target_machine. target_machine )
536
+ } ;
537
+
538
+ Orc ( stack_ref)
539
+ }
540
+
541
+ pub fn add_compiled_ir < ' ctx > ( & self , module : & Module < ' ctx > , lazily : bool ) -> Result < ( ) , ( ) > {
542
+ // let handle = MaybeUninit::uninit();
543
+ // let _err = if lazily {
544
+ // unsafe { LLVMOrcAddLazilyCompiledIR(self.0, handle.as_mut_ptr(), module.module.get(), sym_resolve, sym_resolve_ctx) }
545
+ // } else {
546
+ // unsafe { LLVMOrcAddEagerlyCompiledIR(self.0, handle.as_mut_ptr(), module.module.get(), sym_resolve, sym_resolve_ctx) }
547
+ // };
548
+
549
+ Ok ( ( ) )
550
+ }
551
+ }
552
+
553
+ impl Drop for Orc {
554
+ fn drop ( & mut self ) {
555
+ // REVIEW: This returns an LLVMErrorRef, not sure what we can do with it...
556
+ // print to stderr maybe?
557
+ unsafe {
558
+ LLVMOrcDisposeInstance ( self . 0 ) ;
559
+ }
560
+ }
561
+ }
562
+ }
0 commit comments