Skip to content

Commit 7949baf

Browse files
committed
add ffi dummies for non-autodiff builds
1 parent 2162650 commit 7949baf

File tree

1 file changed

+78
-54
lines changed

1 file changed

+78
-54
lines changed
Lines changed: 78 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(non_camel_case_types)]
22
#![expect(dead_code)]
33

4-
use libc::{c_char, c_uint, c_void};
4+
use libc::{c_char, c_uint};
55

66
use super::ffi::{BasicBlock, Metadata, Module, Type, Value};
77
use crate::llvm::Bool;
@@ -36,69 +36,93 @@ pub enum LLVMRustVerifierFailureAction {
3636
LLVMReturnStatusAction = 2,
3737
}
3838

39-
#[cfg(not(llvm_enzyme))]
40-
pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8) {
41-
unimplemented!()
42-
}
43-
#[cfg(not(llvm_enzyme))]
44-
pub fn EnzymeSetCLInteger(arg1: *mut ::std::os::raw::c_void, arg2: i64) {
45-
unimplemented!()
46-
}
47-
4839
#[cfg(llvm_enzyme)]
49-
extern "C" {
50-
pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
51-
pub fn EnzymeSetCLInteger(arg1: *mut ::std::os::raw::c_void, arg2: i64);
52-
}
40+
pub use self::Enzyme_AD::*;
5341

5442
#[cfg(llvm_enzyme)]
55-
extern "C" {
56-
static mut EnzymePrintPerf: c_void;
57-
static mut EnzymePrintActivity: c_void;
58-
static mut EnzymePrintType: c_void;
59-
static mut EnzymePrint: c_void;
60-
static mut EnzymeStrictAliasing: c_void;
61-
static mut looseTypeAnalysis: c_void;
62-
static mut EnzymeInline: c_void;
63-
static mut RustTypeRules: c_void;
64-
}
65-
pub fn set_print_perf(print: bool) {
66-
unsafe {
67-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintPerf), print as u8);
43+
pub mod Enzyme_AD {
44+
use libc::c_void;
45+
extern "C" {
46+
pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
6847
}
69-
}
70-
pub fn set_print_activity(print: bool) {
71-
unsafe {
72-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintActivity), print as u8);
48+
extern "C" {
49+
static mut EnzymePrintPerf: c_void;
50+
static mut EnzymePrintActivity: c_void;
51+
static mut EnzymePrintType: c_void;
52+
static mut EnzymePrint: c_void;
53+
static mut EnzymeStrictAliasing: c_void;
54+
static mut looseTypeAnalysis: c_void;
55+
static mut EnzymeInline: c_void;
56+
static mut RustTypeRules: c_void;
7357
}
74-
}
75-
pub fn set_print_type(print: bool) {
76-
unsafe {
77-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8);
58+
pub fn set_print_perf(print: bool) {
59+
unsafe {
60+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintPerf), print as u8);
61+
}
7862
}
79-
}
80-
pub fn set_print(print: bool) {
81-
unsafe {
82-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8);
63+
pub fn set_print_activity(print: bool) {
64+
unsafe {
65+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintActivity), print as u8);
66+
}
8367
}
84-
}
85-
pub fn set_strict_aliasing(strict: bool) {
86-
unsafe {
87-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeStrictAliasing), strict as u8);
68+
pub fn set_print_type(print: bool) {
69+
unsafe {
70+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8);
71+
}
8872
}
89-
}
90-
pub fn set_loose_types(loose: bool) {
91-
unsafe {
92-
EnzymeSetCLBool(std::ptr::addr_of_mut!(looseTypeAnalysis), loose as u8);
73+
pub fn set_print(print: bool) {
74+
unsafe {
75+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8);
76+
}
9377
}
94-
}
95-
pub fn set_inline(val: bool) {
96-
unsafe {
97-
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeInline), val as u8);
78+
pub fn set_strict_aliasing(strict: bool) {
79+
unsafe {
80+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeStrictAliasing), strict as u8);
81+
}
82+
}
83+
pub fn set_loose_types(loose: bool) {
84+
unsafe {
85+
EnzymeSetCLBool(std::ptr::addr_of_mut!(looseTypeAnalysis), loose as u8);
86+
}
87+
}
88+
pub fn set_inline(val: bool) {
89+
unsafe {
90+
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeInline), val as u8);
91+
}
92+
}
93+
pub fn set_rust_rules(val: bool) {
94+
unsafe {
95+
EnzymeSetCLBool(std::ptr::addr_of_mut!(RustTypeRules), val as u8);
96+
}
9897
}
9998
}
100-
pub fn set_rust_rules(val: bool) {
101-
unsafe {
102-
EnzymeSetCLBool(std::ptr::addr_of_mut!(RustTypeRules), val as u8);
99+
100+
#[cfg(not(llvm_enzyme))]
101+
pub use self::Fallback_AD::*;
102+
103+
#[cfg(not(llvm_enzyme))]
104+
pub mod Fallback_AD {
105+
#![allow(unused_variables)]
106+
107+
pub fn set_inline(val: bool) {
108+
unimplemented!()
109+
}
110+
pub fn set_print_perf(print: bool) {
111+
unimplemented!()
112+
}
113+
pub fn set_print_activity(print: bool) {
114+
unimplemented!()
115+
}
116+
pub fn set_print_type(print: bool) {
117+
unimplemented!()
118+
}
119+
pub fn set_print(print: bool) {
120+
unimplemented!()
121+
}
122+
pub fn set_strict_aliasing(strict: bool) {
123+
unimplemented!()
124+
}
125+
pub fn set_loose_types(loose: bool) {
126+
unimplemented!()
103127
}
104128
}

0 commit comments

Comments
 (0)