mirror of
https://github.com/danog/ir.git
synced 2025-01-22 05:31:32 +01:00
Add support for ENDBR
This commit is contained in:
parent
66330273b1
commit
d619efa0ad
5
ir.h
5
ir.h
@ -410,8 +410,11 @@ void ir_strtab_free(ir_strtab *strtab);
|
||||
#define IR_HAS_ALLOCA (1<<5)
|
||||
#define IR_HAS_CALLS (1<<6)
|
||||
#define IR_NO_STACK_COMBINE (1<<7)
|
||||
#define IR_START_BR_TARGET (1<<8)
|
||||
#define IR_ENTRY_BR_TARGET (1<<9)
|
||||
#define IR_GEN_ENDBR (1<<10)
|
||||
|
||||
#define IR_IRREDUCIBLE_CFG (1<<8)
|
||||
#define IR_IRREDUCIBLE_CFG (1<<15)
|
||||
|
||||
#define IR_OPT_FOLDING (1<<16)
|
||||
#define IR_OPT_CFG (1<<17) /* merge BBs, by remove END->BEGIN nodes during CFG construction */
|
||||
|
@ -1417,9 +1417,6 @@ static void ir_emit_prologue(ir_ctx *ctx)
|
||||
ir_backend_data *data = ctx->data;
|
||||
dasm_State **Dst = &data->dasm_state;
|
||||
|
||||
if (ctx->flags & IR_SKIP_PROLOGUE) {
|
||||
return;
|
||||
}
|
||||
if (ctx->flags & IR_USE_FRAME_POINTER) {
|
||||
| stp x29, x30, [sp, # (-(data->ra_data.stack_frame_size+16))]!
|
||||
| mov x29, sp
|
||||
@ -4976,7 +4973,9 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
|
||||
/* labels for each block + for each constant + rodata label + jmp_table label + for each entry */
|
||||
dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + entries_count);
|
||||
|
||||
ir_emit_prologue(ctx);
|
||||
if (!(ctx->flags & IR_SKIP_PROLOGUE)) {
|
||||
ir_emit_prologue(ctx);
|
||||
}
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ir_emit_load_params(ctx);
|
||||
}
|
||||
|
22
ir_x86.dasc
22
ir_x86.dasc
@ -2222,9 +2222,6 @@ static void ir_emit_prologue(ir_ctx *ctx)
|
||||
ir_backend_data *data = ctx->data;
|
||||
dasm_State **Dst = &data->dasm_state;
|
||||
|
||||
if (ctx->flags & IR_SKIP_PROLOGUE) {
|
||||
return;
|
||||
}
|
||||
if (ctx->flags & IR_USE_FRAME_POINTER) {
|
||||
| push Ra(IR_REG_RBP)
|
||||
| mov Ra(IR_REG_RBP), Ra(IR_REG_RSP)
|
||||
@ -7530,7 +7527,17 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
|
||||
/* labels for each block + for each constant + rodata label + jmp_table label + for each entry */
|
||||
dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + entries_count);
|
||||
|
||||
ir_emit_prologue(ctx);
|
||||
if ((ctx->flags & IR_GEN_ENDBR) && (ctx->flags & IR_START_BR_TARGET)) {
|
||||
|.if X64
|
||||
| endbr64
|
||||
|.else
|
||||
| endbr32
|
||||
|.endif
|
||||
}
|
||||
|
||||
if (!(ctx->flags & IR_SKIP_PROLOGUE)) {
|
||||
ir_emit_prologue(ctx);
|
||||
}
|
||||
if (ctx->flags & IR_FUNCTION) {
|
||||
ir_emit_load_params(ctx);
|
||||
}
|
||||
@ -7560,6 +7567,13 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
|
||||
{
|
||||
uint32_t label = ctx->cfg_blocks_count + ctx->consts_count + 3 + insn->op3;
|
||||
|=>label:
|
||||
if ((ctx->flags & IR_GEN_ENDBR) && (ctx->flags & IR_ENTRY_BR_TARGET)) {
|
||||
|.if X64
|
||||
| endbr64
|
||||
|.else
|
||||
| endbr32
|
||||
|.endif
|
||||
}
|
||||
ir_emit_prologue(ctx);
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user