From 9653dcc2c9d5d20d3d0e8918aaf1d5b09e963060 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 3 Dec 2019 09:58:59 -0500 Subject: getStringHash on string literals (#1140) * WIP getStringHash * Have a use. * Add slang-string-hash.h/.cpp * Use StringSlicePool for holding strings for StringHash. Add outputBuffer to string-literal-hash.slang so value can be tested. Ignore the GlobalHashedStringLiterals instruction on emit. * Add all the hashed string literals to ProgramLayout. * Add reflection support for hashed string literals to reflection test. * Fix string literal hash test. * Small fixes to pass test suite. * Fix issue in serialization where IRUse is not correctly initialized. * Fix problem initializing IRUse for string hash pass. Remove hack from slang-ir-specialize - specially handling if user is not null. * * Use shared builder when replacing getStringHash * Comments for functions in slang-ir-string-hash * Do not allow zero length string literals. Could be allowed, but doing so would require StringSlicePool to have a special case (or some other mechanism) --- source/slang/slang-emit-c-like.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/slang-emit-c-like.cpp') diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index bf7dd3129..2c1bcbe6d 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -1650,6 +1650,11 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO bool needClose = false; switch(inst->op) { + case kIROp_GlobalHashedStringLiterals: + /* Don't need to to output anything for this instruction - it's used for reflecting string literals that + are hashed with 'getStringHash' */ + break; + case kIROp_IntLit: case kIROp_FloatLit: case kIROp_BoolLit: @@ -3033,6 +3038,11 @@ void CLikeSourceEmitter::emitGlobalInst(IRInst* inst) switch(inst->op) { + case kIROp_GlobalHashedStringLiterals: + /* Don't need to to output anything for this instruction - it's used for reflecting string literals that + are hashed with 'getStringHash' */ + break; + case kIROp_Func: emitFunc((IRFunc*) inst); break; -- cgit v1.2.3