Skip to content

Commit 66f86a6

Browse files
committed
Fwd: Rename Duplicated -> Dual
1 parent 494b102 commit 66f86a6

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

compiler/rustc_ast/src/expand/autodiff_attrs.rs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};//, StableOrd};
2-
use crate::HashStableContext;
31
use crate::expand::typetree::TypeTree;
42
use thin_vec::ThinVec;
53
use std::str::FromStr;
64

75
use crate::NestedMetaItem;
86

97
#[allow(dead_code)]
10-
#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug)]
8+
#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
119
pub enum DiffMode {
1210
Inactive,
1311
Source,
@@ -16,44 +14,16 @@ pub enum DiffMode {
1614
}
1715

1816
#[allow(dead_code)]
19-
#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug)]
17+
#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
2018
pub enum DiffActivity {
2119
None,
2220
Active,
2321
Const,
22+
Dual,
23+
DualNoNeed,
2424
Duplicated,
2525
DuplicatedNoNeed,
2626
}
27-
fn clause_diffactivity_discriminant(value: &DiffActivity) -> usize {
28-
match value {
29-
DiffActivity::None => 0,
30-
DiffActivity::Active => 1,
31-
DiffActivity::Const => 2,
32-
DiffActivity::Duplicated => 3,
33-
DiffActivity::DuplicatedNoNeed => 4,
34-
}
35-
}
36-
fn clause_diffmode_discriminant(value: &DiffMode) -> usize {
37-
match value {
38-
DiffMode::Inactive => 0,
39-
DiffMode::Source => 1,
40-
DiffMode::Forward => 2,
41-
DiffMode::Reverse => 3,
42-
}
43-
}
44-
45-
46-
impl<CTX: HashStableContext> HashStable<CTX> for DiffMode {
47-
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
48-
clause_diffmode_discriminant(self).hash_stable(hcx, hasher);
49-
}
50-
}
51-
52-
impl<CTX: HashStableContext> HashStable<CTX> for DiffActivity {
53-
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
54-
clause_diffactivity_discriminant(self).hash_stable(hcx, hasher);
55-
}
56-
}
5727

5828
impl FromStr for DiffMode {
5929
type Err = ();
@@ -74,6 +44,8 @@ impl FromStr for DiffActivity {
7444
"None" => Ok(DiffActivity::None),
7545
"Active" => Ok(DiffActivity::Active),
7646
"Const" => Ok(DiffActivity::Const),
47+
"Dual" => Ok(DiffActivity::Dual),
48+
"DualNoNeed" => Ok(DiffActivity::DualNoNeed),
7749
"Duplicated" => Ok(DiffActivity::Duplicated),
7850
"DuplicatedNoNeed" => Ok(DiffActivity::DuplicatedNoNeed),
7951
_ => Err(()),

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn gen_enzyme_decl(_ecx: &ExtCtxt<'_>, sig: &ast::FnSig, x: &AutoDiffAttrs, span
240240
//dbg!(&arg);
241241
d_inputs.push(arg.clone());
242242
match activity {
243-
DiffActivity::Duplicated => {
243+
DiffActivity::Duplicated | DiffActivity::Dual => {
244244
let mut shadow_arg = arg.clone();
245245
shadow_arg.ty = P(assure_mut_ref(&arg.ty));
246246
// adjust name depending on mode

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,8 @@ fn cdiffe_from(act: DiffActivity) -> CDIFFE_TYPE {
26892689
DiffActivity::None => CDIFFE_TYPE::DFT_CONSTANT,
26902690
DiffActivity::Active => CDIFFE_TYPE::DFT_OUT_DIFF,
26912691
DiffActivity::Const => CDIFFE_TYPE::DFT_CONSTANT,
2692+
DiffActivity::Dual => CDIFFE_TYPE::DFT_DUP_ARG,
2693+
DiffActivity::DualNoNeed => CDIFFE_TYPE::DFT_DUP_NONEED,
26922694
DiffActivity::Duplicated => CDIFFE_TYPE::DFT_DUP_ARG,
26932695
DiffActivity::DuplicatedNoNeed => CDIFFE_TYPE::DFT_DUP_NONEED,
26942696
};

0 commit comments

Comments
 (0)