HLSL: handle clip and cull distance input builtin type conversion

HLSL allows a range of types for clip and cull distances.  There are
three dimensions, including arrayness, vectorness, and semantic ID.
SPIR-V requires clip and cull distance be a single array of floats in
all cases.

This code provides input side conversion between the SPIR-V form and
the HLSL form.  (Output conversion was added in PR #947 and #997).

This PR extends HlslParseContext::assignClipCullDistance to cope with
the input side conversion.  Not as much changed as appears: there was
also a lot of renaming to reflect the fact that the code now handles
either direction.

Currently, non-{frag,vert} stages are not handled, and are explicitly
rejected.

Fixes #1026.
diff --git a/Test/baseResults/hlsl.clipdistance-8.frag.out b/Test/baseResults/hlsl.clipdistance-8.frag.out
new file mode 100644
index 0000000..a1f6648
--- /dev/null
+++ b/Test/baseResults/hlsl.clipdistance-8.frag.out
@@ -0,0 +1,285 @@
+hlsl.clipdistance-8.frag
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          clip1: direct index for structure ( temp float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            clip1: direct index for structure ( temp float)
+0:?               'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 4-element array of float ClipDistance)
+
+
+Linked fragment stage:
+
+
+Shader version: 500
+gl_FragCoord origin is upper left
+0:? Sequence
+0:8  Function Definition: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:8    Function Parameters: 
+0:8      'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?     Sequence
+0:9      Branch: Return with expression
+0:9        add ( temp 4-component vector of float)
+0:9          add ( temp 4-component vector of float)
+0:9            Position: direct index for structure ( temp 4-component vector of float)
+0:9              'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9              Constant:
+0:9                0 (const int)
+0:9            direct index ( temp float)
+0:9              clip0: direct index for structure ( temp 3-component vector of float)
+0:9                'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9                Constant:
+0:9                  1 (const int)
+0:9              Constant:
+0:9                0 (const int)
+0:9          clip1: direct index for structure ( temp float)
+0:9            'v' ( in structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:9            Constant:
+0:9              2 (const int)
+0:8  Function Definition: main( ( temp void)
+0:8    Function Parameters: 
+0:?     Sequence
+0:8      Sequence
+0:8        move second child to first child ( temp 4-component vector of float)
+0:8          Position: direct index for structure ( temp 4-component vector of float)
+0:?             'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8            Constant:
+0:8              0 (const int)
+0:?           'v.Position' ( in 4-component vector of float FragCoord)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                0 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                0 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                1 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                1 (const int)
+0:8          move second child to first child ( temp float)
+0:8            direct index ( temp float)
+0:8              clip0: direct index for structure ( temp 3-component vector of float)
+0:?                 'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8                Constant:
+0:8                  1 (const int)
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                2 (const int)
+0:?         Sequence
+0:8          move second child to first child ( temp float)
+0:8            clip1: direct index for structure ( temp float)
+0:?               'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:8              Constant:
+0:8                2 (const int)
+0:8            direct index ( temp float)
+0:?               'v.clip1' ( in 4-element array of float ClipDistance)
+0:8              Constant:
+0:8                3 (const int)
+0:8      move second child to first child ( temp 4-component vector of float)
+0:?         '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:8        Function Call: @main(struct-VS_OUTPUT-vf4-vf3-f11; ( temp 4-component vector of float)
+0:?           'v' ( temp structure{ temp 4-component vector of float Position,  temp 3-component vector of float clip0,  temp float clip1})
+0:?   Linker Objects
+0:?     '@entryPointOutput' (layout( location=0) out 4-component vector of float)
+0:?     'v.Position' ( in 4-component vector of float FragCoord)
+0:?     'v.clip1' ( in 4-element array of float ClipDistance)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 65
+
+                              Capability Shader
+                              Capability ClipDistance
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Fragment 4  "main" 37 43 61
+                              ExecutionMode 4 OriginUpperLeft
+                              Source HLSL 500
+                              Name 4  "main"
+                              Name 9  "VS_OUTPUT"
+                              MemberName 9(VS_OUTPUT) 0  "Position"
+                              MemberName 9(VS_OUTPUT) 1  "clip0"
+                              MemberName 9(VS_OUTPUT) 2  "clip1"
+                              Name 13  "@main(struct-VS_OUTPUT-vf4-vf3-f11;"
+                              Name 12  "v"
+                              Name 35  "v"
+                              Name 37  "v.Position"
+                              Name 43  "v.clip1"
+                              Name 61  "@entryPointOutput"
+                              Name 62  "param"
+                              Decorate 37(v.Position) BuiltIn FragCoord
+                              Decorate 43(v.clip1) BuiltIn ClipDistance
+                              Decorate 61(@entryPointOutput) Location 0
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+               7:             TypeVector 6(float) 4
+               8:             TypeVector 6(float) 3
+    9(VS_OUTPUT):             TypeStruct 7(fvec4) 8(fvec3) 6(float)
+              10:             TypePointer Function 9(VS_OUTPUT)
+              11:             TypeFunction 7(fvec4) 10(ptr)
+              15:             TypeInt 32 1
+              16:     15(int) Constant 0
+              17:             TypePointer Function 7(fvec4)
+              20:     15(int) Constant 1
+              21:             TypeInt 32 0
+              22:     21(int) Constant 0
+              23:             TypePointer Function 6(float)
+              28:     15(int) Constant 2
+              36:             TypePointer Input 7(fvec4)
+  37(v.Position):     36(ptr) Variable Input
+              40:     21(int) Constant 4
+              41:             TypeArray 6(float) 40
+              42:             TypePointer Input 41
+     43(v.clip1):     42(ptr) Variable Input
+              44:             TypePointer Input 6(float)
+              50:     21(int) Constant 1
+              54:     21(int) Constant 2
+              56:     15(int) Constant 3
+              60:             TypePointer Output 7(fvec4)
+61(@entryPointOutput):     60(ptr) Variable Output
+         4(main):           2 Function None 3
+               5:             Label
+           35(v):     10(ptr) Variable Function
+       62(param):     10(ptr) Variable Function
+              38:    7(fvec4) Load 37(v.Position)
+              39:     17(ptr) AccessChain 35(v) 16
+                              Store 39 38
+              45:     44(ptr) AccessChain 43(v.clip1) 16
+              46:    6(float) Load 45
+              47:     23(ptr) AccessChain 35(v) 20 22
+                              Store 47 46
+              48:     44(ptr) AccessChain 43(v.clip1) 20
+              49:    6(float) Load 48
+              51:     23(ptr) AccessChain 35(v) 20 50
+                              Store 51 49
+              52:     44(ptr) AccessChain 43(v.clip1) 28
+              53:    6(float) Load 52
+              55:     23(ptr) AccessChain 35(v) 20 54
+                              Store 55 53
+              57:     44(ptr) AccessChain 43(v.clip1) 56
+              58:    6(float) Load 57
+              59:     23(ptr) AccessChain 35(v) 28
+                              Store 59 58
+              63:9(VS_OUTPUT) Load 35(v)
+                              Store 62(param) 63
+              64:    7(fvec4) FunctionCall 13(@main(struct-VS_OUTPUT-vf4-vf3-f11;) 62(param)
+                              Store 61(@entryPointOutput) 64
+                              Return
+                              FunctionEnd
+13(@main(struct-VS_OUTPUT-vf4-vf3-f11;):    7(fvec4) Function None 11
+           12(v):     10(ptr) FunctionParameter
+              14:             Label
+              18:     17(ptr) AccessChain 12(v) 16
+              19:    7(fvec4) Load 18
+              24:     23(ptr) AccessChain 12(v) 20 22
+              25:    6(float) Load 24
+              26:    7(fvec4) CompositeConstruct 25 25 25 25
+              27:    7(fvec4) FAdd 19 26
+              29:     23(ptr) AccessChain 12(v) 28
+              30:    6(float) Load 29
+              31:    7(fvec4) CompositeConstruct 30 30 30 30
+              32:    7(fvec4) FAdd 27 31
+                              ReturnValue 32
+                              FunctionEnd