Commit 13ca75d8 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

x86: Add helper function to check whether an address mode variant has base/index.

parent 1158173a
......@@ -281,13 +281,13 @@ static void amd64_emit_addr(const ir_node *const node,
if (variant == X86_ADDR_RIP) {
be_emit_cstring("%rip");
} else {
if (variant == X86_ADDR_BASE || variant == X86_ADDR_BASE_INDEX) {
if (x86_addr_variant_has_base(variant)) {
arch_register_t const *const reg
= arch_get_irn_register_in(node, addr->base_input);
emit_register(reg);
}
if (variant == X86_ADDR_BASE_INDEX || variant == X86_ADDR_INDEX) {
if (x86_addr_variant_has_index(variant)) {
be_emit_char(',');
arch_register_t const *const reg
= arch_get_irn_register_in(node, addr->index_input);
......
......@@ -124,12 +124,12 @@ static void amd64_turn_back_am(ir_node *const node, arch_register_t const *const
ir_node *load_in[3];
int load_arity = 0;
x86_addr_variant_t variant = attr->addr.variant;
if (variant == X86_ADDR_BASE || variant == X86_ADDR_BASE_INDEX) {
if (x86_addr_variant_has_base(variant)) {
int base_input = load_arity++;
new_addr.base_input = base_input;
load_in[base_input] = get_irn_n(node, attr->addr.base_input);
}
if (variant == X86_ADDR_INDEX || variant == X86_ADDR_BASE_INDEX) {
if (x86_addr_variant_has_index(variant)) {
int index_input = load_arity++;
new_addr.index_input = index_input;
load_in[index_input] = get_irn_n(node, attr->addr.index_input);
......
......@@ -710,14 +710,14 @@ static void perform_address_matching(ir_node *ptr, int *arity,
x86_addr_variant_t variant = maddr.variant;
assert(variant != X86_ADDR_INVALID);
if (variant == X86_ADDR_BASE || variant == X86_ADDR_BASE_INDEX) {
if (x86_addr_variant_has_base(variant)) {
int base_input = (*arity)++;
addr->base_input = base_input;
in[base_input] = be_transform_node(maddr.base);
} else {
assert(maddr.base == NULL);
}
if (variant == X86_ADDR_INDEX || variant == X86_ADDR_BASE_INDEX) {
if (x86_addr_variant_has_index(variant)) {
int index_input = (*arity)++;
addr->index_input = index_input;
in[index_input] = be_transform_node(maddr.index);
......@@ -1759,9 +1759,9 @@ static ir_node *gen_Call(ir_node *const node)
perform_address_matching(load_ptr, &in_arity, in, &addr);
x86_addr_variant_t variant = addr.variant;
if (variant == X86_ADDR_BASE || variant == X86_ADDR_BASE_INDEX)
if (x86_addr_variant_has_base(variant))
in_req[addr.base_input] = &amd64_class_reg_req_gp;
if (variant == X86_ADDR_BASE_INDEX || variant == X86_ADDR_INDEX)
if (x86_addr_variant_has_index(variant))
in_req[addr.index_input] = &amd64_class_reg_req_gp;
ir_node *load_mem = get_Load_mem(load);
......
......@@ -25,6 +25,16 @@ typedef enum {
X86_ADDR_RIP,
} x86_addr_variant_t;
static inline bool x86_addr_variant_has_base(x86_addr_variant_t const variant)
{
return variant == X86_ADDR_BASE || variant == X86_ADDR_BASE_INDEX;
}
static inline bool x86_addr_variant_has_index(x86_addr_variant_t const variant)
{
return variant == X86_ADDR_INDEX || variant == X86_ADDR_BASE_INDEX;
}
/**
* The address mode data: Used to construct (memory) address modes.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment