summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-08-17 12:18:37 -0700
committerGitHub <noreply@github.com>2017-08-17 12:18:37 -0700
commit1965c3f3f265c43c8d1d96bb49d0850ce5d53cc3 (patch)
treeceb6f8b5f4d3c7e941f4edd47984b426d03fb980 /source/slang/lower-to-ir.cpp
parent5230ad2edb28e176d0d7d2a9873ffb8f65285269 (diff)
parent5de3003af561bad33680940ab1809622c428e94b (diff)
Merge pull request #169 from tfoleyNV/ir
IR generation cleanup work
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
-rw-r--r--source/slang/lower-to-ir.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index e00dffa1d..a01279f2e 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -402,7 +402,7 @@ struct ExprLoweringVisitor : ExprVisitor<ExprLoweringVisitor, LoweredValInfo>
{
IRValue* irBase = base.val;
return LoweredValInfo::simple(
- getBuilder()->createFieldExtract(
+ getBuilder()->emitFieldExtract(
getSimpleType(fieldType),
irBase,
fieldIndex));
@@ -517,11 +517,11 @@ struct StmtLoweringVisitor : StmtVisitor<StmtLoweringVisitor>
{
auto loweredExpr = lowerExpr(context, expr);
- getBuilder()->createReturn(getSimpleVal(loweredExpr));
+ getBuilder()->emitReturn(getSimpleVal(loweredExpr));
}
else
{
- getBuilder()->createReturn();
+ getBuilder()->emitReturn();
}
}
};
@@ -599,7 +599,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
IRFunc* irFunc = subBuilder->createFunc();
subBuilder->parentInst = irFunc;
- IRBlock* entryBlock = subBuilder->createBlock();
+ IRBlock* entryBlock = subBuilder->emitBlock();
subBuilder->parentInst = entryBlock;
IRGenContext subContextStorage = *context;
@@ -611,7 +611,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
for( auto paramDecl : decl->GetParameters() )
{
IRType* irParamType = lowerSimpleType(context, paramDecl->getType());
- IRParam* irParam = subBuilder->createParam(irParamType);
+ IRParam* irParam = subBuilder->emitParam(irParamType);
DeclRef<ParamDecl> paramDeclRef = makeDeclRef(paramDecl.Ptr());
@@ -625,6 +625,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
lowerStmt(subContext, decl->Body);
+ getBuilder()->addInst(irFunc);
+
return LoweredValInfo::simple(irFunc);
}
};
@@ -713,13 +715,17 @@ IRModule* lowerEntryPointToIR(
context->shared = sharedContext;
+ SharedIRBuilder sharedBuilderStorage;
+ SharedIRBuilder* sharedBuilder = &sharedBuilderStorage;
+ sharedBuilder->module = nullptr;
+
IRBuilder builderStorage;
IRBuilder* builder = &builderStorage;
- builder->module = nullptr;
+ builder->shared = sharedBuilder;
builder->parentInst = nullptr;
IRModule* module = builder->createModule();
- builder->module = module;
+ sharedBuilder->module = module;
builder->parentInst = module;
context->irBuilder = builder;