Skip to content

Commit

Permalink
Handle "standard library" keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwak-work committed Oct 28, 2024
1 parent 5fefdd3 commit 2b9b4f7
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion source/slang/slang-ast-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SharedASTBuilder : public RefObject
Type* m_overloadedType = nullptr;

// The following types are created lazily, such that part of their definition
// can be in the standard library
// can be in the core module.
//
// Note(tfoley): These logically belong to `Type`,
// but order-of-declaration stuff makes that tricky
Expand Down
8 changes: 4 additions & 4 deletions source/slang/slang-ast-modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ class EntryPointAttribute : public Attribute
};

// A `[__vulkanRayPayload(location)]` attribute, which is used in the
// standard library implementation to indicate that a variable
// core module implementation to indicate that a variable
// actually represents the input/output interface for a Vulkan
// ray tracing shader to pass per-ray payload information.
class VulkanRayPayloadAttribute : public Attribute
Expand All @@ -960,7 +960,7 @@ class VulkanRayPayloadInAttribute : public Attribute
};

// A `[__vulkanCallablePayload(location)]` attribute, which is used in the
// standard library implementation to indicate that a variable
// core module implementation to indicate that a variable
// actually represents the input/output interface for a Vulkan
// ray tracing shader to pass payload information to/from a callee.
class VulkanCallablePayloadAttribute : public Attribute
Expand All @@ -977,7 +977,7 @@ class VulkanCallablePayloadInAttribute : public Attribute
};

// A `[__vulkanHitAttributes]` attribute, which is used in the
// standard library implementation to indicate that a variable
// core module implementation to indicate that a variable
// actually represents the output interface for a Vulkan
// intersection shader to pass hit attribute information.
class VulkanHitAttributesAttribute : public Attribute
Expand All @@ -986,7 +986,7 @@ class VulkanHitAttributesAttribute : public Attribute
};

// A `[__vulkanHitObjectAttributes(location)]` attribute, which is used in the
// standard library implementation to indicate that a variable
// core module implementation to indicate that a variable
// actually represents the attributes on a HitObject as part of
// Shader ExecutionReordering
class VulkanHitObjectAttributesAttribute : public Attribute
Expand Down
12 changes: 6 additions & 6 deletions source/slang/slang-check-decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ namespace Slang
// global shader parameter to Slang, but we want to be able to
// associate special behavior with it to make downstream compilation
// work nicely (especially in the case where certain cross-platform
// operations in the Slang standard library need to use NVAPI).
// operations in the Slang core module need to use NVAPI).
//
// We will detect a global variable declaration that appears to
// be declaring `g_NvidiaExt` from NVAPI, and mark it with a special
Expand Down Expand Up @@ -2957,7 +2957,7 @@ namespace Slang

/// Recursively register any builtin declarations that need to be attached to the `session`.
///
/// This function should only be needed for declarations in the standard library.
/// This function should only be needed for declarations in the core module.
///
static void _registerBuiltinDeclsRec(Session* session, Decl* decl)
{
Expand Down Expand Up @@ -3026,18 +3026,18 @@ namespace Slang

void SemanticsDeclVisitorBase::checkModule(ModuleDecl* moduleDecl)
{
// When we are dealing with code from the standard library,
// When we are dealing with code from the core modules,
// there is a potential problem where we might need to look
// up built-in types like `Int` through the session (e.g.,
// to determine the type for an integer literal), but those
// types might not have been registered yet. We solve that
// by doing a pre-process on standard-library code to find
// by doing a pre-process on the core module code to find
// and register any built-in declarations.
//
// TODO: This could be factored into another visitor pass
// that fits the more standard checking below, but that would
// seemingly add overhead to checking things other than
// the standard library.
// the core module.
//
if(isFromCoreModule(moduleDecl))
{
Expand Down Expand Up @@ -9847,7 +9847,7 @@ namespace Slang
m_candidateExtensionListsBuilt = true;

// We need to make sure that all extensions that were declared
// as part of our standard-library modules are always visible,
// as parts of our core module are always visible,
// even if they are not explicit `import`ed into user code.
//
for( auto module : getSession()->coreModules )
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-check-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ namespace Slang
Type* elementType);

// The way that we have designed out type system, pretyt much *every*
// type is a reference to some declaration in the standard library.
// type is a reference to some declaration in the core module.
// That means that when we construct a new type on the fly, we need
// to make sure that it is wired up to reference the appropriate
// declaration, or else it won't compare as equal to other types
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-check-shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ namespace Slang
// There's actually a lot of detail to semantic checking, in
// that the AST-level code should probably be validating the
// use of system-value semantics by linking them to explicit
// declarations in the standard library. We should also be
// declarations in the core module. We should also be
// using profile information on those declarations to infer
// appropriate profile restrictions on the entry point.
//
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang-compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,8 @@ namespace Slang

List<RefPtr<ComponentType>> const& getUnspecializedEntryPoints() { return m_unspecializedEntryPoints; }

/// Does the code we are compiling represent part of the Slang standard library?
bool m_isStandardLibraryCode = false;
/// Does the code we are compiling represent part of the Slang core module?
bool m_isCoreModuleCode = false;

Name* m_defaultModuleName = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-doc-markdown-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ DocumentPage* DocMarkdownWriter::writeAll(UnownedStringSlice configStr)
m_output[page->path] = page;
return page.get();
};
m_rootPage = addBuiltinPage(nullptr, toSlice("index.md"), m_config.title.getUnownedSlice(), toSlice("Standard Library Reference"));
m_rootPage = addBuiltinPage(nullptr, toSlice("index.md"), m_config.title.getUnownedSlice(), toSlice("Core Module Reference"));
m_rootPage->skipWrite = true;

m_interfacesPage = addBuiltinPage(m_rootPage.get(), toSlice("interfaces/index.md"), toSlice("Interfaces"), toSlice("Interfaces"));
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-synthesize-active-mask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct SynthesizeActiveMaskForModuleContext
{
// We use the plain 32-bit `uint` type masks we
// generate here since it matches the current
// definition of `WaveMask` in the standard library.
// definition of `WaveMask` in the core module.
//
// TODO: If/when the `WaveMask` type in the core module is
// made opaque, this should use the opaque type instead,
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-lower-to-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9681,7 +9681,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
if(decl->body)
return;

// Only standard library declarations should get any kind of catch-all
// Only core module declarations should get any kind of catch-all
// treatment by default. Declarations in user case are responsible
// for marking things as target intrinsics if they want to go down
// that (unsupported) route.
Expand Down
12 changes: 6 additions & 6 deletions source/slang/slang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2937,19 +2937,19 @@ void FrontEndCompileRequest::parseTranslationUnit(
module->setModuleDecl(translationUnitSyntax);

// When compiling a module of code that belongs to the Slang
// standard library, we add a modifier to the module to act
// core module, we add a modifier to the module to act
// as a marker, so that downstream code can detect declarations
// that came from the standard library (by walking up their
// that came from the core module (by walking up their
// chain of ancestors and looking for the marker), and treat
// them differently from user declarations.
//
// We are adding the marker here, before we even parse the
// code in the module, in case the subsequent steps would
// like to treat the standard library differently. Alternatively
// like to treat the core module differently. Alternatively
// we could pass down the `m_isStandardLibraryCode` flag to
// these passes.
//
if( m_isStandardLibraryCode )
if( m_isCoreModuleCode )
{
translationUnitSyntax->modifiers.first = astBuilder->create<FromCoreModuleModifier>();
}
Expand Down Expand Up @@ -5898,7 +5898,7 @@ void Session::addBuiltinSource(
m_builtinLinkage,
nullptr,
&sink);
compileRequest->m_isStandardLibraryCode = true;
compileRequest->m_isCoreModuleCode = true;

// Set the source manager on the sink
sink.setSourceManager(sourceManager);
Expand All @@ -5922,7 +5922,7 @@ void Session::addBuiltinSource(

PlatformUtil::outputDebugMessage(diagnostics);

SLANG_UNEXPECTED("error in Slang standard library");
SLANG_UNEXPECTED("error in Slang core module");
}

// Compiling the core module should not yield any warnings.
Expand Down

0 comments on commit 2b9b4f7

Please sign in to comment.