summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-23 10:54:01 -0700
committerGitHub <noreply@github.com>2024-03-23 10:54:01 -0700
commita23adc221b1ea26db3f3313226b629eb9e308b0f (patch)
tree6f758d64201f2c606dc3e61394899bff4fa72f51
parent9b0df14cdf9d9ea8857b5b9d59505b18020f8414 (diff)
Make `-no-mangle` option work, add `-no-hlsl-binding`. (#3817)
-rw-r--r--slang.h1
-rw-r--r--source/slang/slang-check-decl.cpp8
-rw-r--r--source/slang/slang-emit-hlsl.cpp26
-rw-r--r--source/slang/slang-emit-hlsl.h6
-rw-r--r--source/slang/slang-ir-inst-defs.h2
-rw-r--r--source/slang/slang-ir-insts.h5
-rw-r--r--source/slang/slang-lower-to-ir.cpp5
-rw-r--r--source/slang/slang-options.cpp3
-rw-r--r--source/slang/slang-parser.cpp17
-rw-r--r--tests/bindings/array-of-struct-of-resource.hlsl2
-rw-r--r--tests/bindings/binding0.hlsl2
-rw-r--r--tests/bindings/binding1.hlsl2
-rw-r--r--tests/bindings/explicit-binding.hlsl2
-rw-r--r--tests/bindings/multi-file.hlsl2
-rw-r--r--tests/bindings/parameter-blocks.slang2
-rw-r--r--tests/bindings/resources-in-cbuffer.hlsl2
-rw-r--r--tests/bindings/targets-and-uavs-structure.hlsl2
-rw-r--r--tests/bindings/targets-and-uavs.hlsl2
-rw-r--r--tests/bugs/gh-103.slang2
-rw-r--r--tests/bugs/gh-333.slang2
-rw-r--r--tests/bugs/gh-666.slang2
-rw-r--r--tests/bugs/split-nested-types.hlsl2
-rw-r--r--tests/hlsl/simple/allow-uav-conditional.hlsl4
-rw-r--r--tests/hlsl/simple/compute-numthreads.hlsl2
-rw-r--r--tests/hlsl/simple/implicit_conversion.hlsl2
-rw-r--r--tests/hlsl/simple/literal-typing.hlsl2
-rw-r--r--tests/hlsl/simple/rw-texture.hlsl2
-rw-r--r--tests/language-feature/no-hlsl-binding.slang21
-rw-r--r--tests/language-feature/no-mangle.slang27
-rw-r--r--tests/rewriter/varying-struct.vert2
30 files changed, 127 insertions, 34 deletions
diff --git a/slang.h b/slang.h
index 28835f713..e31de7656 100644
--- a/slang.h
+++ b/slang.h
@@ -925,6 +925,7 @@ extern "C"
FileSystem,
Heterogeneous,
NoMangle,
+ NoHLSLBinding,
ValidateUniformity,
AllowGLSL,
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 093e2599f..c117dbc14 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1772,7 +1772,13 @@ namespace Slang
parentAggTypeDecl->unionTagsWith(getTypeTags(varDeclRefType));
}
}
-
+ if (getOptionSet().getBoolOption(CompilerOptionName::NoMangle) &&
+ isGlobalDecl(varDecl))
+ {
+ // If -no-mangle option is set, we will add `ExternCpp` modifier to all
+ // global variables and struct fields to prevent mangling.
+ addModifier(varDecl, m_astBuilder->create<ExternCppModifier>());
+ }
checkVisibility(varDecl);
}
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 3d45394d3..92866f9c4 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -37,7 +37,7 @@ void HLSLSourceEmitter::_emitHLSLDecorationSingleInt(const char* name, IRFunc* e
m_writer->emit(")]\n");
}
-void HLSLSourceEmitter::_emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitVarChain* chain, char const* uniformSemanticSpelling)
+void HLSLSourceEmitter::_emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitVarChain* chain, IRInst* inst, char const* uniformSemanticSpelling)
{
if (!chain)
return;
@@ -100,6 +100,16 @@ void HLSLSourceEmitter::_emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitV
break;
default:
{
+ if (m_codeGenContext->getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::NoHLSLBinding))
+ {
+ // If we are told not to emit hlsl binding, and the user has not provided explicit binding,
+ // then skip emitting the `: register` semantics here.
+ //
+ if (!inst || !inst->findDecoration<IRHasExplicitHLSLBindingDecoration>())
+ {
+ break;
+ }
+ }
m_writer->emit(" : register(");
switch (kind)
{
@@ -130,7 +140,7 @@ void HLSLSourceEmitter::_emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitV
}
}
-void HLSLSourceEmitter::_emitHLSLRegisterSemantics(EmitVarChain* chain, char const* uniformSemanticSpelling)
+void HLSLSourceEmitter::_emitHLSLRegisterSemantics(EmitVarChain* chain, IRInst* inst, char const* uniformSemanticSpelling)
{
if (!chain) return;
@@ -147,17 +157,17 @@ void HLSLSourceEmitter::_emitHLSLRegisterSemantics(EmitVarChain* chain, char con
for (auto rr : layout->getOffsetAttrs())
{
- _emitHLSLRegisterSemantic(rr->getResourceKind(), chain, uniformSemanticSpelling);
+ _emitHLSLRegisterSemantic(rr->getResourceKind(), chain, inst, uniformSemanticSpelling);
}
}
-void HLSLSourceEmitter::_emitHLSLRegisterSemantics(IRVarLayout* varLayout, char const* uniformSemanticSpelling)
+void HLSLSourceEmitter::_emitHLSLRegisterSemantics(IRVarLayout* varLayout, IRInst* inst, char const* uniformSemanticSpelling)
{
if (!varLayout)
return;
EmitVarChain chain(varLayout);
- _emitHLSLRegisterSemantics(&chain, uniformSemanticSpelling);
+ _emitHLSLRegisterSemantics(&chain, inst, uniformSemanticSpelling);
}
void HLSLSourceEmitter::_emitHLSLParameterGroupFieldLayoutSemantics(EmitVarChain* chain)
@@ -168,7 +178,7 @@ void HLSLSourceEmitter::_emitHLSLParameterGroupFieldLayoutSemantics(EmitVarChain
auto layout = chain->varLayout;
for (auto rr : layout->getOffsetAttrs())
{
- _emitHLSLRegisterSemantic(rr->getResourceKind(), chain, "packoffset");
+ _emitHLSLRegisterSemantic(rr->getResourceKind(), chain, nullptr, "packoffset");
}
}
@@ -207,7 +217,7 @@ void HLSLSourceEmitter::_emitHLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor
typeLayout = parameterGroupTypeLayout->getElementVarLayout()->getTypeLayout();
}
- _emitHLSLRegisterSemantic(LayoutResourceKind::ConstantBuffer, &containerChain);
+ _emitHLSLRegisterSemantic(LayoutResourceKind::ConstantBuffer, &containerChain, varDecl);
auto elementType = type->getElementType();
if (hasExplicitConstantBufferOffset(type))
@@ -299,7 +309,7 @@ void HLSLSourceEmitter::emitLayoutSemanticsImpl(IRInst* inst, char const* unifor
auto layout = getVarLayout(inst);
if (layout)
{
- _emitHLSLRegisterSemantics(layout, uniformSemanticSpelling);
+ _emitHLSLRegisterSemantics(layout, inst, uniformSemanticSpelling);
}
}
diff --git a/source/slang/slang-emit-hlsl.h b/source/slang/slang-emit-hlsl.h
index 707667e90..049d8af65 100644
--- a/source/slang/slang-emit-hlsl.h
+++ b/source/slang/slang-emit-hlsl.h
@@ -66,11 +66,11 @@ protected:
// Emit a single `register` semantic, as appropriate for a given resource-type-specific layout info
// Keyword to use in the uniform case (`register` for globals, `packoffset` inside a `cbuffer`)
- void _emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitVarChain* chain, char const* uniformSemanticSpelling = "register");
+ void _emitHLSLRegisterSemantic(LayoutResourceKind kind, EmitVarChain* chain, IRInst* inst, char const* uniformSemanticSpelling = "register");
// Emit all the `register` semantics that are appropriate for a particular variable layout
- void _emitHLSLRegisterSemantics(EmitVarChain* chain, char const* uniformSemanticSpelling = "register");
- void _emitHLSLRegisterSemantics(IRVarLayout* varLayout, char const* uniformSemanticSpelling = "register");
+ void _emitHLSLRegisterSemantics(EmitVarChain* chain, IRInst* inst, char const* uniformSemanticSpelling = "register");
+ void _emitHLSLRegisterSemantics(IRVarLayout* varLayout, IRInst* inst, char const* uniformSemanticSpelling = "register");
void _emitHLSLParameterGroupFieldLayoutSemantics(EmitVarChain* chain);
void _emitHLSLParameterGroupFieldLayoutSemantics(IRVarLayout* fieldLayout, EmitVarChain* inChain);
diff --git a/source/slang/slang-ir-inst-defs.h b/source/slang/slang-ir-inst-defs.h
index 10df5d0d7..63f063154 100644
--- a/source/slang/slang-ir-inst-defs.h
+++ b/source/slang/slang-ir-inst-defs.h
@@ -714,6 +714,8 @@ INST(HighLevelDeclDecoration, highLevelDecl, 1, 0)
INST(RequireGLSLExtensionDecoration, requireGLSLExtension, 1, 0)
INST(RequireCUDASMVersionDecoration, requireCUDASMVersion, 1, 0)
+ INST(HasExplicitHLSLBindingDecoration, HasExplicitHLSLBinding, 0, 0)
+
INST(ReadNoneDecoration, readNone, 0, 0)
INST(VulkanCallablePayloadDecoration, vulkanCallablePayload, 0, 0)
INST(VulkanCallablePayloadInDecoration, vulkanCallablePayloadIn, 0, 0)
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index b104baca7..36f9159a8 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -349,6 +349,7 @@ struct IRRequireGLSLExtensionDecoration : IRDecoration
}
};
+IR_SIMPLE_DECORATION(HasExplicitHLSLBindingDecoration)
IR_SIMPLE_DECORATION(ReadNoneDecoration)
IR_SIMPLE_DECORATION(NoSideEffectDecoration)
IR_SIMPLE_DECORATION(EarlyDepthStencilDecoration)
@@ -4652,6 +4653,10 @@ public:
{
addDecoration(value, kIROp_HLSLExportDecoration);
}
+ void addHasExplicitHLSLBindingDecoration(IRInst* value)
+ {
+ addDecoration(value, kIROp_HasExplicitHLSLBindingDecoration);
+ }
void addNVAPIMagicDecoration(IRInst* value, UnownedStringSlice const& name)
{
addDecoration(value, kIROp_NVAPIMagicDecoration, getStringValue(name));
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 5a3b0c2c5..3dd8da9f1 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -7626,7 +7626,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
}
addTargetIntrinsicDecorations(nullptr, irParam, decl);
-
+ if (decl->findModifier<HLSLLayoutSemantic>())
+ {
+ builder->addHasExplicitHLSLBindingDecoration(irParam);
+ }
// A global variable's SSA value is a *pointer* to
// the underlying storage.
context->setGlobalValue(decl, paramVal);
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 3d0b22edd..e3ccec36a 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -517,6 +517,8 @@ void initCommandOptions(CommandOptions& options)
"Set the filesystem hook to use for a compile request."},
{ OptionKind::Heterogeneous, "-heterogeneous", nullptr, "Output heterogeneity-related code." },
{ OptionKind::NoMangle, "-no-mangle", nullptr, "Do as little mangling of names as possible." },
+ { OptionKind::NoHLSLBinding, "-no-hlsl-binding", nullptr, "Do not include explicit parameter binding semantics in the output HLSL code,"
+ "except for parameters that has explicit bindings in the input source." },
{ OptionKind::ValidateUniformity, "-validate-uniformity", nullptr, "Perform uniformity validation analysis." },
{ OptionKind::AllowGLSL, "-allow-glsl", nullptr, "Enable GLSL as an input language." },
};
@@ -1694,6 +1696,7 @@ SlangResult OptionsParser::_parse(
case OptionKind::PreprocessorOutput:
case OptionKind::DumpAst:
case OptionKind::IncompleteLibrary:
+ case OptionKind::NoHLSLBinding:
linkage->m_optionSet.set(optionKind, true); break;
break;
case OptionKind::NoCodeGen:
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index d64329add..4522f977d 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -84,6 +84,7 @@ namespace Slang
bool enableEffectAnnotations = false;
bool allowGLSLInput = false;
bool isInLanguageServer = false;
+ CompilerOptionSet optionSet;
};
// TODO: implement two pass parsing for file reference and struct type recognition
@@ -3207,7 +3208,20 @@ namespace Slang
else
{
// Otherwise, we need to generate a name for the buffer variable.
- bufferVarDecl->nameAndLoc.name = generateName(parser, "parameterGroup_" + String(reflectionNameToken.getContent()));
+ if (parser->options.optionSet.getBoolOption(CompilerOptionName::NoMangle))
+ {
+ // If no-mangle option is set, use the reflection name as the variable name,
+ // and mark all members of the buffer object as no mangle.
+ bufferVarDecl->nameAndLoc.name = reflectionNameToken.getName();
+ for (auto m : bufferDataTypeDecl->getMembersOfType<VarDecl>())
+ {
+ addModifier(m, parser->astBuilder->create<ExternCppModifier>());
+ }
+ }
+ else
+ {
+ bufferVarDecl->nameAndLoc.name = generateName(parser, "parameterGroup_" + String(reflectionNameToken.getContent()));
+ }
// We also need to make the declaration "transparent" so that their
// members are implicitly made visible in the parent scope.
@@ -7546,6 +7560,7 @@ namespace Slang
translationUnit->compileRequest->optionSet.getBoolOption(CompilerOptionName::AllowGLSL) ||
sourceLanguage == SourceLanguage::GLSL;
options.isInLanguageServer = translationUnit->compileRequest->getLinkage()->isInLanguageServer();
+ options.optionSet = translationUnit->compileRequest->optionSet;
Parser parser(astBuilder, tokens, sink, outerScope, options);
parser.namePool = translationUnit->getNamePool();
diff --git a/tests/bindings/array-of-struct-of-resource.hlsl b/tests/bindings/array-of-struct-of-resource.hlsl
index 240ffed73..393ff4ec2 100644
--- a/tests/bindings/array-of-struct-of-resource.hlsl
+++ b/tests/bindings/array-of-struct-of-resource.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_1 -entry main
+//TEST:COMPARE_HLSL: -profile ps_5_1 -entry main
// Let's first confirm that Slang can reproduce what the
// HLSL compiler would already do in the simple case (when
diff --git a/tests/bindings/binding0.hlsl b/tests/bindings/binding0.hlsl
index 2ae40ead3..5e74b44cd 100644
--- a/tests/bindings/binding0.hlsl
+++ b/tests/bindings/binding0.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main
// Let's first confirm that Slang can reproduce what the
// HLSL compiler would already do in the simple case (when
diff --git a/tests/bindings/binding1.hlsl b/tests/bindings/binding1.hlsl
index 47ab22bb9..957d9614c 100644
--- a/tests/bindings/binding1.hlsl
+++ b/tests/bindings/binding1.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main
// We want to make sure that the registers Slang generates
// are used, even if there are "dead" parameter earlier in the program.
diff --git a/tests/bindings/explicit-binding.hlsl b/tests/bindings/explicit-binding.hlsl
index 420eafec1..d58e232e9 100644
--- a/tests/bindings/explicit-binding.hlsl
+++ b/tests/bindings/explicit-binding.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main
// We need to allow the user to add explicit bindings to their parameters,
// and we can't go and auto-assign anything to use the same locations.
diff --git a/tests/bindings/multi-file.hlsl b/tests/bindings/multi-file.hlsl
index 1bf025d9c..bc05d6338 100644
--- a/tests/bindings/multi-file.hlsl
+++ b/tests/bindings/multi-file.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile sm_4_0 -entry main1 -stage vertex Tests/bindings/multi-file-extra.hlsl -entry main -stage fragment
+//TEST:COMPARE_HLSL: -profile sm_4_0 -entry main1 -stage vertex Tests/bindings/multi-file-extra.hlsl -entry main -stage fragment
// Here we are going to test that we can correctly generating bindings when we
// are presented with a program spanning multiple input files (and multiple entry points)
diff --git a/tests/bindings/parameter-blocks.slang b/tests/bindings/parameter-blocks.slang
index 6941ce77c..2e5bc908e 100644
--- a/tests/bindings/parameter-blocks.slang
+++ b/tests/bindings/parameter-blocks.slang
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces
+//TEST:COMPARE_HLSL: -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces
// Confirm that Slang `ParameterBlock<T>` generates
// parameter bindings like we expect.
diff --git a/tests/bindings/resources-in-cbuffer.hlsl b/tests/bindings/resources-in-cbuffer.hlsl
index 71eaf40aa..e52c20e06 100644
--- a/tests/bindings/resources-in-cbuffer.hlsl
+++ b/tests/bindings/resources-in-cbuffer.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main
// Confirm that resources inside constant buffers get correct locations,
// including the case where there are *multiple* constant buffers
diff --git a/tests/bindings/targets-and-uavs-structure.hlsl b/tests/bindings/targets-and-uavs-structure.hlsl
index dd860369d..7f5ca2b80 100644
--- a/tests/bindings/targets-and-uavs-structure.hlsl
+++ b/tests/bindings/targets-and-uavs-structure.hlsl
@@ -1,4 +1,4 @@
-//TEST(smoke):COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+//TEST(smoke):COMPARE_HLSL: -profile ps_5_0 -entry main
// Handle the case where the fragment shader output is
// defined a structure, and the semantics are on the sub-fields
diff --git a/tests/bindings/targets-and-uavs.hlsl b/tests/bindings/targets-and-uavs.hlsl
index ac64c8f5f..c56e1151d 100644
--- a/tests/bindings/targets-and-uavs.hlsl
+++ b/tests/bindings/targets-and-uavs.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main
// Render target outputs (`SV_Target`) and UAVs are treated
// as sharing the same binding slots in HLSL, so we need to
diff --git a/tests/bugs/gh-103.slang b/tests/bugs/gh-103.slang
index 4bad20b20..a0992463d 100644
--- a/tests/bugs/gh-103.slang
+++ b/tests/bugs/gh-103.slang
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_4_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_4_0 -entry main
// Ensure that matrix-times-scalar works
diff --git a/tests/bugs/gh-333.slang b/tests/bugs/gh-333.slang
index a1e3ea20d..b3ecf9204 100644
--- a/tests/bugs/gh-333.slang
+++ b/tests/bugs/gh-333.slang
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main
// Ensure declaration order in output is correct
diff --git a/tests/bugs/gh-666.slang b/tests/bugs/gh-666.slang
index fa46d1de7..ff891d794 100644
--- a/tests/bugs/gh-666.slang
+++ b/tests/bugs/gh-666.slang
@@ -1,6 +1,6 @@
// gh-666.slang
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main
static const uint foo = 1;
static const uint bar = foo;
diff --git a/tests/bugs/split-nested-types.hlsl b/tests/bugs/split-nested-types.hlsl
index 2bfea49c2..723e6d414 100644
--- a/tests/bugs/split-nested-types.hlsl
+++ b/tests/bugs/split-nested-types.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0
+//TEST:COMPARE_HLSL: -profile ps_5_0
#ifdef __SLANG__
diff --git a/tests/hlsl/simple/allow-uav-conditional.hlsl b/tests/hlsl/simple/allow-uav-conditional.hlsl
index b9780e97d..c75e42280 100644
--- a/tests/hlsl/simple/allow-uav-conditional.hlsl
+++ b/tests/hlsl/simple/allow-uav-conditional.hlsl
@@ -1,5 +1,5 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile cs_5_0
-//TEST:COMPARE_HLSL:-no-mangle -profile cs_5_0 -verify-debug-serial-ir
+//TEST:COMPARE_HLSL: -profile cs_5_0
+//TEST:COMPARE_HLSL: -profile cs_5_0 -verify-debug-serial-ir
// Check output for `[allow_uav_conditional]`
diff --git a/tests/hlsl/simple/compute-numthreads.hlsl b/tests/hlsl/simple/compute-numthreads.hlsl
index 34d9bfd4f..3c0d8e57b 100644
--- a/tests/hlsl/simple/compute-numthreads.hlsl
+++ b/tests/hlsl/simple/compute-numthreads.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile cs_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile cs_5_0 -entry main
// Confirm that we properly pass along the `numthreads` attribute on an entry point.
diff --git a/tests/hlsl/simple/implicit_conversion.hlsl b/tests/hlsl/simple/implicit_conversion.hlsl
index 2a3700e62..36738ea45 100644
--- a/tests/hlsl/simple/implicit_conversion.hlsl
+++ b/tests/hlsl/simple/implicit_conversion.hlsl
@@ -1,4 +1,4 @@
-//TEST_DISABLED:COMPARE_HLSL:-no-mangle -profile cs_5_0 -entry main
+//TEST_DISABLED:COMPARE_HLSL: -profile cs_5_0 -entry main
// Test various cases of implicit type conversion and preference
// for overload resolution.
diff --git a/tests/hlsl/simple/literal-typing.hlsl b/tests/hlsl/simple/literal-typing.hlsl
index 6c003eb21..51e58201b 100644
--- a/tests/hlsl/simple/literal-typing.hlsl
+++ b/tests/hlsl/simple/literal-typing.hlsl
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -profile cs_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile cs_5_0 -entry main
// Confirm that we get the typing of literal suffixes correct
diff --git a/tests/hlsl/simple/rw-texture.hlsl b/tests/hlsl/simple/rw-texture.hlsl
index 114d9e126..af2f5a183 100644
--- a/tests/hlsl/simple/rw-texture.hlsl
+++ b/tests/hlsl/simple/rw-texture.hlsl
@@ -1,6 +1,6 @@
// rw-texture.hlsl
-//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+//TEST:COMPARE_HLSL: -profile ps_5_0 -entry main
// Ensure that we implement the `Load` operations on
// `RWTexture*` types with the correct signature.
diff --git a/tests/language-feature/no-hlsl-binding.slang b/tests/language-feature/no-hlsl-binding.slang
new file mode 100644
index 000000000..57f0449f9
--- /dev/null
+++ b/tests/language-feature/no-hlsl-binding.slang
@@ -0,0 +1,21 @@
+//TEST:SIMPLE(filecheck=CHECK):-target hlsl -entry main -profile cs_6_0 -no-mangle -no-hlsl-binding
+
+// Test that -no-hlsl-binding option disables automatically assigned bindings in the hlsl output.
+
+// CHECK-DAG: cbuffer {{.*}} : register(b3)
+cbuffer MyCB : register(b3)
+{
+ int member;
+}
+
+// CHECK-DAG: RWStructuredBuffer<float > outputBuffer : register(u2);
+RWStructuredBuffer<float> outputBuffer : register(u2);
+
+// CHECK-DAG: RWStructuredBuffer<int > inputBuffer;
+RWStructuredBuffer<int> inputBuffer;
+
+[numthreads(1,1,1)]
+void main()
+{
+ outputBuffer[0] = inputBuffer[0] + member;
+}
diff --git a/tests/language-feature/no-mangle.slang b/tests/language-feature/no-mangle.slang
new file mode 100644
index 000000000..11462ef26
--- /dev/null
+++ b/tests/language-feature/no-mangle.slang
@@ -0,0 +1,27 @@
+//TEST:SIMPLE(filecheck=CHECK):-target hlsl -entry main -profile cs_6_0 -no-mangle
+
+// Test that -no-mangle option disables name mangling on global parameters and struct fields.
+
+cbuffer BufferName
+{
+ int cbufferParam;
+}
+
+struct MyStruct
+{
+ int v;
+}
+
+RWStructuredBuffer<MyStruct> outputBuffer;
+
+// CHECK-DAG: SLANG_ParameterGroup_BufferName{{.*}} BufferName;
+
+// CHECK-DAG: RWStructuredBuffer<{{.*}}> outputBuffer :
+
+[numthreads(1,1,1)]
+void main()
+{
+ // CHECK-DAG: = {{.*}}cbufferParam;
+
+ outputBuffer[0].v = cbufferParam;
+} \ No newline at end of file
diff --git a/tests/rewriter/varying-struct.vert b/tests/rewriter/varying-struct.vert
index 042125b15..aae26a6ed 100644
--- a/tests/rewriter/varying-struct.vert
+++ b/tests/rewriter/varying-struct.vert
@@ -1,5 +1,5 @@
#version 450 core
-//TEST_DISABLED:COMPARE_GLSL:-no-mangle
+//TEST_DISABLED:COMPARE_GLSL:
#if defined(__SLANG__)