Skip to content

Win32 fixes? #2

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

Open
wants to merge 704 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
704 commits
Select commit Hold shift + click to select a range
bdb6118
fix more memory simplfication logic
Hugobros3 Aug 10, 2024
6e5bfc5
remove subgroup_broadcast_first in favor of using the equivalent spv
Hugobros3 Aug 10, 2024
df9521f
fixed lower_subgroup_vars
Hugobros3 Aug 10, 2024
2477851
spv: converted emit_instruction to single-return
Hugobros3 Aug 11, 2024
1d5e46a
backends: put value code near instruction code
Hugobros3 Aug 11, 2024
2fde749
backends: moved control flow to own files
Hugobros3 Aug 11, 2024
0557bbb
backends cleanup
Hugobros3 Aug 11, 2024
2099567
spirv: use the scheduler
Hugobros3 Aug 11, 2024
af5c8a1
remove subgroup primops (except assume) and use spv ops directly
Hugobros3 Aug 11, 2024
da88439
spv: refactor to put all the fn-related data in a struct
Hugobros3 Aug 11, 2024
b0f5313
spv: get rid of leftover namespacing macros
Hugobros3 Aug 11, 2024
9a71123
spv: namespace everything
Hugobros3 Aug 11, 2024
86ddaee
spv: emit mems
Hugobros3 Aug 11, 2024
62a5a9e
fix reduce op in scheduler
Hugobros3 Aug 11, 2024
9ad6b52
fixing some more spirv bugs
Hugobros3 Aug 11, 2024
862c85e
bind: try to use LEAs for subscript ops
Hugobros3 Aug 12, 2024
7fb6763
move slim-specific passes out of main target
Hugobros3 Aug 12, 2024
6e011ca
fix lower_alloca
Hugobros3 Aug 12, 2024
22c375a
fix debug_printf parsing
Hugobros3 Aug 12, 2024
52a4ff0
added builder sanity-check test
Hugobros3 Aug 12, 2024
2fc88e7
magic control-flow insertion works
Hugobros3 Aug 12, 2024
b79a677
lower_alloca: fix
Hugobros3 Aug 12, 2024
0dc0271
fix lower_physical_ptrs
Hugobros3 Aug 12, 2024
d6560d9
restore spirv_lift_globals_ssbo functionality
Hugobros3 Aug 12, 2024
523888f
move spirv passes to the backend
Hugobros3 Aug 12, 2024
6c3054c
reorganise shady target sources
Hugobros3 Aug 12, 2024
383c262
removed unfinished simt2d pass
Hugobros3 Aug 12, 2024
3e9c315
spv: handle the fact some things cannot be emitted at top level
Hugobros3 Aug 12, 2024
f172575
body_builder: handle blocks with non-trivial control flow
Hugobros3 Aug 12, 2024
2d04955
fixed inlining
Hugobros3 Aug 12, 2024
31b3428
misc. fixes
Hugobros3 Aug 12, 2024
0c229e5
fix lower_generic_ptrs
Hugobros3 Aug 12, 2024
1c2c91c
fix grammar.json grammar
Hugobros3 Aug 12, 2024
3f7bbaa
moved name binding nodes to ExtInstr
Hugobros3 Aug 12, 2024
c1c95a5
slim: remove remnants of old j/br syntax
Hugobros3 Aug 12, 2024
4ba856c
reconvergence_heuristics: in progress
Hugobros3 Aug 12, 2024
5906216
parser: allow continuations to see results in their dominator
Hugobros3 Aug 13, 2024
cecc321
fix bad mem threading in reconvergence_heuristics
Hugobros3 Aug 13, 2024
9704159
print: nest continuations according to dominance
Hugobros3 Aug 13, 2024
8b9d9c1
fixed lift_indirect_targets
Hugobros3 Aug 13, 2024
13a86b9
cfg_dump: avoid % in output
Hugobros3 Aug 13, 2024
81389f3
removed join point primops
Hugobros3 Aug 13, 2024
ccbcb77
fix a bunch more mem threading issues
Hugobros3 Aug 13, 2024
8be3e06
print: accurately deal with late-scheduled instructions
Hugobros3 Aug 13, 2024
cdacaa6
lift_indirect_targets works correctly with transitive dependencies
Hugobros3 Aug 13, 2024
225278a
c: remove namespacing macros
Hugobros3 Aug 13, 2024
ecb8112
dump: make it work when a CFG can't be built
Hugobros3 Aug 13, 2024
1d3e5e8
brought back C backend !
Hugobros3 Aug 13, 2024
d4fa616
disable switch if-tree lowering for now
Hugobros3 Aug 13, 2024
dbbac98
spv: fix structured control flow
Hugobros3 Aug 15, 2024
607c625
spv: emit bbs in the order the validator expects
Hugobros3 Aug 15, 2024
18fde87
fix build on macOS
Hugobros3 Aug 15, 2024
a6a2cd5
add sanity check for dictionnaries
Hugobros3 Aug 16, 2024
01d2ad9
reconvergence_heuristics are doomed, needs rewrite :s
Hugobros3 Aug 16, 2024
032fc93
vcc: added a cmake setting for clang name
Hugobros3 Aug 16, 2024
1cf11fc
l2s: updates to API
Hugobros3 Aug 16, 2024
759f3c1
removed reconvergence heuristics pass
Hugobros3 Aug 19, 2024
4254c97
made tailcall analysis smarter/lighter
Hugobros3 Aug 19, 2024
293c35e
added new free frontier analysis
Hugobros3 Aug 19, 2024
4a56ea8
removed old free_variables analysis
Hugobros3 Aug 19, 2024
1b97c11
rewriter: only import Exported decls
Hugobros3 Aug 19, 2024
219aecb
everything mostly works :tm:
Hugobros3 Aug 19, 2024
b1a8ad6
l2s: fixed scf recovery
Hugobros3 Aug 20, 2024
16c9992
lower_alloca: make fast
Hugobros3 Aug 20, 2024
f588481
improve lower_alloca's reliability
Hugobros3 Aug 20, 2024
df5fb57
spv: be a bit more conservative on what can be emitted at top level
Hugobros3 Aug 20, 2024
a850c80
visitor&uses: provide index in operand list
Hugobros3 Aug 20, 2024
ba83d27
l2s: rewrite params by hand and remove hack in rewrite.c
Hugobros3 Aug 20, 2024
560cd4c
bind: don't generate dummy loads
Hugobros3 Aug 20, 2024
a1c1243
fixed checkerboard sample
Hugobros3 Aug 20, 2024
6157a70
added dominance checks to the scheduler
Hugobros3 Aug 20, 2024
bfd75f7
l2s: use an extinstr to remember scope info
Hugobros3 Aug 20, 2024
c5747ac
l2s: removed wrapper blocks and deal with phis directly
Hugobros3 Aug 20, 2024
90425bd
l2s: removed wrappers map
Hugobros3 Aug 21, 2024
ecc31d0
l2s: refactor the control wrapping code to make decisions prior to re…
Hugobros3 Aug 21, 2024
0c605f4
l2s: rewrite according to domtree
Hugobros3 Aug 21, 2024
6aea21b
removed scope stuff from l2s_postprocess
Hugobros3 Aug 21, 2024
a45c6bd
added lift_everything pass
Hugobros3 Aug 21, 2024
1278dd7
added a pass turning shady.scope into control blocks
Hugobros3 Aug 21, 2024
9e633b7
re-engineered CFG analysis 'works'
Hugobros3 Aug 21, 2024
22b6079
everything 'works'
Hugobros3 Aug 21, 2024
baab2c5
new version of the loop heuristic wip
Hugobros3 Aug 22, 2024
d02b6d5
scope_heuristic: cleanup
Hugobros3 Aug 22, 2024
03399e8
scope_heuristics: more reliably deal with loops by making their heade…
Hugobros3 Aug 22, 2024
9758e72
fix a couple memory safety issues
Hugobros3 Aug 22, 2024
7e8b3ae
printer QOL improvements
Hugobros3 Aug 22, 2024
a6ef11d
scope2control: deal with uniform values
Hugobros3 Aug 22, 2024
8d0a3b2
scope_heuristics: improved
Hugobros3 Aug 22, 2024
1d8bce5
lift_everything: actually don't lift structured targets
Hugobros3 Aug 22, 2024
0566bdf
fix memory leak in body_builder
Hugobros3 Aug 22, 2024
cdd486a
re-added old reconvergence heuristics pass
Hugobros3 Aug 22, 2024
626c6b1
scope2control: fix memory leaks
Hugobros3 Aug 22, 2024
8e50902
remove lifting logic from reconvergence_heuristics (handled by lift_e…
Hugobros3 Aug 22, 2024
f89a0aa
re-added lcssa pass
Hugobros3 Aug 22, 2024
7f19baf
reconvergence_heuristics: rename idom to postdom
Hugobros3 Aug 22, 2024
f86ccba
print: use BB names
Hugobros3 Aug 22, 2024
dca4d83
fixed reconvergence heuristics not inserting joins properly
Hugobros3 Aug 23, 2024
80204bb
config: move relevant options to input_cf section
Hugobros3 Aug 27, 2024
540a06a
slim: added line info to parser and errors
Hugobros3 Aug 27, 2024
e5a159d
fixed lower_workgroups pass
Hugobros3 Aug 31, 2024
1e4414e
c: fix composite emission
Hugobros3 Aug 31, 2024
2f63526
c/ispc: fix various codegen issues
Hugobros3 Aug 31, 2024
7b10dc1
c: fix some memory leaks
Hugobros3 Aug 31, 2024
9dd490a
aobench: fix ispc path
Hugobros3 Aug 31, 2024
9b0cae2
c: make sure to emit bodies recursively _first_
Hugobros3 Aug 31, 2024
967eb9b
c: move some fns about
Hugobros3 Aug 31, 2024
0880a22
c: always bind primops for now
Hugobros3 Aug 31, 2024
07680fb
aobench: disable vectorisation
Hugobros3 Aug 31, 2024
2cc0795
fold: fix broken match folding rule
Hugobros3 Aug 31, 2024
f6eeb56
move opt_restructure to the end of the pipeline
Hugobros3 Sep 1, 2024
e8d557a
lower_generic_globals: avoid creating an useless constant
Hugobros3 Sep 1, 2024
801bfc7
lower_generic_ptrs: fix write path
Hugobros3 Sep 1, 2024
1626e02
fix some asan issues
Hugobros3 Sep 2, 2024
c73082c
mem2reg2: fix broken syntax
Hugobros3 Sep 2, 2024
baacb84
added simplistic mem2reg opt
Hugobros3 Sep 2, 2024
652e134
fix opt_demote_alloca
Hugobros3 Sep 2, 2024
50ac941
improved fixedpoint opt
Hugobros3 Sep 2, 2024
2e26953
cfg: deal with structured edges better
Hugobros3 Sep 2, 2024
80fe794
opt_demote_alloca: stronger against dead stores
Hugobros3 Sep 2, 2024
bda535c
mem2reg: allow searching in dominators
Hugobros3 Sep 2, 2024
a3980b5
remove redudant search_processed calls from all passes
Hugobros3 Sep 2, 2024
a96244e
changed signature of search_processed
Hugobros3 Sep 2, 2024
4ad3d1e
added opt to eliminate trivial control blocks
Hugobros3 Sep 2, 2024
7e8d5d9
fix broken multi-word int serdes
Hugobros3 Sep 2, 2024
5beef4f
split Lea in PtrArrayElementOffset and PtrCompositeElement
Hugobros3 Sep 3, 2024
046dba7
fix mem2reg (i am big dumb)
Hugobros3 Sep 3, 2024
61580d1
fix reconvergence_heuristics
Hugobros3 Sep 3, 2024
5b0161a
fix API that C++ hates
Hugobros3 Sep 3, 2024
61c447b
ignore llvm.var.annotation
Hugobros3 Sep 3, 2024
ece2713
prepare lift_indirect_targets
Hugobros3 Sep 3, 2024
e79683c
eliminate 0-sized memcpy from generated code
Hugobros3 Sep 11, 2024
1ca1ce7
hacky fix for lift_indirect_targets
Hugobros3 Sep 11, 2024
23aefdb
l2s: robustly deal with funny BB orders on-disk
Hugobros3 Sep 11, 2024
cdd1cf4
fix Match merges being emitted wrong in SPIR-V mode
Hugobros3 Sep 11, 2024
4038683
add 'static' to loose functions in vec_mat.h
Hugobros3 Sep 11, 2024
bc760e0
cfg: improved configuration mechanism
Hugobros3 Sep 11, 2024
b6c7443
added a pass to remove critical edges
Hugobros3 Sep 11, 2024
7abfe93
cleaned up reconvergence_heuristics, fix uniform params
Hugobros3 Sep 11, 2024
25001c0
make generic address tags 3-bit wide and reserve 000 and 111 for Global
Hugobros3 Sep 11, 2024
c963dff
fix broken global variable initialisation
Hugobros3 Sep 12, 2024
f2c7f46
fix broken lowering in lower_physical_ptrs
Hugobros3 Sep 12, 2024
3bd459b
work towards fixing fn_pointers
Hugobros3 Sep 12, 2024
595cde3
fix inconsistent types in l2s_instr
Hugobros3 Sep 23, 2024
51d43f6
remove compile.h, move it's functionality elsewhere
Hugobros3 Sep 24, 2024
cf12c72
apply lower_cf_instrs in slim driver
Hugobros3 Sep 24, 2024
1806112
restored mem2reg test functionality
Hugobros3 Sep 24, 2024
6f97e79
comment out broken Vcc test
Hugobros3 Sep 24, 2024
536ebda
remove unused declaration tripping up SWIG
Hugobros3 Sep 24, 2024
7560752
fix infinite loop in chase_ptr_to_source
Hugobros3 Sep 24, 2024
cc3f49e
add shd_ prefix to arena.h and list.h
Hugobros3 Sep 25, 2024
780dd9d
add shd_ prefix to dict.h
Hugobros3 Sep 25, 2024
1119e51
add shd_ prefix to util.h and log.h
Hugobros3 Sep 25, 2024
92fb633
add shd_ prefix to portability.h
Hugobros3 Sep 25, 2024
02566a2
added shd_ prefix to print.h
Hugobros3 Sep 25, 2024
8c6a697
add shd_ prefix to log.h
Hugobros3 Sep 25, 2024
64f36b9
common: normalized all remaining (void) fns
Hugobros3 Sep 25, 2024
d0a3e46
add shd_ prefix to nodes functions
Hugobros3 Sep 25, 2024
dccaa47
add shd_ prefix to scalar type helpers
Hugobros3 Sep 25, 2024
f268eea
slim: added shd_ prefix
Hugobros3 Oct 6, 2024
7fc4a62
fe/spv: add shd_ prefix
Hugobros3 Oct 6, 2024
4a36c0d
fe/slim: move stuff onto the public headers more
Hugobros3 Oct 6, 2024
1967fe0
be/c: prefix with shd_
Hugobros3 Oct 6, 2024
0b958b4
config.h: added shd_ prefix
Hugobros3 Oct 6, 2024
ec2e25b
added shd_ prefix to builtins.h
Hugobros3 Oct 6, 2024
7b40d6b
pass.h: added shd_ prefix
Hugobros3 Oct 6, 2024
1799d9c
print.h: added shd_ prefix
Hugobros3 Oct 6, 2024
e05c975
made add_scheduler_source static
Hugobros3 Oct 6, 2024
8953b6c
driver.h: add shd_ prefix
Hugobros3 Oct 6, 2024
1ed4a7e
move generated node ctors to header-only
Hugobros3 Oct 6, 2024
076ac1f
added basic code style info
Hugobros3 Oct 6, 2024
62fe235
removed manually-built node ctor helpers
Hugobros3 Oct 6, 2024
cd997ef
added shd_ prefix to ir.c
Hugobros3 Oct 7, 2024
be5c774
move memory_layout to the public API
Hugobros3 Oct 7, 2024
daec665
prefix print stuff with shd_
Hugobros3 Oct 7, 2024
3a36021
annotation.c: add shd_ prefix
Hugobros3 Oct 7, 2024
7b4b952
add _shd prefix to more internal stuff
Hugobros3 Oct 7, 2024
0d27ff0
rewrite: added shd_ prefix
Hugobros3 Oct 7, 2024
a1e4df5
moved rewrite.h to public API
Hugobros3 Oct 7, 2024
d21456d
move visit.h to public API
Hugobros3 Oct 7, 2024
e8826a5
prefix hash/cmp node
Hugobros3 Oct 7, 2024
ecd8946
split ir.h into multiple components
Hugobros3 Oct 7, 2024
6fcb7f8
move memory_layout.h to shady/ir/
Hugobros3 Oct 7, 2024
a2f3903
move memory_layout.h to shady/ir/
Hugobros3 Oct 7, 2024
738cb38
remove a bunch of dependencies on old ir.h
Hugobros3 Oct 7, 2024
19cebc1
moved builtins.h to shady/ir/
Hugobros3 Oct 7, 2024
2271fef
move most type helpers to shady/ir/type.h
Hugobros3 Oct 7, 2024
4cb7ef7
remove global variables from ir.h
Hugobros3 Oct 7, 2024
e16433b
split off the final ir.h declarations
Hugobros3 Oct 7, 2024
1cfe756
ir/primop.h: added shd_ prefix
Hugobros3 Oct 7, 2024
fc9ada6
more shd_ prefixing
Hugobros3 Oct 7, 2024
3021dd5
add missing function.h
Hugobros3 Oct 7, 2024
d6ed5c5
yet more shd_ prefixing
Hugobros3 Oct 7, 2024
fa74d55
prefixed all the passes
Hugobros3 Oct 8, 2024
da7406f
move code to match new shady/ir structure
Hugobros3 Oct 7, 2024
472d2cb
body_builder: move struct layout away from ir_private.h
Hugobros3 Oct 7, 2024
f50c332
added literal.c and debug.c
Hugobros3 Oct 7, 2024
f7e7850
add missing check.[c, h] files
Hugobros3 Oct 9, 2024
b1f59cd
prefix some things in check.c
Hugobros3 Oct 9, 2024
356af2d
prefix more type-related stuff, move it to type.h
Hugobros3 Oct 9, 2024
61ff407
don't trust clion's move refactor :/
Hugobros3 Oct 10, 2024
fb80fe2
removed murmur3 as a dependency
Hugobros3 Oct 10, 2024
4a71627
reorganise built-in code in C backend
Hugobros3 Oct 11, 2024
5882b61
use static inline wrappers for nominal defs
Hugobros3 Oct 14, 2024
7affa7b
type.c: add shd_ to most remaining helpers
Hugobros3 Oct 14, 2024
1e1c73a
start melting ir_gen_helpers away
Hugobros3 Oct 14, 2024
aa7fdce
rename all functions in body_builder.h
Hugobros3 Oct 14, 2024
e19e2e8
move builer.h into shady/ir/
Hugobros3 Oct 14, 2024
c5a0cfb
Fix hash algorithm
TheJackiMonster Oct 13, 2024
6be16ae
more renaming/moving
Hugobros3 Oct 14, 2024
b833264
move builin-related builder fns to builder.h
Hugobros3 Oct 14, 2024
79a5064
remove gen_lea
Hugobros3 Oct 14, 2024
ecdae61
moved mem instr builders to mem.h
Hugobros3 Oct 14, 2024
9354900
remove decl utilities from ir_gen_helpers
Hugobros3 Oct 14, 2024
859e977
removed some variants of gen_primop
Hugobros3 Oct 14, 2024
800f476
removed gen_primop_ce
Hugobros3 Oct 14, 2024
e02118f
remove gen_primop_e
Hugobros3 Oct 14, 2024
7761136
fix regression in lower_tailcalls
Hugobros3 Oct 14, 2024
46f3232
move memory_layout.c to shady/ir/
Hugobros3 Oct 14, 2024
b9b7dee
move stack stuff to a new file
Hugobros3 Oct 14, 2024
b2cc958
move comments & debug printf to debug.h
Hugobros3 Oct 14, 2024
a5dc144
remove gen_merge_halves
Hugobros3 Oct 14, 2024
e581a2f
move reinterpret & convert to cast.h
Hugobros3 Oct 14, 2024
336796e
put int conversion stuff in int.h
Hugobros3 Oct 14, 2024
2f2c5a9
put call builder in function.h
Hugobros3 Oct 14, 2024
4d2b96c
add shady/ir/ext.h for external intrinsics
Hugobros3 Oct 14, 2024
293fc6d
removed ir_gen_helper
Hugobros3 Oct 14, 2024
e21f114
prefix everything in transform/
Hugobros3 Oct 14, 2024
a482d7c
check.c: prefix with _shd_
Hugobros3 Oct 14, 2024
0c09c3f
grammar_generator: use more static inline functions
Hugobros3 Oct 14, 2024
d2f9fa9
s2s: make everything static
Hugobros3 Oct 14, 2024
e687f63
spvb: fix issues with namespacing
Hugobros3 Oct 14, 2024
b0da081
c: prefix everything with shd_
Hugobros3 Oct 14, 2024
0b20045
spvb: fix another namespacing issue
Hugobros3 Oct 14, 2024
be140ff
l2s: prefix
Hugobros3 Oct 14, 2024
d1c691c
fix misc symbols
Hugobros3 Oct 14, 2024
aeb43e9
prefix get_node_class_from_tag
Hugobros3 Oct 14, 2024
a9f9379
rename ext.h fns
Hugobros3 Oct 14, 2024
1242fe1
rename string and string_sized
Hugobros3 Oct 14, 2024
9859232
runtime: prefix the world too
Hugobros3 Oct 14, 2024
3ea8f8f
updated codestyle
Hugobros3 Oct 14, 2024
7021616
ir/int: added an unsafe function to resolve a node to a literal directly
Hugobros3 Oct 21, 2024
a8e0d32
added lower_inclusive_scan pass
Hugobros3 Oct 21, 2024
543aa62
c: improved codegen for ExtInstr
Hugobros3 Oct 21, 2024
c43ba10
added printer escape/unescape functions, plus testing
Hugobros3 Oct 22, 2024
29cc0ea
emit_c: fix escape code sequence for debug printf
Hugobros3 Oct 22, 2024
5abaaf6
turn slim's extended ops into a proper extinst using standard tooling
Hugobros3 Oct 22, 2024
f034ee1
ispc: add workarround to broadcast ptrs
Hugobros3 Oct 26, 2024
7a339c9
updated SPIRV-Headers
Hugobros3 Oct 27, 2024
57dca39
added draft support for SPV_SHADY_indirect_tail_calls
Hugobros3 Oct 27, 2024
2554b70
slim: added a 'tailcall' token
Hugobros3 Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 7 additions & 14 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ jobs:
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Install SPIRV-Headers
run: |
git clone https://github.com/KhronosGroup/SPIRV-Headers
mkdir SPIRV-Headers/build
cmake -B SPIRV-Headers/build -S SPIRV-Headers
mkdir SPIRV-Headers/install
cmake --install SPIRV-Headers/build --prefix SPIRV-Headers/install
#- name: Install SPIRV-Headers
# run: |
# git clone https://github.com/KhronosGroup/SPIRV-Headers
# mkdir SPIRV-Headers/build
# cmake -B SPIRV-Headers/build -S SPIRV-Headers
# mkdir SPIRV-Headers/install
# cmake --install SPIRV-Headers/build --prefix SPIRV-Headers/install

- name: Install Clang & LLVM (setup-clang)
if: (!startsWith(matrix.os,'windows'))
uses: egor-tensin/[email protected]

#- name: Install LLVM (winlibs)
Expand All @@ -89,12 +88,6 @@ jobs:
run: |
echo "CMAKE_PLATFORM_SPECIFIC_ARGS=${{ env.CMAKE_PLATFORM_SPECIFIC_ARGS }} -DLLVM_DIR=/usr/lib/llvm-14/cmake" >> $GITHUB_ENV

- name: Install json-c (vcpkg)
if: startsWith(matrix.os,'windows')
run: |
vcpkg install json-c
echo "CMAKE_PLATFORM_SPECIFIC_ARGS=-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" >> "$env:GITHUB_ENV"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "murmur3"]
path = murmur3
url = https://github.com/PeterScott/murmur3
[submodule "SPIRV-Headers"]
path = SPIRV-Headers
url = https://github.com/shady-gang/SPIRV-Headers.git
branch = main
97 changes: 82 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,53 +1,120 @@
cmake_minimum_required(VERSION 3.13)
project (shady C)

include(ExternalProject)
include(FetchContent)

find_package(Git)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(SHADY_USE_FETCHCONTENT "Use FetchContent to grab json-c" ON)
option(SHADY_WIN32_FIX_PARTIAL_LLVM_INSTALL "If you install LLVM on windows, it doesn't come with header files. This fixes it" ON)

if (MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()

find_package(SPIRV-Headers REQUIRED)
if (WIN32)
set(BUILD_SHARED_LIBS OFF)
endif()

add_subdirectory(SPIRV-Headers)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24" AND ${SHADY_USE_FETCHCONTENT})
FetchContent_Declare(
json-c
GIT_REPOSITORY https://github.com/json-c/json-c
GIT_TAG master
OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(json-c)
add_library(json-c::json-c ALIAS json-c)
configure_file(${json-c_SOURCE_DIR}/json.h.cmakein ${json-c_BINARY_DIR}/json-c/json.h @ONLY)
target_include_directories(json-c PUBLIC $<BUILD_INTERFACE:${json-c_BINARY_DIR}>)
else ()
message("CMake 3.24 or later is required to use FetchContent")
endif ()

find_package(LLVM QUIET)
if (LLVM_FOUND)
message("LLVM ${LLVM_VERSION} found")
endif()
if(NOT ${LLVM_FOUND} AND WIN32 AND ${SHADY_WIN32_FIX_PARTIAL_LLVM_INSTALL})
find_program(clang_exe "clang.exe")
if(${clang_exe} STREQUAL "clang_exe-NOTFOUND")
message(STATUS "Win32: Installed LLVM not found")
else()
execute_process(COMMAND ${clang_exe} --version OUTPUT_VARIABLE clang_status)
string(REGEX MATCH "InstalledDir: (.*)[\r\n]" match ${clang_status})
file(TO_CMAKE_PATH "${CMAKE_MATCH_1}/../" LLVM_DIR)
cmake_path(ABSOLUTE_PATH LLVM_DIR NORMALIZE)
string(REGEX MATCH "clang version ([0-9]+).([0-9]+).([0-9]+)" match2 ${clang_status})
set(LLVM_VERSION_MAJOR ${CMAKE_MATCH_1})
set(LLVM_VERSION_MINOR ${CMAKE_MATCH_2})
set(LLVM_VERSION_PATCH ${CMAKE_MATCH_3})
set(LLVM_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
add_library(LLVM-C SHARED IMPORTED)
set_property(TARGET LLVM-C PROPERTY
IMPORTED_LOCATION "${LLVM_DIR}bin/LLVM-C.dll")
set_property(TARGET LLVM-C PROPERTY
IMPORTED_IMPLIB "${LLVM_DIR}lib/LLVM-C.lib")

execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${GIT_EXECUTABLE} clone -n --depth 1 --filter=tree:0 https://github.com/llvm/llvm-project/ --branch "llvmorg-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}"
)
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/llvm-project
COMMAND ${GIT_EXECUTABLE} sparse-checkout set --no-cone llvm/include/llvm-c
)
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/llvm-project
COMMAND ${GIT_EXECUTABLE} checkout
)
target_include_directories(LLVM-C INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm/include)
target_compile_definitions(LLVM-C INTERFACE -DLLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR} -DLLVM_VERSION_PATCH=${LLVM_VERSION_PATCH})
message(STATUS "Win32: Installed LLVM ${LLVM_VERSION} found at ${LLVM_DIR}")
set(LLVM_FOUND TRUE)
endif()
endif()

include(GNUInstallDirs)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# required for MSVC
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1)

cmake_policy(SET CMP0118 NEW)
add_subdirectory(src)
add_subdirectory(vcc)

add_subdirectory(zhady)

include(CTest)
if (BUILD_TESTING)
add_subdirectory(test)
endif()

set(BUILD_SAMPLES ON CACHE BOOL "Whether to build built-in demo applications")
if (BUILD_SAMPLES)
add_subdirectory(samples)
endif()
add_subdirectory(samples)

include(CMakePackageConfigHelpers)

install(TARGETS api EXPORT shady_export_set)
install(TARGETS shady EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

if (TARGET vcc)
add_subdirectory(vcc-std)
endif ()

if (TARGET runtime)
install(TARGETS runtime EXPORT shady_export_set ARCHIVE DESTINATION ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
endif()

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/shady DESTINATION include)
install(EXPORT shady_export_set DESTINATION share/cmake/shady/ NAMESPACE shady:: FILE shady-targets.cmake)

configure_file(cmake/shady-config.cmake.in shady-config.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shady-config.cmake" DESTINATION share/cmake/shady)
#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shady-config.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/shady)
1 change: 1 addition & 0 deletions SPIRV-Headers
Submodule SPIRV-Headers added at 145355
40 changes: 40 additions & 0 deletions doc/code_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Code style Guidelines

This guide is for our own reference as much as anyone else.
If you have a good reason for breaking any of those rules we're happy to consider your contributions without prejudice.

* 4 spaces indentation
* `Type* name`
* `snake_case` by default
* `UpperCamelCase` for types and typedefs
* Use only typedefs or append `_` to struct/union/enums names
* `LOUD_CASE` for public macros
* `{ spaces, surrounding, initializer, lists }`
* Unless you're literally contributing using a 80-column display (for which I'll ask visual proof), don't format your code as if you do.
* Include order:
* If appropriate, (Private) `self.h` should always come first, with other local headers in the same group
* Then other `shady/` headers
* Then in-project utility headers
* Then external headers
* Finally, standard C library headers.
* Each category of includes spaced by an empty line

## Symbol naming

Due to C not having namespaces, we have to deal with this painfully automatable problem ourselves.

* Avoid exposing any symbols that don't need to be exposed (use `static` wherever you can)
* Prefixes:
* `shd_` in front of API functions (in the root `include` folder)
* `slim_`, `l2s_`, `spv_` and `vcc_` are used in various sub-projects
* `subsystem_` is acceptable for internal use
* `shd_subsystem_` is preferable where a clear delineation can be made
* `shd_new_thing` and `shd_destroy_thing` for constructors and destructors
* `static inline` functions in headers are not required to be prefixed
* Types & Typedefs may be prefixed with `Shd`
* Alternatively, subsystem-relevant ones can use another prefix, much like for functions
* Do not expose global variables to external APIs at all (provide getter functions if necessary)

## Cursing in comments

Can be funny but keep it somewhat family friendly.
20 changes: 20 additions & 0 deletions include/shady/analysis/literal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef SHADY_ANALYSIS_LITERAL_H
#define SHADY_ANALYSIS_LITERAL_H

#include "shady/ir/grammar.h"

const char* shd_get_string_literal(IrArena* arena, const Node* node);

typedef struct {
bool enter_loads;
bool allow_incompatible_types;
bool assume_globals_immutability;
} NodeResolveConfig;

NodeResolveConfig shd_default_node_resolve_config(void);
const Node* shd_chase_ptr_to_source(const Node* ptr, NodeResolveConfig config);
const Node* shd_resolve_ptr_to_value(const Node* ptr, NodeResolveConfig config);

const Node* shd_resolve_node_to_definition(const Node* node, NodeResolveConfig config);

#endif
27 changes: 27 additions & 0 deletions include/shady/be/c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef SHD_BE_C_H
#define SHD_BE_C_H

#include "shady/ir/base.h"

typedef enum {
CDialect_C11,
CDialect_GLSL,
CDialect_ISPC,
CDialect_CUDA,
} CDialect;

typedef struct {
CDialect dialect;
bool explicitly_sized_types;
bool allow_compound_literals;
bool decay_unsized_arrays;
int glsl_version;
} CEmitterConfig;

CEmitterConfig shd_default_c_emitter_config(void);

typedef struct CompilerConfig_ CompilerConfig;
void shd_emit_c(const CompilerConfig* compiler_config, CEmitterConfig config, Module* mod, size_t* output_size, char** output, Module** new_mod);

#endif

16 changes: 16 additions & 0 deletions include/shady/be/dump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef SHD_BE_DUMP_H
#define SHD_BE_DUMP_H

#include "shady/ir/base.h"
#include "shady/ir/module.h"

#include <stdio.h>

void shd_dump_module(Module* mod);
void shd_dump_node(const Node* node);

void shd_dump_cfgs(FILE* output, Module* mod);
void shd_dump_loop_trees(FILE* output, Module* mod);

#endif

10 changes: 10 additions & 0 deletions include/shady/be/spirv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef SHD_BE_SPIRV_H
#define SHD_BE_SPIRV_H

#include "shady/ir/base.h"

typedef struct CompilerConfig_ CompilerConfig;
void shd_emit_spirv(const CompilerConfig* config, Module* mod, size_t* output_size, char** output, Module** new_mod);

#endif

55 changes: 0 additions & 55 deletions include/shady/builtins.h

This file was deleted.

Loading