Skip to content

Commit

Permalink
Merge pull request TorqueGameEngines#1 from Ragora/tsneo
Browse files Browse the repository at this point in the history
BugFix: Linux compilation for TSNeo
  • Loading branch information
JeffProgrammer authored Aug 11, 2021
2 parents 464cb7a + 6ad2876 commit 60e05df
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 61 deletions.
120 changes: 60 additions & 60 deletions Engine/source/console/compiledEval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,39 @@ enum class FloatOperation
NE
};

template<FloatOperation Op>
TORQUE_NOINLINE void doSlowMathOp()
{
ConsoleValue& a = stack[_STK];
ConsoleValue& b = stack[_STK - 1];

// Arithmetic
if constexpr (Op == FloatOperation::Add)
stack[_STK - 1].setFloat(a.getFloat() + b.getFloat());
else if constexpr (Op == FloatOperation::Sub)
stack[_STK - 1].setFloat(a.getFloat() - b.getFloat());
else if constexpr (Op == FloatOperation::Mul)
stack[_STK - 1].setFloat(a.getFloat() * b.getFloat());
else if constexpr (Op == FloatOperation::Div)
stack[_STK - 1].setFloat(a.getFloat() / b.getFloat());

// Logical
if constexpr (Op == FloatOperation::LT)
stack[_STK - 1].setInt(a.getFloat() < b.getFloat());
if constexpr (Op == FloatOperation::LE)
stack[_STK - 1].setInt(a.getFloat() <= b.getFloat());
if constexpr (Op == FloatOperation::GR)
stack[_STK - 1].setInt(a.getFloat() > b.getFloat());
if constexpr (Op == FloatOperation::GE)
stack[_STK - 1].setInt(a.getFloat() >= b.getFloat());
if constexpr (Op == FloatOperation::EQ)
stack[_STK - 1].setInt(a.getFloat() == b.getFloat());
if constexpr (Op == FloatOperation::NE)
stack[_STK - 1].setInt(a.getFloat() != b.getFloat());

_STK--;
}

template<FloatOperation Op>
TORQUE_FORCEINLINE void doFloatMathOperation()
{
Expand Down Expand Up @@ -500,39 +533,6 @@ TORQUE_FORCEINLINE void doFloatMathOperation()
}
}

template<FloatOperation Op>
TORQUE_NOINLINE void doSlowMathOp()
{
ConsoleValue& a = stack[_STK];
ConsoleValue& b = stack[_STK - 1];

// Arithmetic
if constexpr (Op == FloatOperation::Add)
stack[_STK - 1].setFloat(a.getFloat() + b.getFloat());
else if constexpr (Op == FloatOperation::Sub)
stack[_STK - 1].setFloat(a.getFloat() - b.getFloat());
else if constexpr (Op == FloatOperation::Mul)
stack[_STK - 1].setFloat(a.getFloat() * b.getFloat());
else if constexpr (Op == FloatOperation::Div)
stack[_STK - 1].setFloat(a.getFloat() / b.getFloat());

// Logical
if constexpr (Op == FloatOperation::LT)
stack[_STK - 1].setInt(a.getFloat() < b.getFloat());
if constexpr (Op == FloatOperation::LE)
stack[_STK - 1].setInt(a.getFloat() <= b.getFloat());
if constexpr (Op == FloatOperation::GR)
stack[_STK - 1].setInt(a.getFloat() > b.getFloat());
if constexpr (Op == FloatOperation::GE)
stack[_STK - 1].setInt(a.getFloat() >= b.getFloat());
if constexpr (Op == FloatOperation::EQ)
stack[_STK - 1].setInt(a.getFloat() == b.getFloat());
if constexpr (Op == FloatOperation::NE)
stack[_STK - 1].setInt(a.getFloat() != b.getFloat());

_STK--;
}

//-----------------------------------------------------------------------------

enum class IntegerOperation
Expand All @@ -547,6 +547,33 @@ enum class IntegerOperation
LogicalOr
};

template<IntegerOperation Op>
TORQUE_NOINLINE void doSlowIntegerOp()
{
ConsoleValue& a = stack[_STK];
ConsoleValue& b = stack[_STK - 1];

// Bitwise Op
if constexpr (Op == IntegerOperation::BitAnd)
stack[_STK - 1].setInt(a.getInt() & b.getInt());
if constexpr (Op == IntegerOperation::BitOr)
stack[_STK - 1].setInt(a.getInt() | b.getInt());
if constexpr (Op == IntegerOperation::Xor)
stack[_STK - 1].setInt(a.getInt() ^ b.getInt());
if constexpr (Op == IntegerOperation::LShift)
stack[_STK - 1].setInt(a.getInt() << b.getInt());
if constexpr (Op == IntegerOperation::RShift)
stack[_STK - 1].setInt(a.getInt() >> b.getInt());

// Logical Op
if constexpr (Op == IntegerOperation::LogicalAnd)
stack[_STK - 1].setInt(a.getInt() && b.getInt());
if constexpr (Op == IntegerOperation::LogicalOr)
stack[_STK - 1].setInt(a.getInt() || b.getInt());

_STK--;
}

template<IntegerOperation Op>
TORQUE_FORCEINLINE void doIntOperation()
{
Expand Down Expand Up @@ -581,33 +608,6 @@ TORQUE_FORCEINLINE void doIntOperation()
}
}

template<IntegerOperation Op>
TORQUE_NOINLINE void doSlowIntegerOp()
{
ConsoleValue& a = stack[_STK];
ConsoleValue& b = stack[_STK - 1];

// Bitwise Op
if constexpr (Op == IntegerOperation::BitAnd)
stack[_STK - 1].setInt(a.getInt() & b.getInt());
if constexpr (Op == IntegerOperation::BitOr)
stack[_STK - 1].setInt(a.getInt() | b.getInt());
if constexpr (Op == IntegerOperation::Xor)
stack[_STK - 1].setInt(a.getInt() ^ b.getInt());
if constexpr (Op == IntegerOperation::LShift)
stack[_STK - 1].setInt(a.getInt() << b.getInt());
if constexpr (Op == IntegerOperation::RShift)
stack[_STK - 1].setInt(a.getInt() >> b.getInt());

// Logical Op
if constexpr (Op == IntegerOperation::LogicalAnd)
stack[_STK - 1].setInt(a.getInt() && b.getInt());
if constexpr (Op == IntegerOperation::LogicalOr)
stack[_STK - 1].setInt(a.getInt() || b.getInt());

_STK--;
}

//-----------------------------------------------------------------------------

U32 gExecCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/console/engineAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ struct EngineUnmarshallData< void >
template<>
struct EngineUnmarshallData< ConsoleValue >
{
ConsoleValue operator()( ConsoleValue &ref ) const
ConsoleValue operator()( ConsoleValue ref ) const
{
return std::move(ref);
}
Expand Down
3 changes: 3 additions & 0 deletions Engine/source/platform/types.gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ typedef unsigned long U64;
// Compiler Version
#define TORQUE_COMPILER_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)

#define TORQUE_FORCEINLINE __attribute__((always_inline))
#define TORQUE_CASE_FALLTHROUGH __attribute__((fallthrough))
#define TORQUE_NOINLINE __attribute__ ((noinline))

//--------------------------------------
// Identify the compiler string
Expand Down

0 comments on commit 60e05df

Please sign in to comment.