summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-hlsl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-15 14:22:59 -0700
committerGitHub <noreply@github.com>2022-09-15 14:22:59 -0700
commita6032446c6bf7f64d1e201bf438a4c7605a3dbb4 (patch)
treea95267c52155e13699ff9aab38ab68353d76939e /source/slang/slang-emit-hlsl.cpp
parent05f9aaf6a4ef246dcf89b00000a8e59e90c47662 (diff)
Language feature: pointer sized int types. (#2401)
* Language feature: pointer sized int types. * Fix. * small change to test. * Fix stdlib. * Fix. * Fix. * Add typedef for `size_t` in stdlib. * Fix test. * Add `intptr_t::size` constant. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
-rw-r--r--source/slang/slang-emit-hlsl.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 48fe86fff..20fcc5bed 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -467,10 +467,12 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
case BaseType::Int16:
case BaseType::Int:
case BaseType::Int64:
+ case BaseType::IntPtr:
case BaseType::UInt8:
case BaseType::UInt16:
case BaseType::UInt:
case BaseType::UInt64:
+ case BaseType::UIntPtr:
case BaseType::Bool:
// Because the intermediate type will always
// be an integer type, we can convert to
@@ -809,11 +811,26 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
case kIROp_DoubleType:
case kIROp_Int16Type:
case kIROp_UInt16Type:
- {
case kIROp_HalfType:
+ {
m_writer->emit(getDefaultBuiltinTypeName(type->getOp()));
return;
}
+#if SLANG_PTR_IS_64
+ case kIROp_IntPtrType:
+ m_writer->emit("int64_t");
+ return;
+ case kIROp_UIntPtrType:
+ m_writer->emit("uint64_t");
+ return;
+#else
+ case kIROp_IntPtrType:
+ m_writer->emit("int");
+ return;
+ case kIROp_UIntPtrType:
+ m_writer->emit("uint");
+ return;
+#endif
case kIROp_StructType:
m_writer->emit(getName(type));
return;
@@ -856,7 +873,7 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
case kIROp_NativeStringType:
case kIROp_StringType:
{
- m_writer->emit("int");
+ m_writer->emit("string");
return;
}
default: break;