summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-09-07 10:31:37 -0700
committerGitHub <noreply@github.com>2017-09-07 10:31:37 -0700
commit0e566a63f0bafb7def65521315e9f19a2bc79e34 (patch)
tree470c20f7948693f39b7603645ad9d09fb693c459 /source/slang/ir.cpp
parentca16ede67d3fc34ec1cc81b8f835199c5ef1ab9a (diff)
parentced92a047e510480cff15be1a1cd102abffa3f82 (diff)
Merge pull request #177 from tfoleyNV/ir-work
Replace old notion of "intrinsic" operations
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);