1
Fork 0

Remove bitflags dependency

This commit is contained in:
bjorn3 2019-10-06 17:52:23 +02:00
parent 75db7cc49d
commit 82fde5b622
5 changed files with 17 additions and 29 deletions

1
Cargo.lock generated
View file

@ -391,7 +391,6 @@ name = "rustc_codegen_cranelift"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)",
"cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)",

View file

@ -19,7 +19,6 @@ faerie = "0.11.0"
#goblin = "0.0.17" #goblin = "0.0.17"
ar = "0.8.0" ar = "0.8.0"
bitflags = "1.1.0"
byteorder = "1.2.7" byteorder = "1.2.7"
libc = "0.2.53" libc = "0.2.53"
gimli = "0.19.0" gimli = "0.19.0"

View file

@ -282,10 +282,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb:
for (local, arg_kind, ty) in func_params { for (local, arg_kind, ty) in func_params {
let layout = fx.layout_of(ty); let layout = fx.layout_of(ty);
let is_ssa = !ssa_analyzed let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
.get(&local)
.unwrap()
.contains(crate::analyze::Flags::NOT_SSA);
match arg_kind { match arg_kind {
ArgKind::Normal(Some(val)) => { ArgKind::Normal(Some(val)) => {
@ -339,10 +336,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb:
let ty = fx.mir.local_decls[local].ty; let ty = fx.mir.local_decls[local].ty;
let layout = fx.layout_of(ty); let layout = fx.layout_of(ty);
let is_ssa = !ssa_analyzed let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
.get(&local)
.unwrap()
.contains(crate::analyze::Flags::NOT_SSA);
local_place(fx, local, layout, is_ssa); local_place(fx, local, layout, is_ssa);
} }

View file

@ -3,7 +3,7 @@ use crate::prelude::*;
pub fn codegen_return_param( pub fn codegen_return_param(
fx: &mut FunctionCx<impl Backend>, fx: &mut FunctionCx<impl Backend>,
ssa_analyzed: &HashMap<Local, crate::analyze::Flags>, ssa_analyzed: &HashMap<Local, crate::analyze::SsaKind>,
start_ebb: Ebb, start_ebb: Ebb,
) { ) {
let ret_layout = fx.return_layout(); let ret_layout = fx.return_layout();
@ -16,10 +16,8 @@ pub fn codegen_return_param(
Empty Empty
} }
PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { PassMode::ByVal(_) | PassMode::ByValPair(_, _) => {
let is_ssa = !ssa_analyzed let is_ssa =
.get(&RETURN_PLACE) *ssa_analyzed.get(&RETURN_PLACE).unwrap() == crate::analyze::SsaKind::Ssa;
.unwrap()
.contains(crate::analyze::Flags::NOT_SSA);
super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa); super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa);

View file

@ -2,22 +2,20 @@ use crate::prelude::*;
use rustc::mir::StatementKind::*; use rustc::mir::StatementKind::*;
bitflags::bitflags! { #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Flags: u8 { pub enum SsaKind {
const NOT_SSA = 0b00000001; NotSsa,
} Ssa,
} }
pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> { pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, SsaKind> {
let mut flag_map = HashMap::new(); let mut flag_map = HashMap::new();
for local in fx.mir.local_decls.indices() {
flag_map.insert(local, Flags::empty());
}
for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { for (local, local_decl) in fx.mir.local_decls.iter_enumerated() {
if fx.clif_type(local_decl.ty).is_none() { if fx.clif_type(local_decl.ty).is_some() {
not_ssa(&mut flag_map, local); flag_map.insert(local, SsaKind::Ssa);
} else {
flag_map.insert(local, SsaKind::NotSsa);
} }
} }
@ -46,13 +44,13 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
flag_map flag_map
} }
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, Flags>, place: &Place) { fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, SsaKind>, place: &Place) {
match place.base { match place.base {
PlaceBase::Local(local) => not_ssa(flag_map, local), PlaceBase::Local(local) => not_ssa(flag_map, local),
_ => {} _ => {}
} }
} }
fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, Flags>, local: L) { fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, SsaKind>, local: L) {
*flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA; *flag_map.get_mut(local.borrow()).unwrap() = SsaKind::NotSsa;
} }