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
6bd4efd6
Commit
6bd4efd6
authored
Feb 16, 2017
by
qinsoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed two bugs that may cause generating invalid assembly
(operand doesnt match instruction, such as movl %rdi, %edx)
parent
99e16961
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
src/compiler/backend/arch/x86_64/inst_sel.rs
src/compiler/backend/arch/x86_64/inst_sel.rs
+16
-2
No files found.
src/compiler/backend/arch/x86_64/inst_sel.rs
View file @
6bd4efd6
...
...
@@ -433,6 +433,8 @@ impl <'a> InstructionSelection {
let
tmp_res
=
self
.get_result_value
(
node
);
// cmov only take (16/32/64bits registers)
// so we use 64bits registers here and truncate later
// make res64, and set to zero
let
tmp_res64
=
self
.make_temporary
(
f_context
,
UINT64_TYPE
.clone
(),
vm
);
self
.backend
.emit_xor_r_r
(
&
tmp_res64
,
&
tmp_res64
);
...
...
@@ -465,7 +467,7 @@ impl <'a> InstructionSelection {
}
// truncate tmp_res64 to tmp_res (probably u8)
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
&
tmp_res64
);
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_res64
.as_type
(
UINT8_TYPE
.clone
())}
);
}
Instruction_
::
Branch1
(
ref
dest
)
=>
{
...
...
@@ -648,10 +650,22 @@ impl <'a> InstructionSelection {
op
::
ConvOp
::
TRUNC
=>
{
if
self
.match_ireg
(
op
)
{
let
tmp_op
=
self
.emit_ireg
(
op
,
f_content
,
f_context
,
vm
);
let
tmp_res
=
self
.get_result_value
(
node
);
let
dst_length
=
match
tmp_res
.ty
.get_int_length
()
{
Some
(
len
)
=>
len
,
None
=>
panic!
(
"dst of TRUNC is not int: {}"
,
tmp_res
)
};
// mov op -> result
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
&
tmp_op
);
match
dst_length
{
1
=>
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_op
.as_type
(
UINT8_TYPE
.clone
())}),
8
=>
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_op
.as_type
(
UINT8_TYPE
.clone
())}),
16
=>
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_op
.as_type
(
UINT16_TYPE
.clone
())}),
32
=>
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_op
.as_type
(
UINT32_TYPE
.clone
())}),
64
=>
self
.backend
.emit_mov_r_r
(
&
tmp_res
,
unsafe
{
&
tmp_op
.as_type
(
UINT64_TYPE
.clone
())}),
_
=>
panic!
(
"unsupported int length: {}"
,
dst_length
)
}
}
else
{
panic!
(
"unexpected op (expect ireg): {}"
,
op
);
}
...
...
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