Commit 40cccf8c authored by Matthias Braun's avatar Matthias Braun
Browse files

bescript: detect ambiguous requirements and provide a way to resolve them

parent e71d75e0
...@@ -788,6 +788,12 @@ sub is_reg_class { ...@@ -788,6 +788,12 @@ sub is_reg_class {
return 0; return 0;
} }
sub is_ambiguous {
my $name = shift;
return 1 if exists($reg_classes{"$name"}) && exists($reg2class{"$name"});
return 0;
}
### ###
# Returns the register class for a given register. # Returns the register class for a given register.
# @return class or undef # @return class or undef
...@@ -1025,10 +1031,23 @@ sub generate_requirements { ...@@ -1025,10 +1031,23 @@ sub generate_requirements {
} }
} }
my $is_cls = 0;
my $is_reg = 0;
if ($reqs =~ /reg-(.*)/) {
$reqs = $1;
$is_reg = 1;
} elsif ($reqs =~ /cls-(.*)/) {
$reqs = $1;
$is_cls = 1;
}
if (is_ambiguous($reqs) && !$is_reg && !$is_cls) {
die("Fatal error: $reqs is ambiguous (try reg-$reqs or cls-$reqs) at node $op")
}
my $class; my $class;
if ($reqs eq "none") { if ($reqs eq "none") {
return "arch_no_requirement"; return "arch_no_requirement";
} elsif (is_reg_class($reqs)) { } elsif (is_reg_class($reqs) && !$is_reg) {
my $reqtype = join(" | ", @req_type_mask) || "arch_register_req_type_none"; my $reqtype = join(" | ", @req_type_mask) || "arch_register_req_type_none";
$class = $reqs; $class = $reqs;
$result = <<EOF; $result = <<EOF;
......
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