fixed formatting issues

parent 612f3aa0
Pipeline #3553 passed with stages
in 47 minutes and 59 seconds
This diff is collapsed.
This diff is collapsed.
...@@ -46,15 +46,19 @@ macro_rules! impl_mu_entity { ...@@ -46,15 +46,19 @@ macro_rules! impl_mu_entity {
($entity: ty) => { ($entity: ty) => {
impl MuEntity for $entity { impl MuEntity for $entity {
#[inline(always)] #[inline(always)]
fn id(&self) -> MuID {self.hdr.id()} fn id(&self) -> MuID {
self.hdr.id()
}
#[inline(always)] #[inline(always)]
fn name(&self) -> MuName {self.hdr.name()} fn name(&self) -> MuName {
self.hdr.name()
}
fn as_entity(&self) -> &MuEntity { fn as_entity(&self) -> &MuEntity {
let ref_ty : &$entity = self; let ref_ty: &$entity = self;
ref_ty as &MuEntity ref_ty as &MuEntity
} }
} }
} };
} }
/// select between two values based on condition /// select between two values based on condition
...@@ -65,12 +69,12 @@ macro_rules! select_value { ...@@ -65,12 +69,12 @@ macro_rules! select_value {
} else { } else {
$res2 $res2
} }
} };
} }
#[macro_use] #[macro_use]
pub mod ir; pub mod ir;
pub mod inst; pub mod inst;
pub mod types;
pub mod ptr;
pub mod op; pub mod op;
pub mod ptr;
pub mod types;
...@@ -36,7 +36,7 @@ pub enum BinOp { ...@@ -36,7 +36,7 @@ pub enum BinOp {
FSub, FSub,
FMul, FMul,
FDiv, FDiv,
FRem FRem,
} }
impl fmt::Display for BinOp { impl fmt::Display for BinOp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...@@ -49,7 +49,7 @@ impl BinOp { ...@@ -49,7 +49,7 @@ impl BinOp {
use op::BinOp::*; use op::BinOp::*;
match self { match self {
FAdd | FSub | FMul | FDiv | FRem => true, FAdd | FSub | FMul | FDiv | FRem => true,
_ => false _ => false,
} }
} }
} }
...@@ -83,7 +83,7 @@ pub enum CmpOp { ...@@ -83,7 +83,7 @@ pub enum CmpOp {
FULT, FULT,
FULE, FULE,
FUNE, FUNE,
FUNO FUNO,
} }
impl fmt::Display for CmpOp { impl fmt::Display for CmpOp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...@@ -116,7 +116,7 @@ impl CmpOp { ...@@ -116,7 +116,7 @@ impl CmpOp {
FUGT => FULT, FUGT => FULT,
FULT => FUGT, FULT => FUGT,
_ => self // all other comparisons are symmetric _ => self, // all other comparisons are symmetric
} }
} }
...@@ -161,7 +161,7 @@ impl CmpOp { ...@@ -161,7 +161,7 @@ impl CmpOp {
FONE => FUEQ, FONE => FUEQ,
FFALSE => FTRUE, FFALSE => FTRUE,
FTRUE => FFALSE FTRUE => FFALSE,
} }
} }
...@@ -173,7 +173,7 @@ impl CmpOp { ...@@ -173,7 +173,7 @@ impl CmpOp {
SLT => ULT, SLT => ULT,
SGT => UGT, SGT => UGT,
SLE => ULE, SLE => ULE,
_ => self _ => self,
} }
} }
...@@ -181,7 +181,7 @@ impl CmpOp { ...@@ -181,7 +181,7 @@ impl CmpOp {
use op::CmpOp::*; use op::CmpOp::*;
match self { match self {
SGE | SLT | SGT | SLE => true, SGE | SLT | SGT | SLE => true,
_ => false _ => false,
} }
} }
...@@ -189,7 +189,7 @@ impl CmpOp { ...@@ -189,7 +189,7 @@ impl CmpOp {
use op::CmpOp::*; use op::CmpOp::*;
match self { match self {
EQ | NE | SGE | SGT | SLE | SLT | UGE | UGT | ULE | ULT => true, EQ | NE | SGE | SGT | SLE | SLT | UGE | UGT | ULE | ULT => true,
_ => false _ => false,
} }
} }
...@@ -200,14 +200,14 @@ impl CmpOp { ...@@ -200,14 +200,14 @@ impl CmpOp {
use op::CmpOp::*; use op::CmpOp::*;
match self { match self {
EQ | NE => true, EQ | NE => true,
_ => false _ => false,
} }
} }
pub fn is_ult_cmp(self) -> bool { pub fn is_ult_cmp(self) -> bool {
use op::CmpOp::*; use op::CmpOp::*;
match self { match self {
UGE | UGT | ULE | ULT => true, UGE | UGT | ULE | ULT => true,
_ => false _ => false,
} }
} }
...@@ -215,7 +215,7 @@ impl CmpOp { ...@@ -215,7 +215,7 @@ impl CmpOp {
use op::CmpOp::*; use op::CmpOp::*;
match self { match self {
EQ | NE | FORD | FUNO | FUNE | FUEQ | FONE | FOEQ => true, EQ | NE | FORD | FUNO | FUNE | FUEQ | FONE | FOEQ => true,
_ => false _ => false,
} }
} }
} }
...@@ -233,7 +233,7 @@ pub enum ConvOp { ...@@ -233,7 +233,7 @@ pub enum ConvOp {
SITOFP, SITOFP,
BITCAST, BITCAST,
REFCAST, REFCAST,
PTRCAST PTRCAST,
} }
impl fmt::Display for ConvOp { impl fmt::Display for ConvOp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...@@ -253,7 +253,7 @@ pub enum AtomicRMWOp { ...@@ -253,7 +253,7 @@ pub enum AtomicRMWOp {
MAX, MAX,
MIN, MIN,
UMAX, UMAX,
UMIN UMIN,
} }
impl fmt::Display for AtomicRMWOp { impl fmt::Display for AtomicRMWOp {
......
This diff is collapsed.
...@@ -16,8 +16,8 @@ use ast::ir::*; ...@@ -16,8 +16,8 @@ use ast::ir::*;
use ast::ptr::P; use ast::ptr::P;
use runtime::ValueLocation; use runtime::ValueLocation;
use compiler::backend::{Mem, Reg};
use compiler::machine_code::MachineCode; use compiler::machine_code::MachineCode;
use compiler::backend::{Reg, Mem};
pub trait CodeGenerator { pub trait CodeGenerator {
fn start_code(&mut self, func_name: MuName, entry: MuName) -> ValueLocation; fn start_code(&mut self, func_name: MuName, entry: MuName) -> ValueLocation;
...@@ -76,7 +76,6 @@ pub trait CodeGenerator { ...@@ -76,7 +76,6 @@ pub trait CodeGenerator {
take the ZR (and vice versa) take the ZR (and vice versa)
*/ */
// loads // loads
// supports the full full range of addressing modes // supports the full full range of addressing modes
fn emit_ldr(&mut self, dest: Reg /*GPR or FPR*/, src: Mem, signed: bool); fn emit_ldr(&mut self, dest: Reg /*GPR or FPR*/, src: Mem, signed: bool);
...@@ -94,7 +93,7 @@ pub trait CodeGenerator { ...@@ -94,7 +93,7 @@ pub trait CodeGenerator {
&mut self, &mut self,
dest1: Reg, /*GPR or FPR*/ dest1: Reg, /*GPR or FPR*/
dest2: Reg, /*GPR or FPR*/ dest2: Reg, /*GPR or FPR*/
src: Mem src: Mem,
); // [base, #simm7] ); // [base, #simm7]
// Stores // Stores
...@@ -114,7 +113,7 @@ pub trait CodeGenerator { ...@@ -114,7 +113,7 @@ pub trait CodeGenerator {
&mut self, &mut self,
dest: Mem, dest: Mem,
src1: Reg, /*GPR or FPR*/ src1: Reg, /*GPR or FPR*/
src2: Reg /*GPR or FPR*/ src2: Reg, /*GPR or FPR*/
); // [base, #simm7] ); // [base, #simm7]
// Calls // Calls
...@@ -125,7 +124,7 @@ pub trait CodeGenerator { ...@@ -125,7 +124,7 @@ pub trait CodeGenerator {
pe: Option<MuName>, pe: Option<MuName>,
args: Vec<P<Value>>, args: Vec<P<Value>>,
ret: Vec<P<Value>>, ret: Vec<P<Value>>,
is_native: bool is_native: bool,
) -> Option<ValueLocation>; ) -> Option<ValueLocation>;
fn emit_blr( fn emit_blr(
&mut self, &mut self,
...@@ -133,7 +132,7 @@ pub trait CodeGenerator { ...@@ -133,7 +132,7 @@ pub trait CodeGenerator {
func: Reg, func: Reg,
pe: Option<MuName>, pe: Option<MuName>,
args: Vec<P<Value>>, args: Vec<P<Value>>,
ret: Vec<P<Value>> ret: Vec<P<Value>>,
) -> Option<ValueLocation>; ) -> Option<ValueLocation>;
// Branches // Branches
fn emit_b(&mut self, dest_name: MuName); fn emit_b(&mut self, dest_name: MuName);
...@@ -147,7 +146,7 @@ pub trait CodeGenerator { ...@@ -147,7 +146,7 @@ pub trait CodeGenerator {
args: Vec<P<Value>>, args: Vec<P<Value>>,
ret: Vec<P<Value>>, ret: Vec<P<Value>>,
is_native: bool, is_native: bool,
may_return: bool may_return: bool,
) -> Option<ValueLocation>; ) -> Option<ValueLocation>;
fn emit_br_call( fn emit_br_call(
&mut self, &mut self,
...@@ -156,10 +155,9 @@ pub trait CodeGenerator { ...@@ -156,10 +155,9 @@ pub trait CodeGenerator {
pe: Option<MuName>, pe: Option<MuName>,
args: Vec<P<Value>>, args: Vec<P<Value>>,
ret: Vec<P<Value>>, ret: Vec<P<Value>>,
may_return: bool may_return: bool,
) -> Option<ValueLocation>; ) -> Option<ValueLocation>;
fn emit_ret(&mut self, src: Reg); fn emit_ret(&mut self, src: Reg);
fn emit_cbnz(&mut self, src: Reg, dest_name: MuName); fn emit_cbnz(&mut self, src: Reg, dest_name: MuName);
fn emit_cbz(&mut self, src: Reg, dest_name: MuName); fn emit_cbz(&mut self, src: Reg, dest_name: MuName);
...@@ -241,7 +239,7 @@ pub trait CodeGenerator { ...@@ -241,7 +239,7 @@ pub trait CodeGenerator {
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: Reg, src2: Reg,
signed: bool, signed: bool,
shift: u8 shift: u8,
); );
fn emit_adds_ext( fn emit_adds_ext(
&mut self, &mut self,
...@@ -249,7 +247,7 @@ pub trait CodeGenerator { ...@@ -249,7 +247,7 @@ pub trait CodeGenerator {
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: Reg, src2: Reg,
signed: bool, signed: bool,
shift: u8 shift: u8,
); );
fn emit_sub_ext( fn emit_sub_ext(
&mut self, &mut self,
...@@ -257,7 +255,7 @@ pub trait CodeGenerator { ...@@ -257,7 +255,7 @@ pub trait CodeGenerator {
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: Reg, src2: Reg,
signed: bool, signed: bool,
shift: u8 shift: u8,
); );
fn emit_subs_ext( fn emit_subs_ext(
&mut self, &mut self,
...@@ -265,7 +263,7 @@ pub trait CodeGenerator { ...@@ -265,7 +263,7 @@ pub trait CodeGenerator {
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: Reg, src2: Reg,
signed: bool, signed: bool,
shift: u8 shift: u8,
); );
// Multiplication // Multiplication
...@@ -334,7 +332,7 @@ pub trait CodeGenerator { ...@@ -334,7 +332,7 @@ pub trait CodeGenerator {
dest: Reg, /*GPR or SP*/ dest: Reg, /*GPR or SP*/
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: u16, src2: u16,
shift: bool shift: bool,
); );
fn emit_adds_imm(&mut self, dest: Reg, src1: Reg /*GPR or SP*/, src2: u16, shift: bool); fn emit_adds_imm(&mut self, dest: Reg, src1: Reg /*GPR or SP*/, src2: u16, shift: bool);
fn emit_sub_imm( fn emit_sub_imm(
...@@ -342,7 +340,7 @@ pub trait CodeGenerator { ...@@ -342,7 +340,7 @@ pub trait CodeGenerator {
dest: Reg, /*GPR or SP*/ dest: Reg, /*GPR or SP*/
src1: Reg, /*GPR or SP*/ src1: Reg, /*GPR or SP*/
src2: u16, src2: u16,
shift: bool shift: bool,
); );
fn emit_subs_imm(&mut self, dest: Reg, src1: Reg /*GPR or SP*/, src2: u16, shift: bool); fn emit_subs_imm(&mut self, dest: Reg, src1: Reg /*GPR or SP*/, src2: u16, shift: bool);
...@@ -365,28 +363,28 @@ pub trait CodeGenerator { ...@@ -365,28 +363,28 @@ pub trait CodeGenerator {
dest: Reg, /*64*/ dest: Reg, /*64*/
src1: Reg, /*32*/ src1: Reg, /*32*/
src2: Reg, /*32*/ src2: Reg, /*32*/
src3: Reg /*64*/ src3: Reg, /*64*/
); );
fn emit_smsubl( fn emit_smsubl(
&mut self, &mut self,
dest: Reg, /*64*/ dest: Reg, /*64*/
src1: Reg, /*32*/ src1: Reg, /*32*/
src2: Reg, /*32*/ src2: Reg, /*32*/
src3: Reg /*64*/ src3: Reg, /*64*/
); );
fn emit_umaddl( fn emit_umaddl(
&mut self, &mut self,
dest: Reg, /*64*/ dest: Reg, /*64*/
src1: Reg, /*32*/ src1: Reg, /*32*/
src2: Reg, /*32*/ src2: Reg, /*32*/
src3: Reg /*64*/ src3: Reg, /*64*/
); );
fn emit_umsubl( fn emit_umsubl(
&mut self, &mut self,
dest: Reg, /*64*/ dest: Reg, /*64*/
src1: Reg, /*32*/ src1: Reg, /*32*/
src2: Reg, /*32*/ src2: Reg, /*32*/
src3: Reg /*64*/ src3: Reg, /*64*/
); );
fn emit_fmadd(&mut self, dest: Reg, src1: Reg, src2: Reg, src3: Reg); fn emit_fmadd(&mut self, dest: Reg, src1: Reg, src2: Reg, src3: Reg);
fn emit_fmsub(&mut self, dest: Reg, src1: Reg, src2: Reg, src3: Reg); fn emit_fmsub(&mut self, dest: Reg, src1: Reg, src2: Reg, src3: Reg);
......
This diff is collapsed.
...@@ -1430,11 +1430,11 @@ impl ASMCodeGen { ...@@ -1430,11 +1430,11 @@ impl ASMCodeGen {
match op.v { match op.v {
// offset(base,index,scale) // offset(base,index,scale)
Value_::Memory(MemoryLocation::Address { Value_::Memory(MemoryLocation::Address {
ref base, ref base,
ref offset, ref offset,
ref index, ref index,
scale, scale,
}) => { }) => {
// deal with offset // deal with offset
if offset.is_some() { if offset.is_some() {
let offset = offset.as_ref().unwrap(); let offset = offset.as_ref().unwrap();
...@@ -1511,11 +1511,11 @@ impl ASMCodeGen { ...@@ -1511,11 +1511,11 @@ impl ASMCodeGen {
loc_cursor += 1; loc_cursor += 1;
} }
Value_::Memory(MemoryLocation::Symbolic { Value_::Memory(MemoryLocation::Symbolic {
ref base, ref base,
ref label, ref label,
is_global, is_global,
is_native, is_native,
}) => { }) => {
let label = if is_native { let label = if is_native {
"/*C*/".to_string() + label.as_str() "/*C*/".to_string() + label.as_str()
} else { } else {
...@@ -4094,7 +4094,7 @@ pub fn emit_context_with_reloc( ...@@ -4094,7 +4094,7 @@ pub fn emit_context_with_reloc(
"\t{}", "\t{}",
directive_equiv(demangled_name, global_cell_name.clone()) directive_equiv(demangled_name, global_cell_name.clone())
) )
.unwrap(); .unwrap();
} }
} }
...@@ -4143,7 +4143,7 @@ pub fn emit_context_with_reloc( ...@@ -4143,7 +4143,7 @@ pub fn emit_context_with_reloc(
"\t.quad {}\n", "\t.quad {}\n",
symbol(&mangle_name(label.clone())) symbol(&mangle_name(label.clone()))
)) ))
.unwrap(); .unwrap();
} else { } else {
// otherwise this offset is plain data // otherwise this offset is plain data
......
use ast::ir::*; use ast::ir::*;
use ast::ptr::*; use ast::ptr::*;
use ast::types::*; use ast::types::*;
use compiler::backend::RegGroup;
use compiler::backend::x86_64; use compiler::backend::x86_64;
use compiler::backend::BackendType; use compiler::backend::BackendType;
use compiler::backend::RegGroup;
use utils::ByteSize; use utils::ByteSize;
use vm::VM; use vm::VM;
...@@ -12,7 +12,7 @@ pub enum CallConvResult { ...@@ -12,7 +12,7 @@ pub enum CallConvResult {
GPR(P<Value>), GPR(P<Value>),
GPREX(P<Value>, P<Value>), GPREX(P<Value>, P<Value>),
FPR(P<Value>), FPR(P<Value>),
STACK STACK,
} }
pub mod mu { pub mod mu {
...@@ -21,8 +21,8 @@ pub mod mu { ...@@ -21,8 +21,8 @@ pub mod mu {
pub mod swapstack { pub mod swapstack {
pub use super::c::compute_arguments; pub use super::c::compute_arguments;
pub use super::c::compute_stack_args;
pub use super::c::compute_arguments as compute_return_values; pub use super::c::compute_arguments as compute_return_values;
pub use super::c::compute_stack_args;
pub use super::c::compute_stack_args as compute_stack_retvals; pub use super::c::compute_stack_args as compute_stack_retvals;
} }
...@@ -168,7 +168,7 @@ pub mod c { ...@@ -168,7 +168,7 @@ pub mod c {
/// returns a tuple of (size, offset for each values on stack) /// returns a tuple of (size, offset for each values on stack)
pub fn compute_stack_locations( pub fn compute_stack_locations(
stack_val_tys: &Vec<P<MuType>>, stack_val_tys: &Vec<P<MuType>>,
vm: &VM vm: &VM,
) -> (ByteSize, Vec<ByteSize>) { ) -> (ByteSize, Vec<ByteSize>) {
let (stack_arg_size, _, stack_arg_offsets) = let (stack_arg_size, _, stack_arg_offsets) =
BackendType::sequential_layout(stack_val_tys, vm); BackendType::sequential_layout(stack_val_tys, vm);
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use ast::ptr::P;
use ast::ir::*; use ast::ir::*;
use ast::ptr::P;
use runtime::ValueLocation; use runtime::ValueLocation;
use compiler::backend::{Mem, Reg};
use compiler::machine_code::MachineCode; use compiler::machine_code::MachineCode;
use compiler::backend::{Reg, Mem};
/// CodeGenerator provides an interface to emit x86_64 code for instruction selection. /// CodeGenerator provides an interface to emit x86_64 code for instruction selection.
/// This allows us to implement the other parts of the compiler (mostly instruction selection) /// This allows us to implement the other parts of the compiler (mostly instruction selection)
...@@ -81,8 +81,8 @@ pub trait CodeGenerator { ...@@ -81,8 +81,8 @@ pub trait CodeGenerator {
fn emit_mov_r_mem(&mut self, dest: Reg, src: Mem); // load fn emit_mov_r_mem(&mut self, dest: Reg, src: Mem); // load
fn emit_mov_r_r(&mut self, dest: Reg, src: Reg); fn emit_mov_r_r(&mut self, dest: Reg, src: Reg);
fn emit_mov_mem_r(&mut self, dest: Mem, src: Reg); // store fn emit_mov_mem_r(&mut self, dest: Mem, src: Reg); // store
// we can infer imm length from Reg, but cannot from Mem // we can infer imm length from Reg, but cannot from Mem
// because mem may only have type as ADDRESS_TYPE // because mem may only have type as ADDRESS_TYPE
fn emit_mov_mem_imm(&mut self, dest: Mem, src: i32, oplen: usize); // store fn emit_mov_mem_imm(&mut self, dest: Mem, src: i32, oplen: usize); // store
fn emit_mov_mem_r_callee_saved(&mut self, dest: Mem, src: Reg); // store callee saved register fn emit_mov_mem_r_callee_saved(&mut self, dest: Mem, src: Reg); // store callee saved register
...@@ -238,7 +238,7 @@ pub trait CodeGenerator { ...@@ -238,7 +238,7 @@ pub trait CodeGenerator {
pe: Option<MuName>, pe: Option<MuName>,
uses: Vec<P<Value>>, uses: Vec<P<Value>>,
defs: Vec<P<Value>>, defs: Vec<P<Value>>,
is_native: bool is_native: bool,
) -> ValueLocation; ) -> ValueLocation;
fn emit_call_near_r64( fn emit_call_near_r64(
&mut self, &mut self,
...@@ -246,7 +246,7 @@ pub trait CodeGenerator { ...@@ -246,7 +246,7 @@ pub trait CodeGenerator {
func: &P<Value>, func: &P<Value>,
pe: Option<MuName>, pe: Option<MuName>,
uses: Vec<P<Value>>, uses: Vec<P<Value>>,
defs: Vec<P<Value>> defs: Vec<P<Value>>,
) -> ValueLocation; ) -> ValueLocation;
fn emit_call_near_mem64( fn emit_call_near_mem64(
&mut self, &mut self,
...@@ -254,7 +254,7 @@ pub trait CodeGenerator { ...@@ -254,7 +254,7 @@ pub trait CodeGenerator {
func: &P<Value>, func: &P<Value>,