Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
25d90410
Commit
25d90410
authored
Sep 06, 2014
by
Damien George
Browse files
py: Adjust regs for x86 so that 1 more local can live in a reg.
parent
91fe0d48
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/asmx86.c
View file @
25d90410
...
...
@@ -413,7 +413,9 @@ void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t label) {
void
asm_x86_entry
(
asm_x86_t
*
as
,
mp_uint_t
num_locals
)
{
asm_x86_push_r32
(
as
,
REG_EBP
);
asm_x86_mov_r32_to_r32
(
as
,
REG_ESP
,
REG_EBP
);
asm_x86_sub_i32_from_r32
(
as
,
num_locals
*
WORD_SIZE
,
REG_ESP
);
if
(
num_locals
>
0
)
{
asm_x86_sub_i32_from_r32
(
as
,
num_locals
*
WORD_SIZE
,
REG_ESP
);
}
asm_x86_push_r32
(
as
,
REG_EBX
);
asm_x86_push_r32
(
as
,
REG_ESI
);
asm_x86_push_r32
(
as
,
REG_EDI
);
...
...
py/asmx86.h
View file @
25d90410
...
...
@@ -53,7 +53,7 @@
#define ASM_X86_CC_JL (0xc) // less, signed
#define REG_RET REG_EAX
#define REG_ARG_1 REG_E
B
X
#define REG_ARG_1 REG_E
A
X
#define REG_ARG_2 REG_ECX
#define REG_ARG_3 REG_EDX
...
...
py/emitnative.c
View file @
25d90410
...
...
@@ -189,13 +189,16 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
#define EXPORT_FUN(name) emit_native_x86_##name
// caller-save, so can be used as temporaries
#define REG_TEMP0 (REG_EAX)
#define REG_TEMP1 (REG_E
B
X)
#define REG_TEMP2 (REG_E
C
X)
#define REG_TEMP1 (REG_E
C
X)
#define REG_TEMP2 (REG_E
D
X)
#define REG_LOCAL_1 (REG_ESI)
#define REG_LOCAL_2 (REG_EDI)
#define REG_LOCAL_NUM (2)
// callee-save, so can be used as locals
#define REG_LOCAL_1 (REG_EBX)
#define REG_LOCAL_2 (REG_ESI)
#define REG_LOCAL_3 (REG_EDI)
#define REG_LOCAL_NUM (3)
#define ASM_PASS_COMPUTE ASM_X86_PASS_COMPUTE
#define ASM_PASS_EMIT ASM_X86_PASS_EMIT
...
...
@@ -528,6 +531,8 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
asm_x86_mov_arg_to_r32
(
emit
->
as
,
i
,
REG_LOCAL_1
);
}
else
if
(
i
==
1
)
{
asm_x86_mov_arg_to_r32
(
emit
->
as
,
i
,
REG_LOCAL_2
);
}
else
if
(
i
==
2
)
{
asm_x86_mov_arg_to_r32
(
emit
->
as
,
i
,
REG_LOCAL_3
);
}
else
{
asm_x86_mov_arg_to_r32
(
emit
->
as
,
i
,
REG_TEMP0
);
asm_x86_mov_r32_to_local
(
emit
->
as
,
REG_TEMP0
,
i
-
REG_LOCAL_NUM
);
...
...
@@ -1022,6 +1027,8 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qstr, uint id_flags, int lo
emit_post_push_reg
(
emit
,
vtype
,
REG_LOCAL_1
);
}
else
if
(
local_num
==
1
)
{
emit_post_push_reg
(
emit
,
vtype
,
REG_LOCAL_2
);
}
else
if
(
local_num
==
2
)
{
emit_post_push_reg
(
emit
,
vtype
,
REG_LOCAL_3
);
}
else
{
need_reg_single
(
emit
,
REG_EAX
,
0
);
asm_x86_mov_local_to_r32
(
emit
->
as
,
local_num
-
REG_LOCAL_NUM
,
REG_EAX
);
...
...
@@ -1125,6 +1132,8 @@ STATIC void emit_native_store_fast(emit_t *emit, qstr qstr, int local_num) {
emit_pre_pop_reg
(
emit
,
&
vtype
,
REG_LOCAL_1
);
}
else
if
(
local_num
==
1
)
{
emit_pre_pop_reg
(
emit
,
&
vtype
,
REG_LOCAL_2
);
}
else
if
(
local_num
==
2
)
{
emit_pre_pop_reg
(
emit
,
&
vtype
,
REG_LOCAL_3
);
}
else
{
emit_pre_pop_reg
(
emit
,
&
vtype
,
REG_EAX
);
asm_x86_mov_r32_to_local
(
emit
->
as
,
REG_EAX
,
local_num
-
REG_LOCAL_NUM
);
...
...
Write
Preview
Supports
Markdown
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