Commit 5fb9fc8a authored by Christoph Mallon's avatar Christoph Mallon
Browse files

bescripts: Make in_r[1-9] zero-based, which is the proper way to count.

parent 60fbd0c3
......@@ -135,7 +135,7 @@ my $shiftop = {
my $unop = {
irn_flags => [ "modify_flags", "rematerializable" ],
in_reqs => [ "gp" ],
out_reqs => [ "in_r1", "flags" ],
out_reqs => [ "in_r0", "flags" ],
ins => [ "val" ],
outs => [ "res", "flags" ],
attr_type => "amd64_addr_attr_t",
......
......@@ -272,10 +272,10 @@ Mul => {
emit => 'mul %D0, %S0, %S1',
constructors => {
"" => { out_reqs => [ "gp" ] },
# TODO: !in_r1 for out constraints the register allocator more than
# TODO: !in_r0 for out constraints the register allocator more than
# necessary, as usually you can fix the problem by swapping the inputs. But
# for this scheme we would need a special if both inputs are the same value.
v5 => { out_reqs => [ "!in_r1" ] },
v5 => { out_reqs => [ "!in_r0" ] },
},
},
......@@ -297,7 +297,7 @@ Mla => {
constructors => {
"" => { out_reqs => [ "gp" ] },
# See comments for Mul_v5 out register constraint
v5 => { out_reqs => [ "!in_r1" ] },
v5 => { out_reqs => [ "!in_r0" ] },
}
},
......@@ -324,7 +324,7 @@ OrPl => {
emit => 'orrpl %D0, %S2, %O',
attr_type => "arm_shifter_operand_t",
in_reqs => [ "gp", "flags", "gp", "gp" ],
out_reqs => [ "in_r3" ],
out_reqs => [ "in_r2" ],
ins => [ "falseval", "flags", "left", "right" ],
init => "init_arm_shifter_operand(res, 3, 0, ARM_SHF_REG, 0);",
},
......
......@@ -124,7 +124,7 @@ my $binop_commutative = {
irn_flags => [ "modify_flags", "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "gp", "gp" ],
out_reqs => [ "in_r4 in_r5", "flags", "mem" ],
out_reqs => [ "in_r3 in_r4", "flags", "mem" ],
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -162,7 +162,7 @@ my $binop_mem = {
my $shiftop = {
irn_flags => [ "modify_flags", "rematerializable" ],
in_reqs => [ "gp", "ecx" ],
out_reqs => [ "in_r1 !in_r2", "flags" ],
out_reqs => [ "in_r0 !in_r1", "flags" ],
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
mode => "first",
......@@ -181,11 +181,11 @@ my $shiftop_double = {
irn_flags => [ "modify_flags", "rematerializable" ],
in_reqs => [ "gp", "gp", "ecx" ],
constructors => {
"" => { out_reqs => [ "in_r1 !in_r2 !in_r3", "flags" ] },
"" => { out_reqs => [ "in_r0 !in_r1 !in_r2", "flags" ] },
# With an immediate shift amount we can swap between ShlD/ShrD and negate
# the shift amount, if the output gets the same register as the second
# input.
imm => { out_reqs => [ "in_r1 in_r2", "flags" ] },
imm => { out_reqs => [ "in_r0 in_r1", "flags" ] },
},
ins => [ "val_high", "val_low", "count" ],
outs => [ "res", "flags" ],
......@@ -218,7 +218,7 @@ my $mulop = {
my $unop = {
irn_flags => [ "modify_flags", "rematerializable" ],
in_reqs => [ "gp" ],
out_reqs => [ "in_r1", "flags" ],
out_reqs => [ "in_r0", "flags" ],
ins => [ "val" ],
outs => [ "res", "flags" ],
mode => "first",
......@@ -228,7 +228,7 @@ my $unop_no_flags = {
# no flags modified
irn_flags => [ "rematerializable" ],
in_reqs => [ "gp" ],
out_reqs => [ "in_r1" ],
out_reqs => [ "in_r0" ],
ins => [ "val" ],
outs => [ "res" ],
};
......@@ -316,7 +316,7 @@ my $xbinop = {
irn_flags => [ "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "xmm", "xmm" ],
out_reqs => [ "in_r4 !in_r5", "flags", "mem" ],
out_reqs => [ "in_r3 !in_r4", "flags", "mem" ],
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -327,7 +327,7 @@ my $xbinop_commutative = {
irn_flags => [ "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "xmm", "xmm" ],
out_reqs => [ "in_r4 in_r5", "flags", "mem" ],
out_reqs => [ "in_r3 in_r4", "flags", "mem" ],
ins => [ "base", "index", "mem", "left", "right" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -345,7 +345,7 @@ my $xconv_i2f = {
my $xshiftop = {
irn_flags => [ "rematerializable" ],
in_reqs => [ "xmm", "xmm" ],
out_reqs => [ "in_r1 !in_r2" ],
out_reqs => [ "in_r0 !in_r1" ],
};
my $xvalueop = {
......@@ -396,7 +396,7 @@ Adc => {
template => $carry_user_op,
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "gp", "gp", "flags" ],
out_reqs => [ "in_r4 in_r5", "flags", "mem" ],
out_reqs => [ "in_r3 in_r4", "flags", "mem" ],
ins => [ "base", "index", "mem", "left", "right", "eflags" ],
outs => [ "res", "flags", "M" ],
emit => "adc%M %B",
......@@ -507,7 +507,7 @@ Sub => {
irn_flags => [ "modify_flags", "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "gp", "gp" ],
out_reqs => [ "in_r4", "flags", "mem" ],
out_reqs => [ "in_r3", "flags", "mem" ],
ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -526,7 +526,7 @@ Sbb => {
template => $carry_user_op,
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "gp", "gp", "flags" ],
out_reqs => [ "in_r4", "flags", "mem" ],
out_reqs => [ "in_r3", "flags", "mem" ],
ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -659,7 +659,7 @@ NegMem => {
Minus64 => {
irn_flags => [ "modify_flags", "rematerializable" ],
in_reqs => [ "gp", "gp" ],
out_reqs => [ "in_r1", "in_r2" ],
out_reqs => [ "in_r0", "in_r1" ],
ins => [ "low", "high" ],
outs => [ "res_low", "res_high" ],
latency => 3,
......@@ -739,7 +739,7 @@ XorHighLow => {
irn_flags => [ "modify_flags", "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "eax ebx ecx edx" ],
out_reqs => [ "in_r1", "flags" ],
out_reqs => [ "in_r0", "flags" ],
emit => "xorb %>D0, %<D0",
ins => [ "value" ],
outs => [ "res", "flags" ],
......@@ -789,7 +789,7 @@ CMovcc => {
# (note: leave the false,true order intact to make it compatible with other
# ia32_binary ops)
in_reqs => [ "gp", "gp", "mem", "gp", "gp", "eflags" ],
out_reqs => [ "in_r4 in_r5", "none", "mem" ],
out_reqs => [ "in_r3 in_r4", "none", "mem" ],
ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
outs => [ "res", "unused", "M" ],
am => "source,binary",
......@@ -1139,7 +1139,7 @@ Call => {
ClimbFrame => {
irn_flags => [ "modify_flags" ],
in_reqs => [ "gp" ],
out_reqs => [ "in_r1", "!in_r1" ],
out_reqs => [ "in_r0", "!in_r0" ],
ins => [ "frame" ],
outs => [ "res", "cnt" ],
latency => 4, # random number
......@@ -1156,7 +1156,7 @@ Bswap => {
Bswap16 => {
irn_flags => [ "rematerializable" ],
in_reqs => [ "eax ebx ecx edx" ],
out_reqs => [ "in_r1" ],
out_reqs => [ "in_r0" ],
emit => "xchg %<D0, %>D0",
ins => [ "val" ],
outs => [ "res" ],
......@@ -1354,7 +1354,7 @@ xSub => {
irn_flags => [ "rematerializable" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "xmm", "xmm" ],
out_reqs => [ "in_r4", "flags", "mem" ],
out_reqs => [ "in_r3", "flags", "mem" ],
ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
outs => [ "res", "flags", "M" ],
am => "source,binary",
......@@ -1618,7 +1618,7 @@ fisttp => {
op_flags => [ "uses_memory", "fragile" ],
state => "exc_pinned",
in_reqs => [ "gp", "gp", "mem", "fp" ],
out_reqs => [ "mem", "exec", "exec", "in_r4" ],
out_reqs => [ "mem", "exec", "exec", "in_r3" ],
ins => [ "base", "index", "mem", "val" ],
outs => [ "M", "X_regular", "X_except", "res" ],
emit => "fisttp%FM %AM",
......
......@@ -95,7 +95,7 @@ sub get_requirement_mode
$req =~ s/[ :].*//;
if ($req =~ s/^!?in_r//) {
$req = $in_reqs->[$req - 1];
$req = $in_reqs->[$req];
$req =~ s/[ :].*//;
}
......@@ -740,7 +740,8 @@ sub build_subset_class_func
# set/unset registers
CHECK_REQS: foreach (split(/ /, $regs)) {
if (!$is_in && /(!)?in_r(\d+)/) {
my $bit_pos = 1 << ($2 - 1);
my $idx = $2;
my $bit_pos = 1 << $idx;
if ($different_pos & $bit_pos) {
if ($1) {
print STDERR "duplicate !in constraint\n";
......@@ -765,8 +766,7 @@ CHECK_REQS: foreach (split(/ /, $regs)) {
$same_pos |= $bit_pos;
}
my $idx = $2;
$class = get_in_req_class($node, $idx - 1);
$class = get_in_req_class($node, $idx);
if (!$class) {
die("Fatal error: Could not get in_reqs register class for '$op' index $idx ... exiting.\n");
}
......
......@@ -670,7 +670,7 @@ Cas => {
ins => [ "ptr", "old", "new", "mem" ],
outs => [ "res", "M" ],
in_reqs => [ "gp", "gp", "gp", "mem" ],
out_reqs => [ "in_r3", "mem" ],
out_reqs => [ "in_r2", "mem" ],
# TODO: we need a must-be-same constraint for the CAS
# for now we use a custom emitter which at least panics if constraints
# are not fulfilled
......
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