[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 6 20:04:14 PDT 2025
================
@@ -6361,6 +6362,143 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
findHandleTypeOnResource(const Type *RT);
};
+/// Instances of this class represent operands to a SPIR-V type instruction.
+class SpirvOperand {
+public:
+ enum SpirvOperandKind : unsigned char {
+ Invalid, ///< Uninitialized.
+ ConstantId, ///< Integral value to represent as a SPIR-V OpConstant
+ ///< instruction ID.
+ Literal, ///< Integral value to represent as an immediate literal.
+ TypeId, ///< Type to represent as a SPIR-V type ID.
+
+ Max,
+ };
+
+private:
+ SpirvOperandKind Kind = Invalid;
+
+ QualType ResultType;
+ llvm::APInt Value; // Signedness of constants is represented by ResultType.
+
+public:
+ SpirvOperand() : Kind(Invalid), ResultType(), Value() {}
+
+ SpirvOperand(SpirvOperandKind Kind, QualType ResultType, llvm::APInt Value)
+ : Kind(Kind), ResultType(ResultType), Value(Value) {}
+
+ SpirvOperand(const SpirvOperand &Other) { *this = Other; }
+ ~SpirvOperand() {}
----------------
shafik wrote:
It would have been better to just default this.
https://github.com/llvm/llvm-project/pull/134034
More information about the cfe-commits
mailing list