summaryrefslogtreecommitdiffhomepage
path: root/ir/be/betranshlp.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-07-22 10:04:18 +0200
committerMatthias Braun <matze@braunis.de>2015-07-22 10:17:04 +0200
commit84b2a7e34baa2f93c533bccd6544d6b04c0100a6 (patch)
tree25a3766042580f3c529d43d3d4c2a67c37946f06 /ir/be/betranshlp.c
parentd28d0a06a0c4ef080079910d63fcd615223126fc (diff)
ia32: Match Relocation node
Diffstat (limited to 'ir/be/betranshlp.c')
-rw-r--r--ir/be/betranshlp.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/ir/be/betranshlp.c b/ir/be/betranshlp.c
index 1a4eb40..6220186 100644
--- a/ir/be/betranshlp.c
+++ b/ir/be/betranshlp.c
@@ -855,25 +855,41 @@ ir_node *be_skip_sameconv(ir_node *node)
return node;
}
-bool be_match_immediate(ir_node const *const node, ir_tarval **const tarval_out, ir_entity **const entity_out)
+bool be_match_immediate(ir_node const *const node, ir_tarval **const tarval_out,
+ ir_entity **const entity_out, unsigned *reloc_kind_out)
{
- ir_node const *addr;
- ir_node const *cnst;
+ unsigned reloc_kind;
+ ir_entity *entity;
+ ir_node const *cnst;
if (is_Const(node)) {
- addr = NULL;
- cnst = node;
+ entity = NULL;
+ cnst = node;
+ reloc_kind = 0;
} else if (is_Address(node)) {
- addr = node;
- cnst = NULL;
+ entity = get_Address_entity(node);
+ cnst = NULL;
+ reloc_kind = 0;
+ } else if (be_is_Relocation(node)) {
+ entity = be_get_Relocation_entity(node);
+ cnst = NULL;
+ reloc_kind = be_get_Relocation_kind(node);
} else if (is_Add(node)) {
- ir_node const *const l = get_Add_left(node);
- ir_node const *const r = get_Add_right(node);
- if (is_Address(l) && is_Const(r)) {
- addr = l;
- cnst = r;
- } else if (is_Const(l) && is_Address(r)) {
- addr = r;
- cnst = l;
+ ir_node const *l = get_Add_left(node);
+ ir_node const *r = get_Add_right(node);
+ if (be_is_Relocation(r) || is_Address(r)) {
+ ir_node const *tmp = l;
+ l = r;
+ r = tmp;
+ }
+ if (!is_Const(l))
+ return false;
+ cnst = l;
+ if (is_Address(r)) {
+ entity = get_Address_entity(node);
+ reloc_kind = 0;
+ } else if (be_is_Relocation(r)) {
+ entity = get_Address_entity(node);
+ reloc_kind = be_get_Relocation_kind(node);
} else {
return false;
}
@@ -881,16 +897,8 @@ bool be_match_immediate(ir_node const *const node, ir_tarval **const tarval_out,
return false;
}
- ir_entity *entity;
- if (addr) {
- entity = get_Address_entity(addr);
- if (is_tls_entity(entity))
- return false;
- } else {
- entity = NULL;
- }
-
- *tarval_out = cnst ? get_Const_tarval(cnst) : NULL;
- *entity_out = entity;
+ *tarval_out = cnst ? get_Const_tarval(cnst) : NULL;
+ *entity_out = entity;
+ *reloc_kind_out = reloc_kind;
return true;
}