Commit 29a68241 authored by Yi Lin's avatar Yi Lin

Merge branch 'develop' into 'master'

merge with develop: testing with new version of pypy-mu, use Rust 1.15, add regalloc validation, etc.

See merge request !3
parents c8774b93 9b9627bf
# This file is a template, and might need editing before it works on your project.
# Unofficial language image. Look for the different tagged releases at:
# https://hub.docker.com/r/scorpil/rust/tags/
image: "qinsoon/ubuntu-zebu-test:v0.1"
image: "qinsoon/ubuntu-zebu-test:lastest"
# Optional: Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
......@@ -32,22 +32,22 @@ before_script:
test:cargo:api:
stage: test
script:
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_api
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_api 2> /dev/null
test:cargo:ir:
stage: test
script:
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_ir
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_ir 2> /dev/null
test:cargo:compiler:
stage: test
script:
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_compiler
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_compiler 2> /dev/null
test:cargo:runtime:
stage: test
script:
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_runtime
- CARGO_HOME=.cargo RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CC=clang cargo test test_runtime 2> /dev/null
testjit:milestones:
stage: test
......@@ -100,10 +100,10 @@ testjit:rpython:
script:
- git clone https://gitlab.anu.edu.au/mu/mu-client-pypy.git tests/test_jit/mu-client-pypy
- cd tests/test_jit/mu-client-pypy
- git checkout test-mu-impl-jit
- cd rpython/translator/mu/rpyc; make
- git checkout mu-rewrite
- git apply pypy.patch
- cd $CI_PROJECT_DIR/tests/test_jit
- RUST_BACKTRACE=1 PYTHONPATH=mu-client-pypy MU_RUST=$CI_PROJECT_DIR pytest test_rpython.py -v
- LD_LIBRARY_PATH=. RUST_BACKTRACE=1 PYTHONPATH=mu-client-pypy MU_ZEBU=$CI_PROJECT_DIR pytest test_rpython*.py -v
cache:
key: "$CI_BUILD_STAGE/$CI_BUILD_REF_NAME"
paths:
......
......@@ -21,10 +21,11 @@ ast = {path = "src/ast"}
utils = {path = "src/utils"}
gc = {path = "src/gc"}
field-offset = "0.1.1"
libloading = "0.3"
lazy_static = "0.1.15"
log = "0.3.5"
simple_logger = "0.4.0"
stderrlog = "0.2.2"
hprof = "0.1.3"
memmap = "0.4.0"
memsec = "0.1.9"
......
extern crate gcc;
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[cfg(target_arch = "x86_64")]
fn main() {
gcc::compile_library("libruntime.a", &["src/runtime/runtime_x64_sysv.c"]);
......@@ -8,14 +8,4 @@ fn main() {
gcc::Config::new().flag("-O3").flag("-c")
.file("src/runtime/swap_stack_x64_sysv.S")
.compile("libswap_stack.a");
}
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
fn main() {
gcc::compile_library("libruntime.a", &["src/runtime/runtime_x64_sysv.c"]);
gcc::Config::new().flag("-O3").flag("-c")
.file("src/runtime/swap_stack_x64_sysv.S")
.compile("libswap_stack.a");
}
}
\ No newline at end of file
#!/bin/bash
echo "Note: this script is only for the convenience of running tests in our lab. "
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
# detect OS
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "{$OS}" == "windowsnt" ]; then
OS=windows
elif [ "{$OS}" == "darwin" ]; then
OS=mac
else
OS=`uname`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
echo "---------"
echo "OS: $OS"
echo "KERNEL: $KERNEL"
echo "ARCH: $MACH"
echo "---------"
echo "building zebu..."
rm -rf emit/*
if [ "$OS" == "linux" ]; then
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 CC=clang-3.8 cargo build
elif [ "$OS" == "Darwin" ]; then
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 cargo build
else
echo "unknown OS. do not use this script to run"
exit
fi
echo ""
echo "fetching rpython..."
git clone https://gitlab.anu.edu.au/mu/mu-client-pypy.git mu-client-pypy
echo ""
echo "compiling rpython..."
# save current path
project_path=$(pwd)
cd mu-client-pypy
git checkout test-mu-impl-jit
cd rpython/translator/mu/rpyc; make
cd $project_path/tests/test_jit
if [ "$OS" == "linux" ]; then
if [ $# -eq 0 ]; then
RUST_BACKTRACE=1 PYTHONPATH=$project_path/mu-client-pypy MU_RUST=$project_path CC=clang-3.8 python -m pytest . -v
else
RUST_BACKTRACE=1 PYTHONPATH=$project_path/mu-client-pypy MU_RUST=$project_path CC=clang-3.8 python -m pytest -v $@
fi
elif [ "$OS" == "Darwin" ]; then
if [ $# -eq 0 ]; then
RUST_BACKTRACE=1 PYTHONPATH=$project_path/mu-client-pypy MU_RUST=$project_path CC=clang python2 -m pytest . -v
else
RUST_BACKTRACE=1 PYTHONPATH=$project_path/mu-client-pypy MU_RUST=$project_path CC=clang python2 -m pytest -v $@
fi
else
echo "unknown OS. do not use this script to run"
exit
fi
#!/bin/bash
echo "Note: this script is only for the convenience of running tests in our lab. "
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
# detect OS
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "{$OS}" == "windowsnt" ]; then
OS=windows
elif [ "{$OS}" == "darwin" ]; then
OS=mac
else
OS=`uname`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
echo "---------"
echo "OS: $OS"
echo "KERNEL: $KERNEL"
echo "ARCH: $MACH"
echo "---------"
rm -rf emit/*
if [ "$OS" == "linux" ]; then
rm -rf target/*
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test "$@"
elif [ "$OS" == "Darwin" ]; then
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test "$@"
else
echo "unknown OS. do not use this script to run"
fi
......@@ -2,20 +2,20 @@ use ir::*;
use ptr::*;
use types::*;
use std::collections::HashMap;
use utils::LinkedHashMap;
pub struct MuBundle {
pub id: MuID,
pub type_defs: HashMap<MuID, P<MuType>>,
pub func_sigs: HashMap<MuID, P<MuFuncSig>>,
pub constants: HashMap<MuID, P<Value>>,
pub globals : HashMap<MuID, P<Value>>,
pub func_defs: HashMap<MuID, MuFunction>,
pub func_decls: HashMap<MuID, MuFunctionVersion>,
pub type_defs: LinkedHashMap<MuID, P<MuType>>,
pub func_sigs: LinkedHashMap<MuID, P<MuFuncSig>>,
pub constants: LinkedHashMap<MuID, P<Value>>,
pub globals : LinkedHashMap<MuID, P<Value>>,
pub func_defs: LinkedHashMap<MuID, MuFunction>,
pub func_decls: LinkedHashMap<MuID, MuFunctionVersion>,
// id_name_map: HashMap<MuID, MuName>,
// name_id_map: HashMap<MuName, MuID>
// id_name_map: LinkedHashMap<MuID, MuName>,
// name_id_map: LinkedHashMap<MuName, MuID>
}
impl MuBundle {
......@@ -23,15 +23,15 @@ impl MuBundle {
MuBundle {
id: id,
type_defs: HashMap::new(),
func_sigs: HashMap::new(),
constants: HashMap::new(),
globals: HashMap::new(),
func_defs: HashMap::new(),
func_decls: HashMap::new(),
type_defs: LinkedHashMap::new(),
func_sigs: LinkedHashMap::new(),
constants: LinkedHashMap::new(),
globals: LinkedHashMap::new(),
func_defs: LinkedHashMap::new(),
func_decls: LinkedHashMap::new(),
// id_name_map: HashMap::new(),
// name_id_map: HashMap::new()
// id_name_map: LinkedHashMap::new(),
// name_id_map: LinkedHashMap::new()
}
}
}
\ No newline at end of file
......@@ -92,6 +92,8 @@ pub enum Instruction_ {
// expressions
BinOp(BinOp, OpIndex, OpIndex),
BinOpWithStatus(BinOp, BinOpStatus, OpIndex, OpIndex),
CmpOp(CmpOp, OpIndex, OpIndex),
ConvOp{
operation: ConvOp,
......@@ -275,13 +277,18 @@ pub enum Instruction_ {
CommonInst_Unpin(OpIndex),
// internal use: mov from ops[0] to value
Move(OpIndex)
Move(OpIndex),
// internal use: print op as hex value
PrintHex(OpIndex)
}
impl Instruction_ {
fn debug_str(&self, ops: &Vec<P<TreeNode>>) -> String {
match self {
&Instruction_::BinOp(op, op1, op2) => format!("{:?} {} {}", op, ops[op1], ops[op2]),
&Instruction_::BinOpWithStatus(op, status, op1, op2) => {
format!("{:?} {:?} {} {}", op, status, ops[op1], ops[op2])
}
&Instruction_::CmpOp(op, op1, op2) => format!("{:?} {} {}", op, ops[op1], ops[op2]),
&Instruction_::ConvOp{operation, ref from_ty, ref to_ty, operand} => {
format!("{:?} {} {} {}", operation, from_ty, to_ty, ops[operand])
......@@ -397,8 +404,58 @@ impl Instruction_ {
&Instruction_::CommonInst_Unpin(op) => format!("COMMONINST Unpin {}", ops[op]),
// move
&Instruction_::Move(from) => format!("MOVE {}", ops[from])
&Instruction_::Move(from) => format!("MOVE {}", ops[from]),
// print hex
&Instruction_::PrintHex(i) => format!("PRINTHEX {}", ops[i])
}
}
}
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct BinOpStatus {
pub flag_n: bool,
pub flag_z: bool,
pub flag_c: bool,
pub flag_v: bool
}
impl BinOpStatus {
pub fn none() -> BinOpStatus {
BinOpStatus {flag_n: false, flag_z: false, flag_c: false, flag_v: false}
}
pub fn n() -> BinOpStatus {
BinOpStatus {flag_n: true, flag_z: false, flag_c: false, flag_v: false}
}
pub fn z() -> BinOpStatus {
BinOpStatus {flag_n: false, flag_z: true, flag_c: false, flag_v: false}
}
pub fn c() -> BinOpStatus {
BinOpStatus {flag_n: false, flag_z: false, flag_c: true, flag_v: false}
}
pub fn v() -> BinOpStatus {
BinOpStatus {flag_n: false, flag_z: false, flag_c: false, flag_v: true}
}
}
impl fmt::Debug for BinOpStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.flag_n {
write!(f, "#N").unwrap();
}
if self.flag_z {
write!(f, "#Z").unwrap();
}
if self.flag_c {
write!(f, "#C").unwrap();
}
if self.flag_v {
write!(f, "#V").unwrap();
}
Ok(())
}
}
......@@ -470,7 +527,17 @@ impl Destination {
ret
}
pub fn get_arguments_as_node(&self, ops: &Vec<P<TreeNode>>) -> Vec<P<TreeNode>> {
vec_utils::map(&self.args,
|x| {
match x {
&DestArg::Normal(i) => ops[i].clone(),
&DestArg::Freshbound(_) => unimplemented!()
}
})
}
pub fn get_arguments(&self, ops: &Vec<P<TreeNode>>) -> Vec<P<Value>> {
vec_utils::map(&self.args,
|x| {
......
......@@ -6,7 +6,6 @@ use op::*;
use utils::vec_utils;
use utils::LinkedHashMap;
use std::collections::HashMap;
use std::fmt;
use std::default;
use std::sync::RwLock;
......@@ -109,6 +108,7 @@ pub struct MuFunctionVersion {
orig_content: Option<FunctionContent>,
pub content: Option<FunctionContent>,
is_defined: bool,
is_compiled: bool,
pub context: FunctionContext,
......@@ -150,6 +150,7 @@ impl MuFunctionVersion {
orig_content: None,
content: None,
is_defined: false,
is_compiled: false,
context: FunctionContext::new(),
block_trace: None,
force_inline: false
......@@ -164,6 +165,7 @@ impl MuFunctionVersion {
orig_content: Some(content.clone()),
content: Some(content),
is_defined: true,
is_compiled: false,
context: context,
block_trace: None,
force_inline: false
......@@ -184,6 +186,13 @@ impl MuFunctionVersion {
self.content = Some(content);
}
pub fn is_compiled(&self) -> bool {
self.is_compiled
}
pub fn set_compiled(&mut self) {
self.is_compiled = true;
}
pub fn new_ssa(&mut self, id: MuID, ty: P<MuType>) -> P<TreeNode> {
let val = P(Value{
hdr: MuEntityHeader::unnamed(id),
......@@ -221,8 +230,8 @@ impl MuFunctionVersion {
}
/// get Map(CallSiteID -> FuncID) that are called by this function
pub fn get_static_call_edges(&self) -> HashMap<MuID, MuID> {
let mut ret = HashMap::new();
pub fn get_static_call_edges(&self) -> LinkedHashMap<MuID, MuID> {
let mut ret = LinkedHashMap::new();
let f_content = self.content.as_ref().unwrap();
......@@ -356,13 +365,13 @@ impl FunctionContent {
#[derive(Default, Debug, RustcEncodable, RustcDecodable)]
pub struct FunctionContext {
pub values: HashMap<MuID, SSAVarEntry>
pub values: LinkedHashMap<MuID, SSAVarEntry>
}
impl FunctionContext {
fn new() -> FunctionContext {
FunctionContext {
values: HashMap::new()
values: LinkedHashMap::new()
}
}
......@@ -675,7 +684,7 @@ pub enum TreeNode_ {
}
/// always use with P<Value>
#[derive(Debug, PartialEq, RustcEncodable, RustcDecodable)]
#[derive(PartialEq, RustcEncodable, RustcDecodable)]
pub struct Value {
pub hdr: MuEntityHeader,
pub ty: P<MuType>,
......@@ -758,20 +767,45 @@ impl Value {
}
}
const DISPLAY_TYPE : bool = false;
impl fmt::Debug for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self)
}
}
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.v {
Value_::SSAVar(_) => {
write!(f, "+({} %{})", self.ty, self.hdr)
},
Value_::Constant(ref c) => {
write!(f, "+({} {} @{})", self.ty, c, self.hdr)
},
Value_::Global(ref ty) => {
write!(f, "+(GLOBAL {} @{})", ty, self.hdr)
},
Value_::Memory(ref mem) => {
write!(f, "+(MEM {} %{})", mem, self.hdr)
if DISPLAY_TYPE {
match self.v {
Value_::SSAVar(_) => {
write!(f, "+({} %{})", self.ty, self.hdr)
},
Value_::Constant(ref c) => {
write!(f, "+({} {} @{})", self.ty, c, self.hdr)
},
Value_::Global(ref ty) => {
write!(f, "+(GLOBAL {} @{})", ty, self.hdr)
},
Value_::Memory(ref mem) => {
write!(f, "+(MEM {} %{})", mem, self.hdr)
}
}
} else {
match self.v {
Value_::SSAVar(_) => {
write!(f, "%{}", self.hdr)
},
Value_::Constant(ref c) => {
write!(f, "{}", c)
},
Value_::Global(_) => {
write!(f, "GLOBAL @{}", self.hdr)
},
Value_::Memory(ref mem) => {
write!(f, "MEM {} %{}", mem, self.hdr)
}
}
}
}
......@@ -893,7 +927,7 @@ pub enum Constant {
impl fmt::Display for Constant {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&Constant::Int(v) => write!(f, "{}", v),
&Constant::Int(v) => write!(f, "{}", v as i64),
&Constant::Float(v) => write!(f, "{}", v),
&Constant::Double(v) => write!(f, "{}", v),
// &Constant::IRef(v) => write!(f, "{}", v),
......@@ -1036,7 +1070,7 @@ impl MuEntityHeader {
*name_guard = Some(MuEntityHeader::name_check(name));
}
fn name_check(name: MuName) -> MuName {
pub fn name_check(name: MuName) -> MuName {
if name.starts_with("@") || name.starts_with("%") {
let (_, name) = name.split_at(1);
......@@ -1053,12 +1087,24 @@ impl PartialEq for MuEntityHeader {
}
}
const PRINT_ABBREVIATE_NAME: bool = false;
impl fmt::Display for MuEntityHeader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.name().is_none() {
write!(f, "UNNAMED #{}", self.id)
} else {
write!(f, "{} #{}", self.name().unwrap(), self.id)
if PRINT_ABBREVIATE_NAME {
let name = self.name().unwrap().clone();
let abbr_name = name.split('.').map(
|x| match x.chars().next() {
Some(c) => c,
None => '_'
}).fold("".to_string(), |mut acc, x| {acc.push(x); acc});
write!(f, "{} #{}", abbr_name, self.id)
} else {
write!(f, "{} #{}", self.name().unwrap(), self.id)
}
}
}
}
......
......@@ -3,7 +3,8 @@ use inst::Instruction_::*;
pub fn is_terminal_inst(inst: &Instruction_) -> bool {
match inst {
&BinOp(_, _, _)
&BinOp(_, _, _)
| &BinOpWithStatus(_, _, _, _)
| &CmpOp(_, _, _)
| &ConvOp{..}
| &ExprCall{..}
......@@ -31,7 +32,8 @@ pub fn is_terminal_inst(inst: &Instruction_) -> bool {
| &CommonInst_SetThreadLocal(_)
| &CommonInst_Pin(_)
| &CommonInst_Unpin(_)
| &Move(_) => false,
| &Move(_)
| &PrintHex(_) => false,
&Return(_)
| &ThreadExit
| &Throw(_)
......@@ -56,6 +58,7 @@ pub fn is_non_terminal_inst(inst: &Instruction_) -> bool {
pub fn has_side_effect(inst: &Instruction_) -> bool {
match inst {
&BinOp(_, _, _) => false,
&BinOpWithStatus(_, _, _, _) => false,
&CmpOp(_, _, _) => false,
&ConvOp{..} => false,
&ExprCall{..} => true,
......@@ -97,5 +100,6 @@ pub fn has_side_effect(inst: &Instruction_) -> bool {
&CommonInst_Pin(_) => true,
&CommonInst_Unpin(_) => true,
&Move(_) => false,
&PrintHex(_) => true
}
}
......@@ -36,6 +36,7 @@ pub enum OpCode {
// expression
Binary(BinOp),
BinaryWithStatus(BinOp),
Comparison(CmpOp),
Conversion(ConvOp),
AtomicRMW(AtomicRMWOp),
......@@ -64,7 +65,8 @@ pub enum OpCode {
CommonInst_Pin,
CommonInst_Unpin,
Move
Move,
PrintHex
}
pub fn pick_op_code_for_ssa(ty: &P<MuType>) -> OpCode {
......@@ -253,6 +255,7 @@ pub fn is_int_cmp(op: CmpOp) -> bool {
pub fn pick_op_code_for_inst(inst: &Instruction) -> OpCode {
match inst.v {
Instruction_::BinOp(op, _, _) => OpCode::Binary(op),
Instruction_::BinOpWithStatus(op, _, _, _) => OpCode::BinaryWithStatus(op),
Instruction_::CmpOp(op, _, _) => OpCode::Comparison(op),
Instruction_::ConvOp{operation, ..} => OpCode::Conversion(operation),
Instruction_::AtomicRMW{op, ..} => OpCode::AtomicRMW(op),
......@@ -294,5 +297,6 @@ pub fn pick_op_code_for_inst(inst: &Instruction) -> OpCode {
Instruction_::CommonInst_Pin(_) => OpCode::CommonInst_Pin,
Instruction_::CommonInst_Unpin(_) => OpCode::CommonInst_Unpin,
Instruction_::Move(_) => OpCode::Move,
Instruction_::PrintHex(_) => OpCode::PrintHex,
}
}
......@@ -5,7 +5,7 @@ use utils::POINTER_SIZE;
use utils::vec_utils;