From 4880789e3003441732cca4471091563f36531635 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 29 Apr 2019 17:03:46 -0400 Subject: String/List closer to conventions, and use Index type (#959) * List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List.Count() -> getSize() * List Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds. --- source/slang/ir-specialize.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source/slang/ir-specialize.cpp') diff --git a/source/slang/ir-specialize.cpp b/source/slang/ir-specialize.cpp index e491eaa31..57d14c11a 100644 --- a/source/slang/ir-specialize.cpp +++ b/source/slang/ir-specialize.cpp @@ -112,7 +112,7 @@ struct SpecializationContext return; } - workList.Add(inst); + workList.add(inst); } // When a transformation makes a change to an instruction, @@ -192,11 +192,11 @@ struct SpecializationContext // the array `[g, a, b, c]`. // Key key; - key.vals.Add(specializeInst->getBase()); + key.vals.add(specializeInst->getBase()); UInt argCount = specializeInst->getArgCount(); for( UInt ii = 0; ii < argCount; ++ii ) { - key.vals.Add(specializeInst->getArg(ii)); + key.vals.add(specializeInst->getArg(ii)); } { @@ -568,10 +568,10 @@ struct SpecializationContext // We will then iterate until our work list goes dry. // - while(workList.Count() != 0) + while(workList.getCount() != 0) { - IRInst* inst = workList.Last(); - workList.RemoveLast(); + IRInst* inst = workList.getLast(); + workList.removeLast(); // For each instruction we process, we want to perform // a few steps. @@ -677,7 +677,7 @@ struct SpecializationContext // The specialized callee will always depend on the unspecialized // function from which it is generated, so we add that to our key. // - key.vals.Add(calleeFunc); + key.vals.add(calleeFunc); // Also, for any parameter that has an existential type, the // specialized function will depend on the concrete type of the @@ -700,7 +700,7 @@ struct SpecializationContext // auto val = makeExistential->getWrappedValue(); auto valType = val->getFullType(); - key.vals.Add(valType); + key.vals.add(valType); // We are also including the witness table in the key. // This isn't required with our current language model, @@ -717,7 +717,7 @@ struct SpecializationContext // table even if it is redundant. // auto witnessTable = makeExistential->getWitnessTable(); - key.vals.Add(witnessTable); + key.vals.add(witnessTable); } else { @@ -757,7 +757,7 @@ struct SpecializationContext // If the parameter doesn't have an existential type, then we // don't want to change up the argument we pass at all. // - newArgs.Add(arg); + newArgs.add(arg); } else { @@ -768,7 +768,7 @@ struct SpecializationContext if( auto makeExistential = as(arg) ) { auto val = makeExistential->getWrappedValue(); - newArgs.Add(val); + newArgs.add(val); } else { @@ -912,7 +912,7 @@ struct SpecializationContext // and we'll use that instead of the original parameter. // auto newParam = builder->createParam(oldParam->getFullType()); - newParams.Add(newParam); + newParams.add(newParam); replacementVal = newParam; } else @@ -936,7 +936,7 @@ struct SpecializationContext // auto valType = val->getFullType(); auto newParam = builder->createParam(valType); - newParams.Add(newParam); + newParams.add(newParam); // Within the body of the function we cannot just use `val` // directly, because the existing code expects an existential @@ -948,7 +948,7 @@ struct SpecializationContext // correct existential type, and stores the right witness table). // auto newMakeExistential = builder->emitMakeExistential(oldParam->getFullType(), newParam, witnessTable); - newBodyInsts.Add(newMakeExistential); + newBodyInsts.add(newMakeExistential); replacementVal = newMakeExistential; } else @@ -972,11 +972,11 @@ struct SpecializationContext List newParamTypes; for( auto newParam : newParams ) { - newParamTypes.Add(newParam->getFullType()); + newParamTypes.add(newParam->getFullType()); } IRType* newFuncType = builder->getFuncType( - newParamTypes.Count(), - newParamTypes.Buffer(), + newParamTypes.getCount(), + newParamTypes.getBuffer(), oldFunc->getResultType()); IRFunc* newFunc = builder->createFunc(); newFunc->setFullType(newFuncType); @@ -1190,7 +1190,7 @@ struct SpecializationContext UInt slotOperandCount = wrapInst->getSlotOperandCount(); for( UInt ii = 0; ii < slotOperandCount; ++ii ) { - slotOperands.Add(wrapInst->getSlotOperand(ii)); + slotOperands.add(wrapInst->getSlotOperand(ii)); } auto newLoadInst = builder.emitLoad(elementType, val); @@ -1198,7 +1198,7 @@ struct SpecializationContext resultType, newLoadInst, slotOperandCount, - slotOperands.Buffer()); + slotOperands.getBuffer()); addUsersToWorkList(inst); -- cgit v1.2.3