To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 495c8587 authored by qinsoon's avatar qinsoon
Browse files

an empty defuse pass

parent bed34cc1
...@@ -3,6 +3,7 @@ use ast::op::{BinOp, CmpOp, AtomicRMWOp}; ...@@ -3,6 +3,7 @@ use ast::op::{BinOp, CmpOp, AtomicRMWOp};
use ast::types::*; use ast::types::*;
use std::fmt; use std::fmt;
use std::cell::Cell;
pub type WPID = usize; pub type WPID = usize;
pub type MuID = usize; pub type MuID = usize;
...@@ -42,6 +43,7 @@ pub struct TreeNode { ...@@ -42,6 +43,7 @@ pub struct TreeNode {
pub id: MuID, pub id: MuID,
pub tag: MuTag, pub tag: MuTag,
pub v: TreeNode_, pub v: TreeNode_,
pub use_count: Cell<usize>
} }
impl TreeNode { impl TreeNode {
...@@ -49,7 +51,8 @@ impl TreeNode { ...@@ -49,7 +51,8 @@ impl TreeNode {
P(TreeNode{ P(TreeNode{
id: id, id: id,
tag: tag, tag: tag,
v: TreeNode_::Value(P(Value{ty: ty, v: Value_::SSAVar})) v: TreeNode_::Value(P(Value{ty: ty, v: Value_::SSAVar})),
use_count: Cell::new(0)
}) })
} }
...@@ -57,7 +60,8 @@ impl TreeNode { ...@@ -57,7 +60,8 @@ impl TreeNode {
P(TreeNode{ P(TreeNode{
id: id, id: id,
tag: tag, tag: tag,
v: TreeNode_::Value(P(Value{ty: ty, v: Value_::Constant(v)})) v: TreeNode_::Value(P(Value{ty: ty, v: Value_::Constant(v)})),
use_count: Cell::new(0)
}) })
} }
...@@ -65,20 +69,14 @@ impl TreeNode { ...@@ -65,20 +69,14 @@ impl TreeNode {
P(TreeNode{ P(TreeNode{
id: id, id: id,
tag: tag, tag: tag,
v: TreeNode_::Value(v) v: TreeNode_::Value(v),
use_count: Cell::new(0)
} }
) )
} }
pub fn new_inst(id: MuID, tag: MuTag, v: Instruction) -> P<TreeNode> { pub fn new_inst(id: MuID, tag: MuTag, v: Instruction) -> P<TreeNode> {
P(TreeNode{id: id, tag: tag, v: TreeNode_::Instruction(v)}) P(TreeNode{id: id, tag: tag, v: TreeNode_::Instruction(v), use_count: Cell::new(0)})
}
pub fn as_value(&self) -> Option<&P<Value>> {
match self.v {
TreeNode_::Value(ref pv) => Some(&pv),
_ => None
}
} }
} }
......
use ast::ir::*; use ast::ir::*;
use ast::ptr::*;
use vm::context::VMContext; use vm::context::VMContext;
use std::cell::RefCell; use std::cell::RefCell;
...@@ -28,12 +29,35 @@ pub struct CompilerPolicy { ...@@ -28,12 +29,35 @@ pub struct CompilerPolicy {
impl CompilerPolicy { impl CompilerPolicy {
pub fn default() -> CompilerPolicy { pub fn default() -> CompilerPolicy {
let mut passes : Vec<Box<CompilerPass>> = vec![]; let mut passes : Vec<Box<CompilerPass>> = vec![];
passes.push(Box::new(passes::tree_gen::TreeGenerationPass::new())); passes.push(Box::new(passes::tree_gen::TreeGenerationPass::new("Tree Generation")));
CompilerPolicy{passes: passes} CompilerPolicy{passes: passes}
} }
} }
pub trait CompilerPass { pub trait CompilerPass {
fn execute(&mut self, vm:&VMContext, func: &mut MuFunction); fn name(&self) -> &'static str;
fn execute(&mut self, vm_context: &VMContext, func: &mut MuFunction) {
debug!("---CompilerPass {} for {}---", self.name(), func.fn_name);
self.visit_function(vm_context, func);
for entry in func.blocks.iter_mut() {
let label : MuTag = entry.0;
let ref mut block : &mut Block = &mut entry.1;
debug!("block: {}", label);
for node in block.content.as_mut().unwrap().body.iter_mut() {
debug!("{:?}", node);
}
debug!("---finish---");
}
}
fn visit_function(&mut self, vm_context: &VMContext, func: &mut MuFunction) {}
fn visit_block(&mut self, vm_context: &VMContext, block: &mut Block) {}
fn visit_node(&mut self, vm_context: &VMContext, node: &mut TreeNode) {}
} }
use ast::ir::*;
use vm::context::VMContext;
use compiler::CompilerPass;
pub struct DefUsePass {
name: &'static str,
}
impl DefUsePass {
pub fn name(name: &'static str) -> DefUsePass {
DefUsePass{name: name}
}
}
impl CompilerPass for DefUsePass {
fn name(&self) -> &'static str {
self.name
}
fn visit_node(&mut self, vm_context: &VMContext, node: &mut TreeNode) {
}
}
\ No newline at end of file
pub mod def_use;
pub mod tree_gen; pub mod tree_gen;
\ No newline at end of file
...@@ -3,29 +3,18 @@ use vm::context::VMContext; ...@@ -3,29 +3,18 @@ use vm::context::VMContext;
use compiler::CompilerPass; use compiler::CompilerPass;
pub struct TreeGenerationPass; pub struct TreeGenerationPass {
name: &'static str,
}
impl TreeGenerationPass { impl TreeGenerationPass {
pub fn new() -> TreeGenerationPass { pub fn new(name: &'static str) -> TreeGenerationPass {
TreeGenerationPass TreeGenerationPass{name: name}
} }
} }
impl CompilerPass for TreeGenerationPass { impl CompilerPass for TreeGenerationPass {
fn execute(&mut self, vm: &VMContext, func: &mut MuFunction) { fn name(&self) -> &'static str {
debug!("Generating Tree for {}", func.fn_name); self.name
for entry in func.blocks.iter_mut() {
let label : MuTag = entry.0;
let ref mut block : &mut Block = &mut entry.1;
debug!(" block: {}", label);
for inst in block.content.take().unwrap().body {
debug!(" {:?}", inst);
}
debug!(" ");
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment