https://github.com/shader-slang/slang
Tip revision: e59516fa8c3a16eb7b99a928c5b85b97bf44fd72 authored by Yong He on 01 February 2022, 00:26:03 UTC
Revise entrypoint renaming interface. (#2113)
Revise entrypoint renaming interface. (#2113)
Tip revision: e59516f
slang-intrinsic-expand.h
// slang-intrinsic-expand.h
#ifndef SLANG_INTRINSIC_EXPAND_H
#define SLANG_INTRINSIC_EXPAND_H
#include "slang-emit-c-like.h"
namespace Slang
{
/* Handles all the special case handling of expansions of intrinsics. In particular handles the expansion
of the 'special cases' prefixed with '$' */
struct IntrinsicExpandContext
{
IntrinsicExpandContext(CLikeSourceEmitter* emitter) :
m_emitter(emitter),
m_writer(emitter->getSourceWriter())
{
}
void emit(IRCall* inst, IRUse* args, Int argCount, const UnownedStringSlice& intrinsicText);
protected:
const char* _emitSpecial(const char* cursor);
SourceWriter* m_writer;
UnownedStringSlice m_text;
IRCall* m_callInst;
IRUse* m_args = nullptr;
Int m_argCount = 0;
Index m_openParenCount = 0;
CLikeSourceEmitter* m_emitter;
// An arbitrary offset to apply to argument indices.
//
// Note: This is a bit of a gross hack to allow the definitions
// of the texture-sampling operations to be easier to share
// between combined and non-combined cases.
//
// TODO: It would be great to slowly migrate away from needing
// so much complicated logic here, but if we decide to keep this
// general approach it would be great to move some of the processing
// to the front-end and allow things like:
//
// __target_intrinsic(hlsl, "specialOp($a - $b)")
// int SomeCoolFunction(int a, int b);
//
// That is, we could try to allow direct by-name references to parameters
// in the intrinsic strings as they appear in the front-end, and then remap
// those to be index-based as part of translation to the IR.
//
Index m_argIndexOffset = 0;
};
}
#endif