summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-01 10:01:13 -0700
committerGitHub <noreply@github.com>2022-09-01 10:01:13 -0700
commit4a94473eb34376dd8474f8ca3f2834b5c1daac14 (patch)
tree218714e897a2821c2b09727590f364519afe3915 /source/slang/slang-check-expr.cpp
parent3c0177134d126956336865623ea3d6861be59cfa (diff)
Deduplicate consts and IRSpecialize in IR, propagate type info for `IntVal`. (#2388)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index e33d26c0c..c7bfdd3a6 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -866,7 +866,7 @@ namespace Slang
IntVal* SemanticsVisitor::getIntVal(IntegerLiteralExpr* expr)
{
// TODO(tfoley): don't keep allocating here!
- return m_astBuilder->create<ConstantIntVal>(expr->value);
+ return m_astBuilder->create<ConstantIntVal>(expr->type.type, expr->value);
}
IntVal* SemanticsVisitor::tryConstantFoldExpr(
@@ -982,7 +982,7 @@ namespace Slang
|| opName == getName("|") || opName == getName("&") || opName == getName("^") || opName == getName("~") || opName == getName("%") ||
opName == getName("?:") || opName == getName("<<") || opName == getName(">>"))
{
- auto result = m_astBuilder->create<FuncCallIntVal>();
+ auto result = m_astBuilder->create<FuncCallIntVal>(invokeExpr.getExpr()->type.type);
result->args.addRange(argVals, argCount);
result->funcDeclRef = funcDeclRef;
result->funcType = as<Type>(funcDeclRefExpr.getExpr()->type->substitute(
@@ -1091,7 +1091,7 @@ namespace Slang
}
}
- IntVal* result = m_astBuilder->create<ConstantIntVal>(resultValue);
+ IntVal* result = m_astBuilder->create<ConstantIntVal>(invokeExpr.getExpr()->type.type, resultValue);
return result;
}
@@ -1176,7 +1176,7 @@ namespace Slang
{
// If it's a boolean, we allow promotion to int.
const IntegerLiteralValue value = IntegerLiteralValue(boolLitExpr.getExpr()->value);
- return m_astBuilder->create<ConstantIntVal>(value);
+ return m_astBuilder->create<ConstantIntVal>(m_astBuilder->getBoolType(), value);
}
// it is possible that we are referring to a generic value param
@@ -1186,8 +1186,9 @@ namespace Slang
if (auto genericValParamRef = declRef.as<GenericValueParamDecl>())
{
- // TODO(tfoley): handle the case of non-`int` value parameters...
- Val* valResult = m_astBuilder->create<GenericParamIntVal>(genericValParamRef);
+ Val* valResult = m_astBuilder->create<GenericParamIntVal>(
+ declRef.substitute(m_astBuilder, genericValParamRef.getDecl()->getType()),
+ genericValParamRef);
valResult = valResult->substitute(m_astBuilder, expr.getSubsts());
return as<IntVal>(valResult);
}
@@ -2145,7 +2146,7 @@ namespace Slang
// here if the input type had a sugared name...
swizExpr->type = QualType(createVectorType(
baseElementType,
- m_astBuilder->create<ConstantIntVal>(elementCount)));
+ m_astBuilder->create<ConstantIntVal>(m_astBuilder->getIntType(), elementCount)));
}
// A swizzle can be used as an l-value as long as there
@@ -2266,7 +2267,7 @@ namespace Slang
// here if the input type had a sugared name...
swizExpr->type = QualType(createVectorType(
baseElementType,
- m_astBuilder->create<ConstantIntVal>(elementCount)));
+ m_astBuilder->create<ConstantIntVal>(m_astBuilder->getIntType(), elementCount)));
}
// A swizzle can be used as an l-value as long as there