De-duplicate ARM literal pools.
This commit is contained in:
parent
fc27be592c
commit
e4e0f76d5c
1 changed files with 9 additions and 0 deletions
|
|
@ -75,9 +75,18 @@ void codegen_reset_literal_pool(codeblock_t *block)
|
||||||
|
|
||||||
int add_literal(codeblock_t *block, uint32_t data)
|
int add_literal(codeblock_t *block, uint32_t data)
|
||||||
{
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
if (literal_offset >= 4096)
|
if (literal_offset >= 4096)
|
||||||
fatal("add_literal - literal pool full\n");
|
fatal("add_literal - literal pool full\n");
|
||||||
|
|
||||||
|
/*Search for pre-existing value*/
|
||||||
|
for (c = 0; c < literal_offset; c += 4)
|
||||||
|
{
|
||||||
|
if (*(uint32_t *)&block->data[ARM_LITERAL_POOL_OFFSET + c] == data)
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
*(uint32_t *)&block->data[ARM_LITERAL_POOL_OFFSET + literal_offset] = data;
|
*(uint32_t *)&block->data[ARM_LITERAL_POOL_OFFSET + literal_offset] = data;
|
||||||
|
|
||||||
literal_offset += 4;
|
literal_offset += 4;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue