diff options
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index 6df9eea46..352d4ee27 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -3,7 +3,7 @@ #include "slang-compiler.h" #include "slang-ir.h" #include "slang-syntax.h" - +#include "slang-ir-util.h" #include "../core/slang-string-util.h" #define STRINGIZE(x) STRINGIZE2(x) @@ -193,6 +193,29 @@ namespace Slang } } + IROp getBaseTypeConversionOp( + BaseTypeConversionInfo const& toInfo, + BaseTypeConversionInfo const& fromInfo) + { + if (toInfo.tag == fromInfo.tag) + return (IROp)0; + + IROp intrinsicOpCode = (IROp)0; + auto toStyle = getTypeStyle(toInfo.tag); + auto fromStyle = getTypeStyle(fromInfo.tag); + if (toStyle == kIROp_BoolType) toStyle = kIROp_IntType; + if (fromStyle == kIROp_BoolType) fromStyle = kIROp_IntType; + if (toStyle == kIROp_IntType && fromStyle == kIROp_IntType) + intrinsicOpCode = kIROp_IntCast; + if (toStyle == kIROp_IntType && fromStyle == kIROp_FloatType) + intrinsicOpCode = kIROp_CastFloatToInt; + if (toStyle == kIROp_FloatType && fromStyle == kIROp_IntType) + intrinsicOpCode = kIROp_CastIntToFloat; + if (toStyle == kIROp_FloatType && fromStyle == kIROp_FloatType) + intrinsicOpCode = kIROp_FloatCast; + return intrinsicOpCode; + } + struct IntrinsicOpInfo { IROp opCode; char const* funcName; char const* opName; char const* interface; unsigned flags; }; static const IntrinsicOpInfo intrinsicUnaryOps[] = { |
