Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-fast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
mu
mu-impl-fast
Commits
8038fb6d
Commit
8038fb6d
authored
May 06, 2016
by
qinsoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[wip] revising instruction selection, multiple backends(asm, binary)
parent
9d2cc163
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
404 additions
and
190 deletions
+404
-190
src/ast/ir.rs
src/ast/ir.rs
+28
-0
src/compiler/backend/arm/mod.rs
src/compiler/backend/arm/mod.rs
+1
-0
src/compiler/backend/inst_sel.rs
src/compiler/backend/inst_sel.rs
+2
-6
src/compiler/backend/mod.rs
src/compiler/backend/mod.rs
+7
-1
src/compiler/backend/x86_64/asm_backend.rs
src/compiler/backend/x86_64/asm_backend.rs
+39
-0
src/compiler/backend/x86_64/codegen.rs
src/compiler/backend/x86_64/codegen.rs
+11
-0
src/compiler/backend/x86_64/inst_sel.rs
src/compiler/backend/x86_64/inst_sel.rs
+298
-183
src/compiler/backend/x86_64/mod.rs
src/compiler/backend/x86_64/mod.rs
+18
-0
No files found.
src/ast/ir.rs
View file @
8038fb6d
...
...
@@ -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
),
...
...
src/compiler/backend/arm/mod.rs
0 → 100644
View file @
8038fb6d
pub
use
inst_sel
;
\ No newline at end of file
src/compiler/backend/inst_sel.rs
View file @
8038fb6d
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
src/compiler/backend/mod.rs
View file @
8038fb6d
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
src/compiler/backend/x86_64/asm_backend.rs
0 → 100644
View file @
8038fb6d
#![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
src/compiler/backend/x86_64/codegen.rs
0 → 100644
View file @
8038fb6d
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
src/compiler/backend/x86_64/inst_sel.rs
View file @
8038fb6d
This diff is collapsed.
Click to expand it.
src/compiler/backend/x86_64/mod.rs
0 → 100644
View file @
8038fb6d
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment