From 10b62eecd94be53eca4ac2555af860f864966d76 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 14 Sep 2017 15:37:05 -0700 Subject: IR: handle control flow constructs (#186) * IR: handle control flow constructs This change includes a bunch of fixes and additions to the IR path: - `slang-ir-assembly` is now a valid output target (so we can use it for testing) - This uses what used to be the IR "dumping" logic, revamped to support much prettier output. - A future change will need to add back support for less prettified output to use when actually debugging - IR generation for `for` loops and `if` statements is supported - HLSL output from the above control flow constructs is implemented - Revamped the handling of l-values, and in particular work on compound ops like `+=` - Add basic IR support for `groupshared` variables - Add basic IR support for storing compute thread-group size - Output semantics on entry point parameters - This uses the AST structures to find semantics, so its still needs work - Pass through loop unroll flags - This is required to match `fxc` output, at least until we implement unrolling ourselves. * Fixup: 64-bit build issues. * fixup for merge --- tests/ir/loop.slang.expected | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/ir/loop.slang.expected (limited to 'tests/ir/loop.slang.expected') diff --git a/tests/ir/loop.slang.expected b/tests/ir/loop.slang.expected new file mode 100644 index 000000000..2dc091b0e --- /dev/null +++ b/tests/ir/loop.slang.expected @@ -0,0 +1,67 @@ +result code = 0 +standard error = { +} +standard output = { +let %41 : Ptr,64>,1> = var() +let %68 : Ptr>,0> = var() +let %243 : Ptr>,0> = var() + +func %1( + param %7 : UInt32, + param %10 : UInt32, + param %13 : UInt32) +{ +block %4: + let %47 : Ptr,0> = getElementPtr(%41, %10) + let %69 : StructuredBuffer> = load(%68) + let %72 : Vec = bufferLoad(%69, %7) + store(%47, %72) + let %81 : Ptr = var() + let %89 : UInt32 = construct(1) + store(%81, %89) + loop(%94, %100, %103) + +block %94: + let %110 : UInt32 = load(%81) + let %119 : UInt32 = construct(64) + let %120 : Bool = cmpLT(%110, %119) + loopTest(%120, %97, %100) + +block %97: + GroupMemoryBarrierWithGroupSync() + let %147 : Ptr,0> = getElementPtr(%41, %10) + let %152 : Ptr,0> = var() + let %153 : Vec = load(%147) + store(%152, %153) + let %174 : UInt32 = load(%81) + let %175 : UInt32 = sub(%10, %174) + let %180 : Ptr,0> = getElementPtr(%41, %175) + let %181 : Vec = load(%180) + let %182 : Vec = load(%152) + let %183 : Vec = add(%182, %181) + store(%152, %183) + let %186 : Vec = load(%152) + store(%147, %186) + unconditionalBranch(%103) + +block %103: + let %199 : Ptr = var() + let %200 : UInt32 = load(%81) + store(%199, %200) + let %211 : UInt32 = construct(1) + let %212 : UInt32 = load(%199) + let %213 : UInt32 = shl(%212, %211) + store(%199, %213) + let %216 : UInt32 = load(%199) + store(%81, %216) + unconditionalBranch(%94) + +block %100: + GroupMemoryBarrierWithGroupSync() + let %244 : RWStructuredBuffer> = load(%243) + let %260 : Ptr,0> = getElementPtr(%41, 0) + let %261 : Vec = load(%260) + bufferStore(%244, %7, %261) + return_void() +} +} -- cgit v1.2.3