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
dc833829
Commit
dc833829
authored
Oct 06, 2013
by
Damien
Browse files
Make runtime able to call inline asm with 1 argument.
parent
03d41243
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/compile.c
View file @
dc833829
...
...
@@ -2683,7 +2683,7 @@ void py_compile(py_parse_node_t pn) {
// compile pass 2 and 3
emit_t
*
emit_bc
=
NULL
;
emit_t
*
emit_
x64
=
NULL
;
emit_t
*
emit_
native
=
NULL
;
emit_inline_asm_t
*
emit_inline_thumb
=
NULL
;
for
(
scope_t
*
s
=
comp
->
scope_head
;
s
!=
NULL
;
s
=
s
->
next
)
{
if
(
s
->
emit_options
==
EMIT_OPT_ASM_THUMB
)
{
...
...
@@ -2699,10 +2699,10 @@ void py_compile(py_parse_node_t pn) {
}
else
{
switch
(
s
->
emit_options
)
{
case
EMIT_OPT_NATIVE_PYTHON
:
if
(
emit_
x64
==
NULL
)
{
emit_
x64
=
emit_x64_new
(
max_num_labels
);
if
(
emit_
native
==
NULL
)
{
emit_
native
=
emit_x64_new
(
max_num_labels
);
}
comp
->
emit
=
emit_
x64
;
comp
->
emit
=
emit_
native
;
comp
->
emit_method_table
=
&
emit_x64_method_table
;
break
;
...
...
py/emitinlinethumb.c
View file @
dc833829
...
...
@@ -57,7 +57,7 @@ static int emit_inline_thumb_count_params(emit_inline_asm_t *emit, int n_params,
}
for
(
int
i
=
0
;
i
<
n_params
;
i
++
)
{
if
(
!
PY_PARSE_NODE_IS_ID
(
pn_params
[
i
]))
{
printf
(
"SyntaxError: parameter to inline assembler must be an identifier
%d
\n
"
,
PY_PARSE_NODE_STRUCT_KIND
((
py_parse_node_struct_t
*
)
pn_params
[
i
])
);
printf
(
"SyntaxError: parameter to inline assembler must be an identifier
\n
"
);
return
0
;
}
const
char
*
p
=
qstr_str
(
PY_PARSE_NODE_LEAF_ARG
(
pn_params
[
i
]));
...
...
@@ -122,7 +122,10 @@ static int get_arg_label(emit_inline_asm_t *emit, qstr op, py_parse_node_t *pn_a
return
i
;
}
}
printf
(
"SyntaxError: label '%s' not defined
\n
"
,
qstr_str
(
label_qstr
));
// only need to have the labels on the last pass
if
(
emit
->
pass
==
PASS_3
)
{
printf
(
"SyntaxError: label '%s' not defined
\n
"
,
qstr_str
(
label_qstr
));
}
return
0
;
}
...
...
py/runtime.c
View file @
dc833829
...
...
@@ -772,6 +772,17 @@ py_obj_t rt_call_function_1(py_obj_t fun, py_obj_t arg) {
assert
(
o
->
u_fun_bc
.
n_args
==
1
);
DEBUG_OP_printf
(
"calling byte code %p with 1 arg
\n
"
,
o
->
u_fun_bc
.
code
);
return
py_execute_byte_code
(
o
->
u_fun_bc
.
code
,
o
->
u_fun_bc
.
len
,
&
arg
,
1
);
}
else
if
(
IS_O
(
fun
,
O_FUN_ASM
))
{
py_obj_base_t
*
o
=
fun
;
assert
(
o
->
u_fun_asm
.
n_args
==
1
);
DEBUG_OP_printf
(
"calling inline asm %p with 1 arg
\n
"
,
o
->
u_fun_asm
.
fun
);
machine_int_t
arg_val
;
if
(
IS_SMALL_INT
(
arg
))
{
arg_val
=
FROM_SMALL_INT
(
arg
);
}
else
{
arg_val
=
arg
;
}
return
((
py_fun_1_t
)
o
->
u_fun_asm
.
fun
)(
arg_val
);
}
else
if
(
IS_O
(
fun
,
O_BOUND_METH
))
{
py_obj_base_t
*
o
=
fun
;
return
rt_call_function_2
(
o
->
u_bound_meth
.
meth
,
o
->
u_bound_meth
.
self
,
arg
);
...
...
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