Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 82fde5b

Browse files
committed
Remove bitflags dependency
1 parent 75db7cc commit 82fde5b

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ faerie = "0.11.0"
1919

2020
#goblin = "0.0.17"
2121
ar = "0.8.0"
22-
bitflags = "1.1.0"
2322
byteorder = "1.2.7"
2423
libc = "0.2.53"
2524
gimli = "0.19.0"

src/abi/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb:
282282
for (local, arg_kind, ty) in func_params {
283283
let layout = fx.layout_of(ty);
284284

285-
let is_ssa = !ssa_analyzed
286-
.get(&local)
287-
.unwrap()
288-
.contains(crate::analyze::Flags::NOT_SSA);
285+
let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
289286

290287
match arg_kind {
291288
ArgKind::Normal(Some(val)) => {
@@ -339,10 +336,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb:
339336
let ty = fx.mir.local_decls[local].ty;
340337
let layout = fx.layout_of(ty);
341338

342-
let is_ssa = !ssa_analyzed
343-
.get(&local)
344-
.unwrap()
345-
.contains(crate::analyze::Flags::NOT_SSA);
339+
let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa;
346340

347341
local_place(fx, local, layout, is_ssa);
348342
}

src/abi/returning.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::prelude::*;
33

44
pub fn codegen_return_param(
55
fx: &mut FunctionCx<impl Backend>,
6-
ssa_analyzed: &HashMap<Local, crate::analyze::Flags>,
6+
ssa_analyzed: &HashMap<Local, crate::analyze::SsaKind>,
77
start_ebb: Ebb,
88
) {
99
let ret_layout = fx.return_layout();
@@ -16,10 +16,8 @@ pub fn codegen_return_param(
1616
Empty
1717
}
1818
PassMode::ByVal(_) | PassMode::ByValPair(_, _) => {
19-
let is_ssa = !ssa_analyzed
20-
.get(&RETURN_PLACE)
21-
.unwrap()
22-
.contains(crate::analyze::Flags::NOT_SSA);
19+
let is_ssa =
20+
*ssa_analyzed.get(&RETURN_PLACE).unwrap() == crate::analyze::SsaKind::Ssa;
2321

2422
super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa);
2523

src/analyze.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@ use crate::prelude::*;
22

33
use rustc::mir::StatementKind::*;
44

5-
bitflags::bitflags! {
6-
pub struct Flags: u8 {
7-
const NOT_SSA = 0b00000001;
8-
}
5+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
6+
pub enum SsaKind {
7+
NotSsa,
8+
Ssa,
99
}
1010

11-
pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
11+
pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, SsaKind> {
1212
let mut flag_map = HashMap::new();
1313

14-
for local in fx.mir.local_decls.indices() {
15-
flag_map.insert(local, Flags::empty());
16-
}
17-
1814
for (local, local_decl) in fx.mir.local_decls.iter_enumerated() {
19-
if fx.clif_type(local_decl.ty).is_none() {
20-
not_ssa(&mut flag_map, local);
15+
if fx.clif_type(local_decl.ty).is_some() {
16+
flag_map.insert(local, SsaKind::Ssa);
17+
} else {
18+
flag_map.insert(local, SsaKind::NotSsa);
2119
}
2220
}
2321

@@ -46,13 +44,13 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
4644
flag_map
4745
}
4846

49-
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, Flags>, place: &Place) {
47+
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, SsaKind>, place: &Place) {
5048
match place.base {
5149
PlaceBase::Local(local) => not_ssa(flag_map, local),
5250
_ => {}
5351
}
5452
}
5553

56-
fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, Flags>, local: L) {
57-
*flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA;
54+
fn not_ssa<L: ::std::borrow::Borrow<Local>>(flag_map: &mut HashMap<Local, SsaKind>, local: L) {
55+
*flag_map.get_mut(local.borrow()).unwrap() = SsaKind::NotSsa;
5856
}

0 commit comments

Comments
 (0)