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"
dependencies = [
"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)",
"cranelift 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"
ar = "0.8.0"
bitflags = "1.1.0"
byteorder = "1.2.7"
libc = "0.2.53"
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 {
let layout = fx.layout_of(ty);
let is_ssa = !ssa_analyzed
.get(&local)
.unwrap()
.contains(crate::analyze::Flags::NOT_SSA);
let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
match arg_kind {
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 layout = fx.layout_of(ty);
let is_ssa = !ssa_analyzed
.get(&local)
.unwrap()
.contains(crate::analyze::Flags::NOT_SSA);
let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
local_place(fx, local, layout, is_ssa);
}

View File

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

View File

@ -2,22 +2,20 @@ use crate::prelude::*;
use rustc::mir::StatementKind::*;
bitflags::bitflags! {
pub struct Flags: u8 {
const NOT_SSA = 0b00000001;
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum SsaKind {
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();
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() {
if fx.clif_type(local_decl.ty).is_none() {
not_ssa(&mut flag_map, local);
if fx.clif_type(local_decl.ty).is_some() {
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
}
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 {
PlaceBase::Local(local) => not_ssa(flag_map, local),
_ => {}
}
}
fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, Flags>, local: L) {
*flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA;
fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, SsaKind>, local: L) {
*flag_map.get_mut(local.borrow()).unwrap() = SsaKind::NotSsa;
}