Skip to content

Commit b5701b1

Browse files
committed
lower width info to enzyme
1 parent 30861c5 commit b5701b1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ fn generate_enzyme_call<'ll>(
136136
let enzyme_dup = cx.create_metadata("enzyme_dup".to_string()).unwrap();
137137
let enzyme_dupnoneed = cx.create_metadata("enzyme_dupnoneed".to_string()).unwrap();
138138
let enzyme_primal_ret = cx.create_metadata("enzyme_primal_return".to_string()).unwrap();
139+
let enzyme_width = cx.create_metadata("enzyme_width".to_string()).unwrap();
140+
141+
// FIXME(ZuseZ4): Find out, how enzyme_primal_ret and enzyme_width are combinable.
142+
if attrs.width > 1 {
143+
args.push(cx.get_metadata_value(enzyme_width));
144+
args.push(cx.get_const_i64(attrs.width as u64));
145+
}
139146

140147
match output {
141148
DiffActivity::Dual => {

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ impl<'ll> SimpleCx<'ll> {
637637
unsafe { llvm::LLVMMetadataAsValue(self.llcx, metadata) }
638638
}
639639

640+
pub(crate) fn get_const_i64(&self, n: u64) -> &'ll Value {
641+
let ty = unsafe {llvm::LLVMInt64TypeInContext(self.llcx) };
642+
unsafe { llvm::LLVMConstInt(ty, n, llvm::False) }
643+
}
644+
640645
pub(crate) fn get_function(&self, name: &str) -> Option<&'ll Value> {
641646
let name = SmallCStr::new(name);
642647
unsafe { llvm::LLVMGetNamedFunction(self.llmod, name.as_ptr()) }

0 commit comments

Comments
 (0)