summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-extract-value-from-type.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-03-19 11:44:04 -0700
committerGitHub <noreply@github.com>2025-03-19 11:44:04 -0700
commit4eb7a27ac4532a49b9d383d2b0d80bc0ec317b4c (patch)
tree3219e185674c04423e3306437e2a31223fadeb49 /source/slang/slang-ir-extract-value-from-type.cpp
parenteee974d74617944ca2b6f6ac424e98a12a51b82c (diff)
Fix reinterpret and bitcast and generic arg parsing. (#6627)
* Fix reinterpret and bitcast. * Fix warning. * Fix. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-extract-value-from-type.cpp')
-rw-r--r--source/slang/slang-ir-extract-value-from-type.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/slang/slang-ir-extract-value-from-type.cpp b/source/slang/slang-ir-extract-value-from-type.cpp
index 919274863..acb17068f 100644
--- a/source/slang/slang-ir-extract-value-from-type.cpp
+++ b/source/slang/slang-ir-extract-value-from-type.cpp
@@ -231,6 +231,7 @@ IRInst* extractMultiByteValueAtOffset(
{
// The request value is fully contained in the found leaf element.
// We can proceed to extract the requested bits from the element.
+ resultValue = builder.emitBitCast(uintType, leaf.leafValue);
uint32_t shift = leaf.offsetInValue * 8;
if (shift > 0)
resultValue =
@@ -242,7 +243,7 @@ IRInst* extractMultiByteValueAtOffset(
bitMask = 0xFF;
break;
case 2:
- bitMask = 0xFFFFF;
+ bitMask = 0xFFFF;
break;
case 3:
bitMask = 0xFFFFFF;
@@ -264,23 +265,25 @@ IRInst* extractMultiByteValueAtOffset(
{
// The requested value crosses the boundaries of different fields.
// We need to extract first and second half separately, and combine them together.
+ auto firstHalfSize = leaf.valueSize - leaf.offsetInValue;
auto firstHalf = extractMultiByteValueAtOffset(
builder,
targetProgram,
dataType,
layout,
src,
- size / 2,
+ firstHalfSize,
offset);
+ auto restSize = size - firstHalfSize;
auto secondHalf = extractMultiByteValueAtOffset(
builder,
targetProgram,
dataType,
layout,
src,
- size / 2,
- offset + size / 2);
- uint32_t shift = (size / 2) * 8;
+ restSize,
+ offset + firstHalfSize);
+ uint32_t shift = firstHalfSize * 8;
resultValue = builder.emitAdd(
builder.getUIntType(),
firstHalf,