Skip to content

Commit 0a56a89

Browse files
committed
basic typetree compiling going to llvm level next
Signed-off-by: Karan Janthe <[email protected]>
1 parent 4ff3fa0 commit 0a56a89

File tree

5 files changed

+364
-10
lines changed

5 files changed

+364
-10
lines changed

compiler/rustc_ast/src/expand/autodiff_attrs.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::fmt::{self, Display, Formatter};
77
use std::str::FromStr;
88

9+
use crate::expand::typetree::TypeTree;
910
use crate::expand::{Decodable, Encodable, HashStable_Generic};
1011
use crate::ptr::P;
1112
use crate::{Ty, TyKind};
@@ -85,6 +86,9 @@ pub struct AutoDiffItem {
8586
/// The name of the function being generated
8687
pub target: String,
8788
pub attrs: AutoDiffAttrs,
89+
// Type Tree support
90+
pub inputs: Vec<TypeTree>,
91+
pub output: TypeTree,
8892
}
8993

9094
#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
@@ -276,14 +280,23 @@ impl AutoDiffAttrs {
276280
!matches!(self.mode, DiffMode::Error | DiffMode::Source)
277281
}
278282

279-
pub fn into_item(self, source: String, target: String) -> AutoDiffItem {
280-
AutoDiffItem { source, target, attrs: self }
283+
pub fn into_item(
284+
self,
285+
source: String,
286+
target: String,
287+
inputs: Vec<TypeTree>,
288+
output: TypeTree,
289+
) -> AutoDiffItem {
290+
AutoDiffItem { source, target, inputs, output, attrs: self }
281291
}
282292
}
283293

284294
impl fmt::Display for AutoDiffItem {
285295
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
286296
write!(f, "Differentiating {} -> {}", self.source, self.target)?;
287-
write!(f, " with attributes: {:?}", self.attrs)
297+
write!(f, " with attributes: {:?}", self.attrs)?;
298+
write!(f, " with attributes: {:?}", self.attrs)?;
299+
write!(f, " with inputs: {:?}", self.inputs)?;
300+
write!(f, " with output: {:?}", self.output)
288301
}
289302
}

compiler/rustc_middle/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub struct UnsupportedUnion {
4444
pub ty_name: String,
4545
}
4646

47-
// FIXME(autodiff): I should get used somewhere
4847
#[derive(Diagnostic)]
4948
#[diag(middle_autodiff_unsafe_inner_const_ref)]
5049
pub struct AutodiffUnsafeInnerConstRef<'tcx> {

0 commit comments

Comments
 (0)