Commit 66fa68a3 authored by Matthias Braun's avatar Matthias Braun
Browse files

be: use designated initializer for regs, regclasses, reg_reqs

parent 216d5d11
...@@ -55,90 +55,93 @@ static pmap *node_to_stack; ...@@ -55,90 +55,93 @@ static pmap *node_to_stack;
static be_stackorder_t *stackorder; static be_stackorder_t *stackorder;
static const arch_register_req_t amd64_requirement_gp = { static const arch_register_req_t amd64_requirement_gp = {
arch_register_req_type_normal, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
0 .width = 1,
}; };
static const arch_register_req_t amd64_requirement_flags = { static const arch_register_req_t amd64_requirement_flags = {
arch_register_req_type_normal, .cls = &amd64_reg_classes[CLASS_amd64_flags],
&amd64_reg_classes[CLASS_amd64_flags], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const arch_register_req_t amd64_requirement_xmm = { static const arch_register_req_t amd64_requirement_xmm = {
arch_register_req_type_normal, .cls = &amd64_reg_classes[CLASS_amd64_xmm],
&amd64_reg_classes[CLASS_amd64_xmm], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
#define BIT(x) (1u << x) #define BIT(x) (1u << x)
static const arch_register_req_t amd64_requirement_gp_same_0 = { static const arch_register_req_t amd64_requirement_gp_same_0 = {
arch_register_req_type_normal | arch_register_req_type_should_be_same, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = NULL,
NULL, .type = arch_register_req_type_normal
BIT(0), | arch_register_req_type_should_be_same,
0, .other_same = BIT(0),
1 .other_different = 0,
.width = 1,
}; };
static const arch_register_req_t amd64_requirement_xmm_same_0 = { static const arch_register_req_t amd64_requirement_xmm_same_0 = {
arch_register_req_type_normal | arch_register_req_type_should_be_same, .cls = &amd64_reg_classes[CLASS_amd64_xmm],
&amd64_reg_classes[CLASS_amd64_xmm], .limited = NULL,
NULL, .type = arch_register_req_type_normal
BIT(0), | arch_register_req_type_should_be_same,
0, .other_same = BIT(0),
1 .other_different = 0,
.width = 1,
}; };
static const arch_register_req_t amd64_requirement_gp_same_0_not_1 = { static const arch_register_req_t amd64_requirement_gp_same_0_not_1 = {
arch_register_req_type_normal | arch_register_req_type_should_be_same .cls = &amd64_reg_classes[CLASS_amd64_gp],
| arch_register_req_type_must_be_different, .limited = NULL,
&amd64_reg_classes[CLASS_amd64_gp], .type = arch_register_req_type_normal
NULL, | arch_register_req_type_should_be_same
BIT(0), | arch_register_req_type_must_be_different,
BIT(1), .other_same = BIT(0),
1 .other_different = BIT(1),
.width = 1,
}; };
static const unsigned amd64_limited_gp_rcx [] = { BIT(REG_GP_RCX) }; static const unsigned amd64_limited_gp_rcx [] = { BIT(REG_GP_RCX) };
static const arch_register_req_t amd64_requirement_rcx = { static const arch_register_req_t amd64_requirement_rcx = {
arch_register_req_type_limited, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = amd64_limited_gp_rcx,
amd64_limited_gp_rcx, .type = arch_register_req_type_limited,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const unsigned amd64_limited_gp_rax [] = { BIT(REG_GP_RAX) }; static const unsigned amd64_limited_gp_rax [] = { BIT(REG_GP_RAX) };
static const arch_register_req_t amd64_requirement_rax = { static const arch_register_req_t amd64_requirement_rax = {
arch_register_req_type_limited, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = amd64_limited_gp_rax,
amd64_limited_gp_rax, .type = arch_register_req_type_limited,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const unsigned amd64_limited_gp_rdx [] = { BIT(REG_GP_RDX) }; static const unsigned amd64_limited_gp_rdx [] = { BIT(REG_GP_RDX) };
static const arch_register_req_t amd64_requirement_rdx = { static const arch_register_req_t amd64_requirement_rdx = {
arch_register_req_type_limited, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = amd64_limited_gp_rdx,
amd64_limited_gp_rdx, .type = arch_register_req_type_limited,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const arch_register_req_t *mem_reqs[] = { static const arch_register_req_t *mem_reqs[] = {
...@@ -155,7 +158,6 @@ static const arch_register_req_t *xmm_mem_reqs[] = { ...@@ -155,7 +158,6 @@ static const arch_register_req_t *xmm_mem_reqs[] = {
&arch_no_requirement, &arch_no_requirement,
}; };
static const arch_register_req_t *reg_reg_mem_reqs[] = { static const arch_register_req_t *reg_reg_mem_reqs[] = {
&amd64_requirement_gp, &amd64_requirement_gp,
&amd64_requirement_gp, &amd64_requirement_gp,
......
...@@ -132,22 +132,22 @@ static void amd64_before_ra(ir_graph *irg) ...@@ -132,22 +132,22 @@ static void amd64_before_ra(ir_graph *irg)
} }
static const arch_register_req_t amd64_requirement_gp = { static const arch_register_req_t amd64_requirement_gp = {
arch_register_req_type_normal, .cls = &amd64_reg_classes[CLASS_amd64_gp],
&amd64_reg_classes[CLASS_amd64_gp], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const unsigned amd64_limited_gp_rsp [] = { (1 << REG_GP_RSP) }; static const unsigned amd64_limited_gp_rsp [] = { (1 << REG_GP_RSP) };
static const arch_register_req_t amd64_single_reg_req_gp_rsp = { static const arch_register_req_t amd64_single_reg_req_gp_rsp = {
arch_register_req_type_limited, .type = arch_register_req_type_limited,
&amd64_reg_classes[CLASS_amd64_gp], .cls = &amd64_reg_classes[CLASS_amd64_gp],
amd64_limited_gp_rsp, .limited = amd64_limited_gp_rsp,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const arch_register_req_t *am_pushpop_base_reqs[] = { static const arch_register_req_t *am_pushpop_base_reqs[] = {
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
#include "raw_bitset.h" #include "raw_bitset.h"
arch_register_req_t const arch_no_requirement = { arch_register_req_t const arch_no_requirement = {
arch_register_req_type_none, .cls = NULL,
NULL, .limited = NULL,
NULL, .type = arch_register_req_type_none,
0, .other_same = 0,
0, .other_different = 0,
0 .width = 0,
}; };
/** /**
......
...@@ -1143,12 +1143,12 @@ sub generate_requirements { ...@@ -1143,12 +1143,12 @@ sub generate_requirements {
$result = <<EOF; $result = <<EOF;
{ {
arch_register_req_type_none, .cls = NULL,
NULL, /* regclass */ .limited = NULL,
NULL, /* limit bitset */ .type = arch_register_req_type_none,
0, /* same pos */ .other_same = 0,
0, /* different pos */ .other_different = 0,
0 /* width */ .width = 0,
}; };
EOF EOF
...@@ -1158,12 +1158,12 @@ EOF ...@@ -1158,12 +1158,12 @@ EOF
$class = $reqs; $class = $reqs;
$result = <<EOF; $result = <<EOF;
{ {
${reqtype}, .cls = &${arch}_reg_classes[CLASS_${arch}_${class}],
& ${arch}_reg_classes[CLASS_${arch}_${class}], .limited = NULL,
NULL, /* limit bitset */ .type = ${reqtype},
0, /* same pos */ .other_same = 0,
0, /* different pos */ .other_different = 0,
$width /* width */ .width = $width,
}; };
EOF EOF
...@@ -1194,12 +1194,12 @@ EOF ...@@ -1194,12 +1194,12 @@ EOF
$class = $regclass; $class = $regclass;
$result = <<EOF; $result = <<EOF;
{ {
${reqtype}, .cls = &${arch}_reg_classes[CLASS_${arch}_${class}],
& ${arch}_reg_classes[CLASS_${arch}_${class}], .limited = ${limit_bitset},
${limit_bitset}, .type = ${reqtype},
${same_pos}, /* same pos */ .other_same = ${same_pos},
${different_pos}, /* different pos */ .other_different = ${different_pos},
$width /* width */ .width = $width,
}; };
EOF EOF
......
...@@ -134,19 +134,30 @@ foreach my $class_name (keys(%reg_classes)) { ...@@ -134,19 +134,30 @@ foreach my $class_name (keys(%reg_classes)) {
$single_constraints .= <<EOF; $single_constraints .= <<EOF;
static const arch_register_req_t ${arch}_class_reg_req_${old_classname} = { static const arch_register_req_t ${arch}_class_reg_req_${old_classname} = {
arch_register_req_type_normal, .cls = &${arch}_reg_classes[CLASS_${arch}_${old_classname}],
&${arch}_reg_classes[CLASS_${arch}_${old_classname}], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
EOF EOF
$classdef .= "\tCLASS_$class_name = $class_idx,\n"; $classdef .= "\tCLASS_$class_name = $class_idx,\n";
my $numregs = @class; my $numregs = @class;
my $first_reg = "&${arch}_registers[REG_". uc($class[0]->{"name"}) . "]"; my $first_reg = "&${arch}_registers[REG_". uc($class[0]->{"name"}) . "]";
push(@regclasses, "{ $class_idx, \"$class_name\", $numregs, NULL, $first_reg, $flags_prepared, &${arch}_class_reg_req_${old_classname} }"); my $rcdef = <<EOF;
{
.name = \"$class_name\",
.mode = NULL,
.regs = $first_reg,
.class_req = &${arch}_class_reg_req_${old_classname},
.index = $class_idx,
.n_regs = $numregs,
.flags = $flags_prepared,
},
EOF
push(@regclasses, $rcdef);
my $idx = 0; my $idx = 0;
$reginit .= "\t$arch\_reg_classes[CLASS_".$class_name."].mode = $class_mode;\n"; $reginit .= "\t$arch\_reg_classes[CLASS_".$class_name."].mode = $class_mode;\n";
...@@ -173,14 +184,14 @@ EOF ...@@ -173,14 +184,14 @@ EOF
$regtypes_def .= <<EOF; $regtypes_def .= <<EOF;
{ {
"${realname}", .name = "${realname}",
${class_ptr}, .reg_class = ${class_ptr},
REG_${classuc}_${ucname}, .single_req = &${arch}_single_reg_req_${old_classname}_${name},
REG_${ucname}, .type = ${type},
${type}, .index = REG_${classuc}_${ucname},
&${arch}_single_reg_req_${old_classname}_${name}, .global_index = REG_${ucname},
${dwarf_number}, .dwarf_number = ${dwarf_number},
${encoding} .encoding = ${encoding},
}, },
EOF EOF
...@@ -188,12 +199,12 @@ EOF ...@@ -188,12 +199,12 @@ EOF
$single_constraints .= <<EOF; $single_constraints .= <<EOF;
static const unsigned ${arch}_limited_${old_classname}_${name} [] = ${limitedarray}; static const unsigned ${arch}_limited_${old_classname}_${name} [] = ${limitedarray};
static const arch_register_req_t ${arch}_single_reg_req_${old_classname}_${name} = { static const arch_register_req_t ${arch}_single_reg_req_${old_classname}_${name} = {
arch_register_req_type_limited, .type = arch_register_req_type_limited,
${class_ptr}, .cls = ${class_ptr},
${arch}_limited_${old_classname}_${name}, .limited = ${arch}_limited_${old_classname}_${name},
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
EOF EOF
...@@ -280,7 +291,7 @@ print OUT<<EOF; ...@@ -280,7 +291,7 @@ print OUT<<EOF;
${single_constraints} ${single_constraints}
EOF EOF
print OUT "arch_register_class_t ${arch}_reg_classes[] = {\n\t".join(",\n\t", @regclasses)."\n};\n\n"; print OUT "arch_register_class_t ${arch}_reg_classes[] = {\n".join("",@regclasses)."\n};\n\n";
print OUT<<EOF; print OUT<<EOF;
......
...@@ -2292,31 +2292,32 @@ static ir_node *gen_Free(ir_node *node) ...@@ -2292,31 +2292,32 @@ static ir_node *gen_Free(ir_node *node)
} }
static const arch_register_req_t float1_req = { static const arch_register_req_t float1_req = {
arch_register_req_type_normal, .cls = &sparc_reg_classes[CLASS_sparc_fp],
&sparc_reg_classes[CLASS_sparc_fp], .limited = NULL,
NULL, .type = arch_register_req_type_normal,
0, .other_same = 0,
0, .other_different = 0,
1 .width = 1,
}; };
static const arch_register_req_t float2_req = { static const arch_register_req_t float2_req = {
arch_register_req_type_normal | arch_register_req_type_aligned, .cls = &sparc_reg_classes[CLASS_sparc_fp],
&sparc_reg_classes[CLASS_sparc_fp], .limited = NULL,
NULL, .type = arch_register_req_type_normal
0, | arch_register_req_type_aligned,
0, .other_same = 0,
2 .other_different = 0,
.width = 2,
}; };
static const arch_register_req_t float4_req = { static const arch_register_req_t float4_req = {
arch_register_req_type_normal | arch_register_req_type_aligned, .cls = &sparc_reg_classes[CLASS_sparc_fp],
&sparc_reg_classes[CLASS_sparc_fp], .limited = NULL,
NULL, .type = arch_register_req_type_normal
0, | arch_register_req_type_aligned,
0, .other_same = 0,
4 .other_different = 0,
.width = 4,
}; };
static const arch_register_req_t *get_float_req(ir_mode *mode) static const arch_register_req_t *get_float_req(ir_mode *mode)
{ {
assert(mode_is_float(mode)); assert(mode_is_float(mode));
......
Supports Markdown
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