From c7c97ad4bb62b83efd6e26cdd4f38ebf164ec40e Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 8 Feb 2018 14:46:12 -0800 Subject: Basic IR support for `static const` globals (#404) * Basic IR support for `static const` globals Our strategy for lowering global *variables* can fall back to putting their initialization into a function, but that isn't really appropriate for global constants (it also isn't appropriate for arrays, but we'll need to deal with that seaprately). This change adds a distinct case for global constants (rather than treating them as variables), and forces the emission logic to always emit them as a single expression. Doing this makes assumptions about how the IR for these constants gets emitted (and what optimziations might do to it). In order to make things work, I had to switch the handling of initializer-list expressions to not be lowered via temporaries and mutation (since that isn't a good fit for reverting to a single expression). I've added a single test case to ensure that this works in the simplest scenario. My next priority will be to see if this unblocks my work in Falcor. * Fixup: bug fixes --- tests/compute/static-const-array.slang.expected.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/compute/static-const-array.slang.expected.txt (limited to 'tests/compute/static-const-array.slang.expected.txt') diff --git a/tests/compute/static-const-array.slang.expected.txt b/tests/compute/static-const-array.slang.expected.txt new file mode 100644 index 000000000..88c4cd187 --- /dev/null +++ b/tests/compute/static-const-array.slang.expected.txt @@ -0,0 +1,4 @@ +10 +1 +20 +2 -- cgit v1.2.3