Commit daa15cd5 authored by Christian Würdig's avatar Christian Würdig
Browse files

added support for abstract machine specification

parent 31871f2c
......@@ -12,6 +12,7 @@ my $target_dir = $ARGV[1];
our $arch;
our %cpu;
our %vliw;
# include spec file
......@@ -36,6 +37,9 @@ my @obst_execunits; # stack for execunit variables
my @obst_execunits_header; # stack for execunit variables
my @obst_init_unit_types; # stack for unit type variable init
my $bundle_size = exists($vliw{"bundle_size"}) ? $vliw{"bundle_size"} : 3;
my $bundles_per_cycle = exists($vliw{"bundles_per_cycle"}) ? $vliw{"bundles_per_cycle"} : 1;
my $num_unit_types = scalar(keys(%cpu));
my $tmp = uc($arch);
my $idx = 0;
......@@ -94,7 +98,7 @@ print OUT<<EOF;
/**
* Returns the $arch machine description.
*/
const be_machine_t *$arch\_get_machine_description(void);
const be_machine_t *$arch\_init_machine_description(void);
EOF
......@@ -134,7 +138,7 @@ print OUT @obst_execunits;
print OUT<<EOF;
static be_execution_unit_type_t $arch\_execution_unit_types[] = {
be_execution_unit_type_t $arch\_execution_unit_types[] = {
EOF
print OUT @obst_init_unit_types;
......@@ -142,7 +146,9 @@ print OUT @obst_init_unit_types;
print OUT<<EOF;
};
static be_machine_t $arch\_cpu = {
be_machine_t $arch\_cpu = {
$bundle_size,
$bundles_per_cycle,
$num_unit_types,
$arch\_execution_unit_types
};
......@@ -150,7 +156,7 @@ static be_machine_t $arch\_cpu = {
/**
* Returns the $arch machines description
*/
const be_machine_t *$arch\_get_machine_description(void) {
const be_machine_t *$arch\_init_machine_description(void) {
static int initialized = 0;
if (! initialized) {
......
......@@ -187,9 +187,7 @@ foreach my $op (keys(%nodes)) {
my $exec_units = "NULL";
# set up static variables for cpu execution unit assigments
if (exists($n{"units"})) {
$temp .= " static const be_execution_unit_t *_exec_units[] =\n {\n";
$temp .= get_execunit_list($n{"units"});
$temp .= " };\n";
$temp .= gen_execunit_list_initializer($n{"units"});
$exec_units = "_exec_units";
}
......@@ -519,10 +517,12 @@ sub translate_arity {
###
# Return the list of pointers for the given execution units.
###
sub get_execunit_list {
sub gen_execunit_list_initializer {
my $units = shift;
my $uc_arch = uc($arch);
my $ret = "";
my $ret2 = "";
my %init;
foreach my $unit (@{ $units }) {
if (exists($cpu{"$unit"})) {
......@@ -531,7 +531,7 @@ sub get_execunit_list {
my $tp_name = "$arch\_execution_units_$unit";
foreach (@{ $cpu{"$unit"} }) {
my $unit_name = "$uc_arch\_EXECUNIT_TP_$unit\_$_";
$ret .= " &".$tp_name."[".$unit_name."],\n";
push(@{ $init{"$unit"} }, " &".$tp_name."[".$unit_name."]");
}
}
else {
......@@ -543,8 +543,8 @@ TP_SEARCH: foreach my $cur_type (keys(%cpu)) {
if ($unit eq $cur_unit) {
my $tp_name = "$arch\_execution_units_$cur_type";
my $unit_name = "$uc_arch\_EXECUNIT_TP_$cur_type\_$unit";
$ret .= " &".$tp_name."[".$unit_name."],\n";
$found = 1;
push(@{ $init{"$unit"} }, " &".$tp_name."[".$unit_name."]");
$found = 1;
last TP_SEARCH;
}
}
......@@ -556,7 +556,19 @@ TP_SEARCH: foreach my $cur_type (keys(%cpu)) {
}
}
$ret .= " NULL\n";
# prepare the 2-dim array init
foreach my $key (keys(%init)) {
$ret .= " static const be_execution_unit_t *_allowed_units_".$key."[] =\n {\n";
foreach (@{ $init{"$key"} }) {
$ret .= "$_,\n";
}
$ret .= " NULL\n";
$ret .= " };\n";
$ret2 .= " _allowed_units_$key,\n";
}
$ret2 .= " NULL\n";
$ret .= " static const be_execution_unit_t **_exec_units[] =\n {\n".$ret2." };\n";
return $ret;
}
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