@@ -858,7 +858,7 @@ ir_ref ir_emit3(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3)
858858static ir_ref _ir_fold_cse (ir_ctx * ctx , uint32_t opt , ir_ref op1 , ir_ref op2 , ir_ref op3 )
859859{
860860 ir_ref ref = ctx -> prev_insn_chain [opt & IR_OPT_OP_MASK ];
861- ir_insn * insn ;
861+ const ir_insn * insn ;
862862
863863 if (ref ) {
864864 ir_ref limit = ctx -> fold_cse_limit ;
@@ -954,7 +954,8 @@ IR_ALWAYS_INLINE ir_ref _ir_fold_cast(ir_ctx *ctx, ir_ref ref, ir_type type)
954954 * ANY and UNUSED ops are represented by 0
955955 */
956956
957- ir_ref ir_folding (ir_ctx * ctx , uint32_t opt , ir_ref op1 , ir_ref op2 , ir_ref op3 , ir_insn * op1_insn , ir_insn * op2_insn , ir_insn * op3_insn )
957+ ir_ref ir_folding (ir_ctx * ctx , uint32_t opt , ir_ref op1 , ir_ref op2 , ir_ref op3 ,
958+ const ir_insn * op1_insn , const ir_insn * op2_insn , const ir_insn * op3_insn )
958959{
959960 uint8_t op ;
960961 ir_ref ref ;
@@ -1136,9 +1137,9 @@ void ir_set_op(ir_ctx *ctx, ir_ref ref, int32_t n, ir_ref val)
11361137 ir_insn_set_op (insn , n , val );
11371138}
11381139
1139- ir_ref ir_get_op (ir_ctx * ctx , ir_ref ref , int32_t n )
1140+ ir_ref ir_get_op (const ir_ctx * ctx , ir_ref ref , int32_t n )
11401141{
1141- ir_insn * insn = & ctx -> ir_base [ref ];
1142+ const ir_insn * insn = & ctx -> ir_base [ref ];
11421143
11431144#ifdef IR_DEBUG
11441145 if (n > 3 ) {
@@ -2025,7 +2026,7 @@ static ir_alias ir_check_aliasing(ir_ctx *ctx, ir_ref addr1, ir_ref addr2)
20252026
20262027ir_alias ir_check_partial_aliasing (const ir_ctx * ctx , ir_ref addr1 , ir_ref addr2 , ir_type type1 , ir_type type2 )
20272028{
2028- ir_insn * insn1 , * insn2 ;
2029+ const ir_insn * insn1 , * insn2 ;
20292030 ir_ref base1 , base2 , off1 , off2 ;
20302031
20312032 /* this must be already check */
@@ -2117,9 +2118,9 @@ ir_alias ir_check_partial_aliasing(const ir_ctx *ctx, ir_ref addr1, ir_ref addr2
21172118 return IR_MAY_ALIAS ;
21182119}
21192120
2120- IR_ALWAYS_INLINE ir_ref ir_find_aliasing_load_i (ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref addr , ir_ref limit )
2121+ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_load_i (const ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref addr , ir_ref limit )
21212122{
2122- ir_insn * insn ;
2123+ const ir_insn * insn ;
21232124 uint32_t modified_regset = 0 ;
21242125
21252126 while (ref > limit ) {
@@ -2159,7 +2160,7 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_load_i(ir_ctx *ctx, ir_ref ref, ir_type
21592160 } else if (insn -> op == IR_RSTORE ) {
21602161 modified_regset |= (1 << insn -> op3 );
21612162 } else if (insn -> op == IR_CALL ) {
2162- ir_insn * func = & ctx -> ir_base [insn -> op2 ];
2163+ const ir_insn * func = & ctx -> ir_base [insn -> op2 ];
21632164 ir_ref func_proto ;
21642165 const ir_proto_t * proto ;
21652166
@@ -2186,14 +2187,14 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_load_i(ir_ctx *ctx, ir_ref ref, ir_type
21862187 return IR_UNUSED ;
21872188}
21882189
2189- ir_ref ir_find_aliasing_load (ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref addr )
2190+ ir_ref ir_find_aliasing_load (const ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref addr )
21902191{
21912192 return ir_find_aliasing_load_i (ctx , ref , type , addr , (addr > 0 && addr < ref ) ? addr : 1 );
21922193}
21932194
2194- IR_ALWAYS_INLINE ir_ref ir_find_aliasing_vload_i (ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref var )
2195+ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_vload_i (const ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref var )
21952196{
2196- ir_insn * insn ;
2197+ const ir_insn * insn ;
21972198
21982199 while (ref > var ) {
21992200 insn = & ctx -> ir_base [ref ];
@@ -2224,7 +2225,7 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_vload_i(ir_ctx *ctx, ir_ref ref, ir_typ
22242225 }
22252226 }
22262227 } else if (insn -> op == IR_CALL ) {
2227- ir_insn * func = & ctx -> ir_base [insn -> op2 ];
2228+ const ir_insn * func = & ctx -> ir_base [insn -> op2 ];
22282229 ir_ref func_proto ;
22292230 const ir_proto_t * proto ;
22302231
@@ -2251,7 +2252,7 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_vload_i(ir_ctx *ctx, ir_ref ref, ir_typ
22512252 return IR_UNUSED ;
22522253}
22532254
2254- ir_ref ir_find_aliasing_vload (ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref var )
2255+ ir_ref ir_find_aliasing_vload (const ir_ctx * ctx , ir_ref ref , ir_type type , ir_ref var )
22552256{
22562257 return ir_find_aliasing_vload_i (ctx , ref , type , var );
22572258}
@@ -2547,12 +2548,12 @@ void _ir_BEGIN(ir_ctx *ctx, ir_ref src)
25472548 }
25482549}
25492550
2550- static ir_ref _ir_fold_condition (ir_ctx * ctx , ir_ref ref )
2551+ static ir_ref _ir_fold_condition (const ir_ctx * ctx , ir_ref ref )
25512552{
2552- ir_insn * insn = & ctx -> ir_base [ref ];
2553+ const ir_insn * insn = & ctx -> ir_base [ref ];
25532554
25542555 if (insn -> op == IR_NE && IR_IS_CONST_REF (insn -> op2 )) {
2555- ir_insn * op2_insn = & ctx -> ir_base [insn -> op2 ];
2556+ const ir_insn * op2_insn = & ctx -> ir_base [insn -> op2 ];
25562557
25572558 if (IR_IS_TYPE_INT (op2_insn -> type ) && op2_insn -> val .u64 == 0 ) {
25582559 ref = insn -> op1 ;
@@ -2565,7 +2566,7 @@ static ir_ref _ir_fold_condition(ir_ctx *ctx, ir_ref ref)
25652566 ref = insn -> op1 ;
25662567 insn = & ctx -> ir_base [ref ];
25672568 } else if (insn -> op == IR_EQ && insn -> op2 == IR_NULL ) {
2568- ir_insn * op1_insn = & ctx -> ir_base [insn -> op1 ];
2569+ const ir_insn * op1_insn = & ctx -> ir_base [insn -> op1 ];
25692570 if (op1_insn -> op == IR_ALLOCA || op1_insn -> op == IR_VADDR ) {
25702571 return IR_FALSE ;
25712572 }
@@ -2577,10 +2578,10 @@ static ir_ref _ir_fold_condition(ir_ctx *ctx, ir_ref ref)
25772578 return ref ;
25782579}
25792580
2580- IR_ALWAYS_INLINE ir_ref ir_check_dominating_predicates_i (ir_ctx * ctx , ir_ref ref , ir_ref condition , ir_ref limit )
2581+ IR_ALWAYS_INLINE ir_ref ir_check_dominating_predicates_i (const ir_ctx * ctx , ir_ref ref , ir_ref condition , ir_ref limit )
25812582{
2582- ir_insn * prev = NULL ;
2583- ir_insn * insn ;
2583+ const ir_insn * prev = NULL ;
2584+ const ir_insn * insn ;
25842585
25852586 while (ref > limit ) {
25862587 insn = & ctx -> ir_base [ref ];
@@ -2610,7 +2611,7 @@ IR_ALWAYS_INLINE ir_ref ir_check_dominating_predicates_i(ir_ctx *ctx, ir_ref ref
26102611 return condition ;
26112612}
26122613
2613- ir_ref ir_check_dominating_predicates (ir_ctx * ctx , ir_ref ref , ir_ref condition )
2614+ ir_ref ir_check_dominating_predicates (const ir_ctx * ctx , ir_ref ref , ir_ref condition )
26142615{
26152616 IR_ASSERT (!IR_IS_CONST_REF (condition ));
26162617 return ir_check_dominating_predicates_i (ctx , ref , condition , (condition < ref ) ? condition : 1 );
@@ -2751,7 +2752,7 @@ void _ir_MERGE_LIST(ir_ctx *ctx, ir_ref list)
27512752
27522753 /* count inputs count */
27532754 do {
2754- ir_insn * insn = & ctx -> ir_base [ref ];
2755+ const ir_insn * insn = & ctx -> ir_base [ref ];
27552756
27562757 IR_ASSERT (insn -> op == IR_END );
27572758 ref = insn -> op2 ;
@@ -2781,8 +2782,10 @@ void _ir_MERGE_LIST(ir_ctx *ctx, ir_ref list)
27812782
27822783ir_ref _ir_PHI_LIST (ir_ctx * ctx , ir_ref list )
27832784{
2784- ir_insn * merge , * end ;
2785- ir_ref phi , * ops , i ;
2785+ const ir_insn * merge ;
2786+ const ir_ref * ops ;
2787+ ir_insn * end ;
2788+ ir_ref phi , i ;
27862789 ir_type type ;
27872790
27882791 if (list == IR_UNUSED ) {
@@ -3246,7 +3249,8 @@ ir_ref _ir_VLOAD(ir_ctx *ctx, ir_type type, ir_ref var)
32463249 if (EXPECTED (ctx -> flags & IR_OPT_FOLDING )) {
32473250 ref = ir_find_aliasing_vload_i (ctx , ctx -> control , type , var );
32483251 if (ref ) {
3249- ir_insn * insn = & ctx -> ir_base [ref ];
3252+ const ir_insn * insn = & ctx -> ir_base [ref ];
3253+
32503254 if (insn -> type == type ) {
32513255 return ref ;
32523256 } else if (ir_type_size [insn -> type ] == ir_type_size [type ]) {
@@ -3312,7 +3316,8 @@ ir_ref _ir_LOAD(ir_ctx *ctx, ir_type type, ir_ref addr)
33123316 }
33133317 ref = ir_find_aliasing_load_i (ctx , ctx -> control , type , addr , (addr > 0 ) ? addr : 1 );
33143318 if (ref ) {
3315- ir_insn * insn = & ctx -> ir_base [ref ];
3319+ const ir_insn * insn = & ctx -> ir_base [ref ];
3320+
33163321 if (insn -> type == type ) {
33173322 return ref ;
33183323 } else if (ir_type_size [insn -> type ] == ir_type_size [type ]) {
0 commit comments