Implement jump tables.

- Add a ir::jumptable module with a JumpTableData struct representing the vector
  of destinations.
- Add an entity map of jump tables to the Function.
- Parse and write jump tables in the function preamble.
- Rewrite EBB references in jumptables after parsing.
This commit is contained in:
Jakob Stoklund Olesen
2016-07-22 11:41:30 -07:00
parent 410c1390d1
commit 274671d12a
7 changed files with 281 additions and 5 deletions

View File

@@ -5,12 +5,14 @@ pub mod types;
pub mod condcodes;
pub mod immediates;
pub mod instructions;
pub mod jumptable;
pub mod dfg;
pub mod layout;
use ir::types::{FunctionName, Signature};
use entity_map::EntityRef;
use ir::entities::StackSlot;
use entity_map::{EntityRef, EntityMap};
use ir::entities::{StackSlot, JumpTable};
use ir::jumptable::JumpTableData;
use ir::dfg::DataFlowGraph;
use ir::layout::Layout;
use std::fmt::{self, Debug, Display, Formatter};
@@ -27,6 +29,9 @@ pub struct Function {
/// Stack slots allocated in this function.
stack_slots: Vec<StackSlotData>,
/// Jump tables used in this function.
pub jump_tables: EntityMap<JumpTable, JumpTableData>,
/// Data flow graph containing the primary definition of all instructions, EBBs and values.
pub dfg: DataFlowGraph,
@@ -41,6 +46,7 @@ impl Function {
name: name,
signature: sig,
stack_slots: Vec::new(),
jump_tables: EntityMap::new(),
dfg: DataFlowGraph::new(),
layout: Layout::new(),
}