[lunarglass] r1088 committed - BottomTranslator/LunarGOO: Handle simple unnested switch/case/default/...

1 view
Skip to first unread message

lunar...@googlecode.com

unread,
May 31, 2015, 5:30:26 PM5/31/15
to lunargla...@googlegroups.com
Revision: 1088
Author: jo...@lunarg.com
Date: Sun May 31 21:29:58 2015 UTC
Log: BottomTranslator/LunarGOO: Handle simple unnested
switch/case/default/break statements. (Arbitrary topologies require an
additional analysis, but this is the correct back-end interface.)

https://code.google.com/p/lunarglass/source/detail?r=1088

Added:
/trunk/test/baseResults/simpleSwitch.vert.out
/trunk/test/simpleSwitch.vert
Modified:
/trunk/Backends/Dummy/BottomToDummy.cpp
/trunk/Backends/GLSL/BottomToGLSL.cpp
/trunk/Core/Backend.h
/trunk/Core/BottomTranslator.cpp
/trunk/test/baseResults/switch.frag.out
/trunk/test/runtests

=======================================
--- /dev/null
+++ /trunk/test/baseResults/simpleSwitch.vert.out Sun May 31 21:29:58 2015
UTC
@@ -0,0 +1,711 @@
+
+Top IR:
+; ModuleID = 'Glslang'
+
+%gl_PerVertex = type { <4 x float>, float, [1 x float], <4 x float>, <4 x
float>, <4 x float>, <4 x float>, <4 x float>, [1 x <4 x float>], float, [1
x float] }
+
+@inf = global float 0.000000e+00
+@b = external addrspace(2) constant i32
+@c = external addrspace(2) constant i32
+@"anon@0" = global %gl_PerVertex zeroinitializer
+@gl_VertexID = global i32 0
+@gl_InstanceID = global i32 0
+
+define fastcc void @main() {
+entry:
+ %"anon@0" = alloca <4 x float>
+ %out_v = alloca <3 x float>
+ %param = alloca <3 x float>
+ %a = alloca i32
+ br label %mainBody
+
+mainBody: ; preds = %entry
+ %a1 = load i32 addrspace(2)* @b, !gla.uniform !6
+ store i32 %a1, i32* %a
+ call void @"foo(vf3;"(<3 x float>* %param)
+ %out_v2 = load <3 x float>* %param
+ store <3 x float> %out_v2, <3 x float>* %out_v
+ %0 = load i32 addrspace(2)* @c, !gla.uniform !8
+ %1 = sub i32 %0, 8
+ switch i32 %1, label %switch-segment7 [
+ i32 1, label %switch-segment
+ i32 2, label %switch-segment3
+ i32 3, label %switch-segment4
+ i32 4, label %switch-segment5
+ i32 9, label %switch-segment6
+ ]
+
+switch-segment: ; preds = %mainBody
+ %2 = load i32* %a
+ %a8 = mul i32 2, %2
+ store i32 %a8, i32* %a
+ br label %switch-merge
+
+switch-segment3: ; preds = %mainBody
+ %3 = load i32* %a
+ %a9 = add i32 %3, 5
+ store i32 %a9, i32* %a
+ br label %switch-segment4
+
+switch-segment4: ; preds
= %switch-segment3, %mainBody
+ %4 = load i32* %a
+ %a10 = sub i32 %4, 15
+ store i32 %a10, i32* %a
+ br label %switch-merge
+
+switch-segment5: ; preds = %mainBody
+ %5 = load i32* %a
+ %6 = load i32 addrspace(2)* @b, !gla.uniform !6
+ %7 = mul i32 %5, %6
+ %8 = load i32* %a
+ %a12 = add i32 %8, %7
+ store i32 %a12, i32* %a
+ br label %switch-merge
+
+switch-segment6: ; preds = %mainBody
+ %9 = load i32* %a
+ %a14 = sub i32 %9, 1
+ store i32 %a14, i32* %a
+ br label %switch-segment7
+
+switch-segment7: ; preds
= %switch-segment6, %mainBody
+ %10 = load i32* %a
+ %a15 = sub i32 %10, 13
+ store i32 %a15, i32* %a
+ br label %switch-merge
+
+switch-merge: ; preds
= %switch-segment7, %switch-segment5, %switch-segment4, %switch-segment
+ %11 = load <3 x float>* %out_v
+ %12 = load i32* %a
+ %13 = sitofp i32 %12 to float
+ %14 = load <4 x float>* %"anon@0"
+ %15 = extractelement <3 x float> %11, i32 0
+ %16 = insertelement <4 x float> %14, float %15, i32 0
+ %17 = extractelement <3 x float> %11, i32 1
+ %18 = insertelement <4 x float> %16, float %17, i32 1
+ %19 = extractelement <3 x float> %11, i32 2
+ %20 = insertelement <4 x float> %18, float %19, i32 2
+ %21 = insertelement <4 x float> %20, float %13, i32 3
+ store <4 x float> %21, <4 x float>* getelementptr inbounds
(%gl_PerVertex* @"anon@0", i32 0, i32 0)
+ br label %stage-epilogue
+
+post-switch-break: ; No predecessors!
+ unreachable
+
+post-switch-break11: ; No predecessors!
+ unreachable
+
+post-switch-break13: ; No predecessors!
+ unreachable
+
+post-switch-break16: ; No predecessors!
+ unreachable
+
+stage-epilogue: ; preds = %switch-merge
+ br label %stage-exit
+
+stage-exit: ; preds = %stage-epilogue
+ ret void
+}
+
+; Function Attrs: alwaysinline
+define internal fastcc void @"foo(vf3;"(<3 x float>*) #0 {
+entry:
+ %out_v17 = alloca <3 x float>
+ %out_v15 = alloca <3 x float>
+ %out_v13 = alloca <3 x float>
+ %out_v11 = alloca <3 x float>
+ %out_v9 = alloca <3 x float>
+ %out_v = alloca <3 x float>
+ %t = alloca float
+ %q = alloca float
+ %p = alloca float
+ %1 = load float* @inf
+ %2 = load float* @inf
+ %3 = fsub float 3.000000e+00, %2
+ %p1 = fmul float %1, %3
+ store float %p1, float* %p
+ %4 = load float* @inf
+ %5 = load float* @inf
+ %6 = fmul float %5, 0x402B9999A0000000
+ %7 = fsub float 3.000000e+00, %6
+ %q2 = fmul float %4, %7
+ store float %q2, float* %q
+ %8 = load float* @inf
+ %9 = load float* @inf
+ %10 = fsub float 3.000000e+00, %9
+ %t3 = fmul float %8, %10
+ store float %t3, float* %t
+ %11 = load i32 addrspace(2)* @b, !gla.uniform !6
+ switch i32 %11, label %switch-merge [
+ i32 0, label %switch-segment
+ i32 1, label %switch-segment4
+ i32 2, label %switch-segment5
+ i32 3, label %switch-segment6
+ i32 4, label %switch-segment7
+ i32 5, label %switch-segment8
+ ]
+
+switch-segment: ; preds = %entry
+ %12 = load float* @inf
+ %13 = load float* %t
+ %14 = load float* %p
+ %15 = load <3 x float>* %out_v
+ %16 = insertelement <3 x float> %15, float %12, i32 0
+ %17 = insertelement <3 x float> %16, float %13, i32 1
+ %18 = insertelement <3 x float> %17, float %14, i32 2
+ store <3 x float> %18, <3 x float>* %0
+ br label %switch-merge
+
+switch-segment4: ; preds = %entry
+ %19 = load float* %q
+ %20 = load float* @inf
+ %21 = load float* %p
+ %22 = load <3 x float>* %out_v9
+ %23 = insertelement <3 x float> %22, float %19, i32 0
+ %24 = insertelement <3 x float> %23, float %20, i32 1
+ %25 = insertelement <3 x float> %24, float %21, i32 2
+ store <3 x float> %25, <3 x float>* %0
+ br label %switch-merge
+
+switch-segment5: ; preds = %entry
+ %26 = load float* %p
+ %27 = load float* @inf
+ %28 = load float* %t
+ %29 = load <3 x float>* %out_v11
+ %30 = insertelement <3 x float> %29, float %26, i32 0
+ %31 = insertelement <3 x float> %30, float %27, i32 1
+ %32 = insertelement <3 x float> %31, float %28, i32 2
+ store <3 x float> %32, <3 x float>* %0
+ br label %switch-merge
+
+switch-segment6: ; preds = %entry
+ %33 = load float* %p
+ %34 = load float* %q
+ %35 = load float* @inf
+ %36 = load <3 x float>* %out_v13
+ %37 = insertelement <3 x float> %36, float %33, i32 0
+ %38 = insertelement <3 x float> %37, float %34, i32 1
+ %39 = insertelement <3 x float> %38, float %35, i32 2
+ store <3 x float> %39, <3 x float>* %0
+ br label %switch-merge
+
+switch-segment7: ; preds = %entry
+ %40 = load float* %t
+ %41 = load float* %p
+ %42 = load float* @inf
+ %43 = load <3 x float>* %out_v15
+ %44 = insertelement <3 x float> %43, float %40, i32 0
+ %45 = insertelement <3 x float> %44, float %41, i32 1
+ %46 = insertelement <3 x float> %45, float %42, i32 2
+ store <3 x float> %46, <3 x float>* %0
+ br label %switch-merge
+
+switch-segment8: ; preds = %entry
+ %47 = load float* @inf
+ %48 = load float* %p
+ %49 = load float* %q
+ %50 = load <3 x float>* %out_v17
+ %51 = insertelement <3 x float> %50, float %47, i32 0
+ %52 = insertelement <3 x float> %51, float %48, i32 1
+ %53 = insertelement <3 x float> %52, float %49, i32 2
+ store <3 x float> %53, <3 x float>* %0
+ br label %switch-merge
+
+switch-merge: ; preds
= %switch-segment8, %switch-segment7, %switch-segment6, %switch-segment5, %switch-segment4, %switch-segment, %entry
+ ret void
+
+post-switch-break: ; No predecessors!
+ unreachable
+
+post-switch-break10: ; No predecessors!
+ unreachable
+
+post-switch-break12: ; No predecessors!
+ unreachable
+
+post-switch-break14: ; No predecessors!
+ unreachable
+
+post-switch-break16: ; No predecessors!
+ unreachable
+
+post-switch-break18: ; No predecessors!
+ unreachable
+}
+
+attributes #0 = { alwaysinline }
+
+!gla.inputs = !{!0, !2, !4}
+!gla.uniforms = !{!6, !8}
+!gla.entrypoint = !{!9}
+!gla.outputs = !{!10}
+!gla.noStaticUse = !{!2, !4}
+
+!0 = metadata !{metadata !"inf", i32 1, float* @inf_typeProxy, metadata !1}
+!1 = metadata !{i32 0, i32 0, i32 1024, null, i32 0}
+!2 = metadata !{metadata !"gl_VertexID", i32 2, i32*
@gl_VertexID_typeProxy, metadata !3}
+!3 = metadata !{i32 0, i32 0, i32 1036, null, i32 0, i32 7}
+!4 = metadata !{metadata !"gl_InstanceID", i32 3, i32*
@gl_InstanceID_typeProxy, metadata !5}
+!5 = metadata !{i32 0, i32 0, i32 1037, null, i32 0, i32 8}
+!6 = metadata !{metadata !"b", i32 12, i32* @b_typeProxy, metadata !7}
+!7 = metadata !{i32 0, i32 0, i32 1024, null}
+!8 = metadata !{metadata !"c", i32 12, i32* @c_typeProxy, metadata !7}
+!9 = metadata !{metadata !"main", i32 15}
+!10 = metadata !{metadata !"", i32 16, %gl_PerVertex* @"anon@0_typeProxy",
metadata !11, metadata !12}
+!11 = metadata !{i32 0, i32 0, i32 1025, null, i32 0}
+!12 = metadata !{metadata !"gl_PerVertex", metadata !7,
metadata !"gl_Position", metadata !13, metadata !"gl_PointSize",
metadata !15, metadata !"gl_ClipDistance", metadata !17,
metadata !"gl_ClipVertex", metadata !19, metadata !"gl_FrontColor",
metadata !21, metadata !"gl_BackColor", metadata !23,
metadata !"gl_FrontSecondaryColor", metadata !25,
metadata !"gl_BackSecondaryColor", metadata !27, metadata !"gl_TexCoord",
metadata !29, metadata !"gl_FogFragCoord", metadata !31,
metadata !"gl_CullDistance", metadata !33}
+!13 = metadata !{metadata !"", metadata !14}
+!14 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 9}
+!15 = metadata !{metadata !"", metadata !16}
+!16 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 10}
+!17 = metadata !{metadata !"", metadata !18}
+!18 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 12}
+!19 = metadata !{metadata !"", metadata !20}
+!20 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 11}
+!21 = metadata !{metadata !"", metadata !22}
+!22 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 24}
+!23 = metadata !{metadata !"", metadata !24}
+!24 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 25}
+!25 = metadata !{metadata !"", metadata !26}
+!26 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 26}
+!27 = metadata !{metadata !"", metadata !28}
+!28 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 27}
+!29 = metadata !{metadata !"", metadata !30}
+!30 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 28}
+!31 = metadata !{metadata !"", metadata !32}
+!32 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 29}
+!33 = metadata !{metadata !"", metadata !34}
+!34 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 13}
+
+
+Bottom IR:
+; ModuleID = 'Glslang'
+
+%gl_PerVertex = type { <4 x float>, float, [1 x float], <4 x float>, <4 x
float>, <4 x float>, <4 x float>, <4 x float>, [1 x <4 x float>], float, [1
x float] }
+
+@inf = global float 0.000000e+00
+@b = external addrspace(2) constant i32
+@c = external addrspace(2) constant i32
+@"anon@0" = global %gl_PerVertex zeroinitializer
+@gl_VertexID = global i32 0
+@gl_InstanceID = global i32 0
+@gla_globalAgg = internal global <3 x float> undef
+
+define fastcc void @main() {
+entry:
+ %a1 = load i32 addrspace(2)* @b, align 4, !gla.uniform !6
+ %0 = load float* @inf, align 4
+ %1 = fsub float 3.000000e+00, %0
+ %p1.i = fmul float %0, %1
+ %2 = fmul float %0, 0x402B9999A0000000
+ %3 = fsub float 3.000000e+00, %2
+ %q2.i = fmul float %0, %3
+ %aggregate = load <3 x float>* @gla_globalAgg
+ switch i32 %a1, label %"foo(vf3;.exit" [
+ i32 0, label %switch-segment.i
+ i32 1, label %switch-segment4.i
+ i32 2, label %switch-segment5.i
+ i32 3, label %switch-segment6.i
+ i32 4, label %switch-segment7.i
+ i32 5, label %switch-segment8.i
+ ]
+
+switch-segment.i: ; preds = %entry
+ %4 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %0, i32 0, float %p1.i, i32 0, float %p1.i, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+switch-segment4.i: ; preds = %entry
+ %5 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %q2.i, i32 0, float %0, i32 0, float %p1.i, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+switch-segment5.i: ; preds = %entry
+ %6 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %p1.i, i32 0, float %0, i32 0, float %p1.i, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+switch-segment6.i: ; preds = %entry
+ %7 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %p1.i, i32 0, float %q2.i, i32 0, float %0, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+switch-segment7.i: ; preds = %entry
+ %8 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %p1.i, i32 0, float %p1.i, i32 0, float %0, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+switch-segment8.i: ; preds = %entry
+ %9 = call <3 x float>
@llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3 x float> undef, i32
7, float %0, i32 0, float %p1.i, i32 0, float %q2.i, i32 0, float undef,
i32 undef)
+ br label %"foo(vf3;.exit"
+
+"foo(vf3;.exit": ; preds
= %entry, %switch-segment.i, %switch-segment4.i, %switch-segment5.i, %switch-segment6.i, %switch-segment7.i, %switch-segment8.i
+ %param.0 = phi <3 x float> [ %aggregate, %entry ],
[ %9, %switch-segment8.i ], [ %8, %switch-segment7.i ],
[ %7, %switch-segment6.i ], [ %6, %switch-segment5.i ],
[ %5, %switch-segment4.i ], [ %4, %switch-segment.i ]
+ %10 = load i32 addrspace(2)* @c, align 4, !gla.uniform !8
+ switch i32 %10, label %switch-segment7 [
+ i32 9, label %switch-segment
+ i32 10, label %switch-segment3
+ i32 11, label %switch-segment4
+ i32 12, label %switch-segment5
+ i32 17, label %switch-segment6
+ ]
+
+switch-segment: ; preds
= %"foo(vf3;.exit"
+ %a8 = shl i32 %a1, 1
+ br label %switch-merge
+
+switch-segment3: ; preds
= %"foo(vf3;.exit"
+ %a9 = add i32 %a1, 5
+ br label %switch-segment4
+
+switch-segment4: ; preds
= %switch-segment3, %"foo(vf3;.exit"
+ %a.0 = phi i32 [ %a1, %"foo(vf3;.exit" ], [ %a9, %switch-segment3 ]
+ %a10 = add i32 %a.0, -15
+ br label %switch-merge
+
+switch-segment5: ; preds
= %"foo(vf3;.exit"
+ %11 = mul i32 %a1, %a1
+ %a12 = add i32 %11, %a1
+ br label %switch-merge
+
+switch-segment6: ; preds
= %"foo(vf3;.exit"
+ %a14 = add i32 %a1, -1
+ br label %switch-segment7
+
+switch-segment7: ; preds
= %switch-segment6, %"foo(vf3;.exit"
+ %a.1 = phi i32 [ %a1, %"foo(vf3;.exit" ], [ %a14, %switch-segment6 ]
+ %a15 = add i32 %a.1, -13
+ br label %switch-merge
+
+switch-merge: ; preds
= %switch-segment7, %switch-segment5, %switch-segment4, %switch-segment
+ %a.2 = phi i32 [ %a15, %switch-segment7 ], [ %a12, %switch-segment5 ],
[ %a10, %switch-segment4 ], [ %a8, %switch-segment ]
+ %12 = sitofp i32 %a.2 to float
+ %13 = call <4 x float>
@llvm.gla.fMultiInsert.v4f32.v4f32.v3f32.v3f32.v3f32.f32(<4 x float> undef,
i32 15, <3 x float> %param.0, i32 0, <3 x float> %param.0, i32 1, <3 x
float> %param.0, i32 2, float %12, i32 0)
+ %gla_constGEP = getelementptr %gl_PerVertex* @"anon@0", i32 0, i32 0
+ store <4 x float> %13, <4 x float>* %gla_constGEP, align 16
+ br label %stage-epilogue
+
+stage-epilogue: ; preds = %switch-merge
+ br label %stage-exit
+
+stage-exit: ; preds = %stage-epilogue
+ ret void
+}
+
+; Function Attrs: nounwind readnone
+declare <3 x float> @llvm.gla.fMultiInsert.v3f32.v3f32.f32.f32.f32.f32(<3
x float>, i32, float, i32, float, i32, float, i32, float, i32) #0
+
+; Function Attrs: nounwind readnone
+declare <4 x float>
@llvm.gla.fMultiInsert.v4f32.v4f32.v3f32.v3f32.v3f32.f32(<4 x float>, i32,
<3 x float>, i32, <3 x float>, i32, <3 x float>, i32, float, i32) #0
+
+attributes #0 = { nounwind readnone }
+
+!gla.inputs = !{!0, !2, !4}
+!gla.uniforms = !{!6, !8}
+!gla.entrypoint = !{!9}
+!gla.outputs = !{!10}
+!gla.noStaticUse = !{!2, !4}
+
+!0 = metadata !{metadata !"inf", i32 1, float* @inf_typeProxy, metadata !1}
+!1 = metadata !{i32 0, i32 0, i32 1024, null, i32 0}
+!2 = metadata !{metadata !"gl_VertexID", i32 2, i32*
@gl_VertexID_typeProxy, metadata !3}
+!3 = metadata !{i32 0, i32 0, i32 1036, null, i32 0, i32 7}
+!4 = metadata !{metadata !"gl_InstanceID", i32 3, i32*
@gl_InstanceID_typeProxy, metadata !5}
+!5 = metadata !{i32 0, i32 0, i32 1037, null, i32 0, i32 8}
+!6 = metadata !{metadata !"b", i32 12, i32* @b_typeProxy, metadata !7}
+!7 = metadata !{i32 0, i32 0, i32 1024, null}
+!8 = metadata !{metadata !"c", i32 12, i32* @c_typeProxy, metadata !7}
+!9 = metadata !{metadata !"main", i32 15}
+!10 = metadata !{metadata !"", i32 16, %gl_PerVertex* @"anon@0_typeProxy",
metadata !11, metadata !12}
+!11 = metadata !{i32 0, i32 0, i32 1025, null, i32 0}
+!12 = metadata !{metadata !"gl_PerVertex", metadata !7,
metadata !"gl_Position", metadata !13, metadata !"gl_PointSize",
metadata !15, metadata !"gl_ClipDistance", metadata !17,
metadata !"gl_ClipVertex", metadata !19, metadata !"gl_FrontColor",
metadata !21, metadata !"gl_BackColor", metadata !23,
metadata !"gl_FrontSecondaryColor", metadata !25,
metadata !"gl_BackSecondaryColor", metadata !27, metadata !"gl_TexCoord",
metadata !29, metadata !"gl_FogFragCoord", metadata !31,
metadata !"gl_CullDistance", metadata !33}
+!13 = metadata !{metadata !"", metadata !14}
+!14 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 9}
+!15 = metadata !{metadata !"", metadata !16}
+!16 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 10}
+!17 = metadata !{metadata !"", metadata !18}
+!18 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 12}
+!19 = metadata !{metadata !"", metadata !20}
+!20 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 11}
+!21 = metadata !{metadata !"", metadata !22}
+!22 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 24}
+!23 = metadata !{metadata !"", metadata !24}
+!24 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 25}
+!25 = metadata !{metadata !"", metadata !26}
+!26 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 26}
+!27 = metadata !{metadata !"", metadata !28}
+!28 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 27}
+!29 = metadata !{metadata !"", metadata !30}
+!30 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 28}
+!31 = metadata !{metadata !"", metadata !32}
+!32 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 29}
+!33 = metadata !{metadata !"", metadata !34}
+!34 = metadata !{i32 0, i32 0, i32 1024, null, i32 -1, i32 13}
+#version 450 core
+// LunarGOO output
+uniform int b;
+uniform int c;
+in float inf;
+out gl_PerVertex {
+ vec4 gl_Position;
+ float gl_PointSize;
+ float gl_ClipDistance[1];
+ vec4 gl_ClipVertex;
+ vec4 gl_FrontColor;
+ vec4 gl_BackColor;
+ vec4 gl_FrontSecondaryColor;
+ vec4 gl_BackSecondaryColor;
+ vec4 gl_TexCoord[1];
+ float gl_FogFragCoord;
+ float gl_CullDistance[1];
+} ;
+vec3 gla_globalAgg;
+const float C_3d0 = 3.0;
+const float C_13d8 = 13.8;
+const int C_1 = 1;
+const int C_5 = 5;
+const int C_a15 = -15;
+const int C_a1 = -1;
+const int C_a13 = -13;
+
+void main()
+{
+ vec3 param;
+ int a;
+ int a1;
+ int a2;
+ float H_chdnkf1 = C_3d0 - inf;
+ float H_ejuvkx = H_chdnkf1 * inf;
+ float H_c3cs4x = inf * C_13d8;
+ float H_0kjy5i1 = C_3d0 - H_c3cs4x;
+ float H_0pbv351 = H_0kjy5i1 * inf;
+ param = gla_globalAgg;
+ switch (b) {
+ case 0:
+ {
+ vec3 H_86mbla1 = vec3(inf, H_ejuvkx, H_ejuvkx);
+ param = H_86mbla1;
+ break;
+
+ }
+ case 1:
+ {
+ vec3 H_qew7qv1 = vec3(H_0pbv351, inf, H_ejuvkx);
+ param = H_qew7qv1;
+ break;
+
+ }
+ case 2:
+ {
+ vec3 H_05b69e = vec3(H_ejuvkx, inf, H_ejuvkx);
+ param = H_05b69e;
+ break;
+
+ }
+ case 3:
+ {
+ vec3 H_qg43sq1 = vec3(H_ejuvkx, H_0pbv351, inf);
+ param = H_qg43sq1;
+ break;
+
+ }
+ case 4:
+ {
+ vec3 H_krxgxz = vec3(H_ejuvkx, H_ejuvkx, inf);
+ param = H_krxgxz;
+ break;
+
+ }
+ case 5:
+ {
+ vec3 H_sr2q011 = vec3(inf, H_ejuvkx, H_0pbv351);
+ param = H_sr2q011;
+ break;
+
+ }
+ }
+
+ a1 = b;
+ a = b;
+ switch (c) {
+ case 9:
+ {
+ int H_61vhzd = b << C_1;
+ a2 = H_61vhzd;
+ break;
+
+ }
+ case 10:
+ {
+ int H_xcwmn21 = b + C_5;
+ a = H_xcwmn21;
+
+ }
+ case 11:
+ {
+ int H_uvebw71 = a + C_a15;
+ a2 = H_uvebw71;
+ break;
+
+ }
+ case 12:
+ {
+ int H_5y2lrl = b * b;
+ int H_daifhe = H_5y2lrl + b;
+ a2 = H_daifhe;
+ break;
+
+ }
+ case 17:
+ {
+ int H_c2awtk = b + C_a1;
+ a1 = H_c2awtk;
+
+ }
+ default:
+ {
+ int H_vqkg1y = a1 + C_a13;
+ a2 = H_vqkg1y;
+ break;
+
+ }
+ }
+
+ float H_fjg2iv = float(a2);
+ vec4 H_hnfrrf1 = vec4(param.x, param.y, param.z, H_fjg2iv);
+ gl_Position = H_hnfrrf1;
+
+}
+
+#version 450 core
+// LunarGOO output
+uniform int b;
+uniform int c;
+in float inf;
+out gl_PerVertex {
+ vec4 gl_Position;
+ float gl_PointSize;
+ float gl_ClipDistance[1];
+ vec4 gl_ClipVertex;
+ vec4 gl_FrontColor;
+ vec4 gl_BackColor;
+ vec4 gl_FrontSecondaryColor;
+ vec4 gl_BackSecondaryColor;
+ vec4 gl_TexCoord[1];
+ float gl_FogFragCoord;
+ float gl_CullDistance[1];
+} ;
+const float C_3d0 = 3.0;
+const float C_13d8 = 13.8;
+const vec3 C_vec3p0d0p = vec3(0.0);
+const int C_1 = 1;
+const int C_5 = 5;
+const int C_a15 = -15;
+const int C_a1 = -1;
+const int C_a13 = -13;
+
+void main()
+{
+ vec3 param;
+ int a;
+ int Lg_1;
+ int Lg_2;
+ float H_chdnkf = C_3d0 - inf;
+ float H_ejuvkx = H_chdnkf * inf;
+ float H_c3cs4x = inf * C_13d8;
+ float H_0kjy5i = C_3d0 - H_c3cs4x;
+ float H_0pbv = H_0kjy5i * inf;
+ param = C_vec3p0d0p;
+ switch (b) {
+ case 0:
+ {
+ vec3 H_86mbla1 = vec3(inf, H_ejuvkx, H_ejuvkx);
+ param = H_86mbla1;
+ break;
+
+ }
+ case 1:
+ {
+ vec3 H_ndzbf6 = vec3(H_0pbv, inf, H_ejuvkx);
+ param = H_ndzbf6;
+ break;
+
+ }
+ case 2:
+ {
+ vec3 H_05b69e = vec3(H_ejuvkx, inf, H_ejuvkx);
+ param = H_05b69e;
+ break;
+
+ }
+ case 3:
+ {
+ vec3 H_vd56yy1 = vec3(H_ejuvkx, H_0pbv, inf);
+ param = H_vd56yy1;
+ break;
+
+ }
+ case 4:
+ {
+ vec3 H_krxgxz = vec3(H_ejuvkx, H_ejuvkx, inf);
+ param = H_krxgxz;
+ break;
+
+ }
+ case 5:
+ {
+ vec3 H_x2iqil1 = vec3(inf, H_ejuvkx, H_0pbv);
+ param = H_x2iqil1;
+ break;
+
+ }
+ }
+
+ Lg_1 = b;
+ a = b;
+ switch (c) {
+ case 9:
+ {
+ int H_61vhzd = b << C_1;
+ Lg_2 = H_61vhzd;
+ break;
+
+ }
+ case 10:
+ {
+ int H_xcwmn = b + C_5;
+ a = H_xcwmn;
+
+ }
+ case 11:
+ {
+ int H_uvebw = a + C_a15;
+ Lg_2 = H_uvebw;
+ break;
+
+ }
+ case 12:
+ {
+ int H_5y2lrl = b * b;
+ int H_daifhe = H_5y2lrl + b;
+ Lg_2 = H_daifhe;
+ break;
+
+ }
+ case 17:
+ {
+ int H_c2awtk = b + C_a1;
+ Lg_1 = H_c2awtk;
+
+ }
+ default:
+ {
+ int H_vqkg1y = Lg_1 + C_a13;
+ Lg_2 = H_vqkg1y;
+ break;
+
+ }
+ }
+
+ float H_fjg2iv = float(Lg_2);
+ vec4 H_hnfrrf1 = vec4(param.x, param.y, param.z, H_fjg2iv);
+ gl_Position = H_hnfrrf1;
+
+}
+
=======================================
--- /dev/null
+++ /trunk/test/simpleSwitch.vert Sun May 31 21:29:58 2015 UTC
@@ -0,0 +1,53 @@
+#version 450
+
+uniform int b;
+uniform int c;
+
+in float inf;
+
+void foo(out vec3 out_v)
+{
+ float p = inf * (3.0F - inf);
+ float q = inf * (3.0F - inf * 13.8);
+ float t = inf * (3.0F - inf);
+
+ switch (b)
+ {
+ case 0 : out_v = vec3 (inf, t, p); break;
+ case 1 : out_v = vec3 (q, inf, p); break;
+ case 2 : out_v = vec3 (p, inf, t); break;
+ case 3 : out_v = vec3 (p, q, inf); break;
+ case 4 : out_v = vec3 (t, p, inf); break;
+ case 5 : out_v = vec3 (inf, p, q); break;
+ }
+}
+
+void main()
+{
+ int a = b;
+
+ vec3 out_v;
+ foo(out_v);
+
+ switch (c-8) {
+ case 1:
+ a = 2 * a;
+ break;
+ case 2:
+ a += 5;
+ case 3:
+ a -= 15;
+ break;
+ case 4:
+ a += a * b;
+ break;
+ case 9:
+ --a;
+ default:
+ a -= 13;
+ break;
+ }
+
+ gl_Position = vec4(out_v, a);
+}
+
=======================================
--- /trunk/Backends/Dummy/BottomToDummy.cpp Sun Aug 3 20:15:57 2014 UTC
+++ /trunk/Backends/Dummy/BottomToDummy.cpp Sun May 31 21:29:58 2015 UTC
@@ -166,6 +166,21 @@

void addEndif()
{ counter++; }
+
+ void addSwitch(const llvm::Value* cond)
+ { counter++; }
+
+ void addCase(int)
+ { counter++; }
+
+ void addDefault()
+ { counter++; }
+
+ void endCase(bool withBreak)
+ { counter++; }
+
+ void endSwitch()
+ { counter++; }

void beginConditionalLoop()
{ counter++; }
=======================================
--- /trunk/Backends/GLSL/BottomToGLSL.cpp Mon May 25 23:01:59 2015 UTC
+++ /trunk/Backends/GLSL/BottomToGLSL.cpp Sun May 31 21:29:58 2015 UTC
@@ -557,6 +557,11 @@
void addIf(const llvm::Value* cond, bool invert = false);
void addElse();
void addEndif();
+ void addSwitch(const llvm::Value* cond);
+ void addCase(int);
+ void addDefault();
+ void endCase(bool withBreak);
+ void endSwitch();
void beginConditionalLoop();
void beginSimpleConditionalLoop(const llvm::CmpInst* cmp, const
llvm::Value* op1, const llvm::Value* op2, bool invert = false);
void beginForLoop(const llvm::PHINode* phi, llvm::ICmpInst::Predicate,
unsigned bound, unsigned increment);
@@ -2303,6 +2308,47 @@
leaveScope();
newLine();
}
+
+void gla::GlslTarget::addSwitch(const llvm::Value* cond)
+{
+ newLine();
+ shader << "switch (";
+ emitGlaOperand(shader, cond);
+ shader << ") ";
+ newScope();
+}
+
+void gla::GlslTarget::addCase(int value)
+{
+ newLine();
+ shader << "case " << value << ":";
+ newLine();
+ newScope();
+}
+
+void gla::GlslTarget::addDefault()
+{
+ newLine();
+ shader << "default:";
+ newLine();
+ newScope();
+}
+
+void gla::GlslTarget::endCase(bool withBreak)
+{
+ if (withBreak) {
+ newLine();
+ shader << "break;";
+ }
+ newLine();
+ leaveScope();
+}
+
+void gla::GlslTarget::endSwitch()
+{
+ leaveScope();
+ newLine();
+}

void gla::GlslTarget::beginConditionalLoop()
{
=======================================
--- /trunk/Core/Backend.h Sun Aug 3 20:15:57 2014 UTC
+++ /trunk/Core/Backend.h Sun May 31 21:29:58 2015 UTC
@@ -188,6 +188,11 @@
virtual void addIf(const llvm::Value* cond, bool invert=false) = 0;
virtual void addElse() = 0;
virtual void addEndif() = 0;
+ virtual void addSwitch(const llvm::Value* cond) = 0;
+ virtual void addCase(int) = 0;
+ virtual void addDefault() = 0;
+ virtual void endCase(bool withBreak) = 0;
+ virtual void endSwitch() = 0;


// Specialized loop constructs
=======================================
--- /trunk/Core/BottomTranslator.cpp Sun Aug 3 20:15:57 2014 UTC
+++ /trunk/Core/BottomTranslator.cpp Sun May 31 21:29:58 2015 UTC
@@ -87,8 +87,6 @@
// an if-then-else construct, it will then call the addElse interface and
// handle the else block. Finally, it calls the addEndIf interface.
//
-// * TODO: functionality: handleSwitchBlock
-//
// * handleReturnBlock handles it's instructions, and calls the
// handleReturnBlock interface
//
@@ -189,6 +187,27 @@
DominanceFrontier* domFront; // Note: this is deprecated, go in
the direction of not needing it
IdentifyStructures* idStructs;

+ // Switch information, dynamically maintained while translating
blocks
+ // for the back end, on a stack of nested switch statements.
+ // TODO: This needs fuller treatment, probably by becoming part of
IdentifyStructures.
+ // It's slightly guess work now to deduce the switch's merge
point, and in complex
+ // topologies, the heuristics used here and in
handleBranchingBlock() breaks down.
+ struct switchDesc {
+ switchDesc(const llvm::BasicBlock* merge, const
llvm::SwitchInst* inst) : mergeBlock(merge), switchInst(inst) { }
+ const llvm::BasicBlock* mergeBlock;
+ const llvm::SwitchInst* switchInst;
+ bool fallthrough(const llvm::BasicBlock* b)
+ {
+ for (auto it = switchInst->case_begin(); it !=
switchInst->case_end(); ++it)
+ if (it.getCaseSuccessor() == b)
+ return true;
+ if (mergeBlock && mergeBlock !=
switchInst->getDefaultDest() && b == switchInst->getDefaultDest())
+ return true;
+ return false;
+ }
+ };
+ llvm::SmallVector<switchDesc, 2> switchStack;
+
bool lastBlock;

// Whether we should call add on all instructions, or only on
output
@@ -293,7 +312,7 @@
void forceDiscard();

// If dominator properly dominates dominatee, then handle it, else
do nothing
- void attemptHandleDominatee(const BasicBlock* dominator, const
BasicBlock* dominatee);
+ bool attemptHandleDominatee(const BasicBlock* dominator, const
BasicBlock* dominatee);

// Sets up a the beginning of a loop for the loop at the top of
our LoopStack.
// Assumes there is something on top of our LoopStack.
@@ -514,21 +533,24 @@
handledBlocks.insert(loops.top()->getLatch());
}

-void BottomTranslator::attemptHandleDominatee(const BasicBlock* dominator,
const BasicBlock* dominatee)
+// Return true if the block topology was recognized and/or handled.
+bool BottomTranslator::attemptHandleDominatee(const BasicBlock* dominator,
const BasicBlock* dominatee)
{
// If the dominatee is a early return or a discard, then force it's
output
// accordingly
- if (dominatee == stageExit) {
- return;
- }
+ if (dominatee == stageExit)
+ return true;
if (dominatee == stageEpilogue) {
forceReturn();
- return;
+ return true;
}

if (ProperlyDominates(dominator, dominatee, *domTree)) {
handleBlock(dominatee);
+ return true;
}
+
+ return false;
}

void BottomTranslator::handleLoopBlock(const BasicBlock* bb, bool
instructionsHandled)
@@ -702,7 +724,7 @@

backEndTranslator->addEndif();

- // We'd like to now shedule the handling of the merge block. If there
is no
+ // We'd like to now schedule the handling of the merge block. If there
is no
// merge block (e.g. there was a return/discard/break/continue), then
we're
// done.
const BasicBlock* merge = cond->getMergeBlock();
@@ -724,7 +746,7 @@

void BottomTranslator::handleBranchingBlock(const BasicBlock* bb)
{
- // Handle it's instructions and do phi node removal if appropriate
+ // Handle its instructions and do phi-node removal if appropriate
handleInstructions(bb);
addPhiCopies(bb);

@@ -733,10 +755,27 @@
if (IsUnconditional(bb)) {
const BasicBlock* succ = GetSuccessor(0,bb);
// If it's the (non-simple) latch, handle it, else handle it if we
dominate it (also includes returns/discards)
- if (! loops.empty() && !loops.top()->isSimpleLatching() && succ ==
loops.top()->getLatch())
+ if (! loops.empty() && ! loops.top()->isSimpleLatching() && succ
== loops.top()->getLatch()) {
handleBlock(succ);
- else
- attemptHandleDominatee(bb, succ);
+ return;
+ }
+
+ if (attemptHandleDominatee(bb, succ))
+ return;
+
+ // see if it's the end of a switch case statement
+ if (switchStack.size() > 0) {
+ if (switchStack.back().fallthrough(succ))
+ backEndTranslator->endCase(false);
+ else if (switchStack.back().mergeBlock == nullptr) {
+ // Speculate that this branches to the merge block of a
switch statement.
+ switchStack.back().mergeBlock = succ;
+ backEndTranslator->endCase(true);
+ } else if (switchStack.back().mergeBlock == succ)
+ backEndTranslator->endCase(true);
+ else
+ gla::UnsupportedFunctionality("switch topology",
gla::EATContinue);
+ }

return;
}
@@ -751,14 +790,49 @@
return;
}

+// Handle a block that ends with a switch branch. This includes
+// handling each case, the default, and the merge block after the switch.
void BottomTranslator::handleSwitchBlock(const BasicBlock* bb)
{
- assert(isa<SwitchInst>(bb->getTerminator()));
+ const SwitchInst* switchInstr =
dyn_cast<SwitchInst>(bb->getTerminator());
+ assert(switchInstr);
+
+ handleInstructions(bb);
+ addPhiCopies(bb);
+
+ // open the structure switch
+ backEndTranslator->addSwitch(switchInstr->getCondition());
+
+ // Start out not knowing the merge block, but knowing we're in a switch
+ switchStack.push_back(switchDesc(0, switchInstr));
+
+ // visit each case (not the default)
+ SwitchInst::ConstCaseIt caseIt = switchInstr->case_begin();
+ for (; caseIt != switchInstr->case_end(); caseIt++) {
+
backEndTranslator->addCase((int)caseIt.getCaseValue()->getSExtValue());
+ handleBlock(caseIt.getCaseSuccessor());
+ }
+
+ // visit the default, which can be hard to distinguish from the merge
block
+ // (sometimes they are two different things, sometimes not)
+ SwitchInst::ConstCaseIt defaultIt = switchInstr->case_default();
+
+ // see if the default block is not the merge block
+ const BasicBlock* defaultBlock = defaultIt.getCaseSuccessor();
+ if (switchStack.back().mergeBlock == 0)
+ switchStack.back().mergeBlock = defaultBlock;
+ else if (defaultBlock != switchStack.back().mergeBlock) {
+ backEndTranslator->addDefault();
+ handleBlock(defaultBlock);
+ }

- gla::UnsupportedFunctionality("switch terminator");
+ // close out the structured switch
+ backEndTranslator->endSwitch();

- handleInstructions(bb);
- backEndTranslator->addInstruction(bb->getTerminator(), lastBlock);
+ // handle merge block
+ if (switchStack.back().mergeBlock)
+ handleBlock(switchStack.back().mergeBlock);
+ switchStack.pop_back();

return;
}
@@ -1042,7 +1116,8 @@

// Only the first block should have to be handled, as every
// subgraph knows how to handle itself.
- assert(IsSubset(function->getBasicBlockList(), handledBlocks));
+ if (! IsSubset(function->getBasicBlockList(), handledBlocks))
+ gla::UnsupportedFunctionality("control flow: not all
blocks were translated", gla::EATContinue);

backEndTranslator->endFunctionBody();
}
=======================================
--- /trunk/test/baseResults/switch.frag.out Sun May 3 23:23:55 2015 UTC
+++ /trunk/test/baseResults/switch.frag.out Sun May 31 21:29:58 2015 UTC
@@ -778,9 +778,325 @@
!8 = metadata !{i32 0, i32 2, i32 1025, null, i32 0}
!9 = metadata !{i32 2}

-***Unsupported functionality: switch terminator
+***Unsupported functionality: switch topology

-Linked fragment stage:
+***Unsupported functionality: switch topology

-ERROR: Linking fragment stage: Missing entry point: Each stage requires
one "void main()" entry point
+***Unsupported functionality: switch topology
+
+***Unsupported functionality: switch topology
+
+***Unsupported functionality: switch topology
+
+***Unsupported functionality: switch topology
+#version 300 es
+// LunarGOO output
+precision mediump float; // this will be almost entirely overridden by
individual declarations
+uniform mediump int c;
+uniform mediump int d;
+uniform mediump vec4 v;
+in mediump float x;
+out mediump float color;
+const int C_1 = 1;
+const int C_0 = 0;
+const int C_9 = 9;
+const int C_20 = 20;
+const int C_29 = 29;
+mediump float Lg_3;
+const float C_1d0 = 1.0;
+const float C_100d2 = 100.2;
+const float C_3d43 = 3.43;
+const vec4 C_vec4p0d0p = vec4(0.0);
+const vec4 C_vec4p1d0p = vec4(1.0);
+
+void main()
+{
+ float f;
+ float f1;
+ float f2;
+ float f3;
+ float f4;
+ float f5;
+ int i;
+ float f6;
+ float f7;
+ int j;
+ float f8;
+ float f9;
+ float fa;
+ float fb;
+ vec4 Lg_1;
+ vec4 Lg_2;
+ mediump int local = c + C_1;
+ switch (c) {
+ case 1:
+ {
+ mediump float H_0lhnah = sin(x);
+ f = H_0lhnah;
+ break;
+
+ }
+ case 2:
+ {
+ mediump float H_v86jke1 = cos(x);
+ f = H_v86jke1;
+ break;
+
+ }
+ default:
+ {
+ mediump float H_3c9cke1 = tan(x);
+ f = H_3c9cke1;
+ break;
+
+ }
+ }
+
+ f1 = f;
+ switch (c) {
+ case 1:
+ {
+ mediump float H_0lhnahr = sin(x);
+ mediump float H_wcnmtj1 = H_0lhnahr + f;
+ f1 = H_wcnmtj1;
+
+ }
+ case 2:
+ {
+ mediump float H_v86jke1r = cos(x);
+ mediump float H_t8w2cv = H_v86jke1r + f1;
+ f2 = H_t8w2cv;
+ break;
+
+ }
+ default:
+ {
+ mediump float H_3c9cke1r = tan(x);
+ mediump float H_mtq1vr = H_3c9cke1r + f;
+ f2 = H_mtq1vr;
+ break;
+
+ }
+ }
+
+ f3 = f2;
+ switch (c) {
+ case 1:
+ {
+ mediump float H_0lhnahrr = sin(x);
+ mediump float H_27zftj = H_0lhnahrr + f2;
+ f3 = H_27zftj;
+ break;
+
+ }
+ case 2:
+ {
+ mediump float H_v86jke1rr = cos(x);
+ mediump float H_o3mdae = H_v86jke1rr + f2;
+ f3 = H_o3mdae;
+ break;
+
+ }
+ }
+
+ switch (c) {
+ case 1:
+ {
+ mediump float H_0lhnahrrr = sin(x);
+ mediump float H_hu2yrb = H_0lhnahrrr + f3;
+ f4 = H_hu2yrb;
+ break;
+
+ }
+ case 2:
+ {
+ f5 = f3;
+ switch (d) {
+ case 1:
+ {
+ mediump float H_hzby3e = x * x;
+ mediump float H_dxsdny = H_hzby3e * x;
+ mediump float H_eyk1vd = H_dxsdny + f3;
+ f5 = H_eyk1vd;
+ break;
+
+ }
+ case 2:
+ {
+ mediump float H_hzby3er = x * x;
+ mediump float H_pzmj7i1 = H_hzby3er + f3;
+ f5 = H_pzmj7i1;
+ break;
+
+ }
+ }
+
+ f4 = f5;
+ default:
+ {
+ mediump float H_3c9cke1rr = tan(x);
+ mediump float H_bmyrry = H_3c9cke1rr + f3;
+ f4 = H_bmyrry;
+ break;
+
+ }
+ }
+
+ mediump float H_3c9cke1rrr = tan(x);
+ mediump float H_0lhnahrrrr = sin(x);
+ mediump float H_v86jke1rrr = cos(x);
+ i = C_0;
+ f6 = f4;
+ while (i <= C_9) {
+ switch (c) {
+ case 1:
+ {
+ mediump float H_q4zp4f1 = H_0lhnahrrrr + f6;
+ j = C_20;
+ f8 = H_q4zp4f1;
+ while (j <= C_29) {
+ Lg_3 = f8 + C_1d0;
+ bool H_93uqn1 = Lg_3 < C_100d2;
+ mediump int H_l69nk4 = C_1 + j;
+ if (H_93uqn1) {
+ f9 = Lg_3;
+ break;
+
+ }
+ break;
+ }
+
+ j = H_l69nk4;
+ f8 = Lg_3;
+ }
+
+ f9 = f8;
+ break;
+
+ }
+ f7 = f9;
+ case 2:
+ {
+ mediump float H_sf4otx1 = H_v86jke1rrr + f6;
+ f7 = H_sf4otx1;
+ default:
+ {
+ mediump float H_ksdj391 = H_3c9cke1rrr + f6;
+ f7 = H_ksdj391;
+ }
+
+ bool H_amefxf1 = f7 < C_3d43;
+ mediump int H_o3goq3 = C_1 + i;
+ if (H_amefxf1) {
+ fa = f7;
+ break;
+ }
+
+ i = H_o3goq3;
+ f6 = f7;
+ }
+
+ fa = f6;
+ fb = fa;
+ switch (c) {
+ case 1:
+ {
+ mediump float H_jyv82r1 = H_0lhnahrrrr + fa;
+ fb = H_jyv82r1;
+ break;
+
+ }
+ case 2:
+ {
+ fb = fa;
+ break;
+
+ }
+ }
+
+ mediump float H_13mhsn1 = float(local);
+ mediump float color1 = H_13mhsn1 + fb;
+ color = color1;
+ switch (c) {
+ case 0:
+ {
+ Lg_1 = v;
+ break;
+
+ }
+ case 2:
+ {
+ Lg_1 = v;
+ break;
+
+ }
+ case 1:
+ {
+ case 3:
+ {
+ mediump vec4 H_hno2sy = v * v;
+ Lg_1 = H_hno2sy;
+ break;
+
+ }
+ default:
+ {
+ Lg_1 = C_vec4p0d0p;
+ break;
+
+ }
+ }
+
+ mediump float color2 = Lg_1.y + color1;
+ color = color2;
+ switch (c) {
+ case 0:
+ {
+ Lg_2 = v;
+ break;
+
+ }
+ case 2:
+ {
+ Lg_2 = C_vec4p1d0p;
+ break;
+
+ }
+ case 1:
+ {
+ Lg_2 = v;
+ break;
+
+ }
+ case 3:
+ {
+ mediump vec4 H_hno2syr = v * v;
+ Lg_2 = H_hno2syr;
+ break;
+
+ }
+ default:
+ {
+ Lg_2 = C_vec4p0d0p;
+ break;
+
+ }
+ }
+
+ mediump float color3 = Lg_2.z + color2;
+ color = color3;
+
+ }
+
+tempglsl.frag
+ERROR: 0:144: 'default' : cannot be nested inside control flow
+ERROR: 0:178: 'H_l69nk4' : undeclared identifier
+ERROR: 0:178: 'assign' : cannot convert from 'temp float' to 'temp
mediump int'
+ERROR: 0:187: 'case' : cannot be nested inside control flow
+ERROR: 0:191: 'default' : cannot be nested inside control flow
+ERROR: 0:244: 'case' : cannot be nested inside control flow
+ERROR: 0:251: 'default' : cannot be nested inside control flow
+ERROR: 0:300: '' : syntax error
+ERROR: 8 compilation errors. No code generated.
+

=======================================
--- /trunk/test/runtests Thu May 21 01:11:19 2015 UTC
+++ /trunk/test/runtests Sun May 31 21:29:58 2015 UTC
@@ -53,6 +53,7 @@
300layout.vert \
300layout.frag \
310.comp \
+ simpleSwitch.vert \
switch.frag \
whileLoop.frag \
doWhileLoop.frag \
Reply all
Reply to author
Forward
0 new messages