@@ -92,4 +92,60 @@ module @InductionVariables {
9292 bmodelica.equation_instance %t1 {indices = #modeling <multidim_range [0 , 1 ]>} : !bmodelica.equation
9393 }
9494 }
95+ }
96+
97+ // -----
98+
99+ module @ArrayResult {
100+ bmodelica.function @FuncWithArrayResult {
101+ bmodelica.variable @x : !bmodelica.variable <f64 , input >
102+ bmodelica.variable @y : !bmodelica.variable <1 xf64 , output >
103+ bmodelica.algorithm {
104+ %0 = bmodelica.constant 0 : index
105+ %1 = bmodelica.variable_get @x : f64
106+ bmodelica.variable_set @y [%0 ], %1 : index , f64
107+ }
108+ }
109+
110+ bmodelica.model @M {
111+ bmodelica.variable @x : !bmodelica.variable <1 xf64 >
112+ bmodelica.variable @y : !bmodelica.variable <1 xf64 >
113+
114+ // CHECK: bmodelica.equation_template
115+ // CHECK-NEXT: %[[R0:.*]] = bmodelica.variable_get @x
116+ // CHECK-NEXT: %[[LHS:.*]] = bmodelica.equation_side %[[R0]]
117+ // CHECK-NEXT: %[[R1:.*]] = bmodelica.constant 1
118+ // CHECK-NEXT: %[[R2:.*]] = bmodelica.call @FuncWithArrayResult(%[[R1]])
119+ // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[R2]]
120+ // CHECK-NEXT: bmodelica.equation_sides %[[LHS]], %[[RHS]]
121+ %t0 = bmodelica.equation_template inductions = [] {
122+ %0 = bmodelica.variable_get @x : tensor <1 xf64 >
123+ %1 = bmodelica.equation_side %0 : tuple <tensor <1 xf64 >>
124+ %2 = bmodelica.constant 1.0 : f64
125+ %3 = bmodelica.call @FuncWithArrayResult (%2 ) : (f64 ) -> tensor <1 xf64 >
126+ %4 = bmodelica.equation_side %3 : tuple <tensor <1 xf64 >>
127+ bmodelica.equation_sides %1 , %4 : tuple <tensor <1 xf64 >>, tuple <tensor <1 xf64 >>
128+ }
129+
130+ // CHECK: bmodelica.equation_template
131+ // CHECK-NEXT: %[[R0:.*]] = bmodelica.variable_get @y
132+ // CHECK-NEXT: %[[LHS:.*]] = bmodelica.equation_side %[[R0]]
133+ // CHECK-NEXT: %[[R1:.*]] = bmodelica.constant 1
134+ // CHECK-NEXT: %[[R2:.*]] = bmodelica.call @FuncWithArrayResult(%[[R1]])
135+ // CHECK-NEXT: %[[RHS:.*]] = bmodelica.equation_side %[[R2]]
136+ // CHECK-NEXT: bmodelica.equation_sides %[[LHS]], %[[RHS]]
137+ %t1 = bmodelica.equation_template inductions = [] {
138+ %0 = bmodelica.variable_get @y : tensor <1 xf64 >
139+ %1 = bmodelica.equation_side %0 : tuple <tensor <1 xf64 >>
140+ %2 = bmodelica.constant 1.0 : f64
141+ %3 = bmodelica.call @FuncWithArrayResult (%2 ) : (f64 ) -> tensor <1 xf64 >
142+ %4 = bmodelica.equation_side %3 : tuple <tensor <1 xf64 >>
143+ bmodelica.equation_sides %1 , %4 : tuple <tensor <1 xf64 >>, tuple <tensor <1 xf64 >>
144+ }
145+
146+ bmodelica.dynamic {
147+ bmodelica.equation_instance %t0 : !bmodelica.equation
148+ bmodelica.equation_instance %t1 : !bmodelica.equation
149+ }
150+ }
95151}
0 commit comments