To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 98dba649 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Merge branch 'ir-validation' of gitlab.anu.edu.au:mu/mu-impl-fast into ir-validation

parents 5f59d00d c962654d
......@@ -63,49 +63,6 @@ impl Instruction {
use inst::Instruction_::*;
match self.v {
BinOp(_, _, _) |
BinOpWithStatus(_, _, _, _) |
CmpOp(_, _, _) |
ConvOp { .. } |
ExprCall { .. } |
ExprCCall { .. } |
Load { .. } |
Store { .. } |
CmpXchg { .. } |
AtomicRMW { .. } |
New(_) |
AllocA(_) |
NewHybrid(_, _) |
AllocAHybrid(_, _) |
NewStack(_) |
NewThread(_, _) |
NewThreadExn(_, _) |
NewFrameCursor(_) |
GetIRef(_) |
GetFieldIRef { .. } |
GetElementIRef { .. } |
ShiftIRef { .. } |
GetVarPartIRef { .. } |
Select { .. } |
Fence(_) |
CommonInst_GetThreadLocal |
CommonInst_SetThreadLocal(_) |
CommonInst_Pin(_) |
CommonInst_Unpin(_) |
CommonInst_GetAddr(_) |
CommonInst_Tr64IsFp(_) |
CommonInst_Tr64IsInt(_) |
CommonInst_Tr64IsRef(_) |
CommonInst_Tr64FromFp(_) |
CommonInst_Tr64FromInt(_) |
CommonInst_Tr64FromRef(_, _) |
CommonInst_Tr64ToFp(_) |
CommonInst_Tr64ToInt(_) |
CommonInst_Tr64ToRef(_) |
CommonInst_Tr64ToTag(_) |
Move(_) |
PrintHex(_) |
SetRetval(_) => false,
Return(_) |
ThreadExit |
Throw(_) |
......@@ -116,9 +73,11 @@ impl Instruction {
WPBranch { .. } |
Call { .. } |
CCall { .. } |
SwapStack { .. } |
SwapStackExc { .. } |
SwapStackKill { .. } |
Switch { .. } |
ExnInstruction { .. } => true
ExnInstruction { .. } => true,
_ => false,
}
}
......@@ -135,58 +94,14 @@ impl Instruction {
use inst::Instruction_::*;
match self.v {
BinOp(_, _, _) => false,
BinOpWithStatus(_, _, _, _) => false,
CmpOp(_, _, _) => false,
ConvOp { .. } => false,
ExprCall { .. } => true,
ExprCCall { .. } => true,
Load { .. } => true,
Store { .. } => true,
CmpXchg { .. } => true,
AtomicRMW { .. } => true,
New(_) => true,
AllocA(_) => true,
NewHybrid(_, _) => true,
AllocAHybrid(_, _) => true,
NewStack(_) => true,
NewThread(_, _) => true,
NewThreadExn(_, _) => true,
NewFrameCursor(_) => true,
GetIRef(_) => false,
GetFieldIRef { .. } => false,
GetElementIRef { .. } => false,
ShiftIRef { .. } => false,
GetVarPartIRef { .. } => false,
Fence(_) => true,
Return(_) => true,
ThreadExit => true,
Throw(_) => true,
TailCall(_) => true,
Branch1(_) => true,
Branch2 { .. } => true,
Select { .. } => false,
Watchpoint { .. } => true,
WPBranch { .. } => true,
Call { .. } => true,
CCall { .. } => true,
SwapStack { .. } => true,
Switch { .. } => true,
ExnInstruction { .. } => true,
CommonInst_GetThreadLocal => true,
CommonInst_SetThreadLocal(_) => true,
CommonInst_Pin(_) | CommonInst_Unpin(_) | CommonInst_GetAddr(_) => true,
CommonInst_Tr64IsFp(_) | CommonInst_Tr64IsInt(_) | CommonInst_Tr64IsRef(_) => false,
CommonInst_Tr64FromFp(_) | CommonInst_Tr64FromInt(_) | CommonInst_Tr64FromRef(_, _) => {
false
}
CommonInst_Tr64ToFp(_) |
CommonInst_Tr64ToInt(_) |
CommonInst_Tr64ToRef(_) |
CommonInst_Tr64ToTag(_) => false,
Move(_) => false,
PrintHex(_) => true,
SetRetval(_) => true
ExprCall { .. } | ExprCCall { .. } | Load { .. } | Store { .. } | CmpXchg { .. } | AtomicRMW { .. } |
New(_) | AllocA(_) | NewHybrid(_, _) | AllocAHybrid(_, _) | NewStack(_) | NewThread(_, _) |
NewThreadExn(_, _) | NewFrameCursor(_) | Fence(_) | Return(_) | ThreadExit | Throw(_) |
TailCall(_) | Branch1(_) | Branch2 { .. } | Watchpoint { .. } | WPBranch { .. } |
Call { .. } | CCall { .. }| SwapStackExpr{..}| SwapStackExc { .. } | SwapStackKill { .. } | Switch { .. } | ExnInstruction { .. } |
CommonInst_GetThreadLocal | CommonInst_SetThreadLocal(_) | CommonInst_Pin(_) | CommonInst_Unpin(_) |
CommonInst_GetAddr(_) | PrintHex(_) | SetRetval(_) => true,
_ => false
}
}
......@@ -199,60 +114,9 @@ impl Instruction {
Watchpoint { .. } |
Call { .. } |
CCall { .. } |
SwapStack { .. } |
SwapStackExc {..} |
ExnInstruction { .. } => true,
BinOp(_, _, _) |
BinOpWithStatus(_, _, _, _) |
CmpOp(_, _, _) |
ConvOp { .. } |
ExprCall { .. } |
ExprCCall { .. } |
Load { .. } |
Store { .. } |
CmpXchg { .. } |
AtomicRMW { .. } |
New(_) |
AllocA(_) |
NewHybrid(_, _) |
AllocAHybrid(_, _) |
NewStack(_) |
NewThread(_, _) |
NewThreadExn(_, _) |
NewFrameCursor(_) |
GetIRef(_) |
GetFieldIRef { .. } |
GetElementIRef { .. } |
ShiftIRef { .. } |
GetVarPartIRef { .. } |
Fence(_) |
Return(_) |
ThreadExit |
Throw(_) |
TailCall(_) |
Branch1(_) |
Branch2 { .. } |
Select { .. } |
WPBranch { .. } |
Switch { .. } |
CommonInst_GetThreadLocal |
CommonInst_SetThreadLocal(_) |
CommonInst_Pin(_) |
CommonInst_Unpin(_) |
CommonInst_GetAddr(_) |
CommonInst_Tr64IsFp(_) |
CommonInst_Tr64IsInt(_) |
CommonInst_Tr64IsRef(_) |
CommonInst_Tr64FromFp(_) |
CommonInst_Tr64FromInt(_) |
CommonInst_Tr64FromRef(_, _) |
CommonInst_Tr64ToFp(_) |
CommonInst_Tr64ToInt(_) |
CommonInst_Tr64ToRef(_) |
CommonInst_Tr64ToTag(_) |
Move(_) |
PrintHex(_) |
SetRetval(_) => false
_ => false,
}
}
......@@ -269,60 +133,9 @@ impl Instruction {
Watchpoint { ref resume, .. } |
Call { ref resume, .. } |
CCall { ref resume, .. } |
SwapStack { ref resume, .. } |
SwapStackExc { ref resume, ..} |
ExnInstruction { ref resume, .. } => Some(resume.exn_dest.target),
BinOp(_, _, _) |
BinOpWithStatus(_, _, _, _) |
CmpOp(_, _, _) |
ConvOp { .. } |
ExprCall { .. } |
ExprCCall { .. } |
Load { .. } |
Store { .. } |
CmpXchg { .. } |
AtomicRMW { .. } |
New(_) |
AllocA(_) |
NewHybrid(_, _) |
AllocAHybrid(_, _) |
NewStack(_) |
NewThread(_, _) |
NewThreadExn(_, _) |
NewFrameCursor(_) |
GetIRef(_) |
GetFieldIRef { .. } |
GetElementIRef { .. } |
ShiftIRef { .. } |
GetVarPartIRef { .. } |
Fence(_) |
Return(_) |
ThreadExit |
Throw(_) |
TailCall(_) |
Branch1(_) |
Branch2 { .. } |
Select { .. } |
WPBranch { .. } |
Switch { .. } |
CommonInst_GetThreadLocal |
CommonInst_SetThreadLocal(_) |
CommonInst_Pin(_) |
CommonInst_Unpin(_) |
CommonInst_GetAddr(_) |
CommonInst_Tr64IsFp(_) |
CommonInst_Tr64IsInt(_) |
CommonInst_Tr64IsRef(_) |
CommonInst_Tr64FromFp(_) |
CommonInst_Tr64FromInt(_) |
CommonInst_Tr64FromRef(_, _) |
CommonInst_Tr64ToFp(_) |
CommonInst_Tr64ToInt(_) |
CommonInst_Tr64ToRef(_) |
CommonInst_Tr64ToTag(_) |
Move(_) |
PrintHex(_) |
SetRetval(_) => None
_ => None
}
}
......@@ -539,15 +352,28 @@ pub enum Instruction_ {
resume: ResumptionData
},
/// swapstack. swap current Mu stack with the named Mu stack,
/// and continue with specified resumption
SwapStack {
// A swap stack with an exception clause (i.e. uses the RET_WITH form)
SwapStackExc {
stack: OpIndex,
is_exception: bool,
args: Vec<OpIndex>,
resume: ResumptionData
},
// A swap stack without an exception clause that is not a terminator (i.e. uses the RET_WITH form)
SwapStackExpr {
stack: OpIndex,
is_exception: bool,
args: Vec<OpIndex>,
},
// A swapstack without an exception clause that is a terminator (i.e. one with KILL_OLD)
SwapStackKill {
stack: OpIndex,
is_exception: bool,
args: Vec<OpIndex>,
},
/// a multiway branch
Switch {
cond: OpIndex,
......@@ -793,11 +619,23 @@ impl Instruction_ {
ref data,
ref resume
} => format!("CALL {} {}", data.debug_str(ops), resume.debug_str(ops)),
&Instruction_::CCall {
&Instruction_::CCall {
ref data,
ref resume
} => format!("CCALL {} {}", data.debug_str(ops), resume.debug_str(ops)),
&Instruction_::SwapStack {
&Instruction_::SwapStackExpr {
stack,
is_exception,
ref args,
} => {
format!(
"SWAPSTACK {} {} {}",
ops[stack],
is_exception,
op_vector_str(args, ops),
)
}
&Instruction_::SwapStackExc {
stack,
is_exception,
ref args,
......@@ -811,6 +649,20 @@ impl Instruction_ {
resume.debug_str(ops)
)
}
&Instruction_::SwapStackKill {
stack,
is_exception,
ref args,
} => {
format!(
"SWAPSTACK {} {} {}",
ops[stack],
is_exception,
op_vector_str(args, ops),
)
}
&Instruction_::Switch {
cond,
ref default,
......@@ -948,7 +800,7 @@ impl fmt::Debug for BinOpStatus {
}
}
#[derive(Copy, Clone, Debug)]
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum MemoryOrder {
NotAtomic,
Relaxed,
......
......@@ -785,7 +785,7 @@ impl BlockContent {
}
Instruction_::Call { ref resume, .. } |
Instruction_::CCall { ref resume, .. } |
Instruction_::SwapStack { ref resume, .. } |
Instruction_::SwapStackExc { ref resume, .. } |
Instruction_::ExnInstruction { ref resume, .. } => {
let mut live_outs = vec![];
live_outs.append(&mut resume.normal_dest.get_arguments(&ops));
......@@ -908,6 +908,25 @@ impl TreeNode {
_ => None
}
}
// The type of the node (for a value node)
pub fn ty(&self) -> P<MuType> {
match self.v {
TreeNode_::Instruction(ref inst) => {
if inst.value.is_some() {
let ref value = inst.value.as_ref().unwrap();
if value.len() != 1 {
panic!("the node {} does not have one result value", self);
}
value[0].ty.clone()
} else {
panic!("expected result from the node {}", self);
}
}
TreeNode_::Value(ref pv) => pv.ty.clone()
}
}
}
impl fmt::Display for TreeNode {
......
......@@ -13,7 +13,8 @@
// limitations under the License.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum BinOp {
pub
enum BinOp {
// BinOp Int(n) Int(n) -> Int(n)
Add,
Sub,
......@@ -39,6 +40,19 @@ pub enum BinOp {
FRem
}
impl BinOp {
pub fn is_fp(self) -> bool {
use op::BinOp::*;
match self {
FAdd |
FSub |
FMul |
FDiv |
FRem => true,
_ => false
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum CmpOp {
// for Int comparison
......@@ -174,6 +188,22 @@ impl CmpOp {
}
}
pub fn is_fp_cmp(self) -> bool { !self.is_int_cmp() }
pub fn is_eq_cmp(self) -> bool {
use op::CmpOp::*;
match self {
EQ | NE => true,
_ => false
}
}
pub fn is_ult_cmp(self) -> bool {
use op::CmpOp::*;
match self {
UGE | UGT | ULE | ULT => true,
_ => false
}
}
pub fn is_symmetric(self) -> bool {
use op::CmpOp::*;
match self {
......
......@@ -75,6 +75,14 @@ lazy_static! {
MuType::new(new_internal_id(), MuType_::iref(VOID_TYPE.clone()))
);
pub static ref STACKREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::StackRef)
);
pub static ref THREADREF_TYPE : P<MuType> = P(
MuType::new(new_internal_id(), MuType_::ThreadRef)
);
pub static ref INTERNAL_TYPES : Vec<P<MuType>> = vec![
ADDRESS_TYPE.clone(),
UINT1_TYPE.clone(),
......@@ -89,6 +97,8 @@ lazy_static! {
VOID_TYPE.clone(),
REF_VOID_TYPE.clone(),
IREF_VOID_TYPE.clone(),
STACKREF_TYPE.clone(),
THREADREF_TYPE.clone(),
];
}
......@@ -106,7 +116,7 @@ pub fn init_types() {
}
/// MuType represents a Mu type
#[derive(PartialEq, Debug)]
#[derive(Debug)]
pub struct MuType {
pub hdr: MuEntityHeader,
pub v: MuType_
......@@ -114,6 +124,11 @@ pub struct MuType {
rodal_struct!(MuType { hdr, v });
impl PartialEq for MuType {
fn eq(&self, other: &MuType) -> bool { self.v == other.v }
fn ne(&self, other: &MuType) -> bool { self.v != other.v }
}
impl MuType {
/// creates a new Mu type
pub fn new(id: MuID, v: MuType_) -> MuType {
......@@ -123,6 +138,19 @@ impl MuType {
}
}
pub fn is_tagref64(&self) -> bool {
match self.v {
MuType_::Tagref64 => true,
_ => false
}
}
pub fn is_funcref(&self) -> bool {
match self.v {
MuType_::Struct(_) => true,
_ => false
}
}
/// is this type struct type?
pub fn is_struct(&self) -> bool {
match self.v {
......@@ -131,6 +159,13 @@ impl MuType {
}
}
pub fn is_void(&self) -> bool {
match self.v {
MuType_::Void => true,
_ => false
}
}
/// is this type hybrid type?
pub fn is_hybrid(&self) -> bool {
match self.v {
......@@ -155,6 +190,22 @@ impl MuType {
}
}
pub fn is_opaque_reference(&self) -> bool {
match self.v {
MuType_::FuncRef(_) | MuType_::StackRef | MuType_::ThreadRef => true,
_ => false
}
}
pub fn is_eq_comparable(&self) -> bool {
self.is_int() || self.is_ptr() || self.is_iref() || self.is_ref() || self.is_opaque_reference()
}
pub fn is_ult_comparable(&self) -> bool {
self.is_int() || self.is_ptr() || self.is_iref()
}
/// is this type a float type (single-precision floating point)
pub fn is_float(&self) -> bool {
match self.v {
......@@ -393,7 +444,7 @@ pub type StructTag = MuName;
pub type HybridTag = MuName;
/// MuType_ is used for pattern matching for MuType
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub enum MuType_ {
/// int <length>
Int(usize),
......@@ -441,7 +492,14 @@ pub enum MuType_ {
/// ufuncptr<@sig>
UFuncPtr(P<MuFuncSig>)
}
impl MuType_ {
pub fn strong_variant(&self) -> MuType_ {
match self {
&MuType_::WeakRef(ref t) => MuType_::Ref(t.clone()),
_ => self.clone()
}
}
}
rodal_enum!(MuType_{(Int: size), Float, Double, (Ref: ty), (IRef: ty), (WeakRef: ty), (UPtr: ty),
(Struct: tag), (Array: ty, size), (Hybrid: tag), Void, ThreadRef, StackRef, Tagref64,
(Vector: ty, size), (FuncRef: ty), (UFuncPtr: ty)});
......
This diff is collapsed.
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