diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-emit-cpp.h | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-emit-cpp.h')
| -rw-r--r-- | source/slang/slang-emit-cpp.h | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/source/slang/slang-emit-cpp.h b/source/slang/slang-emit-cpp.h index 90db780bd..2a1114afc 100644 --- a/source/slang/slang-emit-cpp.h +++ b/source/slang/slang-emit-cpp.h @@ -2,15 +2,14 @@ #ifndef SLANG_EMIT_CPP_H #define SLANG_EMIT_CPP_H +#include "../core/slang-string-slice-pool.h" #include "slang-emit-c-like.h" #include "slang-ir-clone.h" -#include "../core/slang-string-slice-pool.h" - namespace Slang { -class CPPSourceEmitter: public CLikeSourceEmitter +class CPPSourceEmitter : public CLikeSourceEmitter { public: typedef CLikeSourceEmitter Super; @@ -20,9 +19,9 @@ public: { enum Enum : SemanticUsedFlags { - DispatchThreadID = 0x01, - GroupThreadID = 0x02, - GroupID = 0x04, + DispatchThreadID = 0x01, + GroupThreadID = 0x02, + GroupID = 0x04, }; }; @@ -36,22 +35,25 @@ public: }; virtual void useType(IRType* type); - + static UnownedStringSlice getBuiltinTypeName(IROp op); - + SourceWriter* getSourceWriter() const { return m_writer; } CPPSourceEmitter(const Desc& desc); protected: - // Implement CLikeSourceEmitter interface virtual bool doesTargetSupportPtrTypes() SLANG_OVERRIDE { return true; } - virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) SLANG_OVERRIDE; - virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) SLANG_OVERRIDE; + virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) + SLANG_OVERRIDE; + virtual void emitEntryPointAttributesImpl( + IRFunc* irFunc, + IREntryPointDecoration* entryPointDecor) SLANG_OVERRIDE; virtual void emitSimpleTypeImpl(IRType* type) SLANG_OVERRIDE; virtual void _emitType(IRType* type, DeclaratorInfo* declarator) SLANG_OVERRIDE; - virtual void emitVectorTypeNameImpl(IRType* elementType, IRIntegerValue elementCount) SLANG_OVERRIDE; + virtual void emitVectorTypeNameImpl(IRType* elementType, IRIntegerValue elementCount) + SLANG_OVERRIDE; virtual bool tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOuterPrec) SLANG_OVERRIDE; virtual bool tryEmitInstStmtImpl(IRInst* inst) SLANG_OVERRIDE; @@ -60,7 +62,7 @@ protected: virtual void emitSimpleFuncParamImpl(IRParam* param) SLANG_OVERRIDE; virtual void emitModuleImpl(IRModule* module, DiagnosticSink* sink) SLANG_OVERRIDE; virtual void emitSimpleFuncImpl(IRFunc* func) SLANG_OVERRIDE; - virtual void emitOperandImpl(IRInst* inst, EmitOpInfo const& outerPrec) SLANG_OVERRIDE; + virtual void emitOperandImpl(IRInst* inst, EmitOpInfo const& outerPrec) SLANG_OVERRIDE; virtual void emitParamTypeImpl(IRType* type, String const& name) SLANG_OVERRIDE; virtual void emitGlobalRTTISymbolPrefix(); virtual void emitWitnessTable(IRWitnessTable* witnessTable) SLANG_OVERRIDE; @@ -68,7 +70,11 @@ protected: void emitComInterface(IRInterfaceType* interfaceType); virtual void emitRTTIObject(IRRTTIObject* rttiObject) SLANG_OVERRIDE; virtual bool tryEmitGlobalParamImpl(IRGlobalParam* varDecl, IRType* varType) SLANG_OVERRIDE; - virtual void emitIntrinsicCallExprImpl(IRCall* inst, UnownedStringSlice intrinsicDefinition, IRInst* intrinsicInst, EmitOpInfo const& inOuterPrec) SLANG_OVERRIDE; + virtual void emitIntrinsicCallExprImpl( + IRCall* inst, + UnownedStringSlice intrinsicDefinition, + IRInst* intrinsicInst, + EmitOpInfo const& inOuterPrec) SLANG_OVERRIDE; virtual void emitLoopControlDecorationImpl(IRLoopControlDecoration* decl) SLANG_OVERRIDE; virtual void emitFuncDecorationsImpl(IRFunc* func) SLANG_OVERRIDE; virtual void emitVarDecorationsImpl(IRInst* var) SLANG_OVERRIDE; @@ -76,7 +82,7 @@ protected: virtual bool shouldFoldInstIntoUseSites(IRInst* inst) SLANG_OVERRIDE; const UnownedStringSlice* getVectorElementNames(BaseType elemType, Index elemCount); - + // Replaceable for classes derived from CPPSourceEmitter virtual SlangResult calcTypeName(IRType* type, CodeGenTarget target, StringBuilder& out); @@ -88,24 +94,39 @@ protected: static TypeDimension _getTypeDimension(IRType* type, bool vecSwap); - void _emitAccess(const UnownedStringSlice& name, const TypeDimension& dimension, int row, int col, SourceWriter* writer); + void _emitAccess( + const UnownedStringSlice& name, + const TypeDimension& dimension, + int row, + int col, + SourceWriter* writer); UnownedStringSlice _getTypeName(IRType* type); - + SlangResult _calcCPPTextureTypeName(IRTextureTypeBase* texType, StringBuilder& outName); - void _emitEntryPointDefinitionStart(IRFunc* func, const String& funcName, const UnownedStringSlice& varyingTypeName); + void _emitEntryPointDefinitionStart( + IRFunc* func, + const String& funcName, + const UnownedStringSlice& varyingTypeName); void _emitEntryPointDefinitionEnd(IRFunc* func); - void _emitEntryPointGroup(const Int sizeAlongAxis[kThreadGroupAxisCount], const String& funcName); - void _emitEntryPointGroupRange(const Int sizeAlongAxis[kThreadGroupAxisCount], const String& funcName); - - void _emitInitAxisValues(const Int sizeAlongAxis[kThreadGroupAxisCount], const UnownedStringSlice& mulName, const UnownedStringSlice& addName); - - // Emit the actual definition (including intializer list) - // of all the witness table objects in `pendingWitnessTableDefinitions`. + void _emitEntryPointGroup( + const Int sizeAlongAxis[kThreadGroupAxisCount], + const String& funcName); + void _emitEntryPointGroupRange( + const Int sizeAlongAxis[kThreadGroupAxisCount], + const String& funcName); + + void _emitInitAxisValues( + const Int sizeAlongAxis[kThreadGroupAxisCount], + const UnownedStringSlice& mulName, + const UnownedStringSlice& addName); + + // Emit the actual definition (including intializer list) + // of all the witness table objects in `pendingWitnessTableDefinitions`. void _emitWitnessTableDefinitions(); - /// Maybe emits 'export' (such that visible outside binary/dll) and `extern "C"` naming + /// Maybe emits 'export' (such that visible outside binary/dll) and `extern "C"` naming void _getExportStyle(IRInst* inst, bool& outIsExport, bool& outIsExternC); virtual void _maybeEmitExportLike(IRInst* inst); @@ -127,5 +148,5 @@ protected: bool m_hasString = false; }; -} +} // namespace Slang #endif |
