summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-09-11 15:25:31 -0700
committerTim Foley <tfoley@nvidia.com>2017-09-11 15:27:08 -0700
commit4644b64d648893718336d83fae0139ee19405e61 (patch)
treef7c623dc814b823a535d38b68029f529af36780f /source/slang/emit.cpp
parente2de1eaec725e979f98ad6f518b93b4d9ce55a36 (diff)
Get another test working with IR codedgen
- Add support for matrix types in IR/codegen - Add support for basic indexing operations in IR/codegen
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp43
1 files changed, 38 insertions, 5 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index f6c63dff6..40366c43c 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -4036,6 +4036,10 @@ emitDeclImpl(decl, nullptr);
emitIRVectorType(context, (IRVectorType*) type);
break;
+ case kIROp_MatrixType:
+ emitIRMatrixType(context, (IRMatrixType*) type);
+ break;
+
case kIROp_StructType:
emit(getName(type));
break;
@@ -4106,6 +4110,18 @@ emitDeclImpl(decl, nullptr);
emitIRSimpleValue(context, type->getElementCount());
}
+ void emitIRMatrixType(
+ EmitContext* context,
+ IRMatrixType* type)
+ {
+ // TODO: this is a GLSL-vs-HLSL decision point
+
+ emitIRSimpleType(context, type->getElementType());
+ emitIRSimpleValue(context, type->getRowCount());
+ emit("x");
+ emitIRSimpleValue(context, type->getColumnCount());
+ }
+
void emitIRType(
EmitContext* context,
IRType* type,
@@ -4163,6 +4179,7 @@ emitDeclImpl(decl, nullptr);
case kIROp_IntLit:
case kIROp_FloatLit:
case kIROp_FieldAddress:
+ case kIROp_getElementPtr:
return true;
}
@@ -4321,12 +4338,20 @@ emitDeclImpl(decl, nullptr);
}
break;
- case kIROp_Add:
- emitIROperand(context, inst->getArg(1));
- emit(" + ");
- emitIROperand(context, inst->getArg(2));
- break;
+#define CASE(OPCODE, OP) \
+ case OPCODE: \
+ emitIROperand(context, inst->getArg(1)); \
+ emit("" #OP " "); \
+ emitIROperand(context, inst->getArg(2)); \
+ break
+ CASE(kIROp_Add, +);
+ CASE(kIROp_Sub, -);
+ CASE(kIROp_Mul, *);
+ CASE(kIROp_Div, /);
+ CASE(kIROp_Mod, %);
+
+#undef CASE
case kIROp_Sample:
emitIROperand(context, inst->getArg(1));
@@ -4383,6 +4408,14 @@ emitDeclImpl(decl, nullptr);
emit("]");
break;
+ case kIROp_getElement:
+ case kIROp_getElementPtr:
+ emitIROperand(context, inst->getArg(1));
+ emit("[");
+ emitIROperand(context, inst->getArg(2));
+ emit("]");
+ break;
+
default:
emit("/* uhandled */");
break;