diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-04-11 16:18:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-11 16:18:29 -0700 |
| commit | baf194e7456ba4568dcf11249896af35b3ce18cc (patch) | |
| tree | f75e20db450100d41bfa9c384a8bab0fdc28a749 /source/slang/vm.cpp | |
| parent | 6322983fa4dc84ef1e9dd8fad54d4c1580436e67 (diff) | |
Introduce an IR-level type system (#481)
* Introduce an IR-level type system
Up to this point, the Slang IR has used the front-end type system to represent types in the IR.
As a result (but ultimately more importantly) the IR representation of generics and specialization has used AST-level concepts embedded in the IR.
For example, to express the specialization of `vector<T,N>` to a concrete type `float` for `T`, we needed an IR operation that could represent the specialization, with operands that somehow represented the type argument `float`.
The whole thing was very complicated.
The big idea of this change is to introduce a new representation in which types in the IR are just ordinary instructions, so that using them as operands makes sense. The hierarchy of IR types closely mirrors the AST-side hierarchy for now, and that will probably be something we should maintain going forward.
In order to make these changes work, though, I also had to do major overhauls of things like the way substitutions are performed, how we check interface conformances, the way lookup through interface types is done, etc. etc. This is a big change, and unfortunately any attempt to summarize it in the commit message wouldn't do it justice.
* Fix 64-bit build warning
* Fix up some clang warnings/errors
Diffstat (limited to 'source/slang/vm.cpp')
| -rw-r--r-- | source/slang/vm.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/source/slang/vm.cpp b/source/slang/vm.cpp index 38083d631..802c8476b 100644 --- a/source/slang/vm.cpp +++ b/source/slang/vm.cpp @@ -257,7 +257,7 @@ VMSizeAlign getVMSymbolSize(BCSymbol* symbol) SLANG_UNEXPECTED("op"); break; - case kIROp_TypeType: + case kIROp_TypeKind: break; case kIROp_Func: @@ -409,16 +409,16 @@ void dumpVMFrame(VMFrame* vmFrame) { switch (regType.impl->op) { - case kIROp_TypeType: + case kIROp_TypeKind: // TODO: we could recursively go and print types... fprintf(stderr, ": Type = ???"); break; - case kIROp_readWriteStructuredBufferType: + case kIROp_HLSLRWStructuredBufferType: fprintf(stderr, ": RWStructuredBuffer<???> = ???"); break; - case kIROp_structuredBufferType: + case kIROp_HLSLStructuredBufferType: fprintf(stderr, ": StructuredBuffer<???> = ???"); break; @@ -426,11 +426,11 @@ void dumpVMFrame(VMFrame* vmFrame) fprintf(stderr, ": Bool = %s", *(bool*)regData ? "true" : "false"); break; - case kIROp_Int32Type: + case kIROp_IntType: fprintf(stderr, ": Int32 = %d", *(int32_t*)regData); break; - case kIROp_UInt32Type: + case kIROp_UIntType: fprintf(stderr, ": UInt32 = %u", *(uint32_t*)regData); break; @@ -499,16 +499,16 @@ void computeTypeSizeAlign( size = 1; break; - case kIROp_Int32Type: - case kIROp_UInt32Type: - case kIROp_Float32Type: + case kIROp_IntType: + case kIROp_UIntType: + case kIROp_FloatType: size = 4; break; case kIROp_FuncType: case kIROp_PtrType: - case kIROp_readWriteStructuredBufferType: - case kIROp_structuredBufferType: + case kIROp_HLSLRWStructuredBufferType: + case kIROp_HLSLStructuredBufferType: size = sizeof(void*); break; @@ -632,7 +632,7 @@ void* loadVMSymbol( switch(bcSymbol->op) { - case kIROp_global_var: + case kIROp_GlobalVar: { auto type = getType(vmModule, bcSymbol->typeID); assert(type.impl->op == kIROp_PtrType); @@ -650,7 +650,7 @@ void* loadVMSymbol( } break; - case kIROp_global_constant: + case kIROp_GlobalConstant: { auto type = getType(vmModule, bcSymbol->typeID); void* valPtr = allocate(vm, type); @@ -1094,7 +1094,7 @@ void resumeThread( switch (type.impl->op) { - case kIROp_Int32Type: + case kIROp_IntType: *destPtr = *(int32_t*)leftPtr > *(int32_t*)rightPtr; break; @@ -1116,7 +1116,7 @@ void resumeThread( switch (type.impl->op) { - case kIROp_Int32Type: + case kIROp_IntType: *(int32_t*)destPtr = *(int32_t*)leftPtr * *(int32_t*)rightPtr; break; @@ -1138,7 +1138,7 @@ void resumeThread( switch (type.impl->op) { - case kIROp_Int32Type: + case kIROp_IntType: *(int32_t*)destPtr = *(int32_t*)leftPtr - *(int32_t*)rightPtr; break; |
