diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-08-17 13:40:50 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-08-17 13:44:02 -0700 |
| commit | ad19484792dcc5a1fb90720614830c66c4b9712d (patch) | |
| tree | 45e5c5152b4d5deca3125d9fb8159d114bc09d14 /source/slang/lower-to-ir.cpp | |
| parent | 1965c3f3f265c43c8d1d96bb49d0850ce5d53cc3 (diff) | |
Add some dummy logic to print IR to HLSL
- Change IR instructions to just hold an integer opcode instead of a pointer to the "info" structure
- Externalize definition of IR instructions to a header file, and use the "X macro" approach to allow generating different definitions
- Add notion of function types to the IR, so that we can easily query the result type of a function
- Add some convenience accesors to allow walking the IR in a strongly-typed manner (e.g., iterate over the parameters of a function)
- TODO: these should really be changed to assert the type of things, as least in debug builds
- Add very basic logic to `emit.cpp` so that it can walk the generated IR and start printing it back as HLSL
- This isn't meant to be usable as-is, but it is a step toward where we need to go
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
| -rw-r--r-- | source/slang/lower-to-ir.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index a01279f2e..ed8ed3318 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -608,9 +608,13 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // set up sub context for generating our new function + List<IRType*> paramTypes; + for( auto paramDecl : decl->GetParameters() ) { IRType* irParamType = lowerSimpleType(context, paramDecl->getType()); + paramTypes.Add(irParamType); + IRParam* irParam = subBuilder->emitParam(irParamType); DeclRef<ParamDecl> paramDeclRef = makeDeclRef(paramDecl.Ptr()); @@ -620,8 +624,13 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> subContext->shared->declValues.Add(paramDeclRef, irParamVal); } - auto irResultType = lowerType(context, decl->ReturnType); + auto irResultType = lowerSimpleType(context, decl->ReturnType); + auto irFuncType = getBuilder()->getFuncType( + paramTypes.Count(), + ¶mTypes[0], + irResultType); + irFunc->type.init(irFunc, irFuncType); lowerStmt(subContext, decl->Body); |
