Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mesa
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erik Faye-Lund
mesa
Commits
582815d9
Commit
582815d9
authored
Apr 12, 2016
by
Connor Abbott
Committed by
Jason Ekstrand
May 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ir3: fixup for new nir_foreach_block()
parent
31fc4a25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
30 deletions
+21
-30
src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
+21
-30
No files found.
src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
View file @
582815d9
...
...
@@ -58,12 +58,6 @@
* then we should prefer to not flatten the if/else..
*/
struct
lower_state
{
nir_builder
b
;
void
*
mem_ctx
;
bool
progress
;
};
static
bool
valid_dest
(
nir_block
*
block
,
nir_dest
*
dest
)
{
...
...
@@ -213,23 +207,21 @@ flatten_block(nir_builder *bld, nir_block *if_block, nir_block *prev_block,
}
static
bool
lower_if_else_block
(
nir_block
*
block
,
void
*
void_state
)
lower_if_else_block
(
nir_block
*
block
,
nir_builder
*
b
,
void
*
mem_ctx
)
{
struct
lower_state
*
state
=
void_state
;
/* If the block is empty, then it certainly doesn't have any phi nodes,
* so we can skip it. This also ensures that we do an early skip on the
* end block of the function which isn't actually attached to the CFG.
*/
if
(
exec_list_is_empty
(
&
block
->
instr_list
))
return
tru
e
;
return
fals
e
;
if
(
nir_cf_node_is_first
(
&
block
->
cf_node
))
return
tru
e
;
return
fals
e
;
nir_cf_node
*
prev_node
=
nir_cf_node_prev
(
&
block
->
cf_node
);
if
(
prev_node
->
type
!=
nir_cf_node_if
)
return
tru
e
;
return
fals
e
;
nir_if
*
if_stmt
=
nir_cf_node_as_if
(
prev_node
);
nir_cf_node
*
then_node
=
nir_if_first_then_node
(
if_stmt
);
...
...
@@ -238,7 +230,7 @@ lower_if_else_block(nir_block *block, void *void_state)
/* We can only have one block in each side ... */
if
(
nir_if_last_then_node
(
if_stmt
)
!=
then_node
||
nir_if_last_else_node
(
if_stmt
)
!=
else_node
)
return
tru
e
;
return
fals
e
;
nir_block
*
then_block
=
nir_cf_node_as_block
(
then_node
);
nir_block
*
else_block
=
nir_cf_node_as_block
(
else_node
);
...
...
@@ -246,11 +238,11 @@ lower_if_else_block(nir_block *block, void *void_state)
/* ... and those blocks must only contain "allowed" instructions. */
if
(
!
block_check_for_allowed_instrs
(
then_block
)
||
!
block_check_for_allowed_instrs
(
else_block
))
return
tru
e
;
return
fals
e
;
/* condition should be ssa too, which simplifies flatten_block: */
if
(
!
if_stmt
->
condition
.
is_ssa
)
return
tru
e
;
return
fals
e
;
/* At this point, we know that the previous CFG node is an if-then
* statement containing only moves to phi nodes in this block. We can
...
...
@@ -265,9 +257,9 @@ lower_if_else_block(nir_block *block, void *void_state)
* block before. There are a few things that need handling specially
* like discard/discard_if.
*/
flatten_block
(
&
state
->
b
,
then_block
,
prev_block
,
flatten_block
(
b
,
then_block
,
prev_block
,
if_stmt
->
condition
.
ssa
,
false
);
flatten_block
(
&
state
->
b
,
else_block
,
prev_block
,
flatten_block
(
b
,
else_block
,
prev_block
,
if_stmt
->
condition
.
ssa
,
true
);
nir_foreach_instr_safe
(
instr
,
block
)
{
...
...
@@ -275,8 +267,8 @@ lower_if_else_block(nir_block *block, void *void_state)
break
;
nir_phi_instr
*
phi
=
nir_instr_as_phi
(
instr
);
nir_alu_instr
*
sel
=
nir_alu_instr_create
(
state
->
mem_ctx
,
nir_op_bcsel
);
nir_src_copy
(
&
sel
->
src
[
0
].
src
,
&
if_stmt
->
condition
,
state
->
mem_ctx
);
nir_alu_instr
*
sel
=
nir_alu_instr_create
(
mem_ctx
,
nir_op_bcsel
);
nir_src_copy
(
&
sel
->
src
[
0
].
src
,
&
if_stmt
->
condition
,
mem_ctx
);
/* Splat the condition to all channels */
memset
(
sel
->
src
[
0
].
swizzle
,
0
,
sizeof
sel
->
src
[
0
].
swizzle
);
...
...
@@ -286,7 +278,7 @@ lower_if_else_block(nir_block *block, void *void_state)
assert
(
src
->
src
.
is_ssa
);
unsigned
idx
=
src
->
pred
==
then_block
?
1
:
2
;
nir_src_copy
(
&
sel
->
src
[
idx
].
src
,
&
src
->
src
,
state
->
mem_ctx
);
nir_src_copy
(
&
sel
->
src
[
idx
].
src
,
&
src
->
src
,
mem_ctx
);
}
nir_ssa_dest_init
(
&
sel
->
instr
,
&
sel
->
dest
.
dest
,
...
...
@@ -301,26 +293,25 @@ lower_if_else_block(nir_block *block, void *void_state)
}
nir_cf_node_remove
(
&
if_stmt
->
cf_node
);
state
->
progress
=
true
;
return
true
;
}
static
bool
lower_if_else_impl
(
nir_function_impl
*
impl
)
{
struct
lower_state
state
;
state
.
mem_ctx
=
ralloc_parent
(
impl
);
state
.
progress
=
false
;
nir_builder_init
(
&
state
.
b
,
impl
);
void
*
mem_ctx
=
ralloc_parent
(
impl
);
nir_builder
b
;
nir_builder_init
(
&
b
,
impl
);
nir_foreach_block_call
(
impl
,
lower_if_else_block
,
&
state
);
bool
progress
=
false
;
nir_foreach_block
(
block
,
impl
)
{
progress
|=
lower_if_else_block
(
block
,
&
b
,
mem_ctx
);
}
if
(
state
.
progress
)
if
(
progress
)
nir_metadata_preserve
(
impl
,
nir_metadata_none
);
return
state
.
progress
;
return
progress
;
}
bool
...
...
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