diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-04 18:07:09 -0400 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-04 18:07:09 -0400 |
| commit | d1009d1a5ac7463dc74169ed7c6e1e692b3541d7 (patch) | |
| tree | b21cd74ca6daabd655f5a2625c2698de16a92dd1 /source/slang/ir.cpp | |
| parent | 1f9686ce87573efdd4ad56040deb2d424fe51929 (diff) | |
| parent | 784bd914cface6e5837ef0da7aee0df2e16c4999 (diff) | |
merge with fixWarnings branch
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 5f3ca6c62..e424b4cc3 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -212,7 +212,7 @@ namespace Slang return; } - auto parent = block; + auto parent = curBlock; if (!parent) return; @@ -260,7 +260,7 @@ namespace Slang IRInst* inst = (IRInst*) malloc(size); memset(inst, 0, size); - inst->argCount = (uint32_t)(fixedArgCount + varArgCount); + inst->argCount = fixedArgCount + varArgCount; inst->op = op; @@ -492,7 +492,7 @@ namespace Slang key.inst = &keyInst; IRConstant* irValue = nullptr; - if( builder->shared->constantMap.TryGetValue(key, irValue) ) + if( builder->sharedBuilder->constantMap.TryGetValue(key, irValue) ) { // We found a match, so just use that. return irValue; @@ -509,7 +509,7 @@ namespace Slang memcpy(&irValue->u, value, valueSize); key.inst = irValue; - builder->shared->constantMap.Add(key, irValue); + builder->sharedBuilder->constantMap.Add(key, irValue); return irValue; } @@ -890,11 +890,11 @@ namespace Slang { auto bb = createBlock(); - auto f = this->func; + auto f = this->curFunc; if (f) { f->addBlock(bb); - this->block = bb; + this->curBlock = bb; } return bb; } @@ -907,7 +907,7 @@ namespace Slang kIROp_Param, type); - if (auto bb = block) + if (auto bb = curBlock) { bb->addParam(param); } @@ -1695,7 +1695,6 @@ namespace Slang dumpChildrenRaw(context, block); } - #if 0 static void dumpChildrenRaw( IRDumpContext* context, @@ -1720,7 +1719,6 @@ namespace Slang dump(context, "}\n"); } #endif - static void dumpInst( IRDumpContext* context, IRInst* inst) @@ -2239,8 +2237,7 @@ namespace Slang void IRInst::removeArguments() { - UInt oldArgCount = this->argCount; - for( UInt aa = 0; aa < oldArgCount; ++aa ) + for( UInt aa = 0; aa < argCount; ++aa ) { IRUse& use = getArgs()[aa]; @@ -2280,7 +2277,7 @@ namespace Slang shared.session = session; IRBuilder builder; - builder.shared = &shared; + builder.sharedBuilder = &shared; RefPtr<PtrType> ptrType = session->getPtrType(valueType); @@ -2550,6 +2547,7 @@ namespace Slang default: SLANG_UNEXPECTED("unimplemented"); + UNREACHABLE_RETURN(ScalarizedVal()); } } @@ -2667,8 +2665,8 @@ namespace Slang shared.module = module; shared.session = session; IRBuilder builder; - builder.shared = &shared; - builder.func = func; + builder.sharedBuilder = &shared; + builder.curFunc = func; // We will start by looking at the return type of the // function, because that will enable us to do an @@ -2725,7 +2723,7 @@ namespace Slang IRValue* returnValue = returnInst->getVal(); // Make sure we add these instructions to the right block - builder.block = bb; + builder.curBlock = bb; // Write to our global variable(s) from the value being returned. assign(&builder, resultGlobal, ScalarizedVal::value(returnValue)); @@ -2777,7 +2775,7 @@ namespace Slang // Any initialization code we insert nees to be at the start // of the block: - builder.block = firstBlock; + builder.curBlock = firstBlock; builder.insertBeforeInst = firstBlock->getFirstInst(); // TODO: We need to distinguish any true pointers in the @@ -2836,7 +2834,7 @@ namespace Slang break; } - builder.block = bb; + builder.curBlock = bb; builder.insertBeforeInst = terminatorInst; assign(&builder, globalOutputVal, localVal); @@ -3078,6 +3076,7 @@ namespace Slang break; default: SLANG_UNEXPECTED("no value registered for IR value"); + UNREACHABLE_RETURN(nullptr); } } @@ -3238,7 +3237,7 @@ namespace Slang { auto clonedKey = context->maybeCloneValue(originalEntry->requirementKey.usedValue); auto clonedVal = context->maybeCloneValue(originalEntry->satisfyingVal.usedValue); - context->builder->createWitnessTableEntry( + /*auto clonedEntry = */context->builder->createWitnessTableEntry( clonedTable, clonedKey, clonedVal); @@ -3262,7 +3261,7 @@ namespace Slang // Next we are going to clone the actual code. IRBuilder builderStorage = *context->builder; IRBuilder* builder = &builderStorage; - builder->func = clonedFunc; + builder->curFunc = clonedFunc; // We will walk through the blocks of the function, and clone each of them. // @@ -3278,7 +3277,7 @@ namespace Slang registerClonedValue(context, clonedBlock, originalBlock); // We can go ahead and clone parameters here, while we are at it. - builder->block = clonedBlock; + builder->curBlock = clonedBlock; for (auto originalParam = originalBlock->getFirstParam(); originalParam; originalParam = originalParam->getNextParam()) @@ -3299,7 +3298,7 @@ namespace Slang { assert(cb); - builder->block = cb; + builder->curBlock = cb; for (auto oi = ob->getFirstInst(); oi; oi = oi->getNextInst()) { cloneInst(context, builder, oi); @@ -3423,6 +3422,7 @@ namespace Slang default: SLANG_UNEXPECTED("unhandled case"); + UNREACHABLE_RETURN("unknown"); } } @@ -3524,6 +3524,7 @@ namespace Slang { // This shouldn't happen! SLANG_UNEXPECTED("no matching function registered"); + UNREACHABLE_RETURN(cloneSimpleFunc(context, originalFunc)); } // We will try to track the "best" definition we can find. @@ -3595,7 +3596,7 @@ namespace Slang sharedBuilder->session = session; IRBuilder* builder = &sharedContext->builderStorage; - builder->shared = sharedBuilder; + builder->sharedBuilder = sharedBuilder; if( !module ) { @@ -3753,6 +3754,7 @@ namespace Slang else { SLANG_UNEXPECTED("unimplemented"); + UNREACHABLE_RETURN(nullptr); } } |
