forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract typetrees in separate structure to make indepdent of LLVM
- Loading branch information
Lorenz Schmidt
committed
Feb 22, 2023
1 parent
d6cc01b
commit f2372c0
Showing
10 changed files
with
283 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use rustc_middle::middle::typetree::{TypeTree, Kind}; | ||
use crate::llvm; | ||
|
||
pub fn to_enzyme_typetree(tree: TypeTree, llvm_data_layout: &str, llcx: &llvm::Context) -> llvm::TypeTree { | ||
tree.0.iter().fold(llvm::TypeTree::new(), |obj, x| { | ||
let inner_tt = if x.child.0.is_empty() { | ||
let scalar = match x.kind { | ||
Kind::Integer => llvm::CConcreteType::DT_Integer, | ||
Kind::Float => llvm::CConcreteType::DT_Float, | ||
Kind::Double => llvm::CConcreteType::DT_Double, | ||
Kind::Pointer => llvm::CConcreteType::DT_Pointer, | ||
_ => unreachable!(), | ||
}; | ||
|
||
llvm::TypeTree::from_type(scalar, llcx) | ||
} else { | ||
to_enzyme_typetree(x.child.clone(), llvm_data_layout, llcx) | ||
}; | ||
|
||
obj.merge(inner_tt.shift(llvm_data_layout, 0, x.size as isize, x.offset as usize)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.