Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
049ec699
Commit
049ec699
authored
Jun 13, 2014
by
dbarbera
Browse files
Implemented basic input signal generation
parent
36580f60
Changes
1
Hide whitespace changes
Inline
Side-by-side
LlvmGenerator.py
View file @
049ec699
...
...
@@ -107,6 +107,10 @@ def _process(process):
runtr_func
=
_generate_runtr_func
(
process
)
_generate_startup_func
(
process
,
process_name
,
runtr_func
)
# Generate input signals
for
signal
in
process
.
input_signals
:
_generate_input_signal
(
signal
,
mapping
[
signal
[
'name'
]])
print
LLVM
[
'module'
]
...
...
@@ -177,10 +181,48 @@ def _generate_startup_func(process, process_name, runtr_func):
return
func
def
_generate_input_signal
(
signal
,
inputs
):
func_name
=
str
(
signal
[
'name'
])
func_type
=
core
.
Type
.
function
(
core
.
Type
.
void
(),
[])
func
=
core
.
Function
.
new
(
LLVM
[
'module'
],
func_type
,
func_name
)
entry_block
=
func
.
append_basic_block
(
'entry'
)
exit_block
=
func
.
append_basic_block
(
'exit'
)
builder
=
core
.
Builder
.
new
(
entry_block
)
runtr_func
=
LLVM
[
'module'
].
get_function_named
(
'run_transition'
)
g_state_val
=
builder
.
load
(
LLVM
[
'module'
].
get_global_variable_named
(
'state'
))
switch
=
builder
.
switch
(
g_state_val
,
exit_block
)
for
state_name
,
state_id
in
LLVM
[
'states'
].
iteritems
():
state_block
=
func
.
append_basic_block
(
'state_%s'
%
str
(
state_name
))
switch
.
add_case
(
state_id
,
state_block
)
builder
.
position_at_end
(
state_block
)
# TODO: Nested states
inputdef
=
inputs
.
get
(
state_name
)
if
inputdef
:
for
param
in
inputdef
.
parameters
:
raise
NotImplementedError
if
inputdef
.
transition
:
id_val
=
core
.
Constant
.
int
(
core
.
Type
.
int
(),
inputdef
.
transition_id
)
builder
.
call
(
runtr_func
,
[
id_val
])
builder
.
ret_void
()
builder
.
position_at_end
(
exit_block
)
builder
.
ret_void
()
func
.
verify
()
def
write_statement
(
param
,
newline
):
''' Generate the code for the special "write" operator '''
raise
NotImplementedError
@
generate
.
register
(
ogAST
.
Output
)
@
generate
.
register
(
ogAST
.
ProcedureCall
)
def
_call_external_function
(
output
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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