summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/slang/emit.cpp198
-rw-r--r--source/slang/ir-insts.h11
-rw-r--r--source/slang/ir-legalize-types.cpp67
-rw-r--r--source/slang/ir-ssa.cpp21
-rw-r--r--source/slang/ir.cpp8
-rw-r--r--source/slang/ir.h1
-rw-r--r--source/slang/legalize-types.cpp5
-rw-r--r--source/slang/lower-to-ir.cpp111
-rw-r--r--tests/bindings/array-of-struct-of-resource.hlsl6
-rw-r--r--tests/bindings/binding0.hlsl8
-rw-r--r--tests/bindings/binding1.hlsl8
-rw-r--r--tests/bindings/explicit-binding.hlsl24
-rw-r--r--tests/bindings/glsl-parameter-blocks.slang.glsl10
-rw-r--r--tests/bindings/multi-file-extra.hlsl56
-rw-r--r--tests/bindings/multi-file.hlsl56
-rw-r--r--tests/bindings/multiple-parameter-blocks.slang20
-rw-r--r--tests/bindings/packoffset.hlsl18
-rw-r--r--tests/bindings/parameter-blocks.slang6
-rw-r--r--tests/bindings/resources-in-cbuffer.hlsl52
-rw-r--r--tests/bindings/targets-and-uavs-structure.hlsl6
-rw-r--r--tests/bindings/targets-and-uavs.hlsl6
-rw-r--r--tests/bugs/gh-103.slang6
-rw-r--r--tests/bugs/gh-333.slang14
-rw-r--r--tests/bugs/split-nested-types.hlsl18
-rw-r--r--tests/bugs/vec-init-list.hlsl4
-rw-r--r--tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl4
-rw-r--r--tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl10
-rw-r--r--tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl6
-rw-r--r--tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl4
-rw-r--r--tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl6
-rw-r--r--tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl8
-rw-r--r--tests/hlsl/dxsdk/OIT11/SceneVS.hlsl4
-rw-r--r--tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl4
-rw-r--r--tests/hlsl/simple/allow-uav-conditional.hlsl2
-rw-r--r--tests/hlsl/simple/compute-numthreads.hlsl2
-rw-r--r--tests/hlsl/simple/literal-typing.hlsl2
-rw-r--r--tests/parser/cast-precedence.hlsl6
37 files changed, 599 insertions, 199 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 9f9a089c8..4ed7dd5a7 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -136,6 +136,14 @@ struct SharedEmitContext
// How far are we indented?
Int indentLevel = 0;
+
+ // Map a string name to the number of times we have seen this
+ // name used so far during code emission.
+ Dictionary<String, UInt> uniqueNameCounters;
+
+ // Map an IR instruction to the name that we've decided
+ // to use for it when emitting code.
+ Dictionary<IRInst*, String> mapInstToName;
};
struct EmitContext
@@ -1895,8 +1903,128 @@ struct EmitVisitor
return id;
}
- String getIRName(
- IRInst* inst)
+ /// "Scrub" a name so that it complies with restrictions of the target language.
+ String scrubName(
+ String const& name)
+ {
+ // We will use a plain `U` as a dummy character to insert
+ // whenever we need to insert things to make a string into
+ // valid name.
+ //
+ char const* dummyChar = "U";
+
+ // Special case a name that is the empty string, just in case.
+ if(name.Length() == 0)
+ return dummyChar;
+
+ // Otherwise, we are going to walk over the name byte by byte
+ // and write some legal characters to the output as we go.
+ StringBuilder sb;
+
+ if(getTarget(context) == CodeGenTarget::GLSL)
+ {
+ // GLSL reserverse all names that start with `gl_`,
+ // so if we are in danger of collision, then make
+ // our name start with a dummy character instead.
+ if(name.StartsWith("gl_"))
+ {
+ sb.append(dummyChar);
+ }
+ }
+
+ // We will also detect user-defined names that
+ // might overlap with our convention for mangled names,
+ // to avoid an possible collision.
+ if(name.StartsWith("_S"))
+ {
+ sb.Append(dummyChar);
+ }
+
+ // TODO: This is where we might want to consult
+ // a dictionary of reserved words for the chosen target
+ //
+ // if(isReservedWord(name)) { sb.Append(dummyChar); }
+ //
+
+ // We need to track the previous byte in
+ // order to detect consecutive underscores for GLSL.
+ int prevChar = -1;
+
+ for(auto c : name)
+ {
+ // We will treat a dot character just like an underscore
+ // for the purposes of producing a scrubbed name, so
+ // that we translate `SomeType.someMethod` into
+ // `SomeType_someMethod`.
+ //
+ // By handling this case at the top of this loop, we
+ // ensure that a `.`-turned-`_` is handled just like
+ // a `_` in the original name, and will be properly
+ // scrubbed for GLSL output.
+ //
+ if(c == '.')
+ {
+ c = '_';
+ }
+
+ if(((c >= 'a') && (c <= 'z'))
+ || ((c >= 'A') && (c <= 'Z')))
+ {
+ // Ordinary ASCII alphabetic characters are assumed
+ // to always be okay.
+ }
+ else if((c >= '0') && (c <= '9'))
+ {
+ // We don't want to allow a digit as the first
+ // byte in a name, since the result wouldn't
+ // be a valid identifier in many target languages.
+ if(prevChar == -1)
+ {
+ sb.append(dummyChar);
+ }
+ }
+ else if(c == '_')
+ {
+ // We will collapse any consecutive sequence of `_`
+ // characters into a single one (this means that
+ // some names that were unique in the original
+ // code might not resolve to unique names after
+ // scrubbing, but that was true in general).
+
+ if(prevChar == '_')
+ {
+ // Skip this underscore, so we don't output
+ // more than one in a row.
+ continue;
+ }
+ }
+ else
+ {
+ // If we run into a character that wouldn't normally
+ // be allowed in an identifier, we need to translate
+ // it into something that *is* valid.
+ //
+ // Our solution for now will be very clumsy: we will
+ // emit `x` and then the hexadecimal version of
+ // the byte we were given.
+ sb.append("x");
+ sb.append(uint32_t((unsigned char) c), 16);
+
+ // We don't want to apply the default handling below,
+ // so skip to the top of the loop now.
+ prevChar = c;
+ continue;
+ }
+
+ sb.append(c);
+ prevChar = c;
+ }
+
+ return sb.ProduceString();
+ }
+
+ String generateIRName(
+ IRInst* inst)
{
// If the instruction names something
// that should be emitted as a target intrinsic,
@@ -1906,6 +2034,58 @@ struct EmitVisitor
return intrinsicDecoration->definition;
}
+ // If we have a name hint on the instruction, then we will try to use that
+ // to provide the actual name in the output code.
+ //
+ // We need to be careful that the name follows the rules of the target language,
+ // so there is a "scrubbing" step that needs to be applied here.
+ //
+ // We also need to make sure that the name won't collide with other declarations
+ // that might have the same name hint applied, so we will still unique
+ // them by appending the numeric ID of the instruction.
+ //
+ // TODO: Find cases where we can drop the suffix safely.
+ //
+ // TODO: When we start having to handle symbols with external linkage for
+ // things like DXIL libraries, we will need to *not* use the friendly
+ // names for stuff that should be link-able.
+ //
+ if(auto nameHintDecoration = inst->findDecoration<IRNameHintDecoration>())
+ {
+ // The name we output will basically be:
+ //
+ // <nameHint>_<uniqueID>
+ //
+ // Except that we will "scrub" the name hint first,
+ // and we will omit the underscore if the (scrubbed)
+ // name hint already ends with one.
+ //
+
+ String nameHint = nameHintDecoration->name->text;
+ nameHint = scrubName(nameHint);
+
+ StringBuilder sb;
+ sb.append(nameHint);
+
+ // Avoid introducing a double underscore
+ if(!nameHint.EndsWith("_"))
+ {
+ sb.append("_");
+ }
+
+ String key = sb.ProduceString();
+ UInt count = 0;
+ context->shared->uniqueNameCounters.TryGetValue(key, count);
+
+ context->shared->uniqueNameCounters[key] = count+1;
+
+ sb.append(count);
+ return sb.ProduceString();
+ }
+
+
+
+
// If the instruction has a mangled name, then emit using that.
if (auto globalValue = as<IRGlobalValue>(inst))
{
@@ -1925,9 +2105,23 @@ struct EmitVisitor
StringBuilder sb;
sb << "_S";
sb << getID(inst);
+
+
return sb.ProduceString();
}
+ String getIRName(
+ IRInst* inst)
+ {
+ String name;
+ if(!context->shared->mapInstToName.TryGetValue(inst, name))
+ {
+ name = generateIRName(inst);
+ context->shared->mapInstToName.Add(inst, name);
+ }
+ return name;
+ }
+
struct IRDeclaratorInfo
{
enum class Flavor
diff --git a/source/slang/ir-insts.h b/source/slang/ir-insts.h
index 22685f316..804c393c2 100644
--- a/source/slang/ir-insts.h
+++ b/source/slang/ir-insts.h
@@ -121,6 +121,17 @@ struct IRInterpolationModeDecoration : IRDecoration
IRInterpolationMode mode;
};
+/// A decoration that provides a desired name to be used
+/// in conjunction with the given instruction. Back-end
+/// code generation may use this to help derive symbol
+/// names, emit debug information, etc.
+struct IRNameHintDecoration : IRDecoration
+{
+ enum { kDecorationOp = kIRDecorationOp_NameHint };
+
+ Name* name;
+};
+
//
// An IR node to represent a reference to an AST-level
diff --git a/source/slang/ir-legalize-types.cpp b/source/slang/ir-legalize-types.cpp
index 25bd498b8..3465662f3 100644
--- a/source/slang/ir-legalize-types.cpp
+++ b/source/slang/ir-legalize-types.cpp
@@ -117,6 +117,7 @@ static LegalVal declareVars(
LegalType type,
TypeLayout* typeLayout,
LegalVarChain* varChain,
+ String const* nameHint,
IRGlobalNameInfo* globalNameInfo);
static LegalType legalizeType(
@@ -708,6 +709,15 @@ RefPtr<VarLayout> findVarLayout(IRInst* value)
return nullptr;
}
+static String const* findNameHint(IRInst* inst)
+{
+ if( auto nameHintDecoration = inst->findDecoration<IRNameHintDecoration>() )
+ {
+ return &nameHintDecoration->name->text;
+ }
+ return nullptr;
+}
+
static LegalVal legalizeLocalVar(
IRTypeLegalizationContext* context,
IRVar* irLocalVar)
@@ -763,7 +773,8 @@ static LegalVal legalizeLocalVar(
varChain = &varChainStorage;
}
- LegalVal newVal = declareVars(context, kIROp_Var, legalValueType, typeLayout, varChain, nullptr);
+ String const* nameHint = findNameHint(irLocalVar);
+ LegalVal newVal = declareVars(context, kIROp_Var, legalValueType, typeLayout, varChain, nameHint, nullptr);
// Remove the old local var.
irLocalVar->removeFromParent();
@@ -794,7 +805,8 @@ static LegalVal legalizeParam(
context->insertBeforeParam = originalParam;
- auto newVal = declareVars(context, kIROp_Param, legalParamType, nullptr, nullptr, nullptr);
+ String const* nameHint = findNameHint(originalParam);
+ auto newVal = declareVars(context, kIROp_Param, legalParamType, nullptr, nullptr, nameHint, nullptr);
originalParam->removeFromParent();
context->replacedInstructions.Add(originalParam);
@@ -996,12 +1008,25 @@ static LegalVal legalizeFunc(
return LegalVal::simple(irFunc);
}
+static void addNameHint(
+ IRTypeLegalizationContext* context,
+ IRInst* inst,
+ String const& text)
+{
+ if(text.Length() == 0)
+ return;
+
+ auto name = context->session->getNameObj(text);
+ context->builder->addDecoration<IRNameHintDecoration>(inst)->name = name;
+}
+
static LegalVal declareSimpleVar(
IRTypeLegalizationContext* context,
IROp op,
IRType* type,
TypeLayout* typeLayout,
LegalVarChain* varChain,
+ String const* nameHint,
IRGlobalNameInfo* globalNameInfo)
{
RefPtr<VarLayout> varLayout = createVarLayout(varChain, typeLayout);
@@ -1087,17 +1112,23 @@ static LegalVal declareSimpleVar(
{
builder->addHighLevelDeclDecoration(irVar, varDeclRef.getDecl());
}
+
+ if( nameHint )
+ {
+ addNameHint(context, irVar, *nameHint);
+ }
}
return legalVarVal;
}
static LegalVal declareVars(
- IRTypeLegalizationContext* context,
+ IRTypeLegalizationContext* context,
IROp op,
LegalType type,
TypeLayout* typeLayout,
LegalVarChain* varChain,
+ String const* nameHint,
IRGlobalNameInfo* globalNameInfo)
{
switch (type.flavor)
@@ -1106,7 +1137,7 @@ static LegalVal declareVars(
return LegalVal();
case LegalType::Flavor::simple:
- return declareSimpleVar(context, op, type.getSimple(), typeLayout, varChain, globalNameInfo);
+ return declareSimpleVar(context, op, type.getSimple(), typeLayout, varChain, nameHint, globalNameInfo);
break;
case LegalType::Flavor::implicitDeref:
@@ -1120,6 +1151,7 @@ static LegalVal declareVars(
type.getImplicitDeref()->valueType,
getDerefTypeLayout(typeLayout),
varChain,
+ nameHint,
globalNameInfo);
return LegalVal::implicitDeref(val);
}
@@ -1128,8 +1160,8 @@ static LegalVal declareVars(
case LegalType::Flavor::pair:
{
auto pairType = type.getPair();
- auto ordinaryVal = declareVars(context, op, pairType->ordinaryType, typeLayout, varChain, globalNameInfo);
- auto specialVal = declareVars(context, op, pairType->specialType, typeLayout, varChain, globalNameInfo);
+ auto ordinaryVal = declareVars(context, op, pairType->ordinaryType, typeLayout, varChain, nameHint, globalNameInfo);
+ auto specialVal = declareVars(context, op, pairType->specialType, typeLayout, varChain, nameHint, globalNameInfo);
return LegalVal::pair(ordinaryVal, specialVal, pairType->pairInfo);
}
@@ -1158,12 +1190,28 @@ static LegalVal declareVars(
newVarChain = &newVarChainStorage;
}
+ String* fieldNameHint = nullptr;
+ String joinedNameHintStorage;
+ if( nameHint )
+ {
+ if( auto fieldNameHintDecoration = ee.key->findDecoration<IRNameHintDecoration>() )
+ {
+ joinedNameHintStorage.append(*nameHint);
+ joinedNameHintStorage.append(".");
+ joinedNameHintStorage.append(fieldNameHintDecoration->name->text);
+
+ fieldNameHint = &joinedNameHintStorage;
+ }
+
+ }
+
LegalVal fieldVal = declareVars(
context,
op,
ee.type,
fieldTypeLayout,
newVarChain,
+ fieldNameHint,
globalNameInfo);
TuplePseudoVal::Element element;
@@ -1222,7 +1270,8 @@ static LegalVal legalizeGlobalVar(
globalNameInfo.globalVar = irGlobalVar;
globalNameInfo.counter = 0;
- LegalVal newVal = declareVars(context, kIROp_GlobalVar, legalValueType, typeLayout, varChain, &globalNameInfo);
+ String const* nameHint = findNameHint(irGlobalVar);
+ LegalVal newVal = declareVars(context, kIROp_GlobalVar, legalValueType, typeLayout, varChain, nameHint, &globalNameInfo);
// Register the new value as the replacement for the old
registerLegalizedValue(context, irGlobalVar, newVal);
@@ -1263,7 +1312,9 @@ static LegalVal legalizeGlobalConstant(
globalNameInfo.counter = 0;
// TODO: need to handle initializer here!
- LegalVal newVal = declareVars(context, kIROp_GlobalConstant, legalValueType, nullptr, nullptr, &globalNameInfo);
+
+ String const* nameHint = findNameHint(irGlobalConstant);
+ LegalVal newVal = declareVars(context, kIROp_GlobalConstant, legalValueType, nullptr, nullptr, nameHint, &globalNameInfo);
// Register the new value as the replacement for the old
registerLegalizedValue(context, irGlobalConstant, newVal);
diff --git a/source/slang/ir-ssa.cpp b/source/slang/ir-ssa.cpp
index e97298969..6c4cfa8ff 100644
--- a/source/slang/ir-ssa.cpp
+++ b/source/slang/ir-ssa.cpp
@@ -350,6 +350,24 @@ IRInst* readVar(
SSABlockInfo* blockInfo,
IRVar* var);
+/// Try to take any name hint on `var` and apply it to `val`.
+///
+/// Doesn't do anything if `val` already has a name hint,
+/// or if `var` doesn't have one to transfer over.
+///
+void maybeApplyNameHint(
+ ConstructSSAContext* context,
+ IRVar* var,
+ IRInst* val)
+{
+ if( auto nameHint = var->findDecoration<IRNameHintDecoration>() )
+ {
+ if( !val->findDecoration<IRNameHintDecoration>() )
+ {
+ context->getBuilder()->addDecoration<IRNameHintDecoration>(val)->name = nameHint->name;
+ }
+ }
+}
// Add a phi node to represent the given variable
PhiInfo* addPhi(
@@ -365,6 +383,7 @@ PhiInfo* addPhi(
valueType = context->getBuilder()->getRateQualifiedType(rate, valueType);
}
IRParam* phi = builder->createParam(valueType);
+ maybeApplyNameHint(context, var, phi);
RefPtr<PhiInfo> phiInfo = new PhiInfo();
context->phiInfos.Add(phi, phiInfo);
@@ -755,6 +774,8 @@ void processBlock(
// block.
auto val = readVar(context, blockInfo, var);
+ maybeApplyNameHint(context, var, val);
+
val = applyAccessChain(context, &blockInfo->builder, ptrArg, val);
// We can just replace all uses of this
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 53050b6b9..f8ca54639 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -4713,6 +4713,14 @@ namespace Slang
}
break;
+ case kIRDecorationOp_NameHint:
+ {
+ auto originalDecoration = (IRNameHintDecoration*)dd;
+ auto newDecoration = context->builder->addDecoration<IRNameHintDecoration>(clonedValue);
+ newDecoration->name = originalDecoration->name;
+ }
+ break;
+
default:
// Don't clone any decorations we don't understand.
break;
diff --git a/source/slang/ir.h b/source/slang/ir.h
index 4a393cae0..5d9948b70 100644
--- a/source/slang/ir.h
+++ b/source/slang/ir.h
@@ -125,6 +125,7 @@ enum IRDecorationOp : uint16_t
kIRDecorationOp_GLSLOuterArray,
kIRDecorationOp_Semantic,
kIRDecorationOp_InterpolationMode,
+ kIRDecorationOp_NameHint,
};
// represents an object allocated in an IR memory pool
diff --git a/source/slang/legalize-types.cpp b/source/slang/legalize-types.cpp
index 6922a5174..bbfa6264d 100644
--- a/source/slang/legalize-types.cpp
+++ b/source/slang/legalize-types.cpp
@@ -341,6 +341,11 @@ struct TupleTypeBuilder
ordinaryStructType->sourceLoc = originalStructType->sourceLoc;
ordinaryStructType->mangledName = originalStructType->mangledName;
+ if(auto nameHintDecoration = originalStructType->findDecoration<IRNameHintDecoration>())
+ {
+ builder->addDecoration<IRNameHintDecoration>(ordinaryStructType)->name = nameHintDecoration->name;
+ }
+
// The new struct type will appear right after the original in the IR,
// so that we can be sure any instruction that could reference the
// original can also reference the new one.
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index 2d5f169f3..ea82e4b70 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -1232,7 +1232,92 @@ void maybeSetRate(
}
}
+static Name* getNameForNameHint(
+ IRGenContext* context,
+ Decl* decl)
+{
+ // We will use a bit of an ad hoc convention here for now.
+
+ Name* leafName = decl->getName();
+
+ // Handle custom name for a global parameter group (e.g., a `cbuffer`)
+ if(auto reflectionNameModifier = decl->FindModifier<ParameterGroupReflectionName>())
+ {
+ leafName = reflectionNameModifier->nameAndLoc.name;
+ }
+
+ // There is no point in trying to provide a name hint for something with no name,
+ // or with an empty name
+ if(!leafName)
+ return nullptr;
+ if(leafName->text.Length() == 0)
+ return nullptr;
+
+
+ if(auto varDecl = dynamic_cast<VarDeclBase*>(decl))
+ {
+ // For an ordinary local variable, global variable,
+ // parameter, or field, we will just use the name
+ // as declared, and now work in anything from
+ // its parent declaration(s).
+ //
+ // TODO: consider whether global/static variables should
+ // follow different rules.
+ //
+ return leafName;
+ }
+
+ // For other cases of declaration, we want to consider
+ // merging its name with the name of its parent declaration.
+ auto parentDecl = decl->ParentDecl;
+
+ // Skip past a generic parent, if we are a declaration nested in a generic.
+ if(auto genericParentDecl = dynamic_cast<GenericDecl*>(parentDecl))
+ parentDecl = genericParentDecl->ParentDecl;
+
+ auto parentName = getNameForNameHint(context, parentDecl);
+ if(!parentName)
+ {
+ return leafName;
+ }
+
+ // TODO: at some point we will start giving `ModuleDecl`s names,
+ // and in that case we need to think carefully about whether to
+ // include their names here or not.
+ // We will now construct a new `Name` to use as the hint,
+ // combining the name of the parent and the leaf declaration.
+
+ StringBuilder sb;
+ sb.append(parentName->text);
+ sb.append(".");
+ sb.append(leafName->text);
+
+ return context->getSession()->getNameObj(sb.ProduceString());
+}
+
+/// Try to add an appropriate name hint to the instruction,
+/// that can be used for back-end code emission or debug info.
+static void addNameHint(
+ IRGenContext* context,
+ IRInst* inst,
+ Decl* decl)
+{
+ Name* name = getNameForNameHint(context, decl);
+ if(!name)
+ return;
+ context->irBuilder->addDecoration<IRNameHintDecoration>(inst)->name = name;
+}
+
+/// Add a name hint based on a fixed string.
+static void addNameHint(
+ IRGenContext* context,
+ IRInst* inst,
+ char const* text)
+{
+ Name* name = context->getSession()->getNameObj(text);
+ context->irBuilder->addDecoration<IRNameHintDecoration>(inst)->name = name;
+}
LoweredValInfo createVar(
IRGenContext* context,
@@ -1249,6 +1334,8 @@ LoweredValInfo createVar(
addVarDecorations(context, irAlloc, decl);
builder->addHighLevelDeclDecoration(irAlloc, decl);
+
+ addNameHint(context, irAlloc, decl);
}
return LoweredValInfo::ptr(irAlloc);
@@ -3406,6 +3493,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
globalVal = LoweredValInfo::ptr(irGlobal);
}
irGlobal->mangledName = context->getSession()->getNameObj(getMangledName(decl));
+ addNameHint(context, irGlobal, decl);
maybeSetRate(context, irGlobal, decl);
@@ -3605,6 +3693,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
subContext->irBuilder = subBuilder;
IRStructType* irStruct = subBuilder->createStructType();
+ addNameHint(context, irStruct, decl);
setMangledName(irStruct, getMangledName(decl));
@@ -3664,6 +3753,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
auto builder = getBuilder();
auto irFieldKey = builder->createStructKey();
+ addNameHint(context, irFieldKey, fieldDecl);
addVarDecorations(context, irFieldKey, fieldDecl);
@@ -4074,12 +4164,14 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// TODO: use a `TypeKind` to represent the
// classifier of the parameter.
auto param = subBuilder->emitParam(nullptr);
+ addNameHint(context, param, typeParamDecl);
setValue(subContext, typeParamDecl, LoweredValInfo::simple(param));
}
else if (auto valDecl = member.As<GenericValueParamDecl>())
{
auto paramType = lowerType(subContext, valDecl->getType());
auto param = subBuilder->emitParam(paramType);
+ addNameHint(context, param, valDecl);
setValue(subContext, valDecl, LoweredValInfo::simple(param));
}
}
@@ -4092,6 +4184,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// TODO: use a `WitnessTableKind` to represent the
// classifier of the parameter.
auto param = subBuilder->emitParam(nullptr);
+ addNameHint(context, param, constraintDecl);
setValue(subContext, constraintDecl, LoweredValInfo::simple(param));
}
}
@@ -4172,6 +4265,18 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
}
}
+ void addParamNameHint(IRInst* inst, ParameterInfo info)
+ {
+ if(auto decl = info.decl)
+ {
+ addNameHint(context, inst, decl);
+ }
+ else if( info.isThisParam )
+ {
+ addNameHint(context, inst, "this");
+ }
+ }
+
LoweredValInfo lowerFuncDecl(FunctionDeclBase* decl)
{
// We are going to use a nested builder, because we will
@@ -4221,6 +4326,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// need to create an IR function here
IRFunc* irFunc = subBuilder->createFunc();
+ addNameHint(context, irFunc, decl);
setMangledName(irFunc, getMangledName(decl));
@@ -4335,6 +4441,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
subBuilder->addHighLevelDeclDecoration(irParamPtr, paramDecl);
}
+ addParamNameHint(irParamPtr, paramInfo);
paramVal = LoweredValInfo::ptr(irParamPtr);
@@ -4361,6 +4468,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
subBuilder->addHighLevelDeclDecoration(irParam, paramDecl);
}
+ addParamNameHint(irParam, paramInfo);
paramVal = LoweredValInfo::simple(irParam);
//
// HLSL allows a function parameter to be used as a local
@@ -4416,7 +4524,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
// Add the IR parameter for the new value
IRType* irParamType = irResultType;
- subBuilder->emitParam(irParamType);
+ auto irParam = subBuilder->emitParam(irParamType);
+ addNameHint(context, irParam, "newValue");
// TODO: we need some way to wire this up to the `newValue`
// or whatever name we give for that parameter inside
diff --git a/tests/bindings/array-of-struct-of-resource.hlsl b/tests/bindings/array-of-struct-of-resource.hlsl
index 8ba71c7a3..11dcc18da 100644
--- a/tests/bindings/array-of-struct-of-resource.hlsl
+++ b/tests/bindings/array-of-struct-of-resource.hlsl
@@ -27,9 +27,9 @@ float4 main() : SV_Target
#else
-#define a _SV04testL0
-#define b _SV04testL1
-#define s _SV01s
+#define a test_a_0
+#define b test_b_0
+#define s s_0
Texture2D a[2];
Texture2D b[2];
diff --git a/tests/bindings/binding0.hlsl b/tests/bindings/binding0.hlsl
index fcd7e7b54..3e9f92992 100644
--- a/tests/bindings/binding0.hlsl
+++ b/tests/bindings/binding0.hlsl
@@ -9,10 +9,10 @@
#else
#define R(X) X
-#define C _SV022SLANG_parameterGroup_C
-#define t _SV01t
-#define s _SV01s
-#define c _SV022SLANG_ParameterGroup_C1c
+#define C C_0
+#define t t_0
+#define s s_0
+#define c c_0
#endif
diff --git a/tests/bindings/binding1.hlsl b/tests/bindings/binding1.hlsl
index adc06edaa..cc3389d93 100644
--- a/tests/bindings/binding1.hlsl
+++ b/tests/bindings/binding1.hlsl
@@ -16,11 +16,11 @@
#else
#define R(X) X
-#define tB _SV02tB
-#define sB _SV02sB
+#define tB tB_0
+#define sB sB_0
-#define C1 _SV023SLANG_parameterGroup_C1
-#define c1 _SV023SLANG_ParameterGroup_C12c1
+#define C1 C1_0
+#define c1 c1_0
#endif
diff --git a/tests/bindings/explicit-binding.hlsl b/tests/bindings/explicit-binding.hlsl
index 758be959b..b8da9a77a 100644
--- a/tests/bindings/explicit-binding.hlsl
+++ b/tests/bindings/explicit-binding.hlsl
@@ -8,22 +8,22 @@
#else
#define R(X) X
-#define CA _SV023SLANG_parameterGroup_CA
-#define ca _SV023SLANG_ParameterGroup_CA2ca
+#define CA CA_0
+#define ca ca_0
-#define CB _SV023SLANG_parameterGroup_CB
-#define cb _SV023SLANG_ParameterGroup_CB2cb
+#define CB CB_0
+#define cb cb_0
-#define CC _SV023SLANG_parameterGroup_CC
-#define cc _SV023SLANG_ParameterGroup_CC2cc
+#define CC CC_0
+#define cc cc_0
-#define sa _SV02sa
-#define sb _SV02sb
-#define sc _SV02sc
+#define sa sa_0
+#define sb sb_0
+#define sc sc_0
-#define ta _SV02ta
-#define tb _SV02tb
-#define tc _SV02tc
+#define ta ta_0
+#define tb tb_0
+#define tc tc_0
#endif
diff --git a/tests/bindings/glsl-parameter-blocks.slang.glsl b/tests/bindings/glsl-parameter-blocks.slang.glsl
index b65ee0e49..67aca71dc 100644
--- a/tests/bindings/glsl-parameter-blocks.slang.glsl
+++ b/tests/bindings/glsl-parameter-blocks.slang.glsl
@@ -1,12 +1,12 @@
//TEST_IGNORE_FILE:
#version 450 core
-#define Test _ST04Test
-#define a _SV04Test1a
+#define Test Test_0
+#define a a_0
-#define gTest _SV05gTestL0
-#define gTest_t _SV05gTestL1
-#define gTest_s _SV05gTestL2
+#define gTest gTest_0
+#define gTest_t gTest_t_0
+#define gTest_s gTest_s_0
#define ParameterBlock_gTest _S1
diff --git a/tests/bindings/multi-file-extra.hlsl b/tests/bindings/multi-file-extra.hlsl
index 8bf8be414..92227d54a 100644
--- a/tests/bindings/multi-file-extra.hlsl
+++ b/tests/bindings/multi-file-extra.hlsl
@@ -10,34 +10,34 @@
#else
#define R(X) X
-#define sharedC _SV028SLANG_parameterGroup_sharedC
-#define sharedCA _SV028SLANG_ParameterGroup_sharedC8sharedCA
-#define sharedCB _SV028SLANG_ParameterGroup_sharedC8sharedCB
-#define sharedCC _SV028SLANG_ParameterGroup_sharedC8sharedCC
-#define sharedCD _SV028SLANG_ParameterGroup_sharedC8sharedCD
-
-#define vertexC _SV028SLANG_parameterGroup_vertexC
-#define vertexCA _SV028SLANG_ParameterGroup_vertexC8vertexCA
-#define vertexCB _SV028SLANG_ParameterGroup_vertexC8vertexCB
-#define vertexCC _SV028SLANG_ParameterGroup_vertexC8vertexCC
-#define vertexCD _SV028SLANG_ParameterGroup_vertexC8vertexCD
-
-#define fragmentC _SV030SLANG_parameterGroup_fragmentC
-#define fragmentCA _SV030SLANG_ParameterGroup_fragmentC10fragmentCA
-#define fragmentCB _SV030SLANG_ParameterGroup_fragmentC10fragmentCB
-#define fragmentCC _SV030SLANG_ParameterGroup_fragmentC10fragmentCC
-#define fragmentCD _SV030SLANG_ParameterGroup_fragmentC10fragmentCD
-
-#define sharedS _SV07sharedS
-#define sharedT _SV07sharedT
-#define sharedTV _SV08sharedTV
-#define sharedTF _SV08sharedTF
-
-#define vertexS _SV07vertexS
-#define vertexT _SV07vertexT
-
-#define fragmentS _SV09fragmentS
-#define fragmentT _SV09fragmentT
+#define sharedC sharedC_0
+#define sharedCA sharedCA_0
+#define sharedCB sharedCB_0
+#define sharedCC sharedCC_0
+#define sharedCD sharedCD_0
+
+#define vertexC vertexC_0
+#define vertexCA vertexCA_0
+#define vertexCB vertexCB_0
+#define vertexCC vertexCC_0
+#define vertexCD vertexCD_0
+
+#define fragmentC fragmentC_0
+#define fragmentCA fragmentCA_0
+#define fragmentCB fragmentCB_0
+#define fragmentCC fragmentCC_0
+#define fragmentCD fragmentCD_0
+
+#define sharedS sharedS_0
+#define sharedT sharedT_0
+#define sharedTV sharedTV_0
+#define sharedTF sharedTF_0
+
+#define vertexS vertexS_0
+#define vertexT vertexT_0
+
+#define fragmentS fragmentS_0
+#define fragmentT fragmentT_0
#endif
diff --git a/tests/bindings/multi-file.hlsl b/tests/bindings/multi-file.hlsl
index bc00b0f69..992703155 100644
--- a/tests/bindings/multi-file.hlsl
+++ b/tests/bindings/multi-file.hlsl
@@ -11,34 +11,34 @@
#else
#define R(X) X
-#define sharedC _SV028SLANG_parameterGroup_sharedC
-#define sharedCA _SV028SLANG_ParameterGroup_sharedC8sharedCA
-#define sharedCB _SV028SLANG_ParameterGroup_sharedC8sharedCB
-#define sharedCC _SV028SLANG_ParameterGroup_sharedC8sharedCC
-#define sharedCD _SV028SLANG_ParameterGroup_sharedC8sharedCD
-
-#define vertexC _SV028SLANG_parameterGroup_vertexC
-#define vertexCA _SV028SLANG_ParameterGroup_vertexC8vertexCA
-#define vertexCB _SV028SLANG_ParameterGroup_vertexC8vertexCB
-#define vertexCC _SV028SLANG_ParameterGroup_vertexC8vertexCC
-#define vertexCD _SV028SLANG_ParameterGroup_vertexC8vertexCD
-
-#define fragmentC _SV030SLANG_parameterGroup_fragmentC
-#define fragmentCA _SV030SLANG_ParameterGroup_fragmentC10fragmentCA
-#define fragmentCB _SV030SLANG_ParameterGroup_fragmentC10fragmentCB
-#define fragmentCC _SV030SLANG_ParameterGroup_fragmentC10fragmentCC
-#define fragmentCD _SV030SLANG_ParameterGroup_fragmentC10fragmentCD
-
-#define sharedS _SV07sharedS
-#define sharedT _SV07sharedT
-#define sharedTV _SV08sharedTV
-#define sharedTF _SV08sharedTF
-
-#define vertexS _SV07vertexS
-#define vertexT _SV07vertexT
-
-#define fragmentS _SV09fragmentS
-#define fragmentT _SV09fragmentT
+#define sharedC sharedC_0
+#define sharedCA sharedCA_0
+#define sharedCB sharedCB_0
+#define sharedCC sharedCC_0
+#define sharedCD sharedCD_0
+
+#define vertexC vertexC_0
+#define vertexCA vertexCA_0
+#define vertexCB vertexCB_0
+#define vertexCC vertexCC_0
+#define vertexCD vertexCD_0
+
+#define fragmentC fragmentC_0
+#define fragmentCA fragmentCA_0
+#define fragmentCB fragmentCB_0
+#define fragmentCC fragmentCC_0
+#define fragmentCD fragmentCD_0
+
+#define sharedS sharedS_0
+#define sharedT sharedT_0
+#define sharedTV sharedTV_0
+#define sharedTF sharedTF_0
+
+#define vertexS vertexS_0
+#define vertexT vertexT_0
+
+#define fragmentS fragmentS_0
+#define fragmentT fragmentT_0
#endif
diff --git a/tests/bindings/multiple-parameter-blocks.slang b/tests/bindings/multiple-parameter-blocks.slang
index 96a78316a..dee3c60f4 100644
--- a/tests/bindings/multiple-parameter-blocks.slang
+++ b/tests/bindings/multiple-parameter-blocks.slang
@@ -29,20 +29,20 @@ float4 main(float v : V) : SV_Target
#else
-Texture2D _SV01pL0 : register(t0, space0);
-Texture2D _SV01pL1[4] : register(t1, space0);
-SamplerState _SV01pL2 : register(s0, space0);
+Texture2D p_t_0 : register(t0, space0);
+Texture2D p_ta_0[4] : register(t1, space0);
+SamplerState p_s_0 : register(s0, space0);
-Texture2D _SV02p1L0 : register(t0, space1);
-Texture2D _SV02p1L1[4] : register(t1, space1);
-SamplerState _SV02p1L2 : register(s0, space1);
+Texture2D p1_t_0 : register(t0, space1);
+Texture2D p1_ta_0[4] : register(t1, space1);
+SamplerState p1_s_0 : register(s0, space1);
float4 main(float v : V) : SV_TARGET
{
- return use(_SV01pL0, _SV01pL2)
- + use(_SV01pL1[int(v)], _SV01pL2)
- + use(_SV02p1L0, _SV02p1L2)
- + use(_SV02p1L1[int(v)], _SV02p1L2);
+ return use(p_t_0, p_s_0)
+ + use(p_ta_0[int(v)], p_s_0)
+ + use(p1_t_0, p1_s_0)
+ + use(p1_ta_0[int(v)], p1_s_0);
}
#endif
diff --git a/tests/bindings/packoffset.hlsl b/tests/bindings/packoffset.hlsl
index 5b8650a9b..f912e76d8 100644
--- a/tests/bindings/packoffset.hlsl
+++ b/tests/bindings/packoffset.hlsl
@@ -8,15 +8,15 @@
#else
#define R(X) X
-#define CA _SV023SLANG_parameterGroup_CAL0
-#define ca _SV023SLANG_ParameterGroup_CA2ca
-#define cb _SV023SLANG_ParameterGroup_CA2cb
-#define cc _SV023SLANG_ParameterGroup_CA2cc
-#define cd _SV023SLANG_ParameterGroup_CA2cd
-#define ce _SV023SLANG_ParameterGroup_CA2ce
-
-#define ta _SV023SLANG_parameterGroup_CAL1
-#define sa _SV023SLANG_parameterGroup_CAL2
+#define CA CA_0
+#define ca ca_0
+#define cb cb_0
+#define cc cc_0
+#define cd cd_0
+#define ce ce_0
+
+#define ta CA_ta_0
+#define sa CA_sa_0
#endif
diff --git a/tests/bindings/parameter-blocks.slang b/tests/bindings/parameter-blocks.slang
index 62503e49b..756a6ec1a 100644
--- a/tests/bindings/parameter-blocks.slang
+++ b/tests/bindings/parameter-blocks.slang
@@ -26,9 +26,9 @@ float4 main(float v : V) : SV_Target
#else
-#define t _SV01pL0
-#define ta _SV01pL1
-#define s _SV01pL2
+#define t p_t_0
+#define ta p_ta_0
+#define s p_s_0
Texture2D t : register(t0, space0);
Texture2D ta[4] : register(t1, space0);
diff --git a/tests/bindings/resources-in-cbuffer.hlsl b/tests/bindings/resources-in-cbuffer.hlsl
index 5706bd39c..e3dcfc28e 100644
--- a/tests/bindings/resources-in-cbuffer.hlsl
+++ b/tests/bindings/resources-in-cbuffer.hlsl
@@ -9,34 +9,34 @@
#else
#define R(X) X
-#define CA _SV023SLANG_parameterGroup_CAL0
-#define caa _SV023SLANG_ParameterGroup_CA3caa
-#define cab _SV023SLANG_ParameterGroup_CA3cab
-#define cac _SV023SLANG_ParameterGroup_CA3cac
-#define cad _SV023SLANG_ParameterGroup_CA3cad
-#define cae _SV023SLANG_ParameterGroup_CA3cae
-#define ta _SV023SLANG_parameterGroup_CAL1
-#define sa _SV023SLANG_parameterGroup_CAL2
+#define CA CA_0
+#define caa caa_0
+#define cab cab_0
+#define cac cac_0
+#define cad cad_0
+#define cae cae_0
+#define ta CA_ta_0
+#define sa CA_sa_0
-#define CB _SV023SLANG_parameterGroup_CBL0
-#define cba _SV023SLANG_ParameterGroup_CB3cba
-#define cbb _SV023SLANG_ParameterGroup_CB3cbb
-#define cbc _SV023SLANG_ParameterGroup_CB3cbc
-#define cbd _SV023SLANG_ParameterGroup_CB3cbd
-#define cbe _SV023SLANG_ParameterGroup_CB3cbe
-#define tbx _SV023SLANG_parameterGroup_CBL1
-#define tby _SV023SLANG_parameterGroup_CBL2
-#define sb _SV023SLANG_parameterGroup_CBL3
+#define CB CB_0
+#define cba cba_0
+#define cbb cbb_0
+#define cbc cbc_0
+#define cbd cbd_0
+#define cbe cbe_0
+#define tbx CB_tbx_0
+#define tby CB_tby_0
+#define sb CB_sb_0
-#define CC _SV023SLANG_parameterGroup_CCL0
-#define cca _SV023SLANG_ParameterGroup_CC3cca
-#define ccb _SV023SLANG_ParameterGroup_CC3ccb
-#define ccc _SV023SLANG_ParameterGroup_CC3ccc
-#define ccd _SV023SLANG_ParameterGroup_CC3ccd
-#define cce _SV023SLANG_ParameterGroup_CC3cce
-#define tc _SV023SLANG_parameterGroup_CCL1
-#define scx _SV023SLANG_parameterGroup_CCL2
-#define scy _SV023SLANG_parameterGroup_CCL3
+#define CC CC_0
+#define cca cca_0
+#define ccb ccb_0
+#define ccc ccc_0
+#define ccd ccd_0
+#define cce cce_0
+#define tc CC_tc_0
+#define scx CC_scx_0
+#define scy CC_scy_0
#endif
diff --git a/tests/bindings/targets-and-uavs-structure.hlsl b/tests/bindings/targets-and-uavs-structure.hlsl
index 359083069..3c7499cf5 100644
--- a/tests/bindings/targets-and-uavs-structure.hlsl
+++ b/tests/bindings/targets-and-uavs-structure.hlsl
@@ -8,9 +8,9 @@
#else
#define R(X) X
-#define Foo _ST03Foo
-#define v _SV03Foo1v
-#define fooBuffer _SV09fooBuffer
+#define Foo Foo_0
+#define v v_0
+#define fooBuffer fooBuffer_0
#endif
diff --git a/tests/bindings/targets-and-uavs.hlsl b/tests/bindings/targets-and-uavs.hlsl
index 24efa418c..7c6389e36 100644
--- a/tests/bindings/targets-and-uavs.hlsl
+++ b/tests/bindings/targets-and-uavs.hlsl
@@ -10,9 +10,9 @@
#else
#define R(X) X
-#define Foo _ST03Foo
-#define v _SV03Foo1v
-#define fooBuffer _SV09fooBuffer
+#define Foo Foo_0
+#define v v_0
+#define fooBuffer fooBuffer_0
#endif
diff --git a/tests/bugs/gh-103.slang b/tests/bugs/gh-103.slang
index 5d271d508..65e71837b 100644
--- a/tests/bugs/gh-103.slang
+++ b/tests/bugs/gh-103.slang
@@ -3,9 +3,9 @@
// Ensure that matrix-times-scalar works
#ifndef __SLANG__
-#define C _SV022SLANG_parameterGroup_C
-#define a _SV022SLANG_ParameterGroup_C1a
-#define b _SV022SLANG_ParameterGroup_C1b
+#define C C_0
+#define a a_0
+#define b b_0
#endif
float4x4 doIt(float4x4 a, float b)
diff --git a/tests/bugs/gh-333.slang b/tests/bugs/gh-333.slang
index 5a0a5769f..2a23f7751 100644
--- a/tests/bugs/gh-333.slang
+++ b/tests/bugs/gh-333.slang
@@ -3,13 +3,13 @@
// Ensure declaration order in output is correct
#ifndef __SLANG__
-#define A _ST01A
-#define x _SV01A1x
-#define B _ST01B
-#define y _SV01B1y
-#define C _SV022SLANG_parameterGroup_CL0
-#define a _SV022SLANG_ParameterGroup_C1a
-#define b _SV022SLANG_ParameterGroup_C1b
+#define A A_0
+#define x x_0
+#define B B_0
+#define y y_0
+#define C C_0
+#define a a_0
+#define b b_0
#endif
struct A
diff --git a/tests/bugs/split-nested-types.hlsl b/tests/bugs/split-nested-types.hlsl
index 8216a4e36..dc8756ba2 100644
--- a/tests/bugs/split-nested-types.hlsl
+++ b/tests/bugs/split-nested-types.hlsl
@@ -4,18 +4,18 @@
import split_nested_types;
#else
-#define A _ST01A
-#define x _SV01A1x
+#define A A_0
+#define x x_0
-#define B _ST01B
-#define y _SV01B1y
+#define B B_0
+#define y y_0
-#define M _ST01M
-#define a _SV01M1a
-#define b _SV01M1b
+#define M M_0
+#define a a_0
+#define b b_0
-#define C _SV022SLANG_parameterGroup_CL0
-#define m _SV022SLANG_ParameterGroup_C1m
+#define C C_0
+#define m m_0
struct A { int x; };
diff --git a/tests/bugs/vec-init-list.hlsl b/tests/bugs/vec-init-list.hlsl
index d9d0b83f9..d957548e6 100644
--- a/tests/bugs/vec-init-list.hlsl
+++ b/tests/bugs/vec-init-list.hlsl
@@ -4,8 +4,8 @@
#ifndef __SLANG__
-#define C _SV022SLANG_parameterGroup_C
-#define a _SV022SLANG_ParameterGroup_C1a
+#define C C_0
+#define a a_0
#define SV_Position SV_POSITION
#endif
diff --git a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl
index 7b7b285b7..0a3209343 100644
--- a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl
+++ b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl
@@ -1,8 +1,8 @@
//TEST(smoke):COMPARE_HLSL:-no-mangle -profile vs_4_0 -entry RenderBaseVS -profile ps_4_0 -entry RenderPS -target dxbc-assembly
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
#endif
diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl
index 97b8b6c7e..c446b3493 100644
--- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl
+++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl
@@ -1,11 +1,11 @@
//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry PSMain
#ifndef __SLANG__
-#define cbPerFrame _SV031SLANG_parameterGroup_cbPerFrame
-#define g_vLightDir _SV031SLANG_ParameterGroup_cbPerFrame11g_vLightDir
-#define g_fAmbient _SV031SLANG_ParameterGroup_cbPerFrame10g_fAmbient
-#define g_samLinear _SV011g_samLinear
-#define g_txDiffuse _SV011g_txDiffuse
+#define cbPerFrame cbPerFrame_0
+#define g_vLightDir g_vLightDir_0
+#define g_fAmbient g_fAmbient_0
+#define g_samLinear g_samLinear_0
+#define g_txDiffuse g_txDiffuse_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl
index fa5a7e0b4..8ff5e64d7 100644
--- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl
+++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl
@@ -1,9 +1,9 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
-#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
+#define g_mWorld g_mWorld_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl
index e9175834a..5e2cfacf8 100644
--- a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl
+++ b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl
@@ -1,8 +1,8 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain -entry VSMainPancake
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl
index 7421c8aa7..ecbcb85f9 100644
--- a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl
+++ b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl
@@ -1,9 +1,9 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
-#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
+#define g_mWorld g_mWorld_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl
index 464bb4c8a..3f1d90bfd 100644
--- a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl
+++ b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl
@@ -1,10 +1,10 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld
-#define cbPerScene _SV031SLANG_parameterGroup_cbPerScene
-#define g_mViewProj _SV031SLANG_ParameterGroup_cbPerScene11g_mViewProj
+#define cbPerObject cbPerObject_0
+#define g_mWorld g_mWorld_0
+#define cbPerScene cbPerScene_0
+#define g_mViewProj g_mViewProj_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl
index a6b971a57..6f96938ed 100644
--- a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl
+++ b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl
@@ -1,8 +1,8 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry SceneVS
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
#endif
//-----------------------------------------------------------------------------
diff --git a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl
index e80360754..744e16d0e 100644
--- a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl
+++ b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl
@@ -1,8 +1,8 @@
//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain -profile ps_4_0 -entry PSMain
#ifndef __SLANG__
-#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject
-#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection
+#define cbPerObject cbPerObject_0
+#define g_mWorldViewProjection g_mWorldViewProjection_0
#endif
//--------------------------------------------------------------------------------------
diff --git a/tests/hlsl/simple/allow-uav-conditional.hlsl b/tests/hlsl/simple/allow-uav-conditional.hlsl
index 3f12c9be8..8195a9f1d 100644
--- a/tests/hlsl/simple/allow-uav-conditional.hlsl
+++ b/tests/hlsl/simple/allow-uav-conditional.hlsl
@@ -3,7 +3,7 @@
// Check output for `[allow_uav_conditional]`
#ifndef __SLANG__
-#define gBuffer _SV07gBuffer
+#define gBuffer gBuffer_0
#endif
RWStructuredBuffer<uint> gBuffer : register(u0);
diff --git a/tests/hlsl/simple/compute-numthreads.hlsl b/tests/hlsl/simple/compute-numthreads.hlsl
index 4f3291671..805c960c4 100644
--- a/tests/hlsl/simple/compute-numthreads.hlsl
+++ b/tests/hlsl/simple/compute-numthreads.hlsl
@@ -3,7 +3,7 @@
// Confirm that we properly pass along the `numthreads` attribute on an entry point.
#ifndef __SLANG__
-#define b _SV01b
+#define b b_0
#endif
RWStructuredBuffer<float> b;
diff --git a/tests/hlsl/simple/literal-typing.hlsl b/tests/hlsl/simple/literal-typing.hlsl
index 48ea5b2cb..0ecf60506 100644
--- a/tests/hlsl/simple/literal-typing.hlsl
+++ b/tests/hlsl/simple/literal-typing.hlsl
@@ -18,7 +18,7 @@ Bad foo(int x) { Bad b; b.bad = x; return b; }
// or ignore it and call the wrong one.
#ifndef __SLANG__
-#define b _SV01b
+#define b b_0
#endif
RWStructuredBuffer<uint> b;
diff --git a/tests/parser/cast-precedence.hlsl b/tests/parser/cast-precedence.hlsl
index 33cb5983c..3383d9912 100644
--- a/tests/parser/cast-precedence.hlsl
+++ b/tests/parser/cast-precedence.hlsl
@@ -4,9 +4,9 @@
// the appropriate precedence.
#ifndef __SLANG__
-#define C _SV022SLANG_parameterGroup_C
-#define a _SV022SLANG_ParameterGroup_C1a
-#define b _SV022SLANG_ParameterGroup_C1b
+#define C C_0
+#define a a_0
+#define b b_0
#define SV_Position SV_POSITION
#endif