- fixed: RegAvailability never set the number of allocated registers to more than 32.

- fixed register allocation in ?: operator which was quite broken.
This commit is contained in:
Christoph Oelckers 2016-11-07 01:10:56 +01:00
parent 7da4e0d03d
commit b206d19df4
3 changed files with 9 additions and 10 deletions

View file

@ -850,7 +850,6 @@ set( NOT_COMPILED_SOURCE_FILES
sc_man_scanner.re
g_doom/a_bossbrain.cpp
g_doom/a_doomweaps.cpp
g_doom/a_lostsoul.cpp
g_doom/a_painelemental.cpp
g_doom/a_revenant.cpp
g_doom/a_scriptedmarine.cpp

View file

@ -4061,6 +4061,7 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
// Test condition.
build->Emit(OP_EQ_K, 1, cond.RegNum, build->GetConstantInt(0));
falsejump = build->Emit(OP_JMP, 0);
cond.Free(build);
// Evaluate true expression.
if (truex->isConstant() && truex->ValueType->GetRegType() == REGT_INT)
@ -4073,6 +4074,7 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
ExpEmit trueop = truex->Emit(build);
if (trueop.Konst)
{
trueop.Free(build);
if (trueop.RegType == REGT_FLOAT)
{
out = ExpEmit(build, REGT_FLOAT);
@ -4113,20 +4115,18 @@ ExpEmit FxConditional::Emit(VMFunctionBuilder *build)
{
if (falseop.RegType == REGT_FLOAT)
{
out = ExpEmit(build, REGT_FLOAT);
build->Emit(OP_LKF, out.RegNum, falseop.RegNum);
}
else if (falseop.RegType == REGT_POINTER)
{
out = ExpEmit(build, REGT_POINTER);
build->Emit(OP_LKP, out.RegNum, falseop.RegNum);
}
else
{
assert(falseop.RegType == REGT_STRING);
out = ExpEmit(build, REGT_STRING);
build->Emit(OP_LKS, out.RegNum, falseop.RegNum);
}
falseop.Free(build);
}
else
{

View file

@ -336,10 +336,10 @@ int VMFunctionBuilder::RegAvailability::Get(int count)
{
return -1;
}
mask = count == 32 ? ~0u : (1 << count) - 1;
for (i = 0; i < 256/32; ++i)
for (i = 0; i < 256 / 32; ++i)
{
// Find the first word with free registers
VM_UWORD bits = Used[i];
@ -362,9 +362,9 @@ int VMFunctionBuilder::RegAvailability::Get(int count)
{
if (firstbit + count <= 32)
{ // Needed bits all fit in one word, so we got it.
if (firstbit + count > MostUsed)
if (i * 32 + firstbit + count > MostUsed)
{
MostUsed = firstbit + count;
MostUsed = i * 32 + firstbit + count;
}
Used[i] |= mask << firstbit;
return i * 32 + firstbit;
@ -374,9 +374,9 @@ int VMFunctionBuilder::RegAvailability::Get(int count)
{ // There is a next word.
if (((Used[i + 1]) & (mask >> (32 - firstbit))) == 0)
{ // The next word has the needed open space, too.
if (firstbit + count > MostUsed)
if (i * 32 + firstbit + count > MostUsed)
{
MostUsed = firstbit + count;
MostUsed = i * 32 + firstbit + count;
}
Used[i] |= mask << firstbit;
Used[i + 1] |= mask >> (32 - firstbit);