diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-08 18:29:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-08 18:29:32 -0800 |
| commit | f44da6cc5c0f211c13bd1eb0743d79c7861ea64e (patch) | |
| tree | 3ad4edb5e7806c41003280ebf60fd6419a742105 /source/slang/slang-emit-c-like.cpp | |
| parent | a16f712bb99e426519c9a556b17b54bcc4d1d22d (diff) | |
Support pointers in SPIRV. (#3561)
* Support pointers in SPIRV.
* Fix test.
* Enhance test.
* Fix test.
* Cleanup.
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 05c525965..1c01478ed 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -2055,6 +2055,7 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO case kIROp_MatrixReshape: case kIROp_CastPtrToInt: case kIROp_CastIntToPtr: + case kIROp_PtrCast: { // Simple constructor call auto prec = getInfo(EmitOp::Prefix); @@ -2345,6 +2346,15 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO m_writer->emit(".detach()"); break; } + case kIROp_GetOffsetPtr: + { + auto prec = getInfo(EmitOp::Add); + needClose = maybeEmitParens(outerPrec, prec); + emitOperand(inst->getOperand(0), leftSide(outerPrec, prec)); + m_writer->emit(" + "); + emitOperand(inst->getOperand(1), rightSide(prec, outerPrec)); + break; + } case kIROp_GetElement: case kIROp_GetElementPtr: case kIROp_ImageSubscript: @@ -4097,7 +4107,8 @@ void CLikeSourceEmitter::ensureGlobalInst(ComputeEmitActionsContext* ctx, IRInst } if (as<IRBasicType>(inst)) return; - + if (as<IRPtrLit>(inst)) + return; // Certain inst ops will always emit as definition. switch (inst->getOp()) { |
