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