Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/design/autodiff/ir-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ OpModule
{
[OpPrimalInstDecoration]
%a_primal = OpDifferentialPairGetPrimal %dpa : %dpfloat
[OpPrimalInstDecorarion]
[OpPrimalInstDecoration]
%b_primal = OpDifferentialPairGetPrimal %dpa : %dpfloat

[OpPrimalInstDecoration]
Expand All @@ -414,7 +414,7 @@ OpModule
{
[OpDifferentialInstDecoration]
%a_diff = OpDifferentialPairGetDifferential %dpa : %dpfloat
[OpDifferentialInstDecorarion]
[OpDifferentialInstDecoration]
%b_diff = OpDifferentialPairGetDifferential %dpa : %dpfloat

[OpDifferentialInstDecoration]
Expand Down
38 changes: 24 additions & 14 deletions source/slang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,36 @@
set(SLANG_FIDDLE_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(SLANG_FIDDLE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/fiddle")

file(GLOB SLANG_FIDDLE_INPUT_FILE_NAMES
file(
GLOB SLANG_FIDDLE_INPUT_FILE_NAMES
CONFIGURE_DEPENDS
RELATIVE "${SLANG_FIDDLE_INPUT_DIR}"
"*.h"
"*.cpp")
"*.cpp"
)

list(TRANSFORM SLANG_FIDDLE_INPUT_FILE_NAMES
list(
TRANSFORM SLANG_FIDDLE_INPUT_FILE_NAMES
PREPEND "${SLANG_FIDDLE_INPUT_DIR}/"
OUTPUT_VARIABLE SLANG_FIDDLE_INPUTS)
OUTPUT_VARIABLE SLANG_FIDDLE_INPUTS
)
glob_append(SLANG_FIDDLE_LUA_INPUTS "*.lua")

list(TRANSFORM SLANG_FIDDLE_INPUT_FILE_NAMES
list(
TRANSFORM SLANG_FIDDLE_INPUT_FILE_NAMES
APPEND ".fiddle"
OUTPUT_VARIABLE SLANG_FIDDLE_OUTPUTS)
list(TRANSFORM SLANG_FIDDLE_OUTPUTS
PREPEND "${SLANG_FIDDLE_OUTPUT_DIR}/")
OUTPUT_VARIABLE SLANG_FIDDLE_OUTPUTS
)
list(TRANSFORM SLANG_FIDDLE_OUTPUTS PREPEND "${SLANG_FIDDLE_OUTPUT_DIR}/")

add_custom_command(
OUTPUT ${SLANG_FIDDLE_OUTPUTS}
COMMAND ${CMAKE_COMMAND} -E make_directory ${SLANG_FIDDLE_OUTPUT_DIR}
COMMAND slang-fiddle
-i "${SLANG_FIDDLE_INPUT_DIR}/"
-o "${SLANG_FIDDLE_OUTPUT_DIR}/"
${SLANG_FIDDLE_INPUT_FILE_NAMES}
DEPENDS ${SLANG_FIDDLE_INPUTS} slang-fiddle
COMMAND
slang-fiddle -i "${SLANG_FIDDLE_INPUT_DIR}/" -o
"${SLANG_FIDDLE_OUTPUT_DIR}/" ${SLANG_FIDDLE_INPUT_FILE_NAMES}
DEPENDS ${SLANG_FIDDLE_INPUTS} ${SLANG_FIDDLE_LUA_INPUTS} slang-fiddle
WORKING_DIRECTORY ${slang_SOURCE_DIR}
VERBATIM
)
add_library(
Expand Down Expand Up @@ -100,7 +106,11 @@ slang_add_target(
# generated lookup tables
#

get_target_property(SLANG_SPIRV_HEADERS_INCLUDE_DIR SPIRV-Headers::SPIRV-Headers INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(
SLANG_SPIRV_HEADERS_INCLUDE_DIR
SPIRV-Headers::SPIRV-Headers
INTERFACE_INCLUDE_DIRECTORIES
)

set(SLANG_LOOKUP_GENERATOR_INPUT_JSON
"${SLANG_SPIRV_HEADERS_INCLUDE_DIR}/spirv/unified1/extinst.glsl.std.450.grammar.json"
Expand Down
4 changes: 2 additions & 2 deletions source/slang/core.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ struct NativeString
property int length { [__unsafeForceInlineEarly] get{return getLength();} }

__implicit_conversion($(kConversionCost_None))
__intrinsic_op($(kIROp_getNativeStr))
__intrinsic_op($(kIROp_GetNativeStr))
__init(String value);

__init() { this = NativeString(""); }
Expand Down Expand Up @@ -3358,7 +3358,7 @@ __prefix T operator ~(T v0);
// IR level type traits.

__generic<T>
__intrinsic_op($(kIROp_undefined))
__intrinsic_op($(kIROp_Undefined))
T __declVal();

__generic<T>
Expand Down
4 changes: 3 additions & 1 deletion source/slang/slang-ast-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

#pragma once

#include "slang-ast-base.h.fiddle"
#include "slang-ast-forward-declarations.h"
#include "slang-ast-support-types.h"
#include "slang-capability.h"

//
#include "slang-ast-base.h.fiddle"

// This file defines the primary base classes for the hierarchy of
// AST nodes and related objects. For example, this is where the
// basic `Decl`, `Stmt`, `Expr`, `type`, etc. definitions come from.
Expand Down
7 changes: 5 additions & 2 deletions source/slang/slang-ast-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#pragma once

#include "slang-ast-base.h"
#include "slang-ast-decl.h.fiddle"
#include "slang-fossil.h"

//
#include "slang-ast-decl.h.fiddle"

FIDDLE()
namespace Slang
{
Expand Down Expand Up @@ -962,7 +964,8 @@ class SyntaxDecl : public Decl
{
FIDDLE(...)
// What type of syntax node will be produced when parsing with this keyword?
FIDDLE() SyntaxClass<NodeBase> syntaxClass;
FIDDLE()
SyntaxClass<NodeBase> syntaxClass;

// Callback to invoke in order to parse syntax with this keyword.
SyntaxParseCallback parseCallback = nullptr;
Expand Down
1 change: 1 addition & 0 deletions source/slang/slang-ast-modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "slang-ast-base.h"
#include "slang-ast-modifier.h.fiddle"
#include "slang-ir-insts-enum.h"

FIDDLE()
namespace Slang
Expand Down
9 changes: 4 additions & 5 deletions source/slang/slang-ast-support-types.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#ifndef SLANG_AST_SUPPORT_TYPES_H
#define SLANG_AST_SUPPORT_TYPES_H
#pragma once

#include "../compiler-core/slang-doc-extractor.h"
#include "../compiler-core/slang-lexer.h"
#include "../compiler-core/slang-name.h"
#include "../core/slang-basic.h"
#include "../core/slang-semantic-version.h"
#include "slang-ast-forward-declarations.h"
#include "slang-ast-support-types.h.fiddle"
#include "slang-profile.h"
#include "slang-type-system-shared.h"
#include "slang.h"

#include <assert.h>
#include <type_traits>

//
#include "slang-ast-support-types.h.fiddle"

FIDDLE(hidden class RefObject;)

FIDDLE() namespace Slang
Expand Down Expand Up @@ -1731,5 +1732,3 @@ FIDDLE() namespace Slang
};

} // namespace Slang

#endif
3 changes: 3 additions & 0 deletions source/slang/slang-ast-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#pragma once

#include "slang-ast-base.h"
#include "slang-ast-decl.h"

//
#include "slang-ast-type.h.fiddle"

FIDDLE()
Expand Down
28 changes: 14 additions & 14 deletions source/slang/slang-emit-c-like.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void CLikeSourceEmitter::defaultEmitInstStmt(IRInst* inst)
m_writer->emit(");\n");
}
break;
case kIROp_discard:
case kIROp_Discard:
m_writer->emit("discard;\n");
break;
default:
Expand Down Expand Up @@ -1471,7 +1471,7 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
case kIROp_FieldAddress:
case kIROp_GetElementPtr:
case kIROp_Specialize:
case kIROp_LookupWitness:
case kIROp_LookupWitnessMethod:
case kIROp_GetValueFromBoundInterface:
return true;

Expand Down Expand Up @@ -1502,7 +1502,7 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
//
case kIROp_MakeStruct:
case kIROp_MakeArray:
case kIROp_swizzleSet:
case kIROp_SwizzleSet:
case kIROp_MakeArrayFromElement:
case kIROp_MakeCoopVector:

Expand Down Expand Up @@ -1679,7 +1679,7 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
// for GLSL), so we check this only after all those special cases are
// considered.
//
if (inst->getOp() == kIROp_undefined)
if (inst->getOp() == kIROp_Undefined)
return false;

// Okay, at this point we know our instruction must have a single use.
Expand Down Expand Up @@ -2244,7 +2244,7 @@ void CLikeSourceEmitter::emitCallExpr(IRCall* inst, EmitOpInfo outerPrec)
handleRequiredCapabilities(funcValue);

// Detect if this is a call into a COM interface method.
if (funcValue->getOp() == kIROp_LookupWitness)
if (funcValue->getOp() == kIROp_LookupWitnessMethod)
{
auto operand0Type = funcValue->getOperand(0)->getDataType();
switch (operand0Type->getOp())
Expand Down Expand Up @@ -2388,7 +2388,7 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO
case kIROp_RTTIPointerType:
break;

case kIROp_undefined:
case kIROp_Undefined:
case kIROp_DefaultConstruct:
m_writer->emit(getName(inst));
break;
Expand Down Expand Up @@ -2710,7 +2710,7 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO
getInfo(EmitOp::General)); // Directly emit NonUniformResourceIndex Operand0;
break;

case kIROp_getNativeStr:
case kIROp_GetNativeStr:
{
auto prec = getInfo(EmitOp::Postfix);
needClose = maybeEmitParens(outerPrec, prec);
Expand Down Expand Up @@ -2828,7 +2828,7 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO
}
break;

case kIROp_swizzle:
case kIROp_Swizzle:
{
auto prec = getInfo(EmitOp::Postfix);
needClose = maybeEmitParens(outerPrec, prec);
Expand Down Expand Up @@ -3242,7 +3242,7 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst)
case kIROp_LiveRangeEnd:
emitLiveness(inst);
break;
case kIROp_undefined:
case kIROp_Undefined:
case kIROp_DefaultConstruct:
{
auto type = inst->getDataType();
Expand Down Expand Up @@ -3285,11 +3285,11 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst)
m_writer->emit(";\n");
break;

case kIROp_discard:
case kIROp_Discard:
emitInstStmt(inst);
break;

case kIROp_swizzleSet:
case kIROp_SwizzleSet:
{
auto ii = (IRSwizzleSet*)inst;
emitInstResultDecl(inst);
Expand Down Expand Up @@ -3606,7 +3606,7 @@ void CLikeSourceEmitter::emitRegion(Region* inRegion)
break;

case kIROp_Return:
case kIROp_discard:
case kIROp_Discard:
// For extremely simple terminators, we just handle
// them here, so that we don't have to allocate
// separate `Region`s for them.
Expand Down Expand Up @@ -4804,7 +4804,7 @@ void CLikeSourceEmitter::_emitInstAsVarInitializerImpl(IRInst* inst)

bool _isFoldableValue(IRInst* val)
{
if (val->getParent() && val->getParent()->getOp() == kIROp_Module)
if (val->getParent() && val->getParent()->getOp() == kIROp_ModuleInst)
return true;

switch (val->getOp())
Expand Down Expand Up @@ -5148,7 +5148,7 @@ void CLikeSourceEmitter::ensureInstOperandsRec(ComputeEmitActionsContext* ctx, I
case kIROp_NativePtrType:
requiredLevel = EmitAction::ForwardDeclaration;
break;
case kIROp_LookupWitness:
case kIROp_LookupWitnessMethod:
case kIROp_FieldExtract:
case kIROp_FieldAddress:
{
Expand Down
6 changes: 3 additions & 3 deletions source/slang/slang-emit-cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut
m_writer->emit("])");
return true;
}
case kIROp_swizzle:
case kIROp_Swizzle:
{
// For C++ we don't need to emit a swizzle function
// For C we need a construction function
Expand Down Expand Up @@ -1677,7 +1677,7 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut
// try doing automatically
return false;
}
case kIROp_LookupWitness:
case kIROp_LookupWitnessMethod:
{
emitInstExpr(inst->getOperand(0), inOuterPrec);
m_writer->emit("->");
Expand All @@ -1697,7 +1697,7 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut
m_writer->emit(")");
return true;
}
case kIROp_GetAddr:
case kIROp_GetAddress:
{
// Once we clean up the pointer emitting logic, we can
// just use GetElementAddress instruction in place of
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-emit-metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool MetalSourceEmitter::tryEmitInstStmtImpl(IRInst* inst)
};
switch (inst->getOp())
{
case kIROp_discard:
case kIROp_Discard:
m_writer->emit("discard_fragment();\n");
return true;
case kIROp_MetalAtomicCast:
Expand Down
Loading
Loading