GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit 8038fb6d authored by qinsoon's avatar qinsoon

[wip] revising instruction selection, multiple backends(asm, binary)

parent 9d2cc163
......@@ -247,6 +247,34 @@ pub struct Value {
pub v: Value_
}
impl Value {
pub fn is_int_reg(&self) -> bool {
match self.v {
Value_::SSAVar(_) => {
if is_scalar(&self.ty) && !is_fp(&self.ty) {
true
} else {
false
}
}
_ => false
}
}
pub fn is_int_const(&self) -> bool {
match self.v {
Value_::Constant(_) => {
let ty : &MuType_ = &self.ty;
match ty {
&MuType_::Int(_) => true,
_ => false
}
}
_ => false
}
}
}
#[derive(Debug, Clone)]
pub enum Value_ {
SSAVar(MuID),
......
pub use inst_sel;
\ No newline at end of file
pub use self::arch_specific::*;
#[cfg(target_arch = "x86_64")]
#[path="x86_64/inst_sel.rs"]
mod arch_specific;
pub use compiler::backend::x86_64::inst_sel::*;
#[cfg(target_arch = "arm")]
#[path="arm/inst_sel.rs"]
mod arch_specific;
\ No newline at end of file
pub use compiler::backend::arm::inst_sel::*;
\ No newline at end of file
pub mod inst_sel;
\ No newline at end of file
pub mod inst_sel;
#[cfg(target_arch = "x86_64")]
mod x86_64;
#[cfg(target_arch = "arm")]
mod arm;
\ No newline at end of file
#![allow(unused_variables)]
use compiler::backend::x86_64::CodeGenerator;
use ast::ptr::P;
use ast::ir::*;
use ast::types::*;
pub struct ASMCodeGen {
foo: usize
}
impl ASMCodeGen {
pub fn new() -> ASMCodeGen {
ASMCodeGen {foo: 0}
}
}
impl CodeGenerator for ASMCodeGen {
fn emit_cmp_r64_r64(&mut self, op1: &P<Value>, op2: &P<Value>) {
}
fn emit_cmp_r64_imm32(&mut self, op1: &P<Value>, op2: &P<Value>) {
}
fn emit_cmp_r64_mem64(&mut self, op1: &P<Value>, op2: &P<Value>) {
}
fn emit_mov_r64_imm32(&mut self, dest: &P<Value>, src: &P<Value>) {
}
fn emit_mov_r64_mem64(&mut self, dest: &P<Value>, src: &P<Value>) {
}
}
\ No newline at end of file
use ast::ptr::P;
use ast::ir::*;
pub trait CodeGenerator {
fn emit_cmp_r64_r64(&mut self, op1: &P<Value>, op2: &P<Value>);
fn emit_cmp_r64_imm32(&mut self, op1: &P<Value>, op2: &P<Value>);
fn emit_cmp_r64_mem64(&mut self, op1: &P<Value>, op2: &P<Value>);
fn emit_mov_r64_imm32(&mut self, dest: &P<Value>, src: &P<Value>);
fn emit_mov_r64_mem64(&mut self, dest: &P<Value>, src: &P<Value>);
}
\ No newline at end of file
This diff is collapsed.
pub mod inst_sel;
mod codegen;
pub use compiler::backend::x86_64::codegen::CodeGenerator;
mod asm_backend;
pub use compiler::backend::x86_64::asm_backend::ASMCodeGen;
use ast::ptr::P;
use ast::ir::*;
use ast::types::*;
pub fn is_valid_x86_imm(op: &P<Value>) -> bool {
let ty : &MuType_ = &op.ty;
match ty {
&MuType_::Int(len) if len <= 32 => true,
_ => false
}
}
\ 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