Skip to content

Commit 003bfd7

Browse files
AnastaZIukPrzemog1
andauthored
Add support for ulonglong and longlong types in const values handle (#7957)
referencing #7952 for details --------- Co-authored-by: Przemog1 <[email protected]>
1 parent c5c9921 commit 003bfd7

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The included licenses apply to the following files:
2323
- Fixed regression: [#7508](https://github.com/microsoft/DirectXShaderCompiler/issues/7508) crash when calling `Load` with `status`.
2424
- Header file `dxcpix.h` was added to the release package.
2525
- Moved Linear Algebra (Cooperative Vector) DXIL Opcodes to experimental Shader Model 6.10
26+
- Added support for `long long` and `unsigned long long` compile-time constant evaluation, fixes [#7952](https://github.com/microsoft/DirectXShaderCompiler/issues/7952).
2627

2728
### Version 1.8.2505
2829

tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,12 +4920,19 @@ bool DeclResultIdMapper::tryToCreateConstantVar(const ValueDecl *decl) {
49204920
constVal =
49214921
spvBuilder.getConstantInt(astContext.UnsignedIntTy, val->getInt());
49224922
break;
4923+
case BuiltinType::ULongLong: // uint64_t
4924+
constVal =
4925+
spvBuilder.getConstantInt(astContext.UnsignedLongLongTy, val->getInt());
4926+
break;
49234927
case BuiltinType::Short: // int16_t
49244928
constVal = spvBuilder.getConstantInt(astContext.ShortTy, val->getInt());
49254929
break;
49264930
case BuiltinType::Int: // int32_t
49274931
constVal = spvBuilder.getConstantInt(astContext.IntTy, val->getInt());
49284932
break;
4933+
case BuiltinType::LongLong: // int64_t
4934+
constVal = spvBuilder.getConstantInt(astContext.LongLongTy, val->getInt());
4935+
break;
49294936
case BuiltinType::Half: // float16_t
49304937
constVal = spvBuilder.getConstantFloat(astContext.HalfTy, val->getFloat());
49314938
break;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %dxc %s -T lib_6_8 -E main -spirv -enable-16bit-types
2+
3+
// CHECK-DAG: %ulong = OpTypeInt 64 0
4+
// CHECK-DAG: %long = OpTypeInt 64 1
5+
6+
template <typename T> struct S {
7+
static const T value = 0;
8+
};
9+
10+
// CHECK: %u = OpFunction %void None
11+
[shader("vertex")]
12+
uint64_t u() : A
13+
{
14+
// CHECK: OpStore %out_var_A %ulong_0
15+
return S<uint64_t>::value;
16+
}
17+
18+
// CHECK: %s = OpFunction %void None
19+
[shader("vertex")]
20+
int64_t s() : B
21+
{
22+
// CHECK: OpStore %out_var_A %long_0
23+
return S<int64_t>::value;
24+
}

0 commit comments

Comments
 (0)