summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 3f07a685f..eadcd34d0 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -13,15 +13,24 @@ namespace Slang
#include "ir-inst-defs.h"
};
+ //
- static const IROp kIRIntrinsicOps[] =
+ IROp findIROp(char const* name)
{
- (IROp) 0,
+ // TODO: need to make this faster by using a dictionary...
-#define INTRINSIC(NAME) kIROp_Intrinsic_##NAME,
-#include "intrinsic-defs.h"
+ if (0) {}
- };
+#define INST(ID, MNEMONIC, ARG_COUNT, FLAGS) \
+ else if(strcmp(name, #MNEMONIC) == 0) return kIROp_##ID;
+
+#define PSEUDO_INST(ID) \
+ else if(strcmp(name, #ID) == 0) return kIRPseudoOp_##ID;
+
+#include "ir-inst-defs.h"
+
+ return IROp(kIROp_Invalid);
+ }
//
@@ -560,6 +569,7 @@ namespace Slang
IRParentInst* parent = builder->shared->module;
IRConstant keyInst;
+ memset(&keyInst, 0, sizeof(keyInst));
keyInst.op = op;
keyInst.type.usedValue = type;
memcpy(&keyInst.u, value, valueSize);
@@ -767,13 +777,13 @@ namespace Slang
IRInst* IRBuilder::emitIntrinsicInst(
IRType* type,
- IntrinsicOp intrinsicOp,
+ IROp op,
UInt argCount,
IRValue* const* args)
{
auto inst = createInstWithTrailingArgs<IRInst>(
this,
- kIRIntrinsicOps[(int)intrinsicOp],
+ op,
type,
argCount,
args);