summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_double_list.h17
-rw-r--r--src/gallium/drivers/r600/r600_compiler.c75
-rw-r--r--src/gallium/drivers/r600/r600_compiler.h37
-rw-r--r--src/gallium/drivers/r600/r600_compiler_dump.c4
-rw-r--r--src/gallium/drivers/r600/r600_compiler_r600.c58
-rw-r--r--src/gallium/drivers/r600/r600_compiler_r700.c14
-rw-r--r--src/gallium/drivers/r600/r600_shader.c2
-rw-r--r--src/gallium/drivers/r600/r600_shader.h15
8 files changed, 112 insertions, 110 deletions
diff --git a/src/gallium/auxiliary/util/u_double_list.h b/src/gallium/auxiliary/util/u_double_list.h
index 53bb1342ddc..42adb1f0699 100644
--- a/src/gallium/auxiliary/util/u_double_list.h
+++ b/src/gallium/auxiliary/util/u_double_list.h
@@ -98,5 +98,20 @@ struct list_head
#define LIST_IS_EMPTY(__list) \
((__list)->next == (__list))
-
+#ifndef container_of
+#define container_of(ptr, sample, member) \
+ (void *)((char *)(ptr) \
+ - ((char *)&(sample)->member - (char *)(sample)))
+#endif
+
+#define LIST_FOR_EACH_ENTRY(pos, head, member) \
+ for (pos = container_of((head)->next, pos, member); \
+ &pos->member != (head); \
+ pos = container_of(pos->member.next, pos, member))
+
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \
+ for (pos = container_of((head)->next, pos, member), \
+ storage = container_of(pos->member.next, pos, member); \
+ &pos->member != (head); \
+ pos = storage, storage = container_of(storage->member.next, storage, member))
#endif /*_U_DOUBLE_LIST_H_*/
diff --git a/src/gallium/drivers/r600/r600_compiler.c b/src/gallium/drivers/r600/r600_compiler.c
index f1be2bbdf4f..1804b86d24e 100644
--- a/src/gallium/drivers/r600/r600_compiler.c
+++ b/src/gallium/drivers/r600/r600_compiler.c
@@ -34,7 +34,7 @@ struct c_vector *c_vector_new(void)
if (v == NULL) {
return NULL;
}
- c_list_init(v);
+ LIST_INITHEAD(&v->head);
return v;
}
@@ -184,10 +184,10 @@ static unsigned c_opcode_is_alu(unsigned opcode)
void c_node_init(struct c_node *node)
{
memset(node, 0, sizeof(struct c_node));
- c_list_init(&node->predecessors);
- c_list_init(&node->successors);
- c_list_init(&node->childs);
- c_list_init(&node->insts);
+ LIST_INITHEAD(&node->predecessors);
+ LIST_INITHEAD(&node->successors);
+ LIST_INITHEAD(&node->childs);
+ LIST_INITHEAD(&node->insts);
node->parent = NULL;
}
@@ -198,7 +198,7 @@ static struct c_node_link *c_node_link_new(struct c_node *node)
link = calloc(1, sizeof(struct c_node_link));
if (link == NULL)
return NULL;
- c_list_init(link);
+ LIST_INITHEAD(&link->head);
link->node = node;
return link;
}
@@ -214,30 +214,31 @@ int c_node_cfg_link(struct c_node *predecessor, struct c_node *successor)
free(pedge);
return -ENOMEM;
}
- c_list_add_tail(pedge, &predecessor->successors);
- c_list_add_tail(sedge, &successor->predecessors);
+ LIST_ADDTAIL(&pedge->head, &predecessor->successors);
+ LIST_ADDTAIL(&sedge->head, &successor->predecessors);
+
return 0;
}
int c_node_add_new_instruction_head(struct c_node *node, struct c_instruction *instruction)
{
- struct c_instruction *inst = calloc(1, sizeof(struct c_instruction));
+ struct c_instruction *inst = malloc(sizeof(struct c_instruction));
if (inst == NULL)
return -ENOMEM;
memcpy(inst, instruction, sizeof(struct c_instruction));
- c_list_add(inst, &node->insts);
+ LIST_ADD(&inst->head, &node->insts);
return 0;
}
int c_node_add_new_instruction(struct c_node *node, struct c_instruction *instruction)
{
- struct c_instruction *inst = calloc(1, sizeof(struct c_instruction));
+ struct c_instruction *inst = malloc(sizeof(struct c_instruction));
if (inst == NULL)
return -ENOMEM;
memcpy(inst, instruction, sizeof(struct c_instruction));
- c_list_add_tail(inst, &node->insts);
+ LIST_ADDTAIL(&inst->head, &node->insts);
return 0;
}
@@ -252,7 +253,7 @@ struct c_node *c_shader_cfg_new_node_after(struct c_shader *shader, struct c_nod
free(node);
return NULL;
}
- c_list_add_tail(node, &shader->nodes);
+ LIST_ADDTAIL(&node->head, &shader->nodes);
return node;
}
@@ -264,9 +265,9 @@ int c_shader_init(struct c_shader *shader, unsigned type)
shader->type = type;
for (i = 0; i < C_FILE_COUNT; i++) {
shader->files[i].nvectors = 0;
- c_list_init(&shader->files[i].vectors);
+ LIST_INITHEAD(&shader->files[i].vectors);
}
- c_list_init(&shader->nodes);
+ LIST_INITHEAD(&shader->nodes);
c_node_init(&shader->entry);
c_node_init(&shader->end);
shader->entry.opcode = C_OPCODE_ENTRY;
@@ -297,7 +298,7 @@ struct c_vector *c_shader_vector_new(struct c_shader *shader, unsigned file, uns
v->sid = sid;
shader->files[v->file].nvectors++;
v->id = shader->nvectors++;
- c_list_add_tail(v, &shader->files[v->file].vectors);
+ LIST_ADDTAIL(&v->head, &shader->files[v->file].vectors);
return v;
out_err:
for (i = 0; i < 4; i++) {
@@ -307,13 +308,13 @@ out_err:
return NULL;
}
-static void c_node_remove_link(struct c_node_link *head, struct c_node *node)
+static void c_node_remove_link(struct list_head *head, struct c_node *node)
{
struct c_node_link *link, *tmp;
- c_list_for_each_safe(link, tmp, head) {
+ LIST_FOR_EACH_ENTRY_SAFE(link, tmp, head, head) {
if (link->node == node) {
- c_list_del(link);
+ LIST_DEL(&link->head);
free(link);
}
}
@@ -324,26 +325,26 @@ static void c_node_destroy(struct c_node *node)
struct c_instruction *i, *ni;
struct c_node_link *link, *tmp;
- c_list_for_each_safe(i, ni, &node->insts) {
- c_list_del(i);
+ LIST_FOR_EACH_ENTRY_SAFE(i, ni, &node->insts, head) {
+ LIST_DEL(&i->head);
free(i);
}
if (node->parent)
c_node_remove_link(&node->parent->childs, node);
node->parent = NULL;
- c_list_for_each_safe(link, tmp, &node->predecessors) {
+ LIST_FOR_EACH_ENTRY_SAFE(link, tmp, &node->predecessors, head) {
c_node_remove_link(&link->node->successors, node);
- c_list_del(link);
+ LIST_DEL(&link->head);
free(link);
}
- c_list_for_each_safe(link, tmp, &node->successors) {
+ LIST_FOR_EACH_ENTRY_SAFE(link, tmp, &node->successors, head) {
c_node_remove_link(&link->node->predecessors, node);
- c_list_del(link);
+ LIST_DEL(&link->head);
free(link);
}
- c_list_for_each_safe(link, tmp, &node->childs) {
+ LIST_FOR_EACH_ENTRY_SAFE(link, tmp, &node->childs, head) {
link->node->parent = NULL;
- c_list_del(link);
+ LIST_DEL(&link->head);
free(link);
}
}
@@ -356,8 +357,8 @@ void c_shader_destroy(struct c_shader *shader)
for (i = 0; i < C_FILE_COUNT; i++) {
shader->files[i].nvectors = 0;
- c_list_for_each_safe(v, nv, &shader->files[i].vectors) {
- c_list_del(v);
+ LIST_FOR_EACH_ENTRY_SAFE(v, nv, &shader->files[i].vectors, head) {
+ LIST_DEL(&v->head);
free(v->channel[0]);
free(v->channel[1]);
free(v->channel[2]);
@@ -365,8 +366,8 @@ void c_shader_destroy(struct c_shader *shader)
free(v);
}
}
- c_list_for_each_safe(n, nn, &shader->nodes) {
- c_list_del(n);
+ LIST_FOR_EACH_ENTRY_SAFE(n, nn, &shader->nodes, head) {
+ LIST_DEL(&n->head);
c_node_destroy(n);
}
memset(shader, 0, sizeof(struct c_shader));
@@ -379,7 +380,7 @@ static void c_shader_dfs_without_rec(struct c_node *entry, struct c_node *node)
if (entry == node || entry->visited)
return;
entry->visited = 1;
- c_list_for_each(link, &entry->successors) {
+ LIST_FOR_EACH_ENTRY(link, &entry->successors, head) {
c_shader_dfs_without_rec(link->node, node);
}
}
@@ -390,7 +391,7 @@ static void c_shader_dfs_without(struct c_shader *shader, struct c_node *node)
shader->entry.visited = 0;
shader->end.visited = 0;
- c_list_for_each(n, &shader->nodes) {
+ LIST_FOR_EACH_ENTRY(n, &shader->nodes, head) {
n->visited = 0;
}
c_shader_dfs_without_rec(&shader->entry, node);
@@ -405,7 +406,7 @@ static int c_shader_build_dominator_tree_rec(struct c_shader *shader, struct c_n
if (node->done)
return 0;
node->done = 1;
- c_list_for_each(link, &node->predecessors) {
+ LIST_FOR_EACH_ENTRY(link, &node->predecessors, head) {
/* if we remove this predecessor can we reach the current node ? */
c_shader_dfs_without(shader, link->node);
if (node->visited == 0) {
@@ -417,7 +418,7 @@ static int c_shader_build_dominator_tree_rec(struct c_shader *shader, struct c_n
nlink = c_node_link_new(node);
if (nlink == NULL)
return -ENOMEM;
- c_list_add_tail(nlink, &link->node->childs);
+ LIST_ADDTAIL(&nlink->head, &link->node->childs);
found = 1;
break;
}
@@ -428,7 +429,7 @@ static int c_shader_build_dominator_tree_rec(struct c_shader *shader, struct c_n
node, node->opcode);
return -EINVAL;
}
- c_list_for_each(link, &node->predecessors) {
+ LIST_FOR_EACH_ENTRY(link, &node->predecessors, head) {
r = c_shader_build_dominator_tree_rec(shader, link->node);
if (r)
return r;
@@ -439,7 +440,7 @@ static int c_shader_build_dominator_tree_rec(struct c_shader *shader, struct c_n
int c_shader_build_dominator_tree(struct c_shader *shader)
{
struct c_node *node;
- c_list_for_each(node, &shader->nodes) {
+ LIST_FOR_EACH_ENTRY(node, &shader->nodes, head) {
node->done = 0;
}
return c_shader_build_dominator_tree_rec(shader, &shader->end);
diff --git a/src/gallium/drivers/r600/r600_compiler.h b/src/gallium/drivers/r600/r600_compiler.h
index 3de19970c31..77230aed73b 100644
--- a/src/gallium/drivers/r600/r600_compiler.h
+++ b/src/gallium/drivers/r600/r600_compiler.h
@@ -23,12 +23,13 @@
#ifndef R600_COMPILER_H
#define R600_COMPILER_H
+#include "util/u_double_list.h"
+
struct c_vector;
/* operand are the basic source/destination of each operation */
struct c_channel {
- struct c_channel *next;
- struct c_channel *prev;
+ struct list_head head;
unsigned vindex; /**< index in vector X,Y,Z,W (0,1,2,3) */
unsigned value; /**< immediate value 32bits */
struct c_vector *vector; /**< vector to which it belongs */
@@ -39,8 +40,7 @@ struct c_channel {
* operand into a same vector
*/
struct c_vector {
- struct c_vector *next;
- struct c_vector *prev;
+ struct list_head head;
unsigned id; /**< vector uniq id */
unsigned name; /**< semantic name */
unsigned file; /**< operand file C_FILE_* */
@@ -48,16 +48,6 @@ struct c_vector {
struct c_channel *channel[4]; /**< operands */
};
-#define c_list_init(e) do { (e)->next = e; (e)->prev = e; } while(0)
-#define c_list_add(e, h) do { (e)->next = (h)->next; (e)->prev = h; (h)->next = e; (e)->next->prev = e; } while(0)
-#define c_list_add_tail(e, h) do { (e)->next = h; (e)->prev = (h)->prev; (h)->prev = e; (e)->prev->next = e; } while(0)
-#define c_list_del(e) do { (e)->next->prev = (e)->prev; (e)->prev->next = (e)->next; c_list_init(e); } while(0)
-#define c_list_for_each(p, h) for (p = (h)->next; p != (h); p = p->next)
-#define c_list_for_each_from(p, s, h) for (p = s; p != (h); p = p->next)
-#define c_list_for_each_safe(p, n, h) for (p = (h)->next, n = p->next; p != (h); p = n, n = p->next)
-#define c_list_empty(h) ((h)->next == h)
-
-
#define C_PROGRAM_TYPE_VS 0
#define C_PROGRAM_TYPE_FS 1
#define C_PROGRAM_TYPE_COUNT 2
@@ -259,7 +249,7 @@ struct c_op {
};
struct c_instruction {
- struct c_instruction *next, *prev;
+ struct list_head head;
unsigned nop;
struct c_op op[5];
};
@@ -267,8 +257,7 @@ struct c_instruction {
struct c_node;
struct c_node_link {
- struct c_node_link *next;
- struct c_node_link *prev;
+ struct list_head head;
struct c_node *node;
};
@@ -285,12 +274,12 @@ struct c_node_link {
* @childs: child nodes in the depth first walk tree
*/
struct c_node {
- struct c_node *next, *prev;
- struct c_node_link predecessors;
- struct c_node_link successors;
+ struct list_head head;
+ struct list_head predecessors;
+ struct list_head successors;
+ struct list_head childs;
struct c_node *parent;
- struct c_node_link childs;
- struct c_instruction insts;
+ struct list_head insts;
unsigned opcode;
unsigned visited;
unsigned done;
@@ -299,13 +288,13 @@ struct c_node {
struct c_file {
unsigned nvectors;
- struct c_vector vectors;
+ struct list_head vectors;
};
struct c_shader {
unsigned nvectors;
struct c_file files[C_FILE_COUNT];
- struct c_node nodes;
+ struct list_head nodes;
struct c_node entry;
struct c_node end;
unsigned type;
diff --git a/src/gallium/drivers/r600/r600_compiler_dump.c b/src/gallium/drivers/r600/r600_compiler_dump.c
index 485032088c8..bb022b7c298 100644
--- a/src/gallium/drivers/r600/r600_compiler_dump.c
+++ b/src/gallium/drivers/r600/r600_compiler_dump.c
@@ -232,7 +232,7 @@ static void c_node_dump(struct c_node *node, unsigned indent)
unsigned j, k;
pindent(indent); fprintf(stderr, "# node %s\n", c_get_name(c_opcode_str, node->opcode));
- c_list_for_each(i, &node->insts) {
+ LIST_FOR_EACH_ENTRY(i, &node->insts, head) {
for (k = 0; k < i->nop; k++) {
pindent(indent);
fprintf(stderr, "%s", c_get_name(c_opcode_str, i->op[k].opcode));
@@ -256,7 +256,7 @@ static void c_shader_dump_rec(struct c_shader *shader, struct c_node *node, unsi
struct c_node_link *link;
c_node_dump(node, indent);
- c_list_for_each(link, &node->childs) {
+ LIST_FOR_EACH_ENTRY(link, &node->childs, head) {
c_shader_dump_rec(shader, link->node, indent + 1);
}
}
diff --git a/src/gallium/drivers/r600/r600_compiler_r600.c b/src/gallium/drivers/r600/r600_compiler_r600.c
index 14ea8ab6e88..fba0f3df428 100644
--- a/src/gallium/drivers/r600/r600_compiler_r600.c
+++ b/src/gallium/drivers/r600/r600_compiler_r600.c
@@ -53,7 +53,7 @@ int r600_shader_insert_fetch(struct c_shader *shader)
vi = c_shader_vector_new(shader, C_FILE_INPUT, C_SEMANTIC_VERTEXID, -1);
if (vi == NULL)
return -ENOMEM;
- c_list_for_each_safe(v, nv, &shader->files[C_FILE_INPUT].vectors) {
+ LIST_FOR_EACH_ENTRY_SAFE(v, nv, &shader->files[C_FILE_INPUT].vectors, head) {
if (v == vi)
continue;
vr = c_shader_vector_new(shader, C_FILE_RESOURCE, C_SEMANTIC_GENERIC, -1);
@@ -88,9 +88,9 @@ int r600_shader_insert_fetch(struct c_shader *shader)
r = c_node_add_new_instruction_head(&shader->entry, &instruction);
if (r)
return r;
- c_list_del(v);
+ LIST_DEL(&v->head);
shader->files[C_FILE_INPUT].nvectors--;
- c_list_add_tail(v, &shader->files[C_FILE_TEMPORARY].vectors);
+ LIST_ADDTAIL(&v->head, &shader->files[C_FILE_TEMPORARY].vectors);
shader->files[C_FILE_TEMPORARY].nvectors++;
v->file = C_FILE_TEMPORARY;
}
@@ -113,14 +113,14 @@ void r600_shader_cleanup(struct r600_shader *rshader)
free(rshader->gpr);
rshader->gpr = NULL;
}
- c_list_for_each_safe(n, nn, &rshader->nodes) {
- c_list_del(n);
- c_list_for_each_safe(vf, nvf, &n->vfetch) {
- c_list_del(vf);
+ LIST_FOR_EACH_ENTRY_SAFE(n, nn, &rshader->nodes, head) {
+ LIST_DEL(&n->head);
+ LIST_FOR_EACH_ENTRY_SAFE(vf, nvf, &n->vfetch, head) {
+ LIST_DEL(&vf->head);
free(vf);
}
- c_list_for_each_safe(alu, nalu, &n->alu) {
- c_list_del(alu);
+ LIST_FOR_EACH_ENTRY_SAFE(alu, nalu, &n->alu, head) {
+ LIST_DEL(&alu->head);
free(alu);
}
free(n);
@@ -161,8 +161,8 @@ int r600_shader_update(struct r600_shader *rshader, enum pipe_format *resource_f
memcpy(rshader->resource_format, resource_format,
rshader->nresource * sizeof(enum pipe_format));
- c_list_for_each(rnode, &rshader->nodes) {
- c_list_for_each(vfetch, &rnode->vfetch) {
+ LIST_FOR_EACH_ENTRY(rnode, &rshader->nodes, head) {
+ LIST_FOR_EACH_ENTRY(vfetch, &rnode->vfetch, head) {
const struct util_format_description *desc;
i = vfetch->cf_addr + 1;
rshader->bcode[i] &= C_SQ_VTX_WORD1_DST_SEL_X;
@@ -197,7 +197,7 @@ int r600_shader_register(struct r600_shader *rshader)
cid = 0;
rid = 0;
/* alloc input first */
- c_list_for_each(v, &rshader->cshader.files[C_FILE_INPUT].vectors) {
+ LIST_FOR_EACH_ENTRY(v, &rshader->cshader.files[C_FILE_INPUT].vectors, head) {
nv = c_vector_new();
if (nv == NULL) {
return -ENOMEM;
@@ -209,7 +209,7 @@ int r600_shader_register(struct r600_shader *rshader)
for (i = 0; i < C_FILE_COUNT; i++) {
if (i == C_FILE_INPUT || i == C_FILE_IMMEDIATE)
continue;
- c_list_for_each(v, &rshader->cshader.files[i].vectors) {
+ LIST_FOR_EACH_ENTRY(v, &rshader->cshader.files[i].vectors, head) {
switch (v->file) {
case C_FILE_OUTPUT:
case C_FILE_TEMPORARY:
@@ -315,9 +315,9 @@ static struct r600_shader_node *r600_shader_new_node(struct r600_shader *rshader
if (rnode == NULL)
return NULL;
rnode->node = node;
- c_list_init(&rnode->vfetch);
- c_list_init(&rnode->alu);
- c_list_add_tail(rnode, &rshader->nodes);
+ LIST_INITHEAD(&rnode->vfetch);
+ LIST_INITHEAD(&rnode->alu);
+ LIST_ADDTAIL(&rnode->head, &rshader->nodes);
return rnode;
}
@@ -333,7 +333,7 @@ static int r600_shader_add_vfetch(struct r600_shader *rshader,
return 0;
if (instruction->op[0].opcode != C_OPCODE_VFETCH)
return 0;
- if (!c_list_empty(&node->alu)) {
+ if (!LIST_IS_EMPTY(&node->alu)) {
rnode = r600_shader_new_node(rshader, node->node);
if (rnode == NULL)
return -ENOMEM;
@@ -355,7 +355,7 @@ static int r600_shader_add_vfetch(struct r600_shader *rshader,
vfetch->dst[1].chan = C_SWIZZLE_Y;
vfetch->dst[2].chan = C_SWIZZLE_Z;
vfetch->dst[3].chan = C_SWIZZLE_W;
- c_list_add_tail(vfetch, &node->vfetch);
+ LIST_ADDTAIL(&vfetch->head, &node->vfetch);
node->nslot += 2;
return 0;
}
@@ -369,7 +369,7 @@ static int r600_node_translate(struct r600_shader *rshader, struct c_node *node)
rnode = r600_shader_new_node(rshader, node);
if (rnode == NULL)
return -ENOMEM;
- c_list_for_each(instruction, &node->insts) {
+ LIST_FOR_EACH_ENTRY(instruction, &node->insts, head) {
switch (instruction->op[0].opcode) {
case C_OPCODE_VFETCH:
r = r600_shader_add_vfetch(rshader, rnode, instruction);
@@ -400,7 +400,7 @@ int r600_shader_translate_rec(struct r600_shader *rshader, struct c_node *node)
r = r600_node_translate(rshader, node);
if (r)
return r;
- c_list_for_each(link, &node->childs) {
+ LIST_FOR_EACH_ENTRY(link, &node->childs, head) {
r = r600_shader_translate_rec(rshader, link->node);
if (r)
return r;
@@ -425,7 +425,7 @@ static struct r600_shader_alu *r600_shader_insert_alu(struct r600_shader *rshade
alu->alu[2].opcode = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP;
alu->alu[3].opcode = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP;
alu->alu[4].opcode = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP;
- c_list_add_tail(alu, &node->alu);
+ LIST_ADDTAIL(&alu->head, &node->alu);
return alu;
}
@@ -437,7 +437,7 @@ static int r600_shader_alu_translate(struct r600_shader *rshader,
struct r600_shader_alu *alu;
int i, j, r, comp, litteral_lastcomp = -1;
- if (!c_list_empty(&node->vfetch)) {
+ if (!LIST_IS_EMPTY(&node->vfetch)) {
rnode = r600_shader_new_node(rshader, node->node);
if (rnode == NULL) {
fprintf(stderr, "%s %d new node failed\n", __func__, __LINE__);
@@ -541,17 +541,17 @@ void r600_shader_node_place(struct r600_shader *rshader)
rshader->ncf = 0;
rshader->nslot = 0;
- c_list_for_each_safe(node, nnode, &rshader->nodes) {
- c_list_for_each_safe(alu, nalu, &node->alu) {
+ LIST_FOR_EACH_ENTRY_SAFE(node, nnode, &rshader->nodes, head) {
+ LIST_FOR_EACH_ENTRY_SAFE(alu, nalu, &node->alu, head) {
node->nslot += alu->nalu;
node->nslot += alu->nliteral >> 1;
}
node->nfetch = 0;
- c_list_for_each_safe(vfetch, nvfetch, &node->vfetch) {
+ LIST_FOR_EACH_ENTRY_SAFE(vfetch, nvfetch, &node->vfetch, head) {
node->nslot += 2;
node->nfetch += 1;
}
- if (!c_list_empty(&node->vfetch)) {
+ if (!LIST_IS_EMPTY(&node->vfetch)) {
/* fetch node need to be 16 bytes aligned*/
cf_addr += 1;
cf_addr &= 0xFFFFFFFEUL;
@@ -563,7 +563,7 @@ void r600_shader_node_place(struct r600_shader *rshader)
rshader->ncf++;
}
rshader->nslot = cf_addr;
- c_list_for_each_safe(node, nnode, &rshader->nodes) {
+ LIST_FOR_EACH_ENTRY_SAFE(node, nnode, &rshader->nodes, head) {
node->cf_addr += cf_id * 2;
}
rshader->ncf += rshader->cshader.files[C_FILE_OUTPUT].nvectors;
@@ -584,7 +584,7 @@ static int r600_cshader_legalize_rec(struct c_shader *shader, struct c_node *nod
unsigned k;
int r;
- c_list_for_each(i, &node->insts) {
+ LIST_FOR_EACH_ENTRY(i, &node->insts, head) {
for (k = 0; k < i->nop; k++) {
switch (i->op[k].opcode) {
case C_OPCODE_SLT:
@@ -598,7 +598,7 @@ static int r600_cshader_legalize_rec(struct c_shader *shader, struct c_node *nod
}
}
}
- c_list_for_each(link, &node->childs) {
+ LIST_FOR_EACH_ENTRY(link, &node->childs, head) {
r = r600_cshader_legalize_rec(shader, link->node);
if (r) {
return r;
diff --git a/src/gallium/drivers/r600/r600_compiler_r700.c b/src/gallium/drivers/r600/r600_compiler_r700.c
index 809a57ae5c5..ca6447e553c 100644
--- a/src/gallium/drivers/r600/r600_compiler_r700.c
+++ b/src/gallium/drivers/r600/r600_compiler_r700.c
@@ -172,14 +172,14 @@ int r700_shader_translate(struct r600_shader *rshader)
rshader->bcode = malloc(rshader->ndw * 4);
if (rshader->bcode == NULL)
return -ENOMEM;
- c_list_for_each(rnode, &rshader->nodes) {
+ LIST_FOR_EACH_ENTRY(rnode, &rshader->nodes, head) {
id = rnode->cf_addr;
- c_list_for_each(vfetch, &rnode->vfetch) {
+ LIST_FOR_EACH_ENTRY(vfetch, &rnode->vfetch, head) {
r = r600_shader_vfetch_bytecode(rshader, rnode, vfetch, &id);
if (r)
return r;
}
- c_list_for_each(alu, &rnode->alu) {
+ LIST_FOR_EACH_ENTRY(alu, &rnode->alu, head) {
for (i = 0; i < alu->nalu; i++) {
r = r700_shader_alu_bytecode(rshader, rnode, &alu->alu[i], &id);
if (r)
@@ -191,20 +191,20 @@ int r700_shader_translate(struct r600_shader *rshader)
}
}
id = 0;
- c_list_for_each(rnode, &rshader->nodes) {
+ LIST_FOR_EACH_ENTRY(rnode, &rshader->nodes, head) {
r = r700_shader_cf_node_bytecode(rshader, rnode, &id);
if (r)
return r;
}
- c_list_for_each(v, &rshader->cshader.files[C_FILE_OUTPUT].vectors) {
+ LIST_FOR_EACH_ENTRY(v, &rshader->cshader.files[C_FILE_OUTPUT].vectors, head) {
end = 0;
- if (v->next == &rshader->cshader.files[C_FILE_OUTPUT].vectors)
+ if (v->head.next == &rshader->cshader.files[C_FILE_OUTPUT].vectors)
end = 1;
r = r700_shader_cf_output_bytecode(rshader, v, &id, end);
if (r)
return r;
}
- c_list_for_each(v, &rshader->cshader.files[C_FILE_INPUT].vectors) {
+ LIST_FOR_EACH_ENTRY(v, &rshader->cshader.files[C_FILE_INPUT].vectors, head) {
rshader->input[rshader->ninput].gpr = rshader->ninput;
rshader->input[rshader->ninput].sid = v->sid;
rshader->input[rshader->ninput].name = v->name;
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 6b29d333798..2cbfde87130 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -133,7 +133,7 @@ struct r600_pipe_shader *r600_pipe_shader_create(struct pipe_context *ctx, unsig
if (rpshader == NULL)
return NULL;
rpshader->type = type;
- c_list_init(&rshader->nodes);
+ LIST_INITHEAD(&rshader->nodes);
fprintf(stderr, "<<\n");
tgsi_dump(tokens, 0);
fprintf(stderr, "--------------------------------------------------------------\n");
diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h
index 7d30ca79d1b..6e1bd1e37e5 100644
--- a/src/gallium/drivers/r600/r600_shader.h
+++ b/src/gallium/drivers/r600/r600_shader.h
@@ -35,8 +35,7 @@ struct r600_shader_operand {
};
struct r600_shader_vfetch {
- struct r600_shader_vfetch *next;
- struct r600_shader_vfetch *prev;
+ struct list_head head;
unsigned cf_addr;
struct r600_shader_operand src[2];
struct r600_shader_operand dst[4];
@@ -52,8 +51,7 @@ struct r600_shader_inst {
};
struct r600_shader_alu {
- struct r600_shader_alu *next;
- struct r600_shader_alu *prev;
+ struct list_head head;
unsigned nalu;
unsigned nliteral;
unsigned nconstant;
@@ -62,15 +60,14 @@ struct r600_shader_alu {
};
struct r600_shader_node {
- struct r600_shader_node *next;
- struct r600_shader_node *prev;
+ struct list_head head;
unsigned cf_id; /**< cf index (in dw) in byte code */
unsigned cf_addr; /**< instructions index (in dw) in byte code */
unsigned nslot; /**< number of slot (2 dw) needed by this node */
unsigned nfetch;
struct c_node *node; /**< compiler node from which this node originate */
- struct r600_shader_vfetch vfetch; /**< list of vfetch instructions */
- struct r600_shader_alu alu; /**< list of alu instructions */
+ struct list_head vfetch; /**< list of vfetch instructions */
+ struct list_head alu; /**< list of alu instructions */
};
struct r600_shader_io {
@@ -90,7 +87,7 @@ struct r600_shader {
unsigned ncf; /**< total number of cf clauses */
unsigned nslot; /**< total number of slots (2 dw) */
unsigned flat_shade; /**< are we flat shading */
- struct r600_shader_node nodes; /**< list of node */
+ struct list_head nodes; /**< list of node */
struct r600_shader_io input[32];
struct r600_shader_io output[32];
/* TODO replace GPR by some better register allocator */