|
6 | 6 |
|
7 | 7 | namespace Shader::Backend::SPIRV {
|
8 | 8 |
|
9 |
| -Id EmitCompositeConstructU32x2(EmitContext& ctx, Id e1, Id e2) { |
10 |
| - return ctx.OpCompositeConstruct(ctx.U32[2], e1, e2); |
| 9 | +#define CompositeConstructImpl(...) \ |
| 10 | + inst->AreAllArgsImmediates() ? ctx.ConstantComposite(__VA_ARGS__) \ |
| 11 | + : ctx.OpCompositeConstruct(__VA_ARGS__) |
| 12 | + |
| 13 | +Id EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2) { |
| 14 | + return CompositeConstructImpl(ctx.U32[2], e1, e2); |
11 | 15 | }
|
12 | 16 |
|
13 |
| -Id EmitCompositeConstructU32x3(EmitContext& ctx, Id e1, Id e2, Id e3) { |
14 |
| - return ctx.OpCompositeConstruct(ctx.U32[3], e1, e2, e3); |
| 17 | +Id EmitCompositeConstructU32x3(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3) { |
| 18 | + return CompositeConstructImpl(ctx.U32[3], e1, e2, e3); |
15 | 19 | }
|
16 | 20 |
|
17 |
| -Id EmitCompositeConstructU32x4(EmitContext& ctx, Id e1, Id e2, Id e3, Id e4) { |
18 |
| - return ctx.OpCompositeConstruct(ctx.U32[4], e1, e2, e3, e4); |
| 21 | +Id EmitCompositeConstructU32x4(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3, Id e4) { |
| 22 | + return CompositeConstructImpl(ctx.U32[4], e1, e2, e3, e4); |
19 | 23 | }
|
20 | 24 |
|
21 | 25 | Id EmitCompositeExtractU32x2(EmitContext& ctx, Id composite, u32 index) {
|
@@ -56,16 +60,16 @@ Id EmitCompositeShuffleU32x4(EmitContext& ctx, Id composite1, Id composite2, u32
|
56 | 60 | return ctx.OpVectorShuffle(ctx.U32[4], composite1, composite2, comp0, comp1, comp2, comp3);
|
57 | 61 | }
|
58 | 62 |
|
59 |
| -Id EmitCompositeConstructF16x2(EmitContext& ctx, Id e1, Id e2) { |
60 |
| - return ctx.OpCompositeConstruct(ctx.F16[2], e1, e2); |
| 63 | +Id EmitCompositeConstructF16x2(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2) { |
| 64 | + return CompositeConstructImpl(ctx.F16[2], e1, e2); |
61 | 65 | }
|
62 | 66 |
|
63 |
| -Id EmitCompositeConstructF16x3(EmitContext& ctx, Id e1, Id e2, Id e3) { |
64 |
| - return ctx.OpCompositeConstruct(ctx.F16[3], e1, e2, e3); |
| 67 | +Id EmitCompositeConstructF16x3(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3) { |
| 68 | + return CompositeConstructImpl(ctx.F16[3], e1, e2, e3); |
65 | 69 | }
|
66 | 70 |
|
67 |
| -Id EmitCompositeConstructF16x4(EmitContext& ctx, Id e1, Id e2, Id e3, Id e4) { |
68 |
| - return ctx.OpCompositeConstruct(ctx.F16[4], e1, e2, e3, e4); |
| 71 | +Id EmitCompositeConstructF16x4(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3, Id e4) { |
| 72 | + return CompositeConstructImpl(ctx.F16[4], e1, e2, e3, e4); |
69 | 73 | }
|
70 | 74 |
|
71 | 75 | Id EmitCompositeExtractF16x2(EmitContext& ctx, Id composite, u32 index) {
|
@@ -106,16 +110,16 @@ Id EmitCompositeShuffleF16x4(EmitContext& ctx, Id composite1, Id composite2, u32
|
106 | 110 | return ctx.OpVectorShuffle(ctx.F16[4], composite1, composite2, comp0, comp1, comp2, comp3);
|
107 | 111 | }
|
108 | 112 |
|
109 |
| -Id EmitCompositeConstructF32x2(EmitContext& ctx, Id e1, Id e2) { |
110 |
| - return ctx.OpCompositeConstruct(ctx.F32[2], e1, e2); |
| 113 | +Id EmitCompositeConstructF32x2(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2) { |
| 114 | + return CompositeConstructImpl(ctx.F32[2], e1, e2); |
111 | 115 | }
|
112 | 116 |
|
113 |
| -Id EmitCompositeConstructF32x3(EmitContext& ctx, Id e1, Id e2, Id e3) { |
114 |
| - return ctx.OpCompositeConstruct(ctx.F32[3], e1, e2, e3); |
| 117 | +Id EmitCompositeConstructF32x3(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3) { |
| 118 | + return CompositeConstructImpl(ctx.F32[3], e1, e2, e3); |
115 | 119 | }
|
116 | 120 |
|
117 |
| -Id EmitCompositeConstructF32x4(EmitContext& ctx, Id e1, Id e2, Id e3, Id e4) { |
118 |
| - return ctx.OpCompositeConstruct(ctx.F32[4], e1, e2, e3, e4); |
| 121 | +Id EmitCompositeConstructF32x4(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3, Id e4) { |
| 122 | + return CompositeConstructImpl(ctx.F32[4], e1, e2, e3, e4); |
119 | 123 | }
|
120 | 124 |
|
121 | 125 | Id EmitCompositeExtractF32x2(EmitContext& ctx, Id composite, u32 index) {
|
|
0 commit comments