Skip to content

Commit eb51350

Browse files
committed
Update IR
IR commit: 0e3608e3c945140d366134034ee8d86edbe6d050
1 parent 0bf063d commit eb51350

File tree

6 files changed

+289
-14
lines changed

6 files changed

+289
-14
lines changed

ext/opcache/jit/ir/gen_ir_fold_hash.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ int main(int argc, char **argv)
255255

256256
IR_OPS(IR_OP_ADD)
257257

258+
ir_strtab_lookup(&strtab, "C_INTPTR", sizeof("C_INTPTR") - 1, IR_C_INTPTR + 1);
259+
ir_strtab_lookup(&strtab, "C_UINTPTR", sizeof("C_IINTPTR") - 1, IR_C_UINTPTR + 1);
260+
258261
while (fgets(buf, sizeof(buf) - 1, f)) {
259262
size_t len = strlen(buf);
260263
if (len > 0 && (buf[len - 1] == '\r' || buf[len - 1] == '\n')) {

ext/opcache/jit/ir/ir.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,15 @@ typedef enum _ir_type {
156156
# define IR_SSIZE_T IR_I64
157157
# define IR_UINTPTR_T IR_U64
158158
# define IR_INTPTR_T IR_I64
159+
# define IR_C_UINTPTR IR_U64
160+
# define IR_C_INTPTR IR_I64
159161
#else
160162
# define IR_SIZE_T IR_U32
161163
# define IR_SSIZE_T IR_I32
162164
# define IR_UINTPTR_T IR_U32
163165
# define IR_INTPTR_T IR_I32
166+
# define IR_C_UINTPTR IR_U32
167+
# define IR_C_INTPTR IR_I32
164168
#endif
165169

166170
/* List of IR opcodes
@@ -839,8 +843,14 @@ int ir_load_llvm_bitcode(ir_loader *loader, const char *filename);
839843
int ir_load_llvm_asm(ir_loader *loader, const char *filename);
840844

841845
/* IR save API (implementation in ir_save.c) */
846+
#define IR_SAVE_CFG (1<<0) /* add info about CFG */
847+
#define IR_SAVE_CFG_MAP (1<<1) /* add info about CFG block assignment */
848+
#define IR_SAVE_USE_LISTS (1<<2) /* add info about def->use lists */
849+
#define IR_SAVE_RULES (1<<3) /* add info about selected code-generation rules */
850+
#define IR_SAVE_REGS (1<<4) /* add info about selected registers */
851+
842852
void ir_print_proto(const ir_ctx *ctx, ir_ref proto, FILE *f);
843-
void ir_save(const ir_ctx *ctx, FILE *f);
853+
void ir_save(const ir_ctx *ctx, uint32_t save_flags, FILE *f);
844854

845855
/* IR debug dump API (implementation in ir_dump.c) */
846856
void ir_dump(const ir_ctx *ctx, FILE *f);

ext/opcache/jit/ir/ir_dump.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,46 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f)
511511
if ((bb->flags & (IR_BB_START|IR_BB_ENTRY|IR_BB_EMPTY)) == IR_BB_EMPTY) {
512512
continue;
513513
}
514-
fprintf(f, "#BB%d:\n", b);
514+
515+
fprintf(f, "#BB%d: end=l_%d", b, bb->end);
516+
if (bb->flags && IR_BB_UNREACHABLE) {
517+
fprintf(f, ", U");
518+
}
519+
if (bb->dom_parent > 0) {
520+
fprintf(f, ", idom=BB%d(%d)", bb->dom_parent, bb->dom_depth);
521+
}
522+
if (bb->loop_depth != 0) {
523+
if (bb->flags & IR_BB_LOOP_HEADER) {
524+
if (bb->loop_header > 0) {
525+
fprintf(f, ", loop=HDR,BB%d(%d)", bb->loop_header, bb->loop_depth);
526+
} else {
527+
IR_ASSERT(bb->loop_depth == 1);
528+
fprintf(f, ", loop=HDR(%d)", bb->loop_depth);
529+
}
530+
} else {
531+
IR_ASSERT(bb->loop_header > 0);
532+
fprintf(f, ", loop=BB%d(%d)", bb->loop_header, bb->loop_depth);
533+
}
534+
}
535+
if (bb->predecessors_count) {
536+
uint32_t i;
537+
538+
fprintf(f, ", pred(%d)=[BB%d", bb->predecessors_count, ctx->cfg_edges[bb->predecessors]);
539+
for (i = 1; i < bb->predecessors_count; i++) {
540+
fprintf(f, ", BB%d", ctx->cfg_edges[bb->predecessors + i]);
541+
}
542+
fprintf(f, "]");
543+
}
544+
if (bb->successors_count) {
545+
uint32_t i;
546+
547+
fprintf(f, ", succ(%d)=[BB%d", bb->successors_count, ctx->cfg_edges[bb->successors]);
548+
for (i = 1; i < bb->successors_count; i++) {
549+
fprintf(f, ", BB%d", ctx->cfg_edges[bb->successors + i]);
550+
}
551+
fprintf(f, "]");
552+
}
553+
fprintf(f, "\n");
515554

516555
for (i = bb->start, insn = ctx->ir_base + i; i <= bb->end;) {
517556
flags = ir_op_flags[insn->op];
@@ -682,8 +721,14 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f)
682721
}
683722
}
684723
succ = ir_skip_empty_target_blocks(ctx, succ);
685-
if (succ != b + 1) {
686-
fprintf(f, "\t# GOTO BB%d\n", succ);
724+
if (ctx->cfg_schedule) {
725+
if (_b == ctx->cfg_blocks_count || succ != ctx->cfg_schedule[_b + 1]) {
726+
fprintf(f, "\t# GOTO BB%d\n", succ);
727+
}
728+
} else {
729+
if (succ != b + 1) {
730+
fprintf(f, "\t# GOTO BB%d\n", succ);
731+
}
687732
}
688733
} else if (insn->op == IR_IF) {
689734
uint32_t true_block, false_block;

ext/opcache/jit/ir/ir_fold.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,12 @@ IR_FOLD(ADD(C_U64, C_U64))
299299
}
300300

301301
IR_FOLD(ADD(C_ADDR, C_ADDR))
302+
IR_FOLD(ADD(C_ADDR, C_INTPTR))
303+
IR_FOLD(ADD(C_ADDR, C_UINTPTR))
304+
IR_FOLD(ADD(C_INTPTR, C_ADDR))
305+
IR_FOLD(ADD(C_UINTPTR, C_ADDR))
302306
{
303-
IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
307+
// IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
304308
IR_FOLD_CONST_U(op1_insn->val.addr + op2_insn->val.addr);
305309
}
306310

@@ -365,8 +369,12 @@ IR_FOLD(SUB(C_U64, C_U64))
365369
}
366370

367371
IR_FOLD(SUB(C_ADDR, C_ADDR))
372+
IR_FOLD(SUB(C_ADDR, C_INTPTR))
373+
IR_FOLD(SUB(C_ADDR, C_UINTPTR))
374+
IR_FOLD(SUB(C_INTPTR, C_ADDR))
375+
IR_FOLD(SUB(C_UINTPTR, C_ADDR))
368376
{
369-
IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
377+
// IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
370378
IR_FOLD_CONST_U(op1_insn->val.addr - op2_insn->val.addr);
371379
}
372380

@@ -431,8 +439,12 @@ IR_FOLD(MUL(C_U64, C_U64))
431439
}
432440

433441
IR_FOLD(MUL(C_ADDR, C_ADDR))
442+
IR_FOLD(MUL(C_ADDR, C_INTPTR))
443+
IR_FOLD(MUL(C_ADDR, C_UINTPTR))
444+
IR_FOLD(MUL(C_INTPTR, C_ADDR))
445+
IR_FOLD(MUL(C_UINTPTR, C_ADDR))
434446
{
435-
IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
447+
// IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type);
436448
IR_FOLD_CONST_U(op1_insn->val.addr * op2_insn->val.addr);
437449
}
438450

0 commit comments

Comments
 (0)