@@ -342,3 +342,60 @@ func.func @expression_with_subscript_user(%arg0: !emitc.ptr<!emitc.opaque<"void"
342
342
%res_load = emitc.load %res : !emitc.lvalue <i32 >
343
343
return %res_load : i32
344
344
}
345
+
346
+ // CPP-DEFAULT: bool expression_with_load(int32_t [[VAL_1:v.+]], int32_t [[VAL_2:v.+]], int32_t* [[VAL_3:v.+]]) {
347
+ // CPP-DEFAULT-NEXT: int64_t [[VAL_4:v.+]] = 0;
348
+ // CPP-DEFAULT-NEXT: int32_t [[VAL_5:v.+]] = 42;
349
+ // CPP-DEFAULT-NEXT: bool [[VAL_6:v.+]] = [[VAL_5]] + [[VAL_2]] < [[VAL_3]][[[VAL_4]]] + [[VAL_1]];
350
+ // CPP-DEFAULT-NEXT: return [[VAL_6]];
351
+
352
+ // CPP-DECLTOP: bool expression_with_load(int32_t [[VAL_1:v.+]], int32_t [[VAL_2:v.+]], int32_t* [[VAL_3:v.+]]) {
353
+ // CPP-DECLTOP-NEXT: int64_t [[VAL_4:v.+]];
354
+ // CPP-DECLTOP-NEXT: int32_t [[VAL_5:v.+]];
355
+ // CPP-DECLTOP-NEXT: bool [[VAL_6:v.+]];
356
+ // CPP-DECLTOP-NEXT: [[VAL_4]] = 0;
357
+ // CPP-DECLTOP-NEXT: [[VAL_5]] = 42;
358
+ // CPP-DECLTOP-NEXT: [[VAL_6]] = [[VAL_5]] + [[VAL_2]] < [[VAL_3]][[[VAL_4]]] + [[VAL_1]];
359
+ // CPP-DECLTOP-NEXT: return [[VAL_6]];
360
+
361
+ func.func @expression_with_load (%arg0: i32 , %arg1: i32 , %arg2: !emitc.ptr <i32 >) -> i1 {
362
+ %c0 = " emitc.constant" () {value = 0 : i64 } : () -> i64
363
+ %0 = " emitc.variable" () <{value = #emitc.opaque <" 42" >}> : () -> !emitc.lvalue <i32 >
364
+ %ptr = emitc.subscript %arg2 [%c0 ] : (!emitc.ptr <i32 >, i64 ) -> !emitc.lvalue <i32 >
365
+ %result = emitc.expression : i1 {
366
+ %a = emitc.load %0 : !emitc.lvalue <i32 >
367
+ %b = emitc.add %a , %arg1 : (i32 , i32 ) -> i32
368
+ %c = emitc.load %ptr : !emitc.lvalue <i32 >
369
+ %d = emitc.add %c , %arg0 : (i32 , i32 ) -> i32
370
+ %e = emitc.cmp lt , %b , %d :(i32 , i32 ) -> i1
371
+ yield %e : i1
372
+ }
373
+ return %result : i1
374
+ }
375
+
376
+ // CPP-DEFAULT: bool expression_with_load_and_call(int32_t* [[VAL_1:v.+]]) {
377
+ // CPP-DEFAULT-NEXT: int64_t [[VAL_2:v.+]] = 0;
378
+ // CPP-DEFAULT-NEXT: bool [[VAL_3:v.+]] = [[VAL_1]][[[VAL_2]]] + bar([[VAL_1]][[[VAL_2]]]) < [[VAL_1]][[[VAL_2]]];
379
+ // CPP-DEFAULT-NEXT: return [[VAL_3]];
380
+
381
+ // CPP-DECLTOP: bool expression_with_load_and_call(int32_t* [[VAL_1:v.+]]) {
382
+ // CPP-DECLTOP-NEXT: int64_t [[VAL_2:v.+]];
383
+ // CPP-DECLTOP-NEXT: bool [[VAL_3:v.+]];
384
+ // CPP-DECLTOP-NEXT: [[VAL_2]] = 0;
385
+ // CPP-DECLTOP-NEXT: [[VAL_3]] = [[VAL_1]][[[VAL_2]]] + bar([[VAL_1]][[[VAL_2]]]) < [[VAL_1]][[[VAL_2]]];
386
+ // CPP-DECLTOP-NEXT: return [[VAL_3]];
387
+
388
+ func.func @expression_with_load_and_call (%arg0: !emitc.ptr <i32 >) -> i1 {
389
+ %c0 = " emitc.constant" () {value = 0 : i64 } : () -> i64
390
+ %ptr = emitc.subscript %arg0 [%c0 ] : (!emitc.ptr <i32 >, i64 ) -> !emitc.lvalue <i32 >
391
+ %result = emitc.expression : i1 {
392
+ %a = emitc.load %ptr : !emitc.lvalue <i32 >
393
+ %b = emitc.load %ptr : !emitc.lvalue <i32 >
394
+ %c = emitc.load %ptr : !emitc.lvalue <i32 >
395
+ %d = emitc.call_opaque " bar" (%a ) : (i32 ) -> (i32 )
396
+ %e = add %c , %d : (i32 , i32 ) -> i32
397
+ %f = emitc.cmp lt , %e , %b :(i32 , i32 ) -> i1
398
+ yield %f : i1
399
+ }
400
+ return %result : i1
401
+ }
0 commit comments