From fc083a75b94ac4b4e735b4a7ff566191b9123f74 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 6 Jun 2019 17:48:39 -0400 Subject: Split out target code generation from CLikeSourceEmitter (#976) * * Added SourceStyle to CLikeSourceEmitter, to limit cases to actual target types. * Made Impl methods _ prefixed * Small tidyup * * SourceStream -> SourceWriter * use slang-emit- prefix on SourceWriter file * * Remove EmitContext -> merge into CLikeSourceEmitter * slang-c-like-source-emitter -> slang-emit-source.cpp * ExtensionUsageTracker -> GLSLExtensionTracker slang-extension-usage-tracker.cpp/.h -> slang-emit-glsl-extension-tracker.cpp/.h * emit-source.cpp.h -> emit-c-like.cpp/.h * Small fix to move where some _ prefixed functions are declared in CLikeSourceEmitter. * * CLikeSourceEmitter::CInfo -> Desc * Functions to get and find CodeGenTarget by name * Split out empty language impls * Create an impl based on SourceStyle * * CodeGenTarget conversion to and from string * Move HLSL specific functions to HLSLEmitSource. * Emitting texture and image types. * Move move GLSL specific functionality to GLSLSourceEmitter * Split more out of slang-emit-c-like * Refactor more out of slang-emit-c-like * * tryEmitIRInstExprImpl(IRInst* inst, IREmitMode mode, const EmitOpInfo& inOuterPrec) * Fix bug around output of uintBitsToFloat * More work refactoring out target specifics from slang-emit-c-like * Move functions that are only implemented once in GLSL impl into their Impl method. * Move rate qualification out of slang-emit-c-like * * Added getEmitOpForOp - allows for table usage so different ops can be dealt with the same way * Moved vector comparison to slang-emit-glsl * * * Use EmitOpInfo to control output in slang-emit-c-like.cpp for unary ops * Move more functionality from CLikeSourceEmitter to HLSLSourceEmitter * Make output of parameters implementaion specific. * Extracted interpolation modifiers. * Remove IR from methods that don't need them. * Remove IR from method names. * Refactor handling of output of types - to make the impls implement the full path without lots of cases for specific impls * Add variable declaration modifiers and matrix layout to larget specific in slang-emit. * Make target specific internal functions _ prefixed. --- source/slang/slang-emit-precedence.cpp | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'source/slang/slang-emit-precedence.cpp') diff --git a/source/slang/slang-emit-precedence.cpp b/source/slang/slang-emit-precedence.cpp index 43a573f20..8237b31df 100644 --- a/source/slang/slang-emit-precedence.cpp +++ b/source/slang/slang-emit-precedence.cpp @@ -10,4 +10,40 @@ namespace Slang { SLANG_OP_INFO(SLANG_OP_INFO_EXPAND) }; + +EmitOp getEmitOpForOp(IROp op) +{ + switch (op) + { + case kIROp_Add: return EmitOp::Add; + case kIROp_Sub: return EmitOp::Sub; + case kIROp_Mul: return EmitOp::Mul; + case kIROp_Div: return EmitOp::Div; + case kIROp_Mod: return EmitOp::Mod; + + case kIROp_Lsh: return EmitOp::Lsh; + case kIROp_Rsh: return EmitOp::Rsh; + + case kIROp_Eql: return EmitOp::Eql; + case kIROp_Neq: return EmitOp::Neq; + case kIROp_Greater: return EmitOp::Greater; + case kIROp_Less: return EmitOp::Less; + case kIROp_Geq: return EmitOp::Geq; + case kIROp_Leq: return EmitOp::Leq; + + case kIROp_BitXor: return EmitOp::BitXor; + case kIROp_BitOr: return EmitOp::BitOr; + case kIROp_BitAnd: return EmitOp::BitAnd; + + case kIROp_And: return EmitOp::And; + case kIROp_Or: return EmitOp::Or; + + case kIROp_Not: return EmitOp::Not; + case kIROp_Neg: return EmitOp::Neg; + case kIROp_BitNot: return EmitOp::BitNot; + } + + return EmitOp::None; +} + } // namespace Slang -- cgit v1.2.3