make the basic_blocks field private
This commit is contained in:
parent
bc1eb67721
commit
e3af9fa490
24 changed files with 203 additions and 200 deletions
|
|
@ -168,8 +168,7 @@ pub fn cleanup_kinds<'bcx,'tcx>(_bcx: Block<'bcx,'tcx>,
|
|||
{
|
||||
fn discover_masters<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Mir<'tcx>) {
|
||||
for bb in mir.all_basic_blocks() {
|
||||
let data = mir.basic_block_data(bb);
|
||||
for (bb, data) in mir.basic_blocks().iter_enumerated() {
|
||||
match data.terminator().kind {
|
||||
TerminatorKind::Goto { .. } |
|
||||
TerminatorKind::Resume |
|
||||
|
|
@ -195,7 +194,7 @@ pub fn cleanup_kinds<'bcx,'tcx>(_bcx: Block<'bcx,'tcx>,
|
|||
|
||||
fn propagate<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Mir<'tcx>) {
|
||||
let mut funclet_succs = IndexVec::from_elem(None, &mir.basic_blocks);
|
||||
let mut funclet_succs = IndexVec::from_elem(None, mir.basic_blocks());
|
||||
|
||||
let mut set_successor = |funclet: mir::BasicBlock, succ| {
|
||||
match funclet_succs[funclet] {
|
||||
|
|
@ -249,7 +248,7 @@ pub fn cleanup_kinds<'bcx,'tcx>(_bcx: Block<'bcx,'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
let mut result = IndexVec::from_elem(CleanupKind::NotCleanup, &mir.basic_blocks);
|
||||
let mut result = IndexVec::from_elem(CleanupKind::NotCleanup, mir.basic_blocks());
|
||||
|
||||
discover_masters(&mut result, mir);
|
||||
propagate(&mut result, mir);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
pub fn trans_block(&mut self, bb: mir::BasicBlock) {
|
||||
let mut bcx = self.bcx(bb);
|
||||
let mir = self.mir.clone();
|
||||
let data = mir.basic_block_data(bb);
|
||||
let data = &mir[bb];
|
||||
|
||||
debug!("trans_block({:?}={:?})", bb, data);
|
||||
|
||||
|
|
@ -725,7 +725,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
|
||||
pub fn init_cpad(&mut self, bb: mir::BasicBlock) {
|
||||
let bcx = self.bcx(bb);
|
||||
let data = self.mir.basic_block_data(bb);
|
||||
let data = &self.mir[bb];
|
||||
debug!("init_cpad({:?})", data);
|
||||
|
||||
match self.cleanup_kinds[bb] {
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
|
|||
let mut failure = Ok(());
|
||||
|
||||
loop {
|
||||
let data = self.mir.basic_block_data(bb);
|
||||
let data = &self.mir[bb];
|
||||
for statement in &data.statements {
|
||||
let span = statement.source_info.span;
|
||||
match statement.kind {
|
||||
|
|
|
|||
|
|
@ -155,8 +155,6 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
|||
let bcx = fcx.init(false, None).build();
|
||||
let mir = bcx.mir();
|
||||
|
||||
let mir_blocks = mir.all_basic_blocks();
|
||||
|
||||
// Analyze the temps to determine which must be lvalues
|
||||
// FIXME
|
||||
let (lvalue_temps, cleanup_kinds) = bcx.with_block(|bcx| {
|
||||
|
|
@ -202,15 +200,13 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
|||
|
||||
// Allocate a `Block` for every basic block
|
||||
let block_bcxs: IndexVec<mir::BasicBlock, Block<'blk,'tcx>> =
|
||||
mir_blocks.iter()
|
||||
.map(|&bb| {
|
||||
if bb == mir::START_BLOCK {
|
||||
fcx.new_block("start", None)
|
||||
} else {
|
||||
fcx.new_block(&format!("{:?}", bb), None)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
mir.basic_blocks().indices().map(|bb| {
|
||||
if bb == mir::START_BLOCK {
|
||||
fcx.new_block("start", None)
|
||||
} else {
|
||||
fcx.new_block(&format!("{:?}", bb), None)
|
||||
}
|
||||
}).collect();
|
||||
|
||||
// Branch to the START block
|
||||
let start_bcx = block_bcxs[mir::START_BLOCK];
|
||||
|
|
@ -228,14 +224,14 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
|||
blocks: block_bcxs,
|
||||
unreachable_block: None,
|
||||
cleanup_kinds: cleanup_kinds,
|
||||
landing_pads: mir_blocks.iter().map(|_| None).collect(),
|
||||
landing_pads: IndexVec::from_elem(None, mir.basic_blocks()),
|
||||
vars: vars,
|
||||
temps: temps,
|
||||
args: args,
|
||||
scopes: scopes
|
||||
};
|
||||
|
||||
let mut visited = BitVector::new(mir_blocks.len());
|
||||
let mut visited = BitVector::new(mir.basic_blocks().len());
|
||||
|
||||
let mut rpo = traversal::reverse_postorder(&mir);
|
||||
|
||||
|
|
@ -253,7 +249,7 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
|||
|
||||
// Remove blocks that haven't been visited, or have no
|
||||
// predecessors.
|
||||
for &bb in &mir_blocks {
|
||||
for bb in mir.basic_blocks().indices() {
|
||||
let block = mircx.blocks[bb];
|
||||
let block = BasicBlock(block.llbb);
|
||||
// Unreachable block
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue