[clang] [HLSL] Implement `SpirvType` and `SpirvOpaqueType` (PR #134034)
Cassandra Beckley via cfe-commits
cfe-commits at lists.llvm.org
Tue May 6 16:38:11 PDT 2025
================
@@ -1832,6 +1832,48 @@ ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
ToWrappedType, ToContainedType, ToAttrs);
}
+ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
+ const clang::HLSLInlineSpirvType *T) {
+ Error Err = Error::success();
+
+ uint32_t ToOpcode = T->getOpcode();
+ uint32_t ToSize = T->getSize();
+ uint32_t ToAlignment = T->getAlignment();
+
+ size_t NumOperands = T->getOperands().size();
+
+ llvm::SmallVector<SpirvOperand> ToOperands;
+
+ size_t I = 0;
+ for (auto &Operand : T->getOperands()) {
+ using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
+
+ switch (Operand.getKind()) {
+ case SpirvOperandKind::kConstantId:
+ ToOperands.push_back(SpirvOperand::createConstant(
+ importChecked(Err, Operand.getResultType()), Operand.getValue()));
+ break;
+ case SpirvOperandKind::kLiteral:
+ ToOperands.push_back(SpirvOperand::createLiteral(Operand.getValue()));
+ break;
+ case SpirvOperandKind::kTypeId:
+ ToOperands.push_back(SpirvOperand::createType(
+ importChecked(Err, Operand.getResultType())));
+ break;
+ default:
+ llvm_unreachable("Invalid SpirvOperand kind");
+ }
+
+ if (Err)
+ return std::move(Err);
+ }
+
+ assert(I == NumOperands);
----------------
cassiebeckley wrote:
No, it is not. This is a remnant of an older approach that I was using, which was replaced. I'll remove the assert; I'm not sure why it wasn't already failing.
https://github.com/llvm/llvm-project/pull/134034
More information about the cfe-commits
mailing list