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
296dfbcb
Commit
296dfbcb
authored
May 11, 2009
by
Matthias Braun
Browse files
fix a bunch of stuff in my last commit
[r25921]
parent
a3f5aabc
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/ir/irprog.c
View file @
296dfbcb
...
...
@@ -311,27 +311,25 @@ void add_irp_mode(ir_mode *mode) {
/* Adds opcode to the list of opcodes in irp. */
void
add_irp_opcode
(
ir_op
*
opcode
)
{
int
len
;
size_t
code
;
assert
(
opcode
!=
NULL
);
assert
(
irp
);
assert
(
opcode
->
code
==
(
unsigned
)
ARR_LEN
(
irp
->
opcodes
)
&&
"new_ir_op() called in wrong order"
);
ARR_APP1
(
ir_op
*
,
irp
->
opcodes
,
opcode
);
len
=
ARR_LEN
(
irp
->
opcodes
);
code
=
opcode
->
code
;
if
(
code
>=
len
)
{
ARR_RESIZE
(
ir_op
*
,
irp
->
opcodes
,
code
+
1
);
memset
(
&
irp
->
opcodes
[
len
],
0
,
(
code
-
len
+
1
)
*
sizeof
(
irp
->
opcodes
[
0
]));
}
assert
(
irp
->
opcodes
[
code
]
==
NULL
&&
"opcode registered twice"
);
irp
->
opcodes
[
code
]
=
opcode
;
}
/* Removes opcode from the list of opcodes and shrinks the list by one. */
void
remove_irp_opcode
(
ir_op
*
opcode
)
{
int
i
;
assert
(
opcode
);
for
(
i
=
ARR_LEN
(
irp
->
opcodes
)
-
1
;
i
>=
0
;
i
--
)
{
if
(
irp
->
opcodes
[
i
]
!=
opcode
)
continue
;
for
(;
i
<
(
ARR_LEN
(
irp
->
opcodes
))
-
1
;
i
++
)
{
irp
->
opcodes
[
i
]
=
irp
->
opcodes
[
i
+
1
];
}
ARR_SETLEN
(
ir_op
*
,
irp
->
opcodes
,
(
ARR_LEN
(
irp
->
opcodes
))
-
1
);
return
;
}
panic
(
"Deleting unknown opcode"
);
assert
(
opcode
->
code
<
ARR_LEN
(
irp
->
opcodes
));
irp
->
opcodes
[
opcode
->
code
]
=
NULL
;
}
/* Returns the number of all opcodes in the irp. */
...
...
scripts/gen_ir.py
View file @
296dfbcb
...
...
@@ -131,6 +131,11 @@ def format_attr_size(node):
return
"0"
return
"sizeof(%s)"
%
node
[
'attr_struct'
]
def
format_opindex
(
node
):
if
"op_index"
in
node
:
return
node
[
"op_index"
]
return
"-1"
def
filter_isnot
(
list
,
flag
):
result
=
[]
for
nodename
,
node
in
list
:
...
...
@@ -140,11 +145,11 @@ def filter_isnot(list, flag):
return
result
env
=
Environment
()
env
.
filters
[
'argdecls'
]
=
format_argdecls
env
.
filters
[
'args'
]
=
format_args
env
.
filters
[
'blockdecl'
]
=
format_blockdecl
env
.
filters
[
'block'
]
=
format_block
env
.
filters
[
'curblock'
]
=
format_curblock
env
.
filters
[
'argdecls'
]
=
format_argdecls
env
.
filters
[
'args'
]
=
format_args
env
.
filters
[
'blockdecl'
]
=
format_blockdecl
env
.
filters
[
'block'
]
=
format_block
env
.
filters
[
'curblock'
]
=
format_curblock
env
.
filters
[
'insdecl'
]
=
format_insdecl
env
.
filters
[
'arity_and_ins'
]
=
format_arity_and_ins
env
.
filters
[
'arity'
]
=
format_arity
...
...
@@ -152,6 +157,7 @@ env.filters['pinned'] = format_pinned
env
.
filters
[
'flags'
]
=
format_flags
env
.
filters
[
'attr_size'
]
=
format_attr_size
env
.
filters
[
'isnot'
]
=
filter_isnot
env
.
filters
[
'opindex'
]
=
format_opindex
def
add_attr
(
list
,
type
,
name
,
init
=
None
,
initname
=
None
):
if
initname
==
None
:
...
...
@@ -172,6 +178,8 @@ def preprocess_node(nodename, node):
if
"is_a"
in
node
:
parent
=
nodes
[
node
[
"is_a"
]]
node
[
"ins"
]
=
parent
[
"ins"
]
if
"op_index"
in
parent
:
node
[
"op_index"
]
=
parent
[
"op_index"
]
if
"outs"
in
parent
:
node
[
"outs"
]
=
parent
[
"outs"
]
...
...
@@ -374,7 +382,7 @@ ir_op *op_{{nodename}}; ir_op *get_op_{{nodename}}(void) { return op_{{nodename}
void init_op(void)
{
{% for nodename, node in nodes %}
op_{{nodename}} = new_ir_op(iro_{{nodename}}, "{{nodename}}", {{node|pinned}}, {{node|flags}}, {{node|arity}},
-1
, {{node|attr_size}}, NULL);
op_{{nodename}} = new_ir_op(iro_{{nodename}}, "{{nodename}}", {{node|pinned}}, {{node|flags}}, {{node|arity}},
{{node|opindex}}
, {{node|attr_size}}, NULL);
{%- endfor %}
be_init_op();
...
...
scripts/ir_spec.py
View file @
296dfbcb
...
...
@@ -5,12 +5,14 @@ nodes = dict(
#
unop
=
dict
(
abstract
=
True
,
ins
=
[
"op"
]
ins
=
[
"op"
],
op_index
=
0
,
),
binop
=
dict
(
abstract
=
True
,
ins
=
[
"left"
,
"right"
]
ins
=
[
"left"
,
"right"
],
op_index
=
0
,
),
#
...
...
@@ -52,7 +54,6 @@ Anchor = dict(
mode
=
"mode_ANY"
,
arity
=
"variable"
,
flags
=
"dump_noblock"
,
attr_struct
=
"block_attr"
,
knownBlock
=
True
,
singleton
=
True
,
),
...
...
@@ -106,12 +107,13 @@ Bad = dict(
),
Block
=
dict
(
mode
=
"mode_BB"
,
knownBlock
=
True
,
block
=
"NULL"
,
optimize
=
False
,
arity
=
"variable"
,
flags
=
"labeled"
,
mode
=
"mode_BB"
,
knownBlock
=
True
,
block
=
"NULL"
,
optimize
=
False
,
arity
=
"variable"
,
flags
=
"labeled"
,
attr_struct
=
"block_attr"
,
java_noconstr
=
True
,
init
=
'''
...
...
@@ -405,7 +407,8 @@ Div = dict(
)
],
attr_struct
=
"divmod_attr"
,
pinned
=
"exception"
,
pinned
=
"exception"
,
op_index
=
1
,
d_post
=
'''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
...
...
@@ -425,7 +428,8 @@ DivMod = dict(
),
],
attr_struct
=
"divmod_attr"
,
pinned
=
"exception"
,
pinned
=
"exception"
,
op_index
=
1
,
d_post
=
'''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
...
...
@@ -579,7 +583,8 @@ Mod = dict(
),
],
attr_struct
=
"divmod_attr"
,
pinned
=
"exception"
,
pinned
=
"exception"
,
op_index
=
1
,
d_post
=
'''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
...
...
@@ -660,7 +665,8 @@ Quot = dict(
),
],
attr_struct
=
"divmod_attr"
,
pinned
=
"exception"
,
pinned
=
"exception"
,
op_index
=
1
,
d_post
=
'''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
...
...
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