diff options
| author | Yong He <yonghe@outlook.com> | 2022-12-07 12:02:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-07 12:02:30 -0800 |
| commit | 3a3a8b5f7701109fc413f42692c4de5769870489 (patch) | |
| tree | 909df4a30e69f33a76e0158d92b1823629dc2184 /source/slang/slang-stdlib.cpp | |
| parent | f116f43bd12358e87f351f0d3615628ac4e00921 (diff) | |
Lower-to-ir no longer produce `Construct` inst. (#2553)
Co-authored-by: Yong He <yhe@nvidia.com>
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[] = { |
