Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member-wise constructor generation with visibility control #5107

Open
wants to merge 136 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
40f0cbe
Member-wise constructor generation with visibility control
ArielG-NV Aug 6, 2024
ce554c3
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 15, 2024
ceb70c4
fix bug which causes crash
ArielG-NV Aug 15, 2024
6df637d
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 15, 2024
0110058
git merge fix
ArielG-NV Aug 15, 2024
a1b1c50
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 15, 2024
0dca495
fix default init expr with init expr paramDecl
ArielG-NV Aug 15, 2024
44de3d4
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 15, 2024
bab4c9f
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 15, 2024
d82d68b
Fixes
ArielG-NV Aug 15, 2024
892016a
fix bug and incorrect test
ArielG-NV Aug 15, 2024
5755c0a
fix more tests with invalid init-lists
ArielG-NV Aug 15, 2024
f6d5bd3
fix swizzle causing a failiure with `checkExpr` to resolve an `Invoke`
ArielG-NV Aug 15, 2024
251314e
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 15, 2024
045e27a
init expr with default ctor is now more restrictive due to current li…
ArielG-NV Aug 15, 2024
6d50283
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 15, 2024
4c36d3a
Revert "init expr with default ctor is now more restrictive due to cu…
ArielG-NV Aug 15, 2024
cbe95fb
try removing null default-ctor construction logic due to causing fail…
ArielG-NV Aug 16, 2024
f8bf220
undo some code removal
ArielG-NV Aug 16, 2024
1e7819a
make a few additions/changes to init list logic:
ArielG-NV Aug 16, 2024
1e4ec35
remove unused var
ArielG-NV Aug 16, 2024
95e719d
cleanup some tests, logic and auto-documentation code
ArielG-NV Aug 16, 2024
04f7177
add missing include (clang/gcc)
ArielG-NV Aug 16, 2024
b3d18c7
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 16, 2024
67c9d29
Clean up invalid tests, fix some bugs, add better use-site inference …
ArielG-NV Aug 19, 2024
7476962
clang/gcc compiler warning
ArielG-NV Aug 19, 2024
78feed6
cyclic type solution
ArielG-NV Aug 19, 2024
98cd3b3
include header that defines another function (whom is in a header).
ArielG-NV Aug 19, 2024
a788a53
fix bit fields
ArielG-NV Aug 19, 2024
ff905ae
fix no_diff and trySynthesizeDifferentialAssociatedTypeRequirementWit…
ArielG-NV Aug 19, 2024
89e1339
Fix how auto-diff code is auto-generated by synthed ctor's
ArielG-NV Aug 20, 2024
4aced6e
remove debug code
ArielG-NV Aug 20, 2024
8771a3b
Expand on automatic auto-diff modifier resolution
ArielG-NV Aug 20, 2024
26908f5
fix bug related to inheritance walking introduced
ArielG-NV Aug 20, 2024
75a1e7d
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 21, 2024
465e07c
cleanup and fix invalid test + refine auto-diff code
ArielG-NV Aug 21, 2024
906f439
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 21, 2024
f26ea60
clean-up
ArielG-NV Aug 21, 2024
bded32e
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 21, 2024
5b02019
default construct structs without an initExpr (as per how Slang is su…
ArielG-NV Aug 21, 2024
c6acffc
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 21, 2024
3e558d7
redo reverse-addr-elim test properly without partial init
ArielG-NV Aug 21, 2024
6bb3906
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 21, 2024
fd7999f
do not error if unexpected expr is found since this is not exactly 'w…
ArielG-NV Aug 22, 2024
36ec8ce
auto-diff fix
ArielG-NV Aug 22, 2024
8b2cbb4
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 26, 2024
d88849c
undo code which should not be apart of this PR
ArielG-NV Aug 26, 2024
df421c5
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 26, 2024
01274fb
change when we zero-init to stay backwards compatible
ArielG-NV Aug 27, 2024
c9b7080
fix warning
ArielG-NV Aug 27, 2024
83af023
added a special zero-init function to handle `{}` case
ArielG-NV Aug 27, 2024
969dff4
fix inheritance with zero-init-list-func and add test
ArielG-NV Aug 27, 2024
5840d91
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 27, 2024
dcd9081
change order of visiting
ArielG-NV Aug 27, 2024
7b3fd31
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 27, 2024
b1395e1
add missing auto-diff modifiers
ArielG-NV Aug 28, 2024
b2ce412
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 28, 2024
23039c9
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 28, 2024
c9221ea
fix syntax err
ArielG-NV Aug 28, 2024
f55254a
fix functor support regression
ArielG-NV Aug 28, 2024
d948c75
allow `{}` inside `__init()`
ArielG-NV Aug 28, 2024
cd1a46c
fix compile error
ArielG-NV Aug 28, 2024
4403ede
fix another warning
ArielG-NV Aug 28, 2024
99088c3
auto-infer generic from the base-struct type with `constructZeroInitL…
ArielG-NV Aug 28, 2024
24f8c45
fix a test
ArielG-NV Aug 28, 2024
25138e0
fix cyclic ref error for DefaultConstruct
ArielG-NV Aug 29, 2024
93af3db
dont make reg func a `()` wrapped func
ArielG-NV Aug 29, 2024
c026b07
fix visibility and type issue
ArielG-NV Aug 29, 2024
915b0b8
add defaults to syth'ed ctor's under special situations to allow c-st…
ArielG-NV Aug 29, 2024
31c1e46
fix warning
ArielG-NV Aug 29, 2024
7fe2413
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 29, 2024
c270055
handle `shouldUseInitializerDirectly` differently to work better with…
ArielG-NV Aug 29, 2024
c883af4
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 29, 2024
de1bc55
test clean-up and additional test-case
ArielG-NV Aug 29, 2024
4f6a343
remove overload logic added, replace with simple solution of proper l…
ArielG-NV Aug 30, 2024
06eea82
1. Fix isCStyleCtor evaluation 2. update autodiff.slang test to moder…
ArielG-NV Aug 30, 2024
9086f7e
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 30, 2024
bac6c31
fix partial init list bug
ArielG-NV Aug 30, 2024
759a709
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Aug 30, 2024
fb8588e
fix the bug correctly*
ArielG-NV Aug 30, 2024
e5d3c6a
Merge branch 'master' into initializer-list-visibility
ArielG-NV Aug 30, 2024
05d8fd8
Merge branch 'master' of https://github.com/ArielG-NV/slang into init…
ArielG-NV Aug 31, 2024
39bd24d
fix some simple problems
ArielG-NV Sep 3, 2024
e9a9035
ignore undefined resource var's
ArielG-NV Sep 3, 2024
f6b1b4a
check IRNode exists before deallocating
ArielG-NV Sep 3, 2024
b7654d4
fix possible cyclic ref & change `_emitDefaultConstruct` so it cannot…
ArielG-NV Sep 3, 2024
d5c7e16
fix order of evaluation to prevent crash (not auto-diff fixes)
ArielG-NV Sep 3, 2024
6ea9950
fix var check order
ArielG-NV Sep 3, 2024
5712dbb
remove resource-spec change that is wrong
ArielG-NV Sep 3, 2024
4956257
remove failing test as per reccomendation (#4874)
ArielG-NV Sep 3, 2024
8af50a8
Merge branch 'master' into initializer-list-visibility
ArielG-NV Sep 3, 2024
bb3fa44
remove specialize fix, fix recursive init calls
ArielG-NV Sep 4, 2024
561a9f7
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Sep 4, 2024
763055b
changes:
ArielG-NV Sep 4, 2024
d3a6604
clean up not-needed changes
ArielG-NV Sep 4, 2024
1281459
clean up more unneeded overload logic
ArielG-NV Sep 4, 2024
964c3e5
change around how we define ctor and zeroInit to be more flexable
ArielG-NV Sep 4, 2024
0e5e5ba
heavily document and comment on this PR in-case it is handed off to a…
ArielG-NV Sep 5, 2024
997d1f0
Merge branch 'master' into initializer-list-visibility
ArielG-NV Sep 5, 2024
6d40ddc
fix merge error
ArielG-NV Sep 5, 2024
a73795b
fix up wittness table fufillment:
ArielG-NV Sep 5, 2024
afa8812
fix `_structHasMemberWithValue` logic
ArielG-NV Sep 5, 2024
f56d34a
fix bug in `_structHasMemberWithValue`
ArielG-NV Sep 5, 2024
7df745d
allow wittness through inheritance (I misread the code comments)
ArielG-NV Sep 5, 2024
2177db4
try to fix more interface (and such) issues with reordering declarati…
ArielG-NV Sep 5, 2024
989837f
try another balance of fixes
ArielG-NV Sep 5, 2024
c135f85
fix bug with checking for possible values in struct
ArielG-NV Sep 5, 2024
7312af1
remove one of the backup-overload-resolution-hack-cases that was adde…
ArielG-NV Sep 5, 2024
92ed12a
fix incorrect overload candidate resolution
ArielG-NV Sep 5, 2024
6056e40
Merge branch 'master' into initializer-list-visibility
ArielG-NV Sep 5, 2024
1164d27
address autodiff failiures
ArielG-NV Sep 5, 2024
37e788e
fix crash
ArielG-NV Sep 6, 2024
6587a3f
fix vectors to parse correctly with `{...}`, change tests to `dxil` t…
ArielG-NV Sep 6, 2024
f5bbca0
remove unused func
ArielG-NV Sep 6, 2024
d37593a
Merge branch 'master' into initializer-list-visibility
ArielG-NV Sep 6, 2024
2b4bb0d
use more accurate logic to resolve generics wrapped init-list logic
ArielG-NV Sep 6, 2024
56b343b
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Sep 6, 2024
efbca49
add old style init list support --> deprecated
ArielG-NV Sep 6, 2024
ba3a91d
fix now-invalid tests to be valid
ArielG-NV Sep 6, 2024
22bf6f6
Merge branch 'master' into initializer-list-visibility
ArielG-NV Sep 6, 2024
852bbc3
fix warning
ArielG-NV Sep 6, 2024
ddf061d
Merge branch 'initializer-list-visibility' of https://github.com/Arie…
ArielG-NV Sep 6, 2024
af2ef09
fix incorrect test
ArielG-NV Sep 6, 2024
e2cc233
cleanup code & comments
ArielG-NV Sep 6, 2024
c0e59e8
clean up and cover all cases of `{...}` failiure so that we run legac…
ArielG-NV Sep 6, 2024
2682128
Merge branch 'master' into arial/initializer-list
kaizhangNV Sep 18, 2024
bb22fa2
Merge branch 'master' into tmp
kaizhangNV Sep 19, 2024
5401494
fix easy comments
kaizhangNV Sep 19, 2024
39268d6
refactor _getDefaultCtor
kaizhangNV Sep 19, 2024
5771007
change function '_doesCtorExpectInitializerListUsage' to '_isSynthisi…
kaizhangNV Sep 20, 2024
89d221c
Merge branch 'master' into arial/initializer-list
kaizhangNV Sep 20, 2024
d966b3f
replace all 'ZeroInit' to 'DefaultInit'
kaizhangNV Sep 20, 2024
69cb426
remove the WAR in hlsl.meta.slang
kaizhangNV Sep 20, 2024
2b6f7a2
Replace the name '_tryToSpecialCaseOverloadDefaultConstructWithoutIni…
kaizhangNV Sep 20, 2024
1861df4
Do not remove the default ctor
kaizhangNV Sep 24, 2024
fde9141
DNS: Modify all the tests that does not have empty initializer
kaizhangNV Sep 24, 2024
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
5 changes: 5 additions & 0 deletions source/slang/diff.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,14 @@ struct DiffTensorView
}
};

// Note: we need `TorchTensorType` so Slang is aware
// of when we use `TorchTensorType` in a synthisized
// function. This is important since `[CudaHost]` is
// required for any function using `TorchTensorType`
/// Represents the handle of a Torch tensor object.
__generic<T>
__intrinsic_type($(kIROp_TorchTensorType))
__magic_type(TorchTensorType)
struct TorchTensor
{
__intrinsic_op($(kIROp_TorchTensorGetView))
Expand Down
5 changes: 5 additions & 0 deletions source/slang/hlsl.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -19766,6 +19766,11 @@ struct TextureFootprint<let ND:int> : __TextureFootprintData<ND>
{
bool _isSingleLevel;

__init(__TextureFootprintData<ND> data, bool _isSingleLevelIn)
{
_isSingleLevel = _isSingleLevelIn;
}

property isSingleLevel : bool
{
[__NoSideEffect]
Expand Down
10 changes: 10 additions & 0 deletions source/slang/slang-ast-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ class SharedASTBuilder : public RefObject
}
return m_thisTypeName;
}

Name* getCtorName()
{
if (!m_ctorName)
{
m_ctorName = getNamePool()->getName("$init");
}
return m_ctorName;
}
protected:
// State shared between ASTBuilders

Expand Down Expand Up @@ -114,6 +123,7 @@ class SharedASTBuilder : public RefObject
NamePool* m_namePool = nullptr;

Name* m_thisTypeName = nullptr;
Name* m_ctorName = nullptr;

// This is a private builder used for these shared types
ASTBuilder* m_astBuilder = nullptr;
Expand Down
22 changes: 19 additions & 3 deletions source/slang/slang-ast-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,30 @@ class FunctionDeclBase : public CallableDecl
Stmt* body = nullptr;
};

enum class ConstructorTags : int
{
None = 0,

/// Indicates whether the declaration was synthesized by
/// Slang and not actually provided by the user
Synthesized = 1 << 0,

/// Derived classes will call this ctor if they need a memberwise ctor for public members.
MemberwiseCtorForPublicVisibility = 1 << 1,

/// Derived classes will call this ctor if they need a memberwise ctor for public and internal members.
/// A ctor with `MemberwiseCtorForInternalVisibility` may also contain 'isMemberwiseCtorForPublicVisibility'
MemberwiseCtorForInternalVisibility = 1 << 2,
};

// A constructor/initializer to create instances of a type
class ConstructorDecl : public FunctionDeclBase
{
SLANG_AST_CLASS(ConstructorDecl)

// Indicates whether the declaration was synthesized by
// slang and not actually provided by the user
bool isSynthesized = false;
int options = (int)ConstructorTags::None;
void addOption(ConstructorTags option) { options |= (int)option; }
bool containsOption(ConstructorTags option) { return options & (int)option; }
};

// A subscript operation used to index instances of a type
Expand Down
3 changes: 3 additions & 0 deletions source/slang/slang-ast-modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class ToBeSynthesizedModifier : public Modifier {SLANG_AST_CLASS(ToBeSynthesized
// Marks that the definition of a decl is synthesized.
class SynthesizedModifier : public Modifier { SLANG_AST_CLASS(SynthesizedModifier) };

// Marks that the definition of a decl is our $DefaultInit function.
class DefaultInitModifier : public Modifier { SLANG_AST_CLASS(DefaultInitModifier) };

// Marks a synthesized variable as local temporary variable.
class LocalTempVarModifier : public Modifier { SLANG_AST_CLASS(LocalTempVarModifier) };

Expand Down
3 changes: 2 additions & 1 deletion source/slang/slang-ast-support-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ namespace Slang
/// functions, so it belongs in the last phase of checking.
///
DefinitionChecked,
DefaultConstructorReadyForUse = DefinitionChecked,

/// The capabilities required by the decl is infered and validated.
///
Expand All @@ -491,6 +490,8 @@ namespace Slang
CanUseFuncSignature = ReadyForReference,
CanSpecializeGeneric = ReadyForReference,
CanReadInterfaceRequirements = ReadyForLookup,
DefaultConstructorReadyForUse = ReadyForConformances,
VarInitExprAreChecked = DefinitionChecked,
};

/// A `DeclCheckState` plus a bit to track whether a declaration is currently being checked.
Expand Down
5 changes: 5 additions & 0 deletions source/slang/slang-ast-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ class TensorViewType : public BuiltinType
Type* getElementType();
};

class TorchTensorType : public BuiltinType
{
SLANG_AST_CLASS(TorchTensorType)
};

// Base class for built in string types
class StringTypeBase : public BuiltinType
{
Expand Down
Loading
Loading