From b1369040c3d6d6a8704bdb17d9de99f36a108e07 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 26 May 2020 13:53:10 -0400 Subject: Improvements around hashing (#1355) * Fields from upper to lower case in slang-ast-decl.h * Lower camel field names in slang-ast-stmt.h * Fix fields in slang-ast-expr.h * slang-ast-type.h make fields lowerCamel. * slang-ast-base.h members functions lowerCamel. * Method names in slang-ast-type.h to lowerCamel. * GetCanonicalType -> getCanonicalType * Substitute -> substitute * Equals -> equals ToString -> toString * ParentDecl -> parentDecl Members -> members * * Make hash code types explicit * Use HashCode as return type of GetHashCode * Added conversion from double to int64_t * Split Stable from other hash functions * toHash32/64 to convert a HashCode to the other styles. GetHashCode32/64 -> getHashCode32/64 GetStableHashCode32/64 -> getStableHashCode32/64 * Other Get/Stable/HashCode32/64 fixes * GetHashCode -> getHashCode * Equals -> equals * CreateCanonicalType -> createCanonicalType * Catches of polymorphic types should be through references otherwise slicing can occur. * Fixes for newer verison of gcc. Fix hashing problem on gcc for Dictionary. * Another fix for GetHashPos * Fix signed issue around GetHashPos --- source/slang/slang-ir.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 9fb966eba..0a52561c0 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -1651,17 +1651,17 @@ namespace Slang return true; } - int IRInstKey::GetHashCode() + HashCode IRInstKey::getHashCode() { - auto code = Slang::GetHashCode(inst->op); - code = combineHash(code, Slang::GetHashCode(inst->getFullType())); - code = combineHash(code, Slang::GetHashCode(inst->getOperandCount())); + auto code = Slang::getHashCode(inst->op); + code = combineHash(code, Slang::getHashCode(inst->getFullType())); + code = combineHash(code, Slang::getHashCode(inst->getOperandCount())); auto argCount = inst->getOperandCount(); auto args = inst->getOperands(); for( UInt aa = 0; aa < argCount; ++aa ) { - code = combineHash(code, Slang::GetHashCode(args[aa].get())); + code = combineHash(code, Slang::getHashCode(args[aa].get())); } return code; } @@ -1760,10 +1760,10 @@ namespace Slang return isValueEqual(rhs) && getFullType() == rhs->getFullType(); } - int IRConstant::getHashCode() + HashCode IRConstant::getHashCode() { - auto code = Slang::GetHashCode(op); - code = combineHash(code, Slang::GetHashCode(getFullType())); + auto code = Slang::getHashCode(op); + code = combineHash(code, Slang::getHashCode(getFullType())); switch (op) { @@ -1773,16 +1773,16 @@ namespace Slang { SLANG_COMPILE_TIME_ASSERT(sizeof(IRFloatingPointValue) == sizeof(IRIntegerValue)); // ... we can just compare as bits - return combineHash(code, Slang::GetHashCode(value.intVal)); + return combineHash(code, Slang::getHashCode(value.intVal)); } case kIROp_PtrLit: { - return combineHash(code, Slang::GetHashCode(value.ptrVal)); + return combineHash(code, Slang::getHashCode(value.ptrVal)); } case kIROp_StringLit: { const UnownedStringSlice slice = getStringSlice(); - return combineHash(code, Slang::GetHashCode(slice.begin(), slice.getLength())); + return combineHash(code, Slang::getHashCode(slice.begin(), slice.getLength())); } default: { @@ -4537,7 +4537,7 @@ namespace Slang { // TODO: This is contrived in that we want two types that are the same, but are different // pointers to match here. - // If we make GetHashCode for IRType* compatible with isTypeEqual, then we should probably use that. + // If we make getHashCode for IRType* compatible with isTypeEqual, then we should probably use that. return static_cast(a)->isValueEqual(static_cast(b)) && isTypeEqual(a->getFullType(), b->getFullType()); } -- cgit v1.2.3