Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
89434abb
Commit
89434abb
authored
Mar 21, 2014
by
Tobias Rapp
Browse files
amd64: Implemented sign extension by shifting, making the convert nodes obsolete
parent
da880ea9
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/amd64/amd64_spec.pl
View file @
89434abb
...
...
@@ -130,22 +130,6 @@ And => {
},
# Convert doubleword
CDQ
=>
{
reg_req
=>
{
in
=>
[
"
rax
"
],
out
=>
[
"
rdx
"
]
},
fixed
=>
"
amd64_op_mode_t op_mode = AMD64_OP_NONE;
",
emit
=>
"
cdq
",
mode
=>
$mode_gp
,
},
# Convert quadword
CQO
=>
{
reg_req
=>
{
in
=>
[
"
rax
"
],
out
=>
[
"
rdx
"
]
},
fixed
=>
"
amd64_op_mode_t op_mode = AMD64_OP_NONE;
",
emit
=>
"
cqo
",
mode
=>
$mode_gp
,
},
Div
=>
{
state
=>
"
exc_pinned
",
reg_req
=>
{
out
=>
[
"
rax
",
"
flags
",
"
none
",
"
rdx
"
]
},
...
...
ir/be/amd64/amd64_transform.c
View file @
89434abb
...
...
@@ -828,19 +828,23 @@ static ir_node *gen_Shrs(ir_node *const node)
/**
* Creates a signed extension.
*/
static
ir_node
*
create_sext
(
ir_node
*
const
node
,
amd64_insn_mode_t
insn_mode
)
static
ir_node
*
create_sext
(
ir_node
*
const
node
,
ir_mode
*
mode
,
amd64_insn_mode_t
insn_mode
)
{
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
node
);
ir_node
*
const
block
=
get_nodes_block
(
node
);
ir_node
*
sext
;
if
(
insn_mode
==
INSN_MODE_32
)
{
sext
=
new_bd_amd64_CDQ
(
dbgi
,
block
,
node
);
}
else
if
(
insn_mode
==
INSN_MODE_64
)
{
sext
=
new_bd_amd64_CQO
(
dbgi
,
block
,
node
);
}
else
{
panic
(
"Sign extension only implemented for 32 and 64 bit"
);
}
amd64_shift_attr_t
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
base
.
op_mode
=
AMD64_OP_SHIFT_IMM
;
attr
.
insn_mode
=
insn_mode
;
attr
.
immediate
=
get_mode_size_bits
(
mode
)
-
1
;
ir_node
*
in
[
1
]
=
{
node
};
sext
=
new_bd_amd64_Sar
(
dbgi
,
block
,
ARRAY_SIZE
(
in
),
in
,
&
attr
);
arch_set_irn_register_reqs_in
(
sext
,
reg_reqs
);
arch_set_irn_register_req_out
(
sext
,
0
,
&
amd64_requirement_gp_same_0
);
return
sext
;
}
...
...
@@ -866,8 +870,8 @@ static ir_node *create_div(ir_node *const node, ir_mode *const mode,
reqs
=
rax_reg_rdx_reqs
;
if
(
mode_is_signed
(
mode
))
{
/* Sign extend RAX
and
RDX */
ir_node
*
sext
=
create_sext
(
be_transform_node
(
op1
),
insn_mode
);
/* Sign extend RAX
to
RDX */
ir_node
*
sext
=
create_sext
(
be_transform_node
(
op1
),
mode
,
insn_mode
);
in
[
arity
++
]
=
sext
;
res
=
new_bd_amd64_IDiv
(
dbgi
,
block
,
arity
,
in
,
insn_mode
,
...
...
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