Support for function prototypes

This commit is contained in:
Dmitry Stogov 2023-11-30 21:10:41 +03:00
parent 81047af575
commit 76e6418cae
87 changed files with 1142 additions and 755 deletions

119
ir.c
View File

@ -28,6 +28,7 @@
#include "ir.h" #include "ir.h"
#include "ir_private.h" #include "ir_private.h"
#include <stddef.h>
#include <math.h> #include <math.h>
#ifdef HAVE_VALGRIND #ifdef HAVE_VALGRIND
@ -70,13 +71,13 @@ const char *ir_op_name[IR_LAST_OP] = {
void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted) void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted)
{ {
if (insn->op == IR_FUNC || insn->op == IR_SYM) { if (insn->op == IR_FUNC || insn->op == IR_SYM) {
fprintf(f, "%s", ir_get_str(ctx, insn->val.i32)); fprintf(f, "%s", ir_get_str(ctx, insn->val.name));
return; return;
} else if (insn->op == IR_STR) { } else if (insn->op == IR_STR) {
if (quoted) { if (quoted) {
fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.i32)); fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.str));
} else { } else {
fprintf(f, "%s", ir_get_str(ctx, insn->val.i32)); fprintf(f, "%s", ir_get_str(ctx, insn->val.str));
} }
return; return;
} }
@ -217,6 +218,7 @@ void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted
#define ir_op_kind_var IR_OPND_DATA #define ir_op_kind_var IR_OPND_DATA
#define ir_op_kind_prb IR_OPND_PROB #define ir_op_kind_prb IR_OPND_PROB
#define ir_op_kind_opt IR_OPND_PROB #define ir_op_kind_opt IR_OPND_PROB
#define ir_op_kind_pro IR_OPND_PROTO
#define _IR_OP_FLAGS(name, flags, op1, op2, op3) \ #define _IR_OP_FLAGS(name, flags, op1, op2, op3) \
IR_OP_FLAGS(ir_op_flag_ ## flags, ir_op_kind_ ## op1, ir_op_kind_ ## op2, ir_op_kind_ ## op3), IR_OP_FLAGS(ir_op_flag_ ## flags, ir_op_kind_ ## op1, ir_op_kind_ ## op2, ir_op_kind_ ## op3),
@ -562,34 +564,36 @@ ir_ref ir_const_addr(ir_ctx *ctx, uintptr_t c)
return ir_const(ctx, val, IR_ADDR); return ir_const(ctx, val, IR_ADDR);
} }
ir_ref ir_const_func_addr(ir_ctx *ctx, uintptr_t c, uint16_t flags) ir_ref ir_const_func_addr(ir_ctx *ctx, uintptr_t c, ir_ref proto)
{ {
if (c == 0) { if (c == 0) {
return IR_NULL; return IR_NULL;
} }
ir_val val; ir_val val;
val.u64 = c; val.u64 = c;
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_FUNC_ADDR, IR_ADDR, flags)); IR_ASSERT(proto >= 0 && proto < 0xffff);
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_FUNC_ADDR, IR_ADDR, proto));
} }
ir_ref ir_const_func(ir_ctx *ctx, ir_ref str, uint16_t flags) ir_ref ir_const_func(ir_ctx *ctx, ir_ref str, ir_ref proto)
{ {
ir_val val; ir_val val;
val.addr = str; val.u64 = str;
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_FUNC, IR_ADDR, flags)); IR_ASSERT(proto >= 0 && proto < 0xffff);
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_FUNC, IR_ADDR, proto));
} }
ir_ref ir_const_sym(ir_ctx *ctx, ir_ref str) ir_ref ir_const_sym(ir_ctx *ctx, ir_ref str)
{ {
ir_val val; ir_val val;
val.addr = str; val.u64 = str;
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_SYM, IR_ADDR, 0)); return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_SYM, IR_ADDR, 0));
} }
ir_ref ir_const_str(ir_ctx *ctx, ir_ref str) ir_ref ir_const_str(ir_ctx *ctx, ir_ref str)
{ {
ir_val val; ir_val val;
val.addr = str; val.u64 = str;
return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_STR, IR_ADDR, 0)); return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_STR, IR_ADDR, 0));
} }
@ -620,6 +624,101 @@ const char *ir_get_str(const ir_ctx *ctx, ir_ref idx)
return ir_strtab_str(&ctx->strtab, idx - 1); return ir_strtab_str(&ctx->strtab, idx - 1);
} }
const char *ir_get_strl(const ir_ctx *ctx, ir_ref idx, size_t *len)
{
IR_ASSERT(ctx->strtab.data);
return ir_strtab_strl(&ctx->strtab, idx - 1, len);
}
ir_ref ir_proto_0(ir_ctx *ctx, uint8_t flags, ir_type ret_type)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 0;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 0);
}
ir_ref ir_proto_1(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 1;
proto.param_types[0] = t1;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 1);
}
ir_ref ir_proto_2(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 2;
proto.param_types[0] = t1;
proto.param_types[1] = t2;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 2);
}
ir_ref ir_proto_3(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 3;
proto.param_types[0] = t1;
proto.param_types[1] = t2;
proto.param_types[2] = t3;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 3);
}
ir_ref ir_proto_4(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3,
ir_type t4)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 4;
proto.param_types[0] = t1;
proto.param_types[1] = t2;
proto.param_types[2] = t3;
proto.param_types[3] = t4;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 4);
}
ir_ref ir_proto_5(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3,
ir_type t4, ir_type t5)
{
ir_proto_t proto;
proto.flags = flags;
proto.ret_type = ret_type;
proto.params_count = 5;
proto.param_types[0] = t1;
proto.param_types[1] = t2;
proto.param_types[2] = t3;
proto.param_types[3] = t4;
proto.param_types[4] = t5;
return ir_strl(ctx, (const char *)&proto, offsetof(ir_proto_t, param_types) + 5);
}
ir_ref ir_proto(ir_ctx *ctx, uint8_t flags, ir_type ret_type, uint32_t params_count, uint8_t *param_types)
{
ir_proto_t *proto = alloca(offsetof(ir_proto_t, param_types) + params_count);
IR_ASSERT(params_count <= IR_MAX_PROTO_PARAMS);
proto->flags = flags;
proto->ret_type = ret_type;
proto->params_count = params_count;
memcpy(proto->param_types, param_types, params_count);
return ir_strl(ctx, (const char *)proto, offsetof(ir_proto_t, param_types) + params_count);
}
/* IR construction */ /* IR construction */
ir_ref ir_emit(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3) ir_ref ir_emit(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3)
{ {

67
ir.g
View File

@ -132,7 +132,7 @@ ir(ir_loader *loader):
{uint32_t flags = 0;} {uint32_t flags = 0;}
{size_t size;} {size_t size;}
{uint32_t params_count;} {uint32_t params_count;}
{ir_type param_types[256];} {uint8_t param_types[256];}
{p.ctx = &ctx;} {p.ctx = &ctx;}
( (
( (
@ -149,7 +149,8 @@ ir(ir_loader *loader):
} }
| |
{flags = 0;} {flags = 0;}
ir_func_prototype(&p, name, &flags, &ret_type, &params_count, param_types) ir_func_name(name)
ir_func_proto(&p, &flags, &ret_type, &params_count, param_types)
";" ";"
{ {
if (loader->external_func_dcl if (loader->external_func_dcl
@ -187,7 +188,8 @@ ir(ir_loader *loader):
} }
) )
| |
ir_func_prototype(&p, name, &flags, &ret_type, &params_count, param_types) ir_func_name(name)
ir_func_proto(&p, &flags, &ret_type, &params_count, param_types)
( (
";" ";"
{ {
@ -296,15 +298,18 @@ ir_func(ir_parser_ctx *p):
{ir_strtab_free(&p->var_tab);} {ir_strtab_free(&p->var_tab);}
; ;
ir_func_prototype(ir_parser_ctx *p, char *buf, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, ir_type *param_types): ir_func_name(char *buf):
{const char *name;} {const char *name;}
{size_t len;} {size_t len;}
{uint8_t t = 0;}
{uint32_t n = 0;}
"func" ID(&name, &len) "func" ID(&name, &len)
{if (len > 255) yy_error("name too long");} {if (len > 255) yy_error("name too long");}
{memcpy(buf, name, len);} {memcpy(buf, name, len);}
{buf[len] = 0;} {buf[len] = 0;}
;
ir_func_proto(ir_parser_ctx *p, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, uint8_t *param_types):
{uint8_t t = 0;}
{uint32_t n = 0;}
"(" "("
( (
"void" "void"
@ -336,6 +341,10 @@ ir_func_prototype(ir_parser_ctx *p, char *buf, uint32_t *flags, uint8_t *ret_typ
"void" "void"
{*ret_type = IR_VOID;} {*ret_type = IR_VOID;}
) )
(
"__fastcall"
{*flags |= IR_FASTCALL_FUNC;}
)?
{*params_count = n;} {*params_count = n;}
; ;
@ -350,8 +359,11 @@ ir_insn(ir_parser_ctx *p):
{ir_ref ref;} {ir_ref ref;}
{ir_val val;} {ir_val val;}
{ir_val count;} {ir_val count;}
{ir_val flags;}
{int32_t n;} {int32_t n;}
{uint8_t ret_type;}
{uint32_t flags;}
{uint32_t params_count;}
{uint8_t param_types[256];}
( (
type(&t) type(&t)
ID(&str, &len) ID(&str, &len)
@ -366,25 +378,23 @@ ir_insn(ir_parser_ctx *p):
( {val.u64 = 0;} ( {val.u64 = 0;}
const(t, &val) const(t, &val)
{ref = ir_const(p->ctx, val, t);} {ref = ir_const(p->ctx, val, t);}
| "func" "(" ID(&func, &func_len) | "func"
{flags.u64 = 0;} ( ID(&func, &func_len)
( "," {flags = 0;}
DECNUMBER(IR_U16, &flags) ir_func_proto(p, &flags, &ret_type, &params_count, param_types)
)? {ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);}
")" {ref = ir_const_func(p->ctx, ir_strl(p->ctx, func, func_len), ref);}
{ref = ir_const_func(p->ctx, ir_strl(p->ctx, func, func_len), flags.u16);} | "*"
( DECNUMBER(IR_ADDR, &val)
| HEXNUMBER(IR_ADDR, &val)
)
{flags = 0;}
ir_func_proto(p, &flags, &ret_type, &params_count, param_types)
{ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);}
{ref = ir_const_func_addr(p->ctx, val.addr, ref);}
)
| "sym" "(" ID(&func, &func_len) ")" | "sym" "(" ID(&func, &func_len) ")"
{ref = ir_const_sym(p->ctx, ir_strl(p->ctx, func, func_len));} {ref = ir_const_sym(p->ctx, ir_strl(p->ctx, func, func_len));}
| "func_addr" "("
( DECNUMBER(IR_ADDR, &val)
| HEXNUMBER(IR_ADDR, &val)
)
{flags.u64 = 0;}
( ","
DECNUMBER(IR_U16, &flags)
)?
")"
{ref = ir_const_func_addr(p->ctx, val.addr, flags.u16);}
| STRING(&func, &func_len) | STRING(&func, &func_len)
{ref = ir_const_str(p->ctx, ir_strl(p->ctx, func, func_len));} {ref = ir_const_str(p->ctx, ir_strl(p->ctx, func, func_len));}
| func(&op) | func(&op)
@ -475,6 +485,10 @@ val(ir_parser_ctx *p, uint8_t op, uint32_t n, ir_ref *ref):
{size_t len;} {size_t len;}
{ir_val val;} {ir_val val;}
{uint32_t kind = IR_OPND_KIND(ir_op_flags[op], n);} {uint32_t kind = IR_OPND_KIND(ir_op_flags[op], n);}
{uint8_t ret_type;}
{uint32_t flags;}
{uint32_t params_count;}
{uint8_t param_types[256];}
( ID(&str, &len) ( ID(&str, &len)
{if (!IR_IS_REF_OPND_KIND(kind)) yy_error("unexpected reference");} {if (!IR_IS_REF_OPND_KIND(kind)) yy_error("unexpected reference");}
{*ref = ir_use_var(p, n, str, len);} {*ref = ir_use_var(p, n, str, len);}
@ -487,6 +501,11 @@ val(ir_parser_ctx *p, uint8_t op, uint32_t n, ir_ref *ref):
{*ref = val.i32;} {*ref = val.i32;}
| "null" | "null"
{*ref = IR_UNUSED;} {*ref = IR_UNUSED;}
| "func"
{if (kind != IR_OPND_PROTO) yy_error("unexpected function prototype");}
{flags = 0;}
ir_func_proto(p, &flags, &ret_type, &params_count, param_types)
{*ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);}
) )
; ;

90
ir.h
View File

@ -186,6 +186,7 @@ typedef enum _ir_type {
* num - number: argument number (PARAM) * num - number: argument number (PARAM)
* prb - branch probability 1-99 (0 - unspecified): (IF_TRUE, IF_FALSE, CASE_VAL, CASE_DEFAULT) * prb - branch probability 1-99 (0 - unspecified): (IF_TRUE, IF_FALSE, CASE_VAL, CASE_DEFAULT)
* opt - optional number * opt - optional number
* pro - function prototype
* *
* The order of IR opcodes is carefully selected for efficient folding. * The order of IR opcodes is carefully selected for efficient folding.
* - foldable instruction go first * - foldable instruction go first
@ -246,6 +247,7 @@ typedef enum _ir_type {
_(INT2FP, d1, def, ___, ___) /* int to float conversion */ \ _(INT2FP, d1, def, ___, ___) /* int to float conversion */ \
_(FP2INT, d1, def, ___, ___) /* float to int conversion */ \ _(FP2INT, d1, def, ___, ___) /* float to int conversion */ \
_(FP2FP, d1, def, ___, ___) /* float to float conversion */ \ _(FP2FP, d1, def, ___, ___) /* float to float conversion */ \
_(PROTO, d1X1, def, pro, ___) /* apply function prototype */ \
\ \
/* overflow-check */ \ /* overflow-check */ \
_(ADD_OV, d2C, def, def, ___) /* addition */ \ _(ADD_OV, d2C, def, def, ___) /* addition */ \
@ -376,7 +378,6 @@ typedef int32_t ir_ref;
#define IR_CONSTS_LIMIT_MIN (-(IR_TRUE - 1)) #define IR_CONSTS_LIMIT_MIN (-(IR_TRUE - 1))
#define IR_INSNS_LIMIT_MIN (IR_UNUSED + 1) #define IR_INSNS_LIMIT_MIN (IR_UNUSED + 1)
#ifndef IR_64 #ifndef IR_64
# define ADDR_MEMBER uintptr_t addr; # define ADDR_MEMBER uintptr_t addr;
#else #else
@ -395,6 +396,8 @@ typedef union _ir_val {
int32_t i32; int32_t i32;
float f; float f;
ADDR_MEMBER ADDR_MEMBER
ir_ref name;
ir_ref str;
IR_STRUCT_LOHI( IR_STRUCT_LOHI(
union { union {
uint16_t u16; uint16_t u16;
@ -412,17 +415,11 @@ typedef union _ir_val {
uint16_t u16_hi uint16_t u16_hi
); );
}, },
uint32_t u32_hi uint32_t u32_hi;
); );
} ir_val; } ir_val;
#undef ADDR_MEMBER #undef ADDR_MEMBER
/* IR constant flags */
#define IR_CONST_EMIT (1<<0)
#define IR_CONST_FASTCALL_FUNC (1<<1)
#define IR_CONST_VARARG_FUNC (1<<2)
#define IR_CONST_BUILTIN_FUNC (1<<3)
/* IR Instruction */ /* IR Instruction */
typedef struct _ir_insn { typedef struct _ir_insn {
IR_STRUCT_LOHI( IR_STRUCT_LOHI(
@ -438,7 +435,7 @@ typedef struct _ir_insn {
union { union {
uint16_t inputs_count; /* number of input control edges for MERGE, PHI, CALL, TAILCALL */ uint16_t inputs_count; /* number of input control edges for MERGE, PHI, CALL, TAILCALL */
uint16_t prev_insn_offset; /* 16-bit backward offset from current instruction for CSE */ uint16_t prev_insn_offset; /* 16-bit backward offset from current instruction for CSE */
uint16_t const_flags; /* flag to emit constant in rodat section */ uint16_t proto;
} }
); );
uint32_t optx; uint32_t optx;
@ -482,6 +479,7 @@ ir_ref ir_strtab_lookup(ir_strtab *strtab, const char *str, uint32_t len, ir_ref
ir_ref ir_strtab_find(const ir_strtab *strtab, const char *str, uint32_t len); ir_ref ir_strtab_find(const ir_strtab *strtab, const char *str, uint32_t len);
ir_ref ir_strtab_update(ir_strtab *strtab, const char *str, uint32_t len, ir_ref val); ir_ref ir_strtab_update(ir_strtab *strtab, const char *str, uint32_t len, ir_ref val);
const char *ir_strtab_str(const ir_strtab *strtab, ir_ref idx); const char *ir_strtab_str(const ir_strtab *strtab, ir_ref idx);
const char *ir_strtab_strl(const ir_strtab *strtab, ir_ref idx, size_t *len);
void ir_strtab_apply(const ir_strtab *strtab, ir_strtab_apply_t func); void ir_strtab_apply(const ir_strtab *strtab, ir_strtab_apply_t func);
void ir_strtab_free(ir_strtab *strtab); void ir_strtab_free(ir_strtab *strtab);
@ -489,31 +487,32 @@ void ir_strtab_free(ir_strtab *strtab);
#define IR_FUNCTION (1<<0) /* Generate a function. */ #define IR_FUNCTION (1<<0) /* Generate a function. */
#define IR_FASTCALL_FUNC (1<<1) /* Generate a function with fastcall calling convention, x86 32-bit only. */ #define IR_FASTCALL_FUNC (1<<1) /* Generate a function with fastcall calling convention, x86 32-bit only. */
#define IR_VARARG_FUNC (1<<2) #define IR_VARARG_FUNC (1<<2)
#define IR_STATIC (1<<3) #define IR_BUILTIN_FUNC (1<<3)
#define IR_EXTERN (1<<4) #define IR_STATIC (1<<4)
#define IR_CONST (1<<5) #define IR_EXTERN (1<<5)
#define IR_CONST (1<<6)
#define IR_SKIP_PROLOGUE (1<<6) /* Don't generate function prologue. */ #define IR_SKIP_PROLOGUE (1<<8) /* Don't generate function prologue. */
#define IR_USE_FRAME_POINTER (1<<7) #define IR_USE_FRAME_POINTER (1<<9)
#define IR_PREALLOCATED_STACK (1<<8) #define IR_PREALLOCATED_STACK (1<<10)
#define IR_NO_STACK_COMBINE (1<<9) #define IR_NO_STACK_COMBINE (1<<11)
#define IR_START_BR_TARGET (1<<10) #define IR_START_BR_TARGET (1<<12)
#define IR_ENTRY_BR_TARGET (1<<11) #define IR_ENTRY_BR_TARGET (1<<13)
#define IR_GEN_ENDBR (1<<12) #define IR_GEN_ENDBR (1<<14)
#define IR_MERGE_EMPTY_ENTRIES (1<<13) #define IR_MERGE_EMPTY_ENTRIES (1<<15)
#define IR_OPT_FOLDING (1<<18) #define IR_OPT_FOLDING (1<<16)
#define IR_OPT_CFG (1<<19) /* merge BBs, by remove END->BEGIN nodes during CFG construction */ #define IR_OPT_CFG (1<<17) /* merge BBs, by remove END->BEGIN nodes during CFG construction */
#define IR_OPT_CODEGEN (1<<20) #define IR_OPT_CODEGEN (1<<18)
#define IR_GEN_NATIVE (1<<23) #define IR_GEN_NATIVE (1<<19)
#define IR_GEN_CODE (1<<24) /* C or LLVM */ #define IR_GEN_CODE (1<<20) /* C or LLVM */
/* debug related */ /* debug related */
#ifdef IR_DEBUG #ifdef IR_DEBUG
# define IR_DEBUG_SCCP (1<<27) # define IR_DEBUG_SCCP (1<<27)
# define IR_DEBUG_GCM (1<<28) # define IR_DEBUG_GCM (1<<28)
# define IR_DEBUG_SCHEDULE (1<<29) # define IR_DEBUG_SCHEDULE (1<<29)
# define IR_DEBUG_RA (1<<30) # define IR_DEBUG_RA (1<<30)
#endif #endif
typedef struct _ir_ctx ir_ctx; typedef struct _ir_ctx ir_ctx;
@ -627,9 +626,9 @@ ir_ref ir_const_char(ir_ctx *ctx, char c);
ir_ref ir_const_float(ir_ctx *ctx, float c); ir_ref ir_const_float(ir_ctx *ctx, float c);
ir_ref ir_const_double(ir_ctx *ctx, double c); ir_ref ir_const_double(ir_ctx *ctx, double c);
ir_ref ir_const_addr(ir_ctx *ctx, uintptr_t c); ir_ref ir_const_addr(ir_ctx *ctx, uintptr_t c);
ir_ref ir_const_func_addr(ir_ctx *ctx, uintptr_t c, uint16_t flags);
ir_ref ir_const_func(ir_ctx *ctx, ir_ref str, uint16_t flags); ir_ref ir_const_func_addr(ir_ctx *ctx, uintptr_t c, ir_ref proto);
ir_ref ir_const_func(ir_ctx *ctx, ir_ref str, ir_ref proto);
ir_ref ir_const_sym(ir_ctx *ctx, ir_ref str); ir_ref ir_const_sym(ir_ctx *ctx, ir_ref str);
ir_ref ir_const_str(ir_ctx *ctx, ir_ref str); ir_ref ir_const_str(ir_ctx *ctx, ir_ref str);
@ -640,6 +639,26 @@ void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted
ir_ref ir_str(ir_ctx *ctx, const char *s); ir_ref ir_str(ir_ctx *ctx, const char *s);
ir_ref ir_strl(ir_ctx *ctx, const char *s, size_t len); ir_ref ir_strl(ir_ctx *ctx, const char *s, size_t len);
const char *ir_get_str(const ir_ctx *ctx, ir_ref idx); const char *ir_get_str(const ir_ctx *ctx, ir_ref idx);
const char *ir_get_strl(const ir_ctx *ctx, ir_ref idx, size_t *len);
#define IR_MAX_PROTO_PARAMS 255
typedef struct _ir_proto_t {
uint8_t flags;
uint8_t ret_type;
uint8_t params_count;
uint8_t param_types[5];
} ir_proto_t;
ir_ref ir_proto_0(ir_ctx *ctx, uint8_t flags, ir_type ret_type);
ir_ref ir_proto_1(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1);
ir_ref ir_proto_2(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2);
ir_ref ir_proto_3(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3);
ir_ref ir_proto_4(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3,
ir_type t4);
ir_ref ir_proto_5(ir_ctx *ctx, uint8_t flags, ir_type ret_type, ir_type t1, ir_type t2, ir_type t3,
ir_type t4, ir_type t5);
ir_ref ir_proto(ir_ctx *ctx, uint8_t flags, ir_type ret_type, uint32_t params_counts, uint8_t *param_types);
ir_ref ir_emit(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3); ir_ref ir_emit(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3);
@ -768,9 +787,9 @@ struct _ir_loader {
bool (*init_module) (ir_loader *loader, const char *name, const char *filename, const char *target); bool (*init_module) (ir_loader *loader, const char *name, const char *filename, const char *target);
bool (*external_sym_dcl) (ir_loader *loader, const char *name, uint32_t flags); bool (*external_sym_dcl) (ir_loader *loader, const char *name, uint32_t flags);
bool (*external_func_dcl) (ir_loader *loader, const char *name, bool (*external_func_dcl) (ir_loader *loader, const char *name,
uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types); uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types);
bool (*forward_func_dcl) (ir_loader *loader, const char *name, bool (*forward_func_dcl) (ir_loader *loader, const char *name,
uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types); uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types);
bool (*sym_dcl) (ir_loader *loader, const char *name, uint32_t flags, size_t size, bool has_data); bool (*sym_dcl) (ir_loader *loader, const char *name, uint32_t flags, size_t size, bool has_data);
bool (*sym_data) (ir_loader *loader, ir_type type, uint32_t count, const void *data); bool (*sym_data) (ir_loader *loader, ir_type type, uint32_t count, const void *data);
bool (*sym_data_ref) (ir_loader *loader, ir_op op, const char *ref); bool (*sym_data_ref) (ir_loader *loader, ir_op op, const char *ref);
@ -789,6 +808,7 @@ int ir_load_llvm_bitcode(ir_loader *loader, const char *filename);
int ir_load_llvm_asm(ir_loader *loader, const char *filename); int ir_load_llvm_asm(ir_loader *loader, const char *filename);
/* IR save API (implementation in ir_save.c) */ /* IR save API (implementation in ir_save.c) */
void ir_print_proto(const ir_ctx *ctx, ir_ref proto, FILE *f);
void ir_save(const ir_ctx *ctx, FILE *f); void ir_save(const ir_ctx *ctx, FILE *f);
/* IR debug dump API (implementation in ir_dump.c) */ /* IR debug dump API (implementation in ir_dump.c) */
@ -802,11 +822,11 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f);
/* IR to C conversion (implementation in ir_emit_c.c) */ /* IR to C conversion (implementation in ir_emit_c.c) */
int ir_emit_c(ir_ctx *ctx, const char *name, FILE *f); int ir_emit_c(ir_ctx *ctx, const char *name, FILE *f);
void ir_emit_c_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types, FILE *f); void ir_emit_c_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types, FILE *f);
/* IR to LLVM conversion (implementation in ir_emit_llvm.c) */ /* IR to LLVM conversion (implementation in ir_emit_llvm.c) */
int ir_emit_llvm(ir_ctx *ctx, const char *name, FILE *f); int ir_emit_llvm(ir_ctx *ctx, const char *name, FILE *f);
void ir_emit_llvm_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types, FILE *f); void ir_emit_llvm_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types, FILE *f);
/* IR verification API (implementation in ir_check.c) */ /* IR verification API (implementation in ir_check.c) */
bool ir_check(const ir_ctx *ctx); bool ir_check(const ir_ctx *ctx);

View File

@ -159,6 +159,7 @@ typedef struct _ir_backend_data {
ir_reg_alloc_data ra_data; ir_reg_alloc_data ra_data;
uint32_t dessa_from_block; uint32_t dessa_from_block;
dasm_State *dasm_state; dasm_State *dasm_state;
ir_bitset emit_constants;
int rodata_label, jmp_table_label; int rodata_label, jmp_table_label;
} ir_backend_data; } ir_backend_data;
@ -506,6 +507,7 @@ int ir_get_target_constraints(const ir_ctx *ctx, ir_ref ref, ir_target_constrain
break; break;
case IR_TRUNC: case IR_TRUNC:
case IR_BITCAST: case IR_BITCAST:
case IR_PROTO:
flags = IR_USE_MUST_BE_IN_REG | IR_OP1_SHOULD_BE_IN_REG; flags = IR_USE_MUST_BE_IN_REG | IR_OP1_SHOULD_BE_IN_REG;
break; break;
case IR_RSTORE: case IR_RSTORE:
@ -1126,7 +1128,7 @@ static void ir_emit_load_imm_fp(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref sr
| fmov Rd(reg-IR_REG_FP_FIRST), xzr | fmov Rd(reg-IR_REG_FP_FIRST), xzr
} else { } else {
label = ctx->cfg_blocks_count - src; label = ctx->cfg_blocks_count - src;
insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -src);
if (type == IR_DOUBLE) { if (type == IR_DOUBLE) {
| ldr Rd(reg-IR_REG_FP_FIRST), =>label | ldr Rd(reg-IR_REG_FP_FIRST), =>label
} else { } else {
@ -4268,13 +4270,13 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
if (val_insn->op == IR_STR) { if (val_insn->op == IR_STR) {
int label = ctx->cfg_blocks_count - arg; int label = ctx->cfg_blocks_count - arg;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -arg);
| adr Rx(dst_reg), =>label | adr Rx(dst_reg), =>label
continue; continue;
} else if (val_insn->op == IR_SYM || val_insn->op == IR_FUNC) { } else if (val_insn->op == IR_SYM || val_insn->op == IR_FUNC) {
void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ? void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.name));
ir_emit_load_imm_int(ctx, IR_ADDR, dst_reg, (intptr_t)addr); ir_emit_load_imm_int(ctx, IR_ADDR, dst_reg, (intptr_t)addr);
continue; continue;
} }
@ -4296,14 +4298,14 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
if (val_insn->op == IR_STR) { if (val_insn->op == IR_STR) {
int label = ctx->cfg_blocks_count - arg; int label = ctx->cfg_blocks_count - arg;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -arg);
IR_ASSERT(tmp_reg != IR_REG_NONE); IR_ASSERT(tmp_reg != IR_REG_NONE);
| adr Rx(tmp_reg), =>label | adr Rx(tmp_reg), =>label
| str Rx(tmp_reg), [sp, #stack_offset] | str Rx(tmp_reg), [sp, #stack_offset]
} else if (val_insn->op == IR_FUNC || val_insn->op == IR_SYM) { } else if (val_insn->op == IR_FUNC || val_insn->op == IR_SYM) {
void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ? void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.name));
ir_emit_load_imm_int(ctx, IR_ADDR, tmp_reg, (intptr_t)addr); ir_emit_load_imm_int(ctx, IR_ADDR, tmp_reg, (intptr_t)addr);
| str Rx(tmp_reg), [sp, #stack_offset] | str Rx(tmp_reg), [sp, #stack_offset]
} else { } else {
@ -4355,8 +4357,8 @@ static void ir_emit_call(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;
@ -4434,8 +4436,8 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;
@ -4817,8 +4819,8 @@ static void ir_emit_exitcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;
@ -5372,6 +5374,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
dasm_setup(&data.dasm_state, dasm_actions); dasm_setup(&data.dasm_state, dasm_actions);
/* labels for each block + for each constant + rodata label + jmp_table label + for each entry */ /* 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 + ctx->entries_count); dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count);
data.emit_constants = ir_bitset_malloc(ctx->consts_count);
if (!(ctx->flags & IR_SKIP_PROLOGUE)) { if (!(ctx->flags & IR_SKIP_PROLOGUE)) {
ir_emit_prologue(ctx); ir_emit_prologue(ctx);
@ -5455,6 +5458,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
ir_emit_trunc(ctx, i, insn); ir_emit_trunc(ctx, i, insn);
break; break;
case IR_BITCAST: case IR_BITCAST:
case IR_PROTO:
ir_emit_bitcast(ctx, i, insn); ir_emit_bitcast(ctx, i, insn);
break; break;
case IR_INT2FP: case IR_INT2FP:
@ -5612,6 +5616,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
break; break;
default: default:
IR_ASSERT(0 && "NIY rule/instruction"); IR_ASSERT(0 && "NIY rule/instruction");
ir_mem_free(data.emit_constants);
dasm_free(&data.dasm_state); dasm_free(&data.dasm_state);
ctx->data = NULL; ctx->data = NULL;
ctx->status = IR_ERROR_UNSUPPORTED_CODE_RULE; ctx->status = IR_ERROR_UNSUPPORTED_CODE_RULE;
@ -5639,105 +5644,105 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
if (data.rodata_label) { if (data.rodata_label) {
|.rodata |.rodata
} }
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { IR_BITSET_FOREACH(data.emit_constants, ir_bitset_len(ctx->consts_count), i) {
if (insn->const_flags & IR_CONST_EMIT) { insn = &ctx->ir_base[-i];
if (IR_IS_TYPE_FP(insn->type)) { if (IR_IS_TYPE_FP(insn->type)) {
int label = ctx->cfg_blocks_count + i; int label = ctx->cfg_blocks_count + i;
if (!data.rodata_label) { if (!data.rodata_label) {
data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2; data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
|.rodata |.rodata
|=>data.rodata_label: |=>data.rodata_label:
} }
if (insn->type == IR_DOUBLE) { if (insn->type == IR_DOUBLE) {
|.align 8
|=>label:
|.long insn->val.u32, insn->val.u32_hi
} else {
IR_ASSERT(insn->type == IR_FLOAT);
|.align 4
|=>label:
|.long insn->val.u32
}
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.i32);
int i = 0;
if (!data.rodata_label) {
data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
|.rodata
|=>data.rodata_label:
}
|.align 8 |.align 8
|=>label: |=>label:
while (1) { |.long insn->val.u32, insn->val.u32_hi
char c; } else {
uint32_t w = 0; IR_ASSERT(insn->type == IR_FLOAT);
int j; |.align 4
|=>label:
|.long insn->val.u32
}
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.str);
int i = 0;
for (j = 0; j < 4; j++) { if (!data.rodata_label) {
c = str[i]; data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
if (!c) {
break; |.rodata
} else if (c == '\\') { |=>data.rodata_label:
if (str[i+1] == '\\') { }
i++; |.align 8
c = '\\'; |=>label:
} else if (str[i+1] == '\'') { while (1) {
i++; char c;
c = '\''; uint32_t w = 0;
} else if (str[i+1] == '"') { int j;
i++;
c = '"'; for (j = 0; j < 4; j++) {
} else if (str[i+1] == 'a') { c = str[i];
i++;
c = '\a';
} else if (str[i+1] == 'b') {
i++;
c = '\b';
} else if (str[i+1] == 'e') {
i++;
c = 27; /* '\e'; */
} else if (str[i+1] == 'f') {
i++;
c = '\f';
} else if (str[i+1] == 'n') {
i++;
c = '\n';
} else if (str[i+1] == 'r') {
i++;
c = '\r';
} else if (str[i+1] == 't') {
i++;
c = '\t';
} else if (str[i+1] == 'v') {
i++;
c = '\v';
} else if (str[i+1] == '?') {
i++;
c = 0x3f;
}
}
w |= c << (8 * j);
i++;
}
| .long w
if (!c) { if (!c) {
break; break;
} else if (c == '\\') {
if (str[i+1] == '\\') {
i++;
c = '\\';
} else if (str[i+1] == '\'') {
i++;
c = '\'';
} else if (str[i+1] == '"') {
i++;
c = '"';
} else if (str[i+1] == 'a') {
i++;
c = '\a';
} else if (str[i+1] == 'b') {
i++;
c = '\b';
} else if (str[i+1] == 'e') {
i++;
c = 27; /* '\e'; */
} else if (str[i+1] == 'f') {
i++;
c = '\f';
} else if (str[i+1] == 'n') {
i++;
c = '\n';
} else if (str[i+1] == 'r') {
i++;
c = '\r';
} else if (str[i+1] == 't') {
i++;
c = '\t';
} else if (str[i+1] == 'v') {
i++;
c = '\v';
} else if (str[i+1] == '?') {
i++;
c = 0x3f;
}
} }
w |= c << (8 * j);
i++;
}
| .long w
if (!c) {
break;
} }
} else {
IR_ASSERT(0);
} }
} else {
IR_ASSERT(0);
} }
} } IR_BITSET_FOREACH_END();
if (data.rodata_label) { if (data.rodata_label) {
|.code |.code
} }
ir_mem_free(data.emit_constants);
if (ctx->status) { if (ctx->status) {
dasm_free(&data.dasm_state); dasm_free(&data.dasm_state);

View File

@ -458,20 +458,14 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f)
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) {
fprintf(f, "\t%s c_%d = ", ir_type_cname[insn->type], i); fprintf(f, "\t%s c_%d = ", ir_type_cname[insn->type], i);
if (insn->op == IR_FUNC) { if (insn->op == IR_FUNC) {
if (!insn->const_flags) { fprintf(f, "func %s", ir_get_str(ctx, insn->val.name));
fprintf(f, "func(%s)", ir_get_str(ctx, insn->val.i32)); ir_print_proto(ctx, insn->proto, f);
} else {
fprintf(f, "func(%s, %d)", ir_get_str(ctx, insn->val.i32), insn->const_flags);
}
} else if (insn->op == IR_SYM) { } else if (insn->op == IR_SYM) {
fprintf(f, "sym(%s)", ir_get_str(ctx, insn->val.i32)); fprintf(f, "sym(%s)", ir_get_str(ctx, insn->val.name));
} else if (insn->op == IR_FUNC_ADDR) { } else if (insn->op == IR_FUNC_ADDR) {
fprintf(f, "func_addr("); fprintf(f, "func *");
ir_print_const(ctx, insn, f, true); ir_print_const(ctx, insn, f, true);
if (insn->const_flags) { ir_print_proto(ctx, insn->proto, f);
fprintf(f, ", %d", insn->const_flags);
}
fprintf(f, ")");
} else { } else {
ir_print_const(ctx, insn, f, true); ir_print_const(ctx, insn, f, true);
} }
@ -564,6 +558,10 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f)
fprintf(f, "%s\"%s\"", first ? "(" : ", ", ir_get_str(ctx, ref)); fprintf(f, "%s\"%s\"", first ? "(" : ", ", ir_get_str(ctx, ref));
first = 0; first = 0;
break; break;
case IR_OPND_PROTO:
fprintf(f, "%sfunc ", first ? "(" : ", ");
ir_print_proto(ctx, ref, f);
break;
case IR_OPND_PROB: case IR_OPND_PROB:
if (ref == 0) { if (ref == 0) {
break; break;

View File

@ -74,9 +74,19 @@ bool ir_is_fastcall(const ir_ctx *ctx, const ir_insn *insn)
{ {
if (sizeof(void*) == 4) { if (sizeof(void*) == 4) {
if (IR_IS_CONST_REF(insn->op2)) { if (IR_IS_CONST_REF(insn->op2)) {
return (ctx->ir_base[insn->op2].const_flags & IR_CONST_FASTCALL_FUNC) != 0; const ir_insn *func = &ctx->ir_base[insn->op2];
} else if (ctx->ir_base[insn->op2].op == IR_BITCAST) {
return (ctx->ir_base[insn->op2].op2 & IR_CONST_FASTCALL_FUNC) != 0; if (func->op == IR_FUNC || func->op == IR_FUNC_ADDR) {
if (func->proto) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, func->proto);
return (proto->flags & IR_FASTCALL_FUNC) != 0;
}
}
} else if (ctx->ir_base[insn->op2].op == IR_PROTO) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, ctx->ir_base[insn->op2].op2);
return (proto->flags & IR_FASTCALL_FUNC) != 0;
} }
return 0; return 0;
} }
@ -92,9 +102,19 @@ bool ir_is_fastcall(const ir_ctx *ctx, const ir_insn *insn)
bool ir_is_vararg(const ir_ctx *ctx, ir_insn *insn) bool ir_is_vararg(const ir_ctx *ctx, ir_insn *insn)
{ {
if (IR_IS_CONST_REF(insn->op2)) { if (IR_IS_CONST_REF(insn->op2)) {
return (ctx->ir_base[insn->op2].const_flags & IR_CONST_VARARG_FUNC) != 0; const ir_insn *func = &ctx->ir_base[insn->op2];
} else if (ctx->ir_base[insn->op2].op == IR_BITCAST) {
return (ctx->ir_base[insn->op2].op2 & IR_CONST_VARARG_FUNC) != 0; if (func->op == IR_FUNC || func->op == IR_FUNC_ADDR) {
if (func->proto) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, func->proto);
return (proto->flags & IR_VARARG_FUNC) != 0;
}
}
} else if (ctx->ir_base[insn->op2].op == IR_PROTO) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, ctx->ir_base[insn->op2].op2);
return (proto->flags & IR_VARARG_FUNC) != 0;
} }
return 0; return 0;
} }
@ -309,8 +329,8 @@ static void *ir_jmp_addr(ir_ctx *ctx, ir_insn *insn, ir_insn *addr_insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;

View File

@ -580,7 +580,8 @@ static void ir_emit_call(ir_ctx *ctx, FILE *f, ir_ref def, ir_insn *insn)
fprintf(f, "\t"); fprintf(f, "\t");
} }
if (IR_IS_CONST_REF(insn->op2)) { if (IR_IS_CONST_REF(insn->op2)) {
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.i32)); IR_ASSERT(ctx->ir_base[insn->op2].op == IR_FUNC);
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.name));
} else { } else {
ir_emit_ref(ctx, f, insn->op2); ir_emit_ref(ctx, f, insn->op2);
} }
@ -605,7 +606,8 @@ static void ir_emit_tailcall(ir_ctx *ctx, FILE *f, ir_insn *insn)
fprintf(f, "\t"); fprintf(f, "\t");
} }
if (IR_IS_CONST_REF(insn->op2)) { if (IR_IS_CONST_REF(insn->op2)) {
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.i32)); IR_ASSERT(ctx->ir_base[insn->op2].op == IR_FUNC);
fprintf(f, "%s", ir_get_str(ctx, ctx->ir_base[insn->op2].val.name));
} else { } else {
ir_emit_ref(ctx, f, insn->op2); ir_emit_ref(ctx, f, insn->op2);
} }
@ -712,7 +714,8 @@ static int ir_emit_func(ir_ctx *ctx, const char *name, FILE *f)
if (ctx->flags & IR_STATIC) { if (ctx->flags & IR_STATIC) {
fprintf(f, "static "); fprintf(f, "static ");
} }
fprintf(f, "%s %s(", ir_type_cname[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID], name); fprintf(f, "%s %s%s(", ir_type_cname[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID],
(ctx->flags & IR_FASTCALL_FUNC) ? "__fastcall " : "", name);
use_list = &ctx->use_lists[1]; use_list = &ctx->use_lists[1];
n = use_list->count; n = use_list->count;
first = 1; first = 1;
@ -922,6 +925,7 @@ static int ir_emit_func(ir_ctx *ctx, const char *name, FILE *f)
ir_emit_trunc(ctx, f, i, insn); ir_emit_trunc(ctx, f, i, insn);
break; break;
case IR_BITCAST: case IR_BITCAST:
case IR_PROTO:
ir_emit_bitcast(ctx, f, i, insn); ir_emit_bitcast(ctx, f, i, insn);
break; break;
case IR_INT2FP: case IR_INT2FP:
@ -1047,16 +1051,20 @@ int ir_emit_c(ir_ctx *ctx, const char *name, FILE *f)
return ir_emit_func(ctx, name, f); return ir_emit_func(ctx, name, f);
} }
void ir_emit_c_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types, FILE *f) void ir_emit_c_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types, FILE *f)
{ {
if (flags & IR_EXTERN) { if (flags & IR_EXTERN) {
fprintf(f, "extern "); fprintf(f, "extern ");
} else if (flags & IR_STATIC) { } else if (flags & IR_STATIC) {
fprintf(f, "static "); fprintf(f, "static ");
} }
fprintf(f, "%s %s(", ir_type_cname[ret_type], name); fprintf(f, "%s ", ir_type_cname[ret_type]);
if (flags & IR_FASTCALL_FUNC) {
fprintf(f, "__fastcall ");
}
fprintf(f, "%s(", name);
if (params_count) { if (params_count) {
ir_type *p = param_types; const uint8_t *p = param_types;
fprintf(f, "%s", ir_type_cname[*p]); fprintf(f, "%s", ir_type_cname[*p]);
p++; p++;

View File

@ -32,7 +32,7 @@ static void ir_emit_ref(ir_ctx *ctx, FILE *f, ir_ref ref)
if (IR_IS_CONST_REF(ref)) { if (IR_IS_CONST_REF(ref)) {
ir_insn *insn = &ctx->ir_base[ref]; ir_insn *insn = &ctx->ir_base[ref];
if (insn->op == IR_FUNC || insn->op == IR_SYM) { if (insn->op == IR_FUNC || insn->op == IR_SYM) {
fprintf(f, "@%s", ir_get_str(ctx, insn->val.i32)); fprintf(f, "@%s", ir_get_str(ctx, insn->val.name));
} else if (insn->op == IR_STR) { } else if (insn->op == IR_STR) {
fprintf(f, "@.str%d", -ref); fprintf(f, "@.str%d", -ref);
} else if (insn->op == IR_ADDR) { } else if (insn->op == IR_ADDR) {
@ -533,9 +533,17 @@ static void ir_emit_call(ir_ctx *ctx, FILE *f, ir_ref def, ir_insn *insn)
// TODO: function prototype ??? // TODO: function prototype ???
if (IR_IS_CONST_REF(insn->op2)) { if (IR_IS_CONST_REF(insn->op2)) {
const char *name = ir_get_str(ctx, ctx->ir_base[insn->op2].val.i32); const ir_insn *func = &ctx->ir_base[insn->op2];
if (ctx->ir_base[insn->op2].const_flags & IR_CONST_BUILTIN_FUNC) { const char *name;
name = ir_builtin_func_name(name, &last_arg);
IR_ASSERT(func->op == IR_FUNC);
name = ir_get_str(ctx, func->val.name);
if (func->proto) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, func->proto);
if (proto->flags & IR_BUILTIN_FUNC) {
name = ir_builtin_func_name(name, &last_arg);
}
} }
fprintf(f, "@%s", name); fprintf(f, "@%s", name);
} else { } else {
@ -651,7 +659,7 @@ static int ir_emit_func(ir_ctx *ctx, const char *name, FILE *f)
fprintf(f, "internal "); fprintf(f, "internal ");
} }
if (ctx->flags & IR_FASTCALL_FUNC) { if (ctx->flags & IR_FASTCALL_FUNC) {
// TODO: fprintf(f, "x86_fastcallcc ");
} }
fprintf(f, "%s", ir_type_llvm_name[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID]); fprintf(f, "%s", ir_type_llvm_name[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID]);
fprintf(f, " @%s(", name); fprintf(f, " @%s(", name);
@ -840,6 +848,9 @@ static int ir_emit_func(ir_ctx *ctx, const char *name, FILE *f)
ir_emit_conv(ctx, f, i, insn, "bitcast"); ir_emit_conv(ctx, f, i, insn, "bitcast");
} }
break; break;
case IR_PROTO:
ir_emit_conv(ctx, f, i, insn, "bitcast");
break;
case IR_INT2FP: case IR_INT2FP:
IR_ASSERT(IR_IS_TYPE_FP(insn->type)); IR_ASSERT(IR_IS_TYPE_FP(insn->type));
IR_ASSERT(IR_IS_TYPE_INT(ctx->ir_base[insn->op1].type)); IR_ASSERT(IR_IS_TYPE_INT(ctx->ir_base[insn->op1].type));
@ -973,19 +984,26 @@ static int ir_emit_func(ir_ctx *ctx, const char *name, FILE *f)
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) {
if (insn->op == IR_FUNC) { if (insn->op == IR_FUNC) {
const char *name = ir_get_str(ctx, insn->val.i32); const char *name;
if (insn->const_flags & IR_CONST_BUILTIN_FUNC) {
name = ir_get_str(ctx, insn->val.name);
if (insn->proto) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, insn->proto);
ir_ref dummy; ir_ref dummy;
name = ir_builtin_func_name(name, &dummy);
if (proto->flags & IR_BUILTIN_FUNC) {
name = ir_builtin_func_name(name, &dummy);
}
ir_emit_llvm_func_decl(name, proto->flags, proto->ret_type, proto->params_count, proto->param_types, f);
} else {
fprintf(f, "declare void @%s()\n", name);
} }
// TODO: function prototype ???
fprintf(f, "declare void @%s()\n", name);
} else if (insn->op == IR_SYM) { } else if (insn->op == IR_SYM) {
// TODO: symbol "global" or "constant" ??? // TODO: symbol "global" or "constant" ???
// TODO: symbol type ??? // TODO: symbol type ???
fprintf(f, "@%s = external global ptr\n", ir_get_str(ctx, insn->val.i32)); fprintf(f, "@%s = external global ptr\n", ir_get_str(ctx, insn->val.name));
} else if (insn->op == IR_STR) { } else if (insn->op == IR_STR) {
const char *str = ir_get_str(ctx, insn->val.i32); const char *str = ir_get_str(ctx, insn->val.str);
// TODO: strlen != size ??? // TODO: strlen != size ???
int len = strlen(str); int len = strlen(str);
int j; int j;
@ -1055,11 +1073,13 @@ int ir_emit_llvm(ir_ctx *ctx, const char *name, FILE *f)
return ir_emit_func(ctx, name, f); return ir_emit_func(ctx, name, f);
} }
void ir_emit_llvm_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types, FILE *f) void ir_emit_llvm_func_decl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types, FILE *f)
{ {
fprintf(f, "declare %s @%s(", ir_type_llvm_name[ret_type], name); fprintf(f, "declare %s%s @%s(",
(flags & IR_FASTCALL_FUNC) ? "x86_fastcallcc ": "",
ir_type_llvm_name[ret_type], name);
if (params_count) { if (params_count) {
ir_type *p = param_types; const uint8_t *p = param_types;
fprintf(f, "%s", ir_type_llvm_name[*p]); fprintf(f, "%s", ir_type_llvm_name[*p]);
p++; p++;

View File

@ -722,8 +722,21 @@ restart:
memcpy(new_insn, insn, sizeof(ir_insn) * (IR_TRUE - ref)); memcpy(new_insn, insn, sizeof(ir_insn) * (IR_TRUE - ref));
if (ctx->strtab.data) { if (ctx->strtab.data) {
while (ref != IR_TRUE) { while (ref != IR_TRUE) {
if (new_insn->op == IR_FUNC || new_insn->op == IR_SYM || new_insn->op == IR_STR) { if (new_insn->op == IR_FUNC_ADDR) {
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, new_insn->val.i32)); if (new_insn->proto) {
size_t len;
const char *proto = ir_get_strl(ctx, new_insn->proto, &len);
new_insn->proto = ir_strl(&new_ctx, proto, len);
}
} else if (new_insn->op == IR_FUNC) {
new_insn->val.u64 = ir_str(&new_ctx, ir_get_str(ctx, new_insn->val.name));
if (new_insn->proto) {
size_t len;
const char *proto = ir_get_strl(ctx, new_insn->proto, &len);
new_insn->proto = ir_strl(&new_ctx, proto, len);
}
} else if (new_insn->op == IR_SYM || new_insn->op == IR_STR) {
new_insn->val.u64 = ir_str(&new_ctx, ir_get_str(ctx, new_insn->val.name));
} }
new_insn++; new_insn++;
ref++; ref++;
@ -738,8 +751,26 @@ restart:
} }
new_insn->optx = insn->optx; new_insn->optx = insn->optx;
new_insn->prev_const = 0; new_insn->prev_const = 0;
if (insn->op == IR_FUNC || insn->op == IR_SYM || insn->op == IR_STR) { if (insn->op == IR_FUNC_ADDR) {
new_insn->val.addr = ir_str(&new_ctx, ir_get_str(ctx, insn->val.i32)); new_insn->val.u64 = insn->val.u64;
if (insn->proto) {
size_t len;
const char *proto = ir_get_strl(ctx, insn->proto, &len);
new_insn->proto = ir_strl(&new_ctx, proto, len);
} else {
new_insn->proto = 0;
}
} else if (insn->op == IR_FUNC) {
new_insn->val.u64 = ir_str(&new_ctx, ir_get_str(ctx, insn->val.name));
if (insn->proto) {
size_t len;
const char *proto = ir_get_strl(ctx, insn->proto, &len);
new_insn->proto = ir_strl(&new_ctx, proto, len);
} else {
new_insn->proto = 0;
}
} else if (insn->op == IR_SYM || insn->op == IR_STR) {
new_insn->val.u64 = ir_str(&new_ctx, ir_get_str(ctx, insn->val.name));
} else { } else {
new_insn->val.u64 = insn->val.u64; new_insn->val.u64 = insn->val.u64;
} }
@ -806,6 +837,10 @@ restart:
new_insn->op1 = _xlat[insn->op1]; new_insn->op1 = _xlat[insn->op1];
if (new_insn->op == IR_PARAM || insn->op == IR_VAR) { if (new_insn->op == IR_PARAM || insn->op == IR_VAR) {
new_insn->op2 = ir_str(&new_ctx, ir_get_str(ctx, insn->op2)); new_insn->op2 = ir_str(&new_ctx, ir_get_str(ctx, insn->op2));
} else if (new_insn->op == IR_PROTO) {
size_t len;
const char *proto = ir_get_strl(ctx, insn->op2, &len);
new_insn->op2 = ir_strl(&new_ctx, proto, len);
} else { } else {
new_insn->op2 = insn->op2; new_insn->op2 = insn->op2;
} }

382
ir_load.c
View File

@ -126,22 +126,23 @@ static void yy_error_str(const char *msg, const char *str);
#define YY_VOID 16 #define YY_VOID 16
#define YY__POINT_POINT_POINT 17 #define YY__POINT_POINT_POINT 17
#define YY__COLON 18 #define YY__COLON 18
#define YY_FUNC_ADDR 19 #define YY___FASTCALL 19
#define YY__SLASH 20 #define YY__STAR 20
#define YY_NULL 21 #define YY__SLASH 21
#define YY_INF 22 #define YY_NULL 22
#define YY_NAN 23 #define YY_INF 23
#define YY__MINUS 24 #define YY_NAN 24
#define YY_ID 25 #define YY__MINUS 25
#define YY_DECNUMBER 26 #define YY_ID 26
#define YY_HEXNUMBER 27 #define YY_DECNUMBER 27
#define YY_FLOATNUMBER 28 #define YY_HEXNUMBER 28
#define YY_CHARACTER 29 #define YY_FLOATNUMBER 29
#define YY_STRING 30 #define YY_CHARACTER 30
#define YY_EOL 31 #define YY_STRING 31
#define YY_WS 32 #define YY_EOL 32
#define YY_ONE_LINE_COMMENT 33 #define YY_WS 33
#define YY_COMMENT 34 #define YY_ONE_LINE_COMMENT 34
#define YY_COMMENT 35
static const char * sym_name[] = { static const char * sym_name[] = {
"<EOF>", "<EOF>",
@ -163,7 +164,8 @@ static const char * sym_name[] = {
"void", "void",
"...", "...",
":", ":",
"func_addr", "__fastcall",
"*",
"/", "/",
"null", "null",
"inf", "inf",
@ -252,7 +254,8 @@ static int parse_ir_sym(int sym, char *buf, uint32_t *flags);
static int parse_ir_sym_size(int sym, size_t *size); static int parse_ir_sym_size(int sym, size_t *size);
static int parse_ir_sym_data(int sym, ir_loader *loader); static int parse_ir_sym_data(int sym, ir_loader *loader);
static int parse_ir_func(int sym, ir_parser_ctx *p); static int parse_ir_func(int sym, ir_parser_ctx *p);
static int parse_ir_func_prototype(int sym, ir_parser_ctx *p, char *buf, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, ir_type *param_types); static int parse_ir_func_name(int sym, char *buf);
static int parse_ir_func_proto(int sym, ir_parser_ctx *p, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, uint8_t *param_types);
static int parse_ir_insn(int sym, ir_parser_ctx *p); static int parse_ir_insn(int sym, ir_parser_ctx *p);
static int parse_type(int sym, uint8_t *t); static int parse_type(int sym, uint8_t *t);
static int parse_func(int sym, uint8_t *op); static int parse_func(int sym, uint8_t *op);
@ -290,21 +293,21 @@ _yy_state_start:
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'n') goto _yy_tunnel_4; if (ch != 'n') goto _yy_tunnel_4;
ret = YY_EXTERN; ret = YY_EXTERN;
goto _yy_state_103; goto _yy_state_109;
case 'v': case 'v':
ch = *++YYPOS; ch = *++YYPOS;
if (ch == 'a') { if (ch == 'a') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'r') goto _yy_tunnel_4; if (ch != 'r') goto _yy_tunnel_4;
ret = YY_VAR; ret = YY_VAR;
goto _yy_state_103; goto _yy_state_109;
} else if (ch == 'o') { } else if (ch == 'o') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'i') goto _yy_tunnel_4; if (ch != 'i') goto _yy_tunnel_4;
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'd') goto _yy_tunnel_4; if (ch != 'd') goto _yy_tunnel_4;
ret = YY_VOID; ret = YY_VOID;
goto _yy_state_103; goto _yy_state_109;
} else { } else {
goto _yy_tunnel_4; goto _yy_tunnel_4;
} }
@ -318,7 +321,7 @@ _yy_state_start:
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 't') goto _yy_tunnel_4; if (ch != 't') goto _yy_tunnel_4;
ret = YY_CONST; ret = YY_CONST;
goto _yy_state_103; goto _yy_state_109;
case 'A': case 'A':
case 'B': case 'B':
case 'C': case 'C':
@ -364,7 +367,6 @@ _yy_state_start:
case 'x': case 'x':
case 'y': case 'y':
case 'z': case 'z':
case '_':
goto _yy_state_4; goto _yy_state_4;
case 'f': case 'f':
ch = *++YYPOS; ch = *++YYPOS;
@ -373,39 +375,29 @@ _yy_state_start:
if (ch != 'n') goto _yy_tunnel_4; if (ch != 'n') goto _yy_tunnel_4;
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'c') goto _yy_tunnel_4; if (ch != 'c') goto _yy_tunnel_4;
ch = *++YYPOS; ret = YY_FUNC;
if (ch != '_') {ret = YY_FUNC; goto _yy_tunnel_103;} goto _yy_state_109;
ch = *++YYPOS;
if (ch != 'a') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'd') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'd') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'r') goto _yy_tunnel_4;
ret = YY_FUNC_ADDR;
goto _yy_state_103;
case 'i': case 'i':
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'n') goto _yy_tunnel_4; if (ch != 'n') goto _yy_tunnel_4;
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'f') goto _yy_tunnel_4; if (ch != 'f') goto _yy_tunnel_4;
ret = YY_INF; ret = YY_INF;
goto _yy_state_103; goto _yy_state_109;
case 'n': case 'n':
ch = *++YYPOS; ch = *++YYPOS;
if (ch == 'a') { if (ch == 'a') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'n') goto _yy_tunnel_4; if (ch != 'n') goto _yy_tunnel_4;
ret = YY_NAN; ret = YY_NAN;
goto _yy_state_103; goto _yy_state_109;
} else if (ch == 'u') { } else if (ch == 'u') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'l') goto _yy_tunnel_4; if (ch != 'l') goto _yy_tunnel_4;
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'l') goto _yy_tunnel_4; if (ch != 'l') goto _yy_tunnel_4;
ret = YY_NULL; ret = YY_NULL;
goto _yy_state_103; goto _yy_state_109;
} else { } else {
goto _yy_tunnel_4; goto _yy_tunnel_4;
} }
@ -421,15 +413,36 @@ _yy_state_start:
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'c') goto _yy_tunnel_4; if (ch != 'c') goto _yy_tunnel_4;
ret = YY_STATIC; ret = YY_STATIC;
goto _yy_state_103; goto _yy_state_109;
} else if (ch == 'y') { } else if (ch == 'y') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'm') goto _yy_tunnel_4; if (ch != 'm') goto _yy_tunnel_4;
ret = YY_SYM; ret = YY_SYM;
goto _yy_state_103; goto _yy_state_109;
} else { } else {
goto _yy_tunnel_4; goto _yy_tunnel_4;
} }
case '_':
ch = *++YYPOS;
if (ch != '_') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'f') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'a') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 's') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 't') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'c') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'a') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'l') goto _yy_tunnel_4;
ch = *++YYPOS;
if (ch != 'l') goto _yy_tunnel_4;
ret = YY___FASTCALL;
goto _yy_state_109;
case ';': case ';':
YYPOS++; YYPOS++;
ret = YY__SEMICOLON; ret = YY__SEMICOLON;
@ -450,7 +463,7 @@ _yy_state_start:
goto _yy_state_error; goto _yy_state_error;
} }
} else if ((ch >= '0' && ch <= '9')) { } else if ((ch >= '0' && ch <= '9')) {
goto _yy_state_43; goto _yy_state_46;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
@ -475,11 +488,11 @@ _yy_state_start:
accept = YY__MINUS; accept = YY__MINUS;
accept_pos = yy_pos; accept_pos = yy_pos;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_18; goto _yy_state_19;
} else if (ch == '.') { } else if (ch == '.') {
ch = *++YYPOS; ch = *++YYPOS;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_43; goto _yy_state_46;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
@ -489,10 +502,10 @@ _yy_state_start:
} }
case '0': case '0':
ch = *++YYPOS; ch = *++YYPOS;
if (ch != 'x') goto _yy_tunnel_18; if (ch != 'x') goto _yy_tunnel_19;
ch = *++YYPOS; ch = *++YYPOS;
if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) { if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
goto _yy_state_72; goto _yy_state_76;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
@ -505,7 +518,7 @@ _yy_state_start:
case '7': case '7':
case '8': case '8':
case '9': case '9':
goto _yy_state_18; goto _yy_state_19;
case ']': case ']':
YYPOS++; YYPOS++;
ret = YY__RBRACK; ret = YY__RBRACK;
@ -519,21 +532,25 @@ _yy_state_start:
ret = YY__LBRACE; ret = YY__LBRACE;
goto _yy_fin; goto _yy_fin;
case '\'': case '\'':
goto _yy_state_22; goto _yy_state_23;
case '}': case '}':
YYPOS++; YYPOS++;
ret = YY__RBRACE; ret = YY__RBRACE;
goto _yy_fin; goto _yy_fin;
case '*':
YYPOS++;
ret = YY__STAR;
goto _yy_fin;
case '"': case '"':
goto _yy_state_24; goto _yy_state_26;
case '/': case '/':
ch = *++YYPOS; ch = *++YYPOS;
accept = YY__SLASH; accept = YY__SLASH;
accept_pos = yy_pos; accept_pos = yy_pos;
if (ch == '*') { if (ch == '*') {
goto _yy_state_55; goto _yy_state_58;
} else if (ch == '/') { } else if (ch == '/') {
goto _yy_state_29; goto _yy_state_31;
} else { } else {
ret = YY__SLASH; ret = YY__SLASH;
goto _yy_fin; goto _yy_fin;
@ -558,9 +575,9 @@ _yy_state_start:
case '\t': case '\t':
case '\f': case '\f':
case '\v': case '\v':
goto _yy_state_28; goto _yy_state_30;
case '#': case '#':
goto _yy_state_29; goto _yy_state_31;
case '\0': case '\0':
if (ch == 0 && YYPOS < YYEND) goto _yy_state_error; if (ch == 0 && YYPOS < YYEND) goto _yy_state_error;
YYPOS++; YYPOS++;
@ -578,22 +595,22 @@ _yy_tunnel_4:
ret = YY_ID; ret = YY_ID;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_18: _yy_state_19:
ch = *++YYPOS; ch = *++YYPOS;
_yy_tunnel_18: _yy_tunnel_19:
accept = YY_DECNUMBER; accept = YY_DECNUMBER;
accept_pos = yy_pos; accept_pos = yy_pos;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_18; goto _yy_state_19;
} else if (ch == 'E' || ch == 'e') { } else if (ch == 'E' || ch == 'e') {
goto _yy_state_47; goto _yy_state_50;
} else if (ch == '.') { } else if (ch == '.') {
goto _yy_state_43; goto _yy_state_46;
} else { } else {
ret = YY_DECNUMBER; ret = YY_DECNUMBER;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_22: _yy_state_23:
ch = *++YYPOS; ch = *++YYPOS;
if (ch == '\\') { if (ch == '\\') {
ch = *++YYPOS; ch = *++YYPOS;
@ -601,7 +618,7 @@ _yy_state_22:
if (ch == '\n') { if (ch == '\n') {
yy_line++; yy_line++;
} }
goto _yy_state_22; goto _yy_state_23;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
@ -613,11 +630,11 @@ _yy_state_22:
if (ch == '\n') { if (ch == '\n') {
yy_line++; yy_line++;
} }
goto _yy_state_22; goto _yy_state_23;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
_yy_state_24: _yy_state_26:
ch = *++YYPOS; ch = *++YYPOS;
if (ch == '\\') { if (ch == '\\') {
ch = *++YYPOS; ch = *++YYPOS;
@ -625,7 +642,7 @@ _yy_state_24:
if (ch == '\n') { if (ch == '\n') {
yy_line++; yy_line++;
} }
goto _yy_state_24; goto _yy_state_26;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
@ -637,19 +654,19 @@ _yy_state_24:
if (ch == '\n') { if (ch == '\n') {
yy_line++; yy_line++;
} }
goto _yy_state_24; goto _yy_state_26;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
_yy_state_28: _yy_state_30:
ch = *++YYPOS; ch = *++YYPOS;
if (ch == '\t' || ch == '\v' || ch == '\f' || ch == ' ') { if (ch == '\t' || ch == '\v' || ch == '\f' || ch == ' ') {
goto _yy_state_28; goto _yy_state_30;
} else { } else {
ret = YY_WS; ret = YY_WS;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_29: _yy_state_31:
ch = *++YYPOS; ch = *++YYPOS;
if (ch == '\r') { if (ch == '\r') {
ch = *++YYPOS; ch = *++YYPOS;
@ -668,42 +685,42 @@ _yy_state_29:
ret = YY_ONE_LINE_COMMENT; ret = YY_ONE_LINE_COMMENT;
goto _yy_fin; goto _yy_fin;
} else if (YYPOS < YYEND && (ch <= '\t' || ch == '\v' || ch == '\f' || ch >= '\016')) { } else if (YYPOS < YYEND && (ch <= '\t' || ch == '\v' || ch == '\f' || ch >= '\016')) {
goto _yy_state_29; goto _yy_state_31;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
_yy_state_43: _yy_state_46:
ch = *++YYPOS; ch = *++YYPOS;
accept = YY_FLOATNUMBER; accept = YY_FLOATNUMBER;
accept_pos = yy_pos; accept_pos = yy_pos;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_43; goto _yy_state_46;
} else if (ch == 'E' || ch == 'e') { } else if (ch == 'E' || ch == 'e') {
goto _yy_state_47; goto _yy_state_50;
} else { } else {
ret = YY_FLOATNUMBER; ret = YY_FLOATNUMBER;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_47: _yy_state_50:
ch = *++YYPOS; ch = *++YYPOS;
if (ch == '+' || ch == '-') { if (ch == '+' || ch == '-') {
ch = *++YYPOS; ch = *++YYPOS;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_75; goto _yy_state_79;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
} else if ((ch >= '0' && ch <= '9')) { } else if ((ch >= '0' && ch <= '9')) {
goto _yy_state_75; goto _yy_state_79;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
_yy_state_55: _yy_state_58:
ch = *++YYPOS; ch = *++YYPOS;
_yy_tunnel_55: _yy_tunnel_58:
if (ch == '*') { if (ch == '*') {
ch = *++YYPOS; ch = *++YYPOS;
if (ch != '/') goto _yy_tunnel_55; if (ch != '/') goto _yy_tunnel_58;
YYPOS++; YYPOS++;
ret = YY_COMMENT; ret = YY_COMMENT;
goto _yy_fin; goto _yy_fin;
@ -711,29 +728,28 @@ _yy_tunnel_55:
if (ch == '\n') { if (ch == '\n') {
yy_line++; yy_line++;
} }
goto _yy_state_55; goto _yy_state_58;
} else { } else {
goto _yy_state_error; goto _yy_state_error;
} }
_yy_state_72: _yy_state_76:
ch = *++YYPOS; ch = *++YYPOS;
if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) { if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
goto _yy_state_72; goto _yy_state_76;
} else { } else {
ret = YY_HEXNUMBER; ret = YY_HEXNUMBER;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_75: _yy_state_79:
ch = *++YYPOS; ch = *++YYPOS;
if ((ch >= '0' && ch <= '9')) { if ((ch >= '0' && ch <= '9')) {
goto _yy_state_75; goto _yy_state_79;
} else { } else {
ret = YY_FLOATNUMBER; ret = YY_FLOATNUMBER;
goto _yy_fin; goto _yy_fin;
} }
_yy_state_103: _yy_state_109:
ch = *++YYPOS; ch = *++YYPOS;
_yy_tunnel_103:
if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) { if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {
goto _yy_state_4; goto _yy_state_4;
} else { } else {
@ -812,7 +828,7 @@ static int parse_ir(int sym, ir_loader *loader) {
const unsigned char *save_pos; const unsigned char *save_pos;
const unsigned char *save_text; const unsigned char *save_text;
int save_line; int save_line;
int alt12; int alt13;
ir_parser_ctx p; ir_parser_ctx p;
ir_ctx ctx; ir_ctx ctx;
uint8_t ret_type; uint8_t ret_type;
@ -820,7 +836,7 @@ static int parse_ir(int sym, ir_loader *loader) {
uint32_t flags = 0; uint32_t flags = 0;
size_t size; size_t size;
uint32_t params_count; uint32_t params_count;
ir_type param_types[256]; uint8_t param_types[256];
p.ctx = &ctx; p.ctx = &ctx;
if (YY_IN_SET(sym, (YY_EXTERN,YY_STATIC,YY_VAR,YY_CONST,YY_FUNC), "\012\203\000\000\000")) { if (YY_IN_SET(sym, (YY_EXTERN,YY_STATIC,YY_VAR,YY_CONST,YY_FUNC), "\012\203\000\000\000")) {
do { do {
@ -839,7 +855,8 @@ static int parse_ir(int sym, ir_loader *loader) {
} }
} else if (sym == YY_FUNC) { } else if (sym == YY_FUNC) {
flags = 0; flags = 0;
sym = parse_ir_func_prototype(sym, &p, name, &flags, &ret_type, &params_count, param_types); sym = parse_ir_func_name(sym, name);
sym = parse_ir_func_proto(sym, &p, &flags, &ret_type, &params_count, param_types);
if (sym != YY__SEMICOLON) { if (sym != YY__SEMICOLON) {
yy_error_sym("';' expected, got", sym); yy_error_sym("';' expected, got", sym);
} }
@ -879,38 +896,38 @@ static int parse_ir(int sym, ir_loader *loader) {
save_pos = yy_pos; save_pos = yy_pos;
save_text = yy_text; save_text = yy_text;
save_line = yy_line; save_line = yy_line;
alt12 = -2; alt13 = -2;
sym2 = sym; sym2 = sym;
if (sym2 == YY__COMMA) { if (sym2 == YY__COMMA) {
sym2 = get_sym(); sym2 = get_sym();
goto _yy_state_12_1; goto _yy_state_13_1;
} else if (sym2 == YY__RBRACE) { } else if (sym2 == YY__RBRACE) {
alt12 = 16; alt13 = 17;
goto _yy_state_12; goto _yy_state_13;
} else { } else {
yy_error_sym("unexpected", sym2); yy_error_sym("unexpected", sym2);
} }
_yy_state_12_1: _yy_state_13_1:
if (sym2 == YY_ID) { if (sym2 == YY_ID) {
alt12 = 13; alt13 = 14;
goto _yy_state_12; goto _yy_state_13;
} else if (sym2 == YY__RBRACE) { } else if (sym2 == YY__RBRACE) {
alt12 = 15; alt13 = 16;
goto _yy_state_12; goto _yy_state_13;
} else { } else {
yy_error_sym("unexpected", sym2); yy_error_sym("unexpected", sym2);
} }
_yy_state_12: _yy_state_13:
yy_pos = save_pos; yy_pos = save_pos;
yy_text = save_text; yy_text = save_text;
yy_line = save_line; yy_line = save_line;
if (alt12 != 13) { if (alt13 != 14) {
break; break;
} }
sym = get_sym(); sym = get_sym();
sym = parse_ir_sym_data(sym, loader); sym = parse_ir_sym_data(sym, loader);
} }
if (alt12 == 15) { if (alt13 == 16) {
sym = get_sym(); sym = get_sym();
} }
if (sym != YY__RBRACE) { if (sym != YY__RBRACE) {
@ -928,7 +945,8 @@ _yy_state_12:
yy_error_sym("unexpected", sym); yy_error_sym("unexpected", sym);
} }
} else if (sym == YY_FUNC) { } else if (sym == YY_FUNC) {
sym = parse_ir_func_prototype(sym, &p, name, &flags, &ret_type, &params_count, param_types); sym = parse_ir_func_name(sym, name);
sym = parse_ir_func_proto(sym, &p, &flags, &ret_type, &params_count, param_types);
if (sym == YY__SEMICOLON) { if (sym == YY__SEMICOLON) {
sym = get_sym(); sym = get_sym();
if (loader->forward_func_dcl if (loader->forward_func_dcl
@ -1043,7 +1061,7 @@ static int parse_ir_sym_data(int sym, ir_loader *loader) {
yy_error("sym_data_ref error"); yy_error("sym_data_ref error");
} }
} }
} else if (YY_IN_SET(sym, (YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_CHARACTER,YY_INF,YY_NAN,YY__MINUS), "\000\000\300\075\000")) { } else if (YY_IN_SET(sym, (YY_DECNUMBER,YY_HEXNUMBER,YY_FLOATNUMBER,YY_CHARACTER,YY_INF,YY_NAN,YY__MINUS), "\000\000\200\173\000")) {
sym = parse_const(sym, t, &val); sym = parse_const(sym, t, &val);
if (loader->sym_data) { if (loader->sym_data) {
switch (ir_type_size[t]) { switch (ir_type_size[t]) {
@ -1088,16 +1106,9 @@ static int parse_ir_func(int sym, ir_parser_ctx *p) {
return sym; return sym;
} }
static int parse_ir_func_prototype(int sym, ir_parser_ctx *p, char *buf, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, ir_type *param_types) { static int parse_ir_func_name(int sym, char *buf) {
int sym2;
const unsigned char *save_pos;
const unsigned char *save_text;
int save_line;
int alt63;
const char *name; const char *name;
size_t len; size_t len;
uint8_t t = 0;
uint32_t n = 0;
if (sym != YY_FUNC) { if (sym != YY_FUNC) {
yy_error_sym("'func' expected, got", sym); yy_error_sym("'func' expected, got", sym);
} }
@ -1106,6 +1117,17 @@ static int parse_ir_func_prototype(int sym, ir_parser_ctx *p, char *buf, uint32_
if (len > 255) yy_error("name too long"); if (len > 255) yy_error("name too long");
memcpy(buf, name, len); memcpy(buf, name, len);
buf[len] = 0; buf[len] = 0;
return sym;
}
static int parse_ir_func_proto(int sym, ir_parser_ctx *p, uint32_t *flags, uint8_t *ret_type, uint32_t *params_count, uint8_t *param_types) {
int sym2;
const unsigned char *save_pos;
const unsigned char *save_text;
int save_line;
int alt63;
uint8_t t = 0;
uint32_t n = 0;
if (sym != YY__LPAREN) { if (sym != YY__LPAREN) {
yy_error_sym("'(' expected, got", sym); yy_error_sym("'(' expected, got", sym);
} }
@ -1182,6 +1204,10 @@ _yy_state_63:
} else { } else {
yy_error_sym("unexpected", sym); yy_error_sym("unexpected", sym);
} }
if (sym == YY___FASTCALL) {
sym = get_sym();
*flags |= IR_FASTCALL_FUNC;
}
*params_count = n; *params_count = n;
return sym; return sym;
} }
@ -1191,7 +1217,7 @@ static int parse_ir_insn(int sym, ir_parser_ctx *p) {
const unsigned char *save_pos; const unsigned char *save_pos;
const unsigned char *save_text; const unsigned char *save_text;
int save_line; int save_line;
int alt72; int alt73;
const char *str, *str2 = NULL, *func; const char *str, *str2 = NULL, *func;
size_t len, len2 = 0, func_len; size_t len, len2 = 0, func_len;
uint8_t op; uint8_t op;
@ -1202,41 +1228,44 @@ static int parse_ir_insn(int sym, ir_parser_ctx *p) {
ir_ref ref; ir_ref ref;
ir_val val; ir_val val;
ir_val count; ir_val count;
ir_val flags;
int32_t n; int32_t n;
uint8_t ret_type;
uint32_t flags;
uint32_t params_count;
uint8_t param_types[256];
save_pos = yy_pos; save_pos = yy_pos;
save_text = yy_text; save_text = yy_text;
save_line = yy_line; save_line = yy_line;
alt72 = -2; alt73 = -2;
sym2 = sym; sym2 = sym;
if (sym2 == YY_ID) { if (sym2 == YY_ID) {
sym2 = get_sym(); sym2 = get_sym();
goto _yy_state_72_1; goto _yy_state_73_1;
} else { } else {
yy_error_sym("unexpected", sym2); yy_error_sym("unexpected", sym2);
} }
_yy_state_72_1: _yy_state_73_1:
if (sym2 == YY_ID) { if (sym2 == YY_ID) {
alt72 = 73; alt73 = 74;
goto _yy_state_72; goto _yy_state_73;
} else if (sym2 == YY__EQUAL) { } else if (sym2 == YY__EQUAL) {
alt72 = 77; alt73 = 78;
goto _yy_state_72; goto _yy_state_73;
} else { } else {
yy_error_sym("unexpected", sym2); yy_error_sym("unexpected", sym2);
} }
_yy_state_72: _yy_state_73:
yy_pos = save_pos; yy_pos = save_pos;
yy_text = save_text; yy_text = save_text;
yy_line = save_line; yy_line = save_line;
if (alt72 == 73) { if (alt73 == 74) {
sym = parse_type(sym, &t); sym = parse_type(sym, &t);
sym = parse_ID(sym, &str, &len); sym = parse_ID(sym, &str, &len);
if (sym == YY__COMMA) { if (sym == YY__COMMA) {
sym = get_sym(); sym = get_sym();
sym = parse_ID(sym, &str2, &len2); sym = parse_ID(sym, &str2, &len2);
} }
} else if (alt72 == 77) { } else if (alt73 == 78) {
sym = parse_ID(sym, &str, &len); sym = parse_ID(sym, &str, &len);
} else { } else {
yy_error_sym("unexpected", sym); yy_error_sym("unexpected", sym);
@ -1259,21 +1288,28 @@ _yy_state_72:
break; break;
case YY_FUNC: case YY_FUNC:
sym = get_sym(); sym = get_sym();
if (sym != YY__LPAREN) { if (sym == YY_ID) {
yy_error_sym("'(' expected, got", sym); sym = parse_ID(sym, &func, &func_len);
} flags = 0;
sym = get_sym(); sym = parse_ir_func_proto(sym, p, &flags, &ret_type, &params_count, param_types);
sym = parse_ID(sym, &func, &func_len); ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);
flags.u64 = 0; ref = ir_const_func(p->ctx, ir_strl(p->ctx, func, func_len), ref);
if (sym == YY__COMMA) { } else if (sym == YY__STAR) {
sym = get_sym(); sym = get_sym();
sym = parse_DECNUMBER(sym, IR_U16, &flags); if (sym == YY_DECNUMBER) {
sym = parse_DECNUMBER(sym, IR_ADDR, &val);
} else if (sym == YY_HEXNUMBER) {
sym = parse_HEXNUMBER(sym, IR_ADDR, &val);
} else {
yy_error_sym("unexpected", sym);
}
flags = 0;
sym = parse_ir_func_proto(sym, p, &flags, &ret_type, &params_count, param_types);
ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);
ref = ir_const_func_addr(p->ctx, val.addr, ref);
} else {
yy_error_sym("unexpected", sym);
} }
if (sym != YY__RPAREN) {
yy_error_sym("')' expected, got", sym);
}
sym = get_sym();
ref = ir_const_func(p->ctx, ir_strl(p->ctx, func, func_len), flags.u16);
break; break;
case YY_SYM: case YY_SYM:
sym = get_sym(); sym = get_sym();
@ -1288,30 +1324,6 @@ _yy_state_72:
sym = get_sym(); sym = get_sym();
ref = ir_const_sym(p->ctx, ir_strl(p->ctx, func, func_len)); ref = ir_const_sym(p->ctx, ir_strl(p->ctx, func, func_len));
break; break;
case YY_FUNC_ADDR:
sym = get_sym();
if (sym != YY__LPAREN) {
yy_error_sym("'(' expected, got", sym);
}
sym = get_sym();
if (sym == YY_DECNUMBER) {
sym = parse_DECNUMBER(sym, IR_ADDR, &val);
} else if (sym == YY_HEXNUMBER) {
sym = parse_HEXNUMBER(sym, IR_ADDR, &val);
} else {
yy_error_sym("unexpected", sym);
}
flags.u64 = 0;
if (sym == YY__COMMA) {
sym = get_sym();
sym = parse_DECNUMBER(sym, IR_U16, &flags);
}
if (sym != YY__RPAREN) {
yy_error_sym("')' expected, got", sym);
}
sym = get_sym();
ref = ir_const_func_addr(p->ctx, val.addr, flags.u16);
break;
case YY_STRING: case YY_STRING:
sym = parse_STRING(sym, &func, &func_len); sym = parse_STRING(sym, &func, &func_len);
ref = ir_const_str(p->ctx, ir_strl(p->ctx, func, func_len)); ref = ir_const_str(p->ctx, ir_strl(p->ctx, func, func_len));
@ -1327,7 +1339,7 @@ _yy_state_72:
ref = ir_emit_N(p->ctx, IR_OPT(op, t), count.i32); ref = ir_emit_N(p->ctx, IR_OPT(op, t), count.i32);
if (sym == YY__LPAREN) { if (sym == YY__LPAREN) {
sym = get_sym(); sym = get_sym();
if (sym == YY_ID || sym == YY_STRING || sym == YY_DECNUMBER || sym == YY_NULL) { if (YY_IN_SET(sym, (YY_ID,YY_STRING,YY_DECNUMBER,YY_NULL,YY_FUNC), "\000\200\100\214\000")) {
sym = parse_val(sym, p, op, 1, &op1); sym = parse_val(sym, p, op, 1, &op1);
n = 1; n = 1;
if (n > count.i32) yy_error("too many operands"); if (n > count.i32) yy_error("too many operands");
@ -1349,7 +1361,7 @@ _yy_state_72:
n = 0; n = 0;
if (sym == YY__LPAREN) { if (sym == YY__LPAREN) {
sym = get_sym(); sym = get_sym();
if (sym == YY_ID || sym == YY_STRING || sym == YY_DECNUMBER || sym == YY_NULL) { if (YY_IN_SET(sym, (YY_ID,YY_STRING,YY_DECNUMBER,YY_NULL,YY_FUNC), "\000\200\100\214\000")) {
sym = parse_val(sym, p, op, 1, &op1); sym = parse_val(sym, p, op, 1, &op1);
n = 1; n = 1;
if (sym == YY__COMMA) { if (sym == YY__COMMA) {
@ -1424,24 +1436,40 @@ static int parse_val(int sym, ir_parser_ctx *p, uint8_t op, uint32_t n, ir_ref *
size_t len; size_t len;
ir_val val; ir_val val;
uint32_t kind = IR_OPND_KIND(ir_op_flags[op], n); uint32_t kind = IR_OPND_KIND(ir_op_flags[op], n);
if (sym == YY_ID) { uint8_t ret_type;
sym = parse_ID(sym, &str, &len); uint32_t flags;
if (!IR_IS_REF_OPND_KIND(kind)) yy_error("unexpected reference"); uint32_t params_count;
*ref = ir_use_var(p, n, str, len); uint8_t param_types[256];
} else if (sym == YY_STRING) { switch (sym) {
sym = parse_STRING(sym, &str, &len); case YY_ID:
if (kind != IR_OPND_STR) yy_error("unexpected string"); sym = parse_ID(sym, &str, &len);
*ref = ir_strl(p->ctx, str, len); if (!IR_IS_REF_OPND_KIND(kind)) yy_error("unexpected reference");
} else if (sym == YY_DECNUMBER) { *ref = ir_use_var(p, n, str, len);
sym = parse_DECNUMBER(sym, IR_I32, &val); break;
if (kind != IR_OPND_NUM && kind != IR_OPND_PROB) yy_error("unexpected number"); case YY_STRING:
if (val.i64 < 0 || val.i64 > 0x7fffffff) yy_error("number out of range"); sym = parse_STRING(sym, &str, &len);
*ref = val.i32; if (kind != IR_OPND_STR) yy_error("unexpected string");
} else if (sym == YY_NULL) { *ref = ir_strl(p->ctx, str, len);
sym = get_sym(); break;
*ref = IR_UNUSED; case YY_DECNUMBER:
} else { sym = parse_DECNUMBER(sym, IR_I32, &val);
yy_error_sym("unexpected", sym); if (kind != IR_OPND_NUM && kind != IR_OPND_PROB) yy_error("unexpected number");
if (val.i64 < 0 || val.i64 > 0x7fffffff) yy_error("number out of range");
*ref = val.i32;
break;
case YY_NULL:
sym = get_sym();
*ref = IR_UNUSED;
break;
case YY_FUNC:
sym = get_sym();
if (kind != IR_OPND_PROTO) yy_error("unexpected function prototype");
flags = 0;
sym = parse_ir_func_proto(sym, p, &flags, &ret_type, &params_count, param_types);
*ref = ir_proto(p->ctx, flags, ret_type, params_count, param_types);
break;
default:
yy_error_sym("unexpected", sym);
} }
return sym; return sym;
} }

View File

@ -16,11 +16,18 @@
#define IR_BAD_TYPE IR_LAST_TYPE #define IR_BAD_TYPE IR_LAST_TYPE
#define BUILTIN_FUNC(name) \ #define BUILTIN_FUNC_1(name, ret_type, arg1_type) \
ir_const_func(ctx, ir_strl(ctx, name, strlen(name)), IR_CONST_BUILTIN_FUNC) ir_const_func(ctx, \
ir_strl(ctx, name, strlen(name)), \
#define BUILTIN_FP_FUNC(type, dname, fname) \ ir_proto_1(ctx, IR_BUILTIN_FUNC, ret_type, arg1_type))
((type == IR_DOUBLE) ? BUILTIN_FUNC(dname) : BUILTIN_FUNC(fname)) #define BUILTIN_FUNC_2(name, ret_type, arg1_type, arg2_type) \
ir_const_func(ctx, \
ir_strl(ctx, name, strlen(name)), \
ir_proto_2(ctx, IR_BUILTIN_FUNC, ret_type, arg1_type, arg2_type))
#define BUILTIN_FUNC_3(name, ret_type, arg1_type, arg2_type, arg3_type) \
ir_const_func(ctx, \
ir_strl(ctx, name, strlen(name)), \
ir_proto_3(ctx, IR_BUILTIN_FUNC, ret_type, arg1_type, arg2_type, arg3_type))
static ir_ref llvm2ir_const_expr(ir_ctx *ctx, LLVMValueRef expr); static ir_ref llvm2ir_const_expr(ir_ctx *ctx, LLVMValueRef expr);
static ir_ref llvm2ir_auto_cast(ir_ctx *ctx, ir_ref ref, ir_type src_type, ir_type type); static ir_ref llvm2ir_auto_cast(ir_ctx *ctx, ir_ref ref, ir_type src_type, ir_type type);
@ -105,13 +112,44 @@ static const char *llvm2ir_sym_name(char *buf, const char *name, size_t name_len
return buf; return buf;
} }
static ir_ref llvm2ir_proto(ir_ctx *ctx, uint32_t cconv, LLVMTypeRef ftype)
{
uint8_t flags = 0;
ir_type ret_type;
uint8_t *arg_types;
uint32_t i, num_args;
LLVMTypeRef *types;
if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) {
/* skip */
} else if (cconv == LLVMX86FastcallCallConv) {
flags |= IR_FASTCALL_FUNC;
} else {
fprintf(stderr, "Unsupported Calling Convention: %d\n", cconv);
IR_ASSERT(0);
return 0;
}
if (LLVMIsFunctionVarArg(ftype)) {
flags |= IR_VARARG_FUNC;
}
ret_type = llvm2ir_type(LLVMGetReturnType(ftype));
num_args = LLVMCountParamTypes(ftype);
types = alloca(sizeof(LLVMTypeRef) * num_args);
arg_types = alloca(num_args);
LLVMGetParamTypes(ftype, types);
for (i = 0; i < num_args; i++) {
arg_types[i] = llvm2ir_type(types[i]);
}
return ir_proto(ctx, flags, ret_type, num_args, arg_types);
}
static ir_ref llvm2ir_op(ir_ctx *ctx, LLVMValueRef op, ir_type type) static ir_ref llvm2ir_op(ir_ctx *ctx, LLVMValueRef op, ir_type type)
{ {
ir_ref ref; ir_ref ref;
LLVMBool lose; LLVMBool lose;
const char *name; const char *name;
size_t name_len; size_t name_len;
uint32_t cconv, flags; ir_ref proto;
ir_val val; ir_val val;
char buf[256]; char buf[256];
@ -158,24 +196,10 @@ static ir_ref llvm2ir_op(ir_ctx *ctx, LLVMValueRef op, ir_type type)
} }
return ir_const_sym(ctx, ir_strl(ctx, name, name_len)); return ir_const_sym(ctx, ir_strl(ctx, name, name_len));
case LLVMFunctionValueKind: case LLVMFunctionValueKind:
// TODO: function prototype
// TODO: resolve function address // TODO: resolve function address
flags = 0; proto = llvm2ir_proto(ctx, LLVMGetFunctionCallConv(op), LLVMGlobalGetValueType(op));
cconv = LLVMGetFunctionCallConv(op);
if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) {
/* skip */
} else if (cconv == LLVMX86FastcallCallConv) {
flags |= IR_CONST_FASTCALL_FUNC;
} else {
fprintf(stderr, "Unsupported Calling Convention: %d\n", cconv);
IR_ASSERT(0);
return 0;
}
if (LLVMIsFunctionVarArg(LLVMTypeOf(op))) {
flags |= IR_CONST_VARARG_FUNC;
}
name = LLVMGetValueName2(op, &name_len); name = LLVMGetValueName2(op, &name_len);
return ir_const_func(ctx, ir_strl(ctx, name, name_len), flags); return ir_const_func(ctx, ir_strl(ctx, name, name_len), proto);
case LLVMUndefValueValueKind: case LLVMUndefValueValueKind:
val.u64 = 0; val.u64 = 0;
return ir_const(ctx, val, type); return ir_const(ctx, val, type);
@ -314,7 +338,11 @@ static ir_ref llvm2ir_fcmp_op_isnan(ir_ctx *ctx, LLVMValueRef expr, ir_type type
{ {
ir_ref func, ref; ir_ref func, ref;
func = BUILTIN_FP_FUNC(type, "isnan", "isnanf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("isnan", IR_BOOL, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("isnanf", IR_BOOL, IR_FLOAT);
}
if (LLVMGetValueKind(op1) == LLVMConstantIntValueKind) { if (LLVMGetValueKind(op1) == LLVMConstantIntValueKind) {
ref = ir_CALL_1(IR_BOOL, func, llvm2ir_op(ctx, op0, type)); ref = ir_CALL_1(IR_BOOL, func, llvm2ir_op(ctx, op0, type));
} else { } else {
@ -790,21 +818,21 @@ static ir_ref llvm2ir_intrinsic(ir_ctx *ctx, LLVMValueRef insn, LLVMTypeRef ftyp
return ir_CTTZ(type, llvm2ir_op(ctx, op0, type)); return ir_CTTZ(type, llvm2ir_op(ctx, op0, type));
} else if (STR_START(name, name_len, "llvm.memset.")) { } else if (STR_START(name, name_len, "llvm.memset.")) {
IR_ASSERT(count == 3 || count == 4); IR_ASSERT(count == 3 || count == 4);
func = BUILTIN_FUNC("memset"); func = BUILTIN_FUNC_3("memset", IR_ADDR, IR_ADDR, IR_I32, IR_SIZE_T);
return ir_CALL_3(IR_VOID, func, return ir_CALL_3(IR_VOID, func,
llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR), llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_I8), llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_I8),
llvm2ir_op(ctx, LLVMGetOperand(insn, 2), IR_SIZE_T)); llvm2ir_op(ctx, LLVMGetOperand(insn, 2), IR_SIZE_T));
} else if (STR_START(name, name_len, "llvm.memcpy.")) { } else if (STR_START(name, name_len, "llvm.memcpy.")) {
IR_ASSERT(count == 3 || count == 4); IR_ASSERT(count == 3 || count == 4);
func = BUILTIN_FUNC("memcpy"); func = BUILTIN_FUNC_3("memcpy", IR_ADDR, IR_ADDR, IR_ADDR, IR_SIZE_T);
return ir_CALL_3(IR_VOID, func, return ir_CALL_3(IR_VOID, func,
llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR), llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR), llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR),
llvm2ir_op(ctx, LLVMGetOperand(insn, 2), IR_SIZE_T)); llvm2ir_op(ctx, LLVMGetOperand(insn, 2), IR_SIZE_T));
} else if (STR_START(name, name_len, "llvm.memmove.")) { } else if (STR_START(name, name_len, "llvm.memmove.")) {
IR_ASSERT(count == 3 || count == 4); IR_ASSERT(count == 3 || count == 4);
func = BUILTIN_FUNC("memmove"); func = BUILTIN_FUNC_3("memmove", IR_ADDR, IR_ADDR, IR_ADDR, IR_SIZE_T);
return ir_CALL_3(IR_VOID, func, return ir_CALL_3(IR_VOID, func,
llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR), llvm2ir_op(ctx, LLVMGetOperand(insn, 0), IR_ADDR),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR), llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR),
@ -820,107 +848,175 @@ static ir_ref llvm2ir_intrinsic(ir_ctx *ctx, LLVMValueRef insn, LLVMTypeRef ftyp
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "sqrt", "sqrtf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("sqrt", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("sqrtf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.sin.")) { } else if (STR_START(name, name_len, "llvm.sin.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "sin", "sinf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("sin", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("sinf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.cos.")) { } else if (STR_START(name, name_len, "llvm.cos.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "cos", "cosf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("cos", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("cosf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.pow.")) { } else if (STR_START(name, name_len, "llvm.pow.")) {
IR_ASSERT(count == 2); IR_ASSERT(count == 2);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "pow", "powf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("pow", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("powf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type), return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), type)); llvm2ir_op(ctx, LLVMGetOperand(insn, 1), type));
} else if (STR_START(name, name_len, "llvm.exp.")) { } else if (STR_START(name, name_len, "llvm.exp.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "exp", "expf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("exp", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("expf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.exp2.")) { } else if (STR_START(name, name_len, "llvm.exp2.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "exp2", "exp2f"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("exp2", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("exp2f", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.exp10.")) { } else if (STR_START(name, name_len, "llvm.exp10.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "exp10", "exp10f"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("exp10", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("exp10f", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.ldexp.")) { } else if (STR_START(name, name_len, "llvm.ldexp.")) {
IR_ASSERT(count == 2); IR_ASSERT(count == 2);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "ldexp", "ldexpf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_2("ldexp", IR_DOUBLE, IR_DOUBLE, IR_I32);
} else {
func = BUILTIN_FUNC_2("ldexpf", IR_FLOAT, IR_FLOAT, IR_I32);
}
return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type), return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_I32)); llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_I32));
} else if (STR_START(name, name_len, "llvm.frexp.")) { } else if (STR_START(name, name_len, "llvm.frexp.")) {
IR_ASSERT(count == 2); IR_ASSERT(count == 2);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "frexp", "frexpf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_2("frexp", IR_DOUBLE, IR_DOUBLE, IR_ADDR);
} else {
func = BUILTIN_FUNC_2("frexpf", IR_FLOAT, IR_FLOAT, IR_ADDR);
}
return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type), return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR)); llvm2ir_op(ctx, LLVMGetOperand(insn, 1), IR_ADDR));
} else if (STR_START(name, name_len, "llvm.log.")) { } else if (STR_START(name, name_len, "llvm.log.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "log", "logf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("log", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("logf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.log2.")) { } else if (STR_START(name, name_len, "llvm.log2.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "log2", "log2f"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("log2", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("log2f", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.log10.")) { } else if (STR_START(name, name_len, "llvm.log10.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "log10", "log10f"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("log10", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("log10f", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.copysign.")) { } else if (STR_START(name, name_len, "llvm.copysign.")) {
IR_ASSERT(count == 2); IR_ASSERT(count == 2);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "copysign", "copysignf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_2("copysign", IR_DOUBLE, IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_2("copysignf", IR_FLOAT, IR_FLOAT, IR_FLOAT);
}
return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type), return ir_CALL_2(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type),
llvm2ir_op(ctx, LLVMGetOperand(insn, 1), type)); llvm2ir_op(ctx, LLVMGetOperand(insn, 1), type));
} else if (STR_START(name, name_len, "llvm.floor.")) { } else if (STR_START(name, name_len, "llvm.floor.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "floor", "floorf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("floor", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("floorf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.ceil.")) { } else if (STR_START(name, name_len, "llvm.ceil.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "ceil", "ceilf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("ceil", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("ceilf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.trunc.")) { } else if (STR_START(name, name_len, "llvm.trunc.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "trunc", "truncf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("trunc", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("truncf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.round.")) { } else if (STR_START(name, name_len, "llvm.round.")) {
IR_ASSERT(count == 1); IR_ASSERT(count == 1);
type = llvm2ir_type(LLVMGetReturnType(ftype)); type = llvm2ir_type(LLVMGetReturnType(ftype));
IR_ASSERT(IR_IS_TYPE_FP(type)); IR_ASSERT(IR_IS_TYPE_FP(type));
func = BUILTIN_FP_FUNC(type, "round", "roundf"); if (type == IR_DOUBLE) {
func = BUILTIN_FUNC_1("round", IR_DOUBLE, IR_DOUBLE);
} else {
func = BUILTIN_FUNC_1("roundf", IR_FLOAT, IR_FLOAT);
}
return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type)); return ir_CALL_1(type, func, llvm2ir_op(ctx, LLVMGetOperand(insn, 0), type));
} else if (STR_START(name, name_len, "llvm.fmuladd.") } else if (STR_START(name, name_len, "llvm.fmuladd.")
|| STR_START(name, name_len, "llvm.fma.")) { || STR_START(name, name_len, "llvm.fma.")) {
@ -1782,9 +1878,9 @@ static int llvm2ir_external_func(ir_loader *loader, const char *name, LLVMValueR
{ {
uint32_t i, count, cconv, flags = 0; uint32_t i, count, cconv, flags = 0;
LLVMTypeRef ftype; LLVMTypeRef ftype;
ir_type ret_type, *param_types; ir_type ret_type;
uint8_t *param_types;
// TODO: function prototype
ftype = LLVMGlobalGetValueType(func); ftype = LLVMGlobalGetValueType(func);
cconv = LLVMGetFunctionCallConv(func); cconv = LLVMGetFunctionCallConv(func);
if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) { if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) {
@ -1814,9 +1910,9 @@ static int llvm2ir_forward_func(ir_loader *loader, const char *name, LLVMValueRe
{ {
uint32_t i, count, cconv, flags = 0; uint32_t i, count, cconv, flags = 0;
LLVMTypeRef ftype; LLVMTypeRef ftype;
ir_type ret_type, *param_types; ir_type ret_type;
uint8_t *param_types;
// TODO: function prototype
ftype = LLVMGlobalGetValueType(func); ftype = LLVMGlobalGetValueType(func);
cconv = LLVMGetFunctionCallConv(func); cconv = LLVMGetFunctionCallConv(func);
if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) { if (cconv == LLVMCCallConv || cconv == LLVMFastCallConv) {

View File

@ -306,7 +306,7 @@ static bool ir_loader_external_sym_dcl(ir_loader *loader, const char *name, uint
return 1; return 1;
} }
static void ir_dump_func_dcl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types, FILE *f) static void ir_dump_func_dcl(const char *name, uint32_t flags, ir_type ret_type, uint32_t params_count, const uint8_t *param_types, FILE *f)
{ {
if (flags & IR_EXTERN) { if (flags & IR_EXTERN) {
fprintf(f, "extern "); fprintf(f, "extern ");
@ -315,7 +315,7 @@ static void ir_dump_func_dcl(const char *name, uint32_t flags, ir_type ret_type,
} }
fprintf(f, "func %s(", name); fprintf(f, "func %s(", name);
if (params_count) { if (params_count) {
ir_type *p = param_types; const uint8_t *p = param_types;
fprintf(f, "%s", ir_type_cname[*p]); fprintf(f, "%s", ir_type_cname[*p]);
p++; p++;
@ -328,14 +328,16 @@ static void ir_dump_func_dcl(const char *name, uint32_t flags, ir_type ret_type,
} }
} else if (flags & IR_VARARG_FUNC) { } else if (flags & IR_VARARG_FUNC) {
fprintf(f, "..."); fprintf(f, "...");
} else {
fprintf(f, "void");
} }
fprintf(f, "): %s;\n", ir_type_cname[ret_type]); fprintf(f, "): %s", ir_type_cname[ret_type]);
if (flags & IR_FASTCALL_FUNC) {
fprintf(f, " __fastcall");
}
fprintf(f, ";\n");
} }
static bool ir_loader_external_func_dcl(ir_loader *loader, const char *name, static bool ir_loader_external_func_dcl(ir_loader *loader, const char *name, uint32_t flags,
uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types) ir_type ret_type, uint32_t params_count, const uint8_t *param_types)
{ {
ir_main_loader *l = (ir_main_loader*) loader; ir_main_loader *l = (ir_main_loader*) loader;
@ -361,8 +363,8 @@ static bool ir_loader_external_func_dcl(ir_loader *loader, const char *name,
return 1; return 1;
} }
static bool ir_loader_forward_func_dcl(ir_loader *loader, const char *name, static bool ir_loader_forward_func_dcl(ir_loader *loader, const char *name, uint32_t flags,
uint32_t flags, ir_type ret_type, uint32_t params_count, ir_type *param_types) ir_type ret_type, uint32_t params_count, const uint8_t *param_types)
{ {
ir_main_loader *l = (ir_main_loader*) loader; ir_main_loader *l = (ir_main_loader*) loader;
@ -554,10 +556,12 @@ static bool ir_loader_func_process(ir_loader *loader, ir_ctx *ctx, const char *n
} }
} else if (ctx->flags & IR_VARARG_FUNC) { } else if (ctx->flags & IR_VARARG_FUNC) {
fprintf(l->dump_file, "..."); fprintf(l->dump_file, "...");
} else {
fprintf(l->dump_file, "void");
} }
fprintf(l->dump_file, "): %s\n", ir_type_cname[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID]); fprintf(l->dump_file, "): %s", ir_type_cname[ctx->ret_type != (ir_type)-1 ? ctx->ret_type : IR_VOID]);
if (ctx->flags & IR_FASTCALL_FUNC) {
fprintf(l->dump_file, " __fastcall");
}
fprintf(l->dump_file, "\n");
} }
if (!ir_compile_func(ctx, l->opt_level, l->dump, l->dump_file, name)) { if (!ir_compile_func(ctx, l->opt_level, l->dump, l->dump_file, name)) {
@ -620,7 +624,7 @@ static bool ir_loader_func_process(ir_loader *loader, ir_ctx *ctx, const char *n
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) {
if (insn->op == IR_FUNC) { if (insn->op == IR_FUNC) {
const char *name = ir_get_str(ctx, insn->val.i32); const char *name = ir_get_str(ctx, insn->val.name);
void *addr = ir_loader_resolve_sym_name(loader, name); void *addr = ir_loader_resolve_sym_name(loader, name);
ir_disasm_add_symbol(name, (uintptr_t)addr, sizeof(void*)); ir_disasm_add_symbol(name, (uintptr_t)addr, sizeof(void*));

View File

@ -828,6 +828,7 @@ IR_ALWAYS_INLINE bool ir_ref_is_true(ir_ctx *ctx, ir_ref ref)
#define IR_OPND_STR 0x5 #define IR_OPND_STR 0x5
#define IR_OPND_NUM 0x6 #define IR_OPND_NUM 0x6
#define IR_OPND_PROB 0x7 #define IR_OPND_PROB 0x7
#define IR_OPND_PROTO 0x8
#define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \ #define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \
((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28)) ((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28))

View File

@ -8,6 +8,34 @@
#include "ir.h" #include "ir.h"
#include "ir_private.h" #include "ir_private.h"
void ir_print_proto(const ir_ctx *ctx, ir_ref func_proto, FILE *f)
{
ir_ref j;
if (func_proto) {
const ir_proto_t *proto = (const ir_proto_t *)ir_get_str(ctx, func_proto);
fprintf(f, "(");
if (proto->params_count > 0) {
fprintf(f, "%s", ir_type_cname[proto->param_types[0]]);
for (j = 1; j < proto->params_count; j++) {
fprintf(f, ", %s", ir_type_cname[proto->param_types[j]]);
}
if (proto->flags & IR_VARARG_FUNC) {
fprintf(f, ", ...");
}
} else if (proto->flags & IR_VARARG_FUNC) {
fprintf(f, "...");
}
fprintf(f, "): %s", ir_type_cname[proto->ret_type]);
if (proto->flags & IR_FASTCALL_FUNC) {
fprintf(f, " __fastcall");
}
} else {
fprintf(f, "(): int32_t");
}
}
void ir_save(const ir_ctx *ctx, FILE *f) void ir_save(const ir_ctx *ctx, FILE *f)
{ {
ir_ref i, j, n, ref, *p; ir_ref i, j, n, ref, *p;
@ -19,20 +47,14 @@ void ir_save(const ir_ctx *ctx, FILE *f)
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) {
fprintf(f, "\t%s c_%d = ", ir_type_cname[insn->type], i); fprintf(f, "\t%s c_%d = ", ir_type_cname[insn->type], i);
if (insn->op == IR_FUNC) { if (insn->op == IR_FUNC) {
if (!insn->const_flags) { fprintf(f, "func %s", ir_get_str(ctx, insn->val.name));
fprintf(f, "func(%s)", ir_get_str(ctx, insn->val.i32)); ir_print_proto(ctx, insn->proto, f);
} else {
fprintf(f, "func(%s, %d)", ir_get_str(ctx, insn->val.i32), insn->const_flags);
}
} else if (insn->op == IR_SYM) { } else if (insn->op == IR_SYM) {
fprintf(f, "sym(%s)", ir_get_str(ctx, insn->val.i32)); fprintf(f, "sym(%s)", ir_get_str(ctx, insn->val.name));
} else if (insn->op == IR_FUNC_ADDR) { } else if (insn->op == IR_FUNC_ADDR) {
fprintf(f, "func_addr("); fprintf(f, "func *");
ir_print_const(ctx, insn, f, true); ir_print_const(ctx, insn, f, true);
if (insn->const_flags) { ir_print_proto(ctx, insn->proto, f);
fprintf(f, ", %d", insn->const_flags);
}
fprintf(f, ")");
} else { } else {
ir_print_const(ctx, insn, f, true); ir_print_const(ctx, insn, f, true);
} }
@ -89,6 +111,10 @@ void ir_save(const ir_ctx *ctx, FILE *f)
fprintf(f, "%s\"%s\"", first ? "(" : ", ", ir_get_str(ctx, ref)); fprintf(f, "%s\"%s\"", first ? "(" : ", ", ir_get_str(ctx, ref));
first = 0; first = 0;
break; break;
case IR_OPND_PROTO:
fprintf(f, "%sfunc ", first ? "(" : ", ");
ir_print_proto(ctx, ref, f);
break;
case IR_OPND_PROB: case IR_OPND_PROB:
if (ref == 0) { if (ref == 0) {
break; break;

View File

@ -204,6 +204,14 @@ const char *ir_strtab_str(const ir_strtab *strtab, ir_ref idx)
return ((const ir_strtab_bucket*)strtab->data)[idx].str; return ((const ir_strtab_bucket*)strtab->data)[idx].str;
} }
const char *ir_strtab_strl(const ir_strtab *strtab, ir_ref idx, size_t *len)
{
const ir_strtab_bucket *b = ((const ir_strtab_bucket*)strtab->data) + idx;
IR_ASSERT(idx >= 0 && (uint32_t)idx < strtab->count);
*len = b->len;
return b->str;
}
void ir_strtab_free(ir_strtab *strtab) void ir_strtab_free(ir_strtab *strtab)
{ {
uint32_t hash_size = (uint32_t)(-(int32_t)strtab->mask); uint32_t hash_size = (uint32_t)(-(int32_t)strtab->mask);

View File

@ -364,6 +364,7 @@ typedef struct _ir_backend_data {
ir_reg_alloc_data ra_data; ir_reg_alloc_data ra_data;
uint32_t dessa_from_block; uint32_t dessa_from_block;
dasm_State *dasm_state; dasm_State *dasm_state;
ir_bitset emit_constants;
int rodata_label, jmp_table_label; int rodata_label, jmp_table_label;
bool double_neg_const; bool double_neg_const;
bool float_neg_const; bool float_neg_const;
@ -1927,6 +1928,7 @@ store_int:
case IR_INT2FP: case IR_INT2FP:
case IR_FP2INT: case IR_FP2INT:
case IR_FP2FP: case IR_FP2FP:
case IR_PROTO:
ir_match_fuse_load(ctx, insn->op1, ref); ir_match_fuse_load(ctx, insn->op1, ref);
return insn->op; return insn->op;
case IR_CTLZ: case IR_CTLZ:
@ -2117,7 +2119,7 @@ static void ir_emit_load_imm_fp(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref sr
} }
} else { } else {
label = ctx->cfg_blocks_count - src; label = ctx->cfg_blocks_count - src;
insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -src);
| ASM_FP_REG_MEM_OP movss, movsd, vmovss, vmovsd, type, reg, [=>label] | ASM_FP_REG_MEM_OP movss, movsd, vmovss, vmovsd, type, reg, [=>label]
} }
} }
@ -2310,10 +2312,10 @@ static void ir_emit_prologue(ir_ctx *ctx)
} }
} }
if ((ctx->flags & IR_VARARG_FUNC) && (ctx->flags2 & IR_HAS_VA_START)) { if ((ctx->flags & IR_VARARG_FUNC) && (ctx->flags2 & IR_HAS_VA_START)) {
#if defined(_WIN64)
ir_reg fp; ir_reg fp;
int offset; int offset;
#if defined(_WIN64)
if (ctx->flags & IR_USE_FRAME_POINTER) { if (ctx->flags & IR_USE_FRAME_POINTER) {
fp = IR_REG_FRAME_POINTER; fp = IR_REG_FRAME_POINTER;
offset = sizeof(void*) * 2; offset = sizeof(void*) * 2;
@ -2330,6 +2332,8 @@ static void ir_emit_prologue(ir_ctx *ctx)
const int8_t *int_reg_params = _ir_int_reg_params; const int8_t *int_reg_params = _ir_int_reg_params;
const int8_t *fp_reg_params = _ir_fp_reg_params; const int8_t *fp_reg_params = _ir_fp_reg_params;
uint32_t i; uint32_t i;
ir_reg fp;
int offset;
if (ctx->flags & IR_USE_FRAME_POINTER) { if (ctx->flags & IR_USE_FRAME_POINTER) {
fp = IR_REG_FRAME_POINTER; fp = IR_REG_FRAME_POINTER;
@ -4046,10 +4050,9 @@ static void ir_emit_binop_sse2(ir_ctx *ctx, ir_ref def, ir_insn *insn)
break; break;
} }
} else if (IR_IS_CONST_REF(op2)) { } else if (IR_IS_CONST_REF(op2)) {
ir_insn *val_insn = &ctx->ir_base[op2];
int label = ctx->cfg_blocks_count - op2; int label = ctx->cfg_blocks_count - op2;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -op2);
switch (insn->op) { switch (insn->op) {
default: default:
IR_ASSERT(0 && "NIY binary op"); IR_ASSERT(0 && "NIY binary op");
@ -4155,10 +4158,9 @@ static void ir_emit_binop_avx(ir_ctx *ctx, ir_ref def, ir_insn *insn)
break; break;
} }
} else if (IR_IS_CONST_REF(op2)) { } else if (IR_IS_CONST_REF(op2)) {
ir_insn *val_insn = &ctx->ir_base[op2];
int label = ctx->cfg_blocks_count - op2; int label = ctx->cfg_blocks_count - op2;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -op2);
switch (insn->op) { switch (insn->op) {
default: default:
IR_ASSERT(0 && "NIY binary op"); IR_ASSERT(0 && "NIY binary op");
@ -4528,10 +4530,9 @@ static ir_op ir_emit_cmp_fp_common(ir_ctx *ctx, ir_ref cmp_ref, ir_insn *cmp_ins
} }
| ASM_FP_REG_REG_OP ucomiss, ucomisd, vucomiss, vucomisd, type, op1_reg, op2_reg | ASM_FP_REG_REG_OP ucomiss, ucomisd, vucomiss, vucomisd, type, op1_reg, op2_reg
} else if (IR_IS_CONST_REF(op2)) { } else if (IR_IS_CONST_REF(op2)) {
ir_insn *val_insn = &ctx->ir_base[op2];
int label = ctx->cfg_blocks_count - op2; int label = ctx->cfg_blocks_count - op2;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -op2);
| ASM_FP_REG_MEM_OP ucomiss, ucomisd, vucomiss, vucomisd, type, op1_reg, [=>label] | ASM_FP_REG_MEM_OP ucomiss, ucomisd, vucomiss, vucomisd, type, op1_reg, [=>label]
} else { } else {
int32_t offset = 0; int32_t offset = 0;
@ -5448,10 +5449,9 @@ static void ir_emit_bitcast(ir_ctx *ctx, ir_ref def, ir_insn *insn)
} }
} }
} else if (IR_IS_CONST_REF(insn->op1)) { } else if (IR_IS_CONST_REF(insn->op1)) {
ir_insn *val_insn = &ctx->ir_base[insn->op1];
int label = ctx->cfg_blocks_count - insn->op1; int label = ctx->cfg_blocks_count - insn->op1;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -insn->op1);
| ASM_FP_REG_MEM_OP movss, movsd, vmovss, vmovsd, dst_type, def_reg, [=>label] | ASM_FP_REG_MEM_OP movss, movsd, vmovss, vmovsd, dst_type, def_reg, [=>label]
} else { } else {
int32_t offset = 0; int32_t offset = 0;
@ -5648,10 +5648,9 @@ static void ir_emit_fp2int(ir_ctx *ctx, ir_ref def, ir_insn *insn)
|.endif |.endif
} }
} else if (IR_IS_CONST_REF(insn->op1)) { } else if (IR_IS_CONST_REF(insn->op1)) {
ir_insn *_insn = &ctx->ir_base[insn->op1];
int label = ctx->cfg_blocks_count - insn->op1; int label = ctx->cfg_blocks_count - insn->op1;
_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -insn->op1);
if (!dst64) { if (!dst64) {
if (src_type == IR_DOUBLE) { if (src_type == IR_DOUBLE) {
if (ctx->mflags & IR_X86_AVX) { if (ctx->mflags & IR_X86_AVX) {
@ -5771,10 +5770,9 @@ static void ir_emit_fp2fp(ir_ctx *ctx, ir_ref def, ir_insn *insn)
} }
} }
} else if (IR_IS_CONST_REF(insn->op1)) { } else if (IR_IS_CONST_REF(insn->op1)) {
ir_insn *_insn = &ctx->ir_base[insn->op1];
int label = ctx->cfg_blocks_count - insn->op1; int label = ctx->cfg_blocks_count - insn->op1;
_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -insn->op1);
if (src_type == IR_DOUBLE) { if (src_type == IR_DOUBLE) {
if (ctx->mflags & IR_X86_AVX) { if (ctx->mflags & IR_X86_AVX) {
| vcvtsd2ss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), qword [=>label] | vcvtsd2ss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), qword [=>label]
@ -7149,13 +7147,13 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
if (val_insn->op == IR_STR) { if (val_insn->op == IR_STR) {
int label = ctx->cfg_blocks_count - arg; int label = ctx->cfg_blocks_count - arg;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -arg);
| lea Ra(dst_reg), aword [=>label] | lea Ra(dst_reg), aword [=>label]
continue; continue;
} else if (val_insn->op == IR_SYM || val_insn->op == IR_FUNC) { } else if (val_insn->op == IR_SYM || val_insn->op == IR_FUNC) {
void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ? void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.name));
if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) { if (sizeof(void*) == 4 || IR_IS_SIGNED_32BIT(addr)) {
| mov Ra(dst_reg), ((ptrdiff_t)addr) | mov Ra(dst_reg), ((ptrdiff_t)addr)
} else { } else {
@ -7222,7 +7220,7 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
if (val_insn->op == IR_STR) { if (val_insn->op == IR_STR) {
int label = ctx->cfg_blocks_count - arg; int label = ctx->cfg_blocks_count - arg;
val_insn->const_flags |= IR_CONST_EMIT; ir_bitset_incl(data->emit_constants, -arg);
IR_ASSERT(tmp_reg != IR_REG_NONE); IR_ASSERT(tmp_reg != IR_REG_NONE);
|.if X64 |.if X64
| lea Ra(tmp_reg), aword [=>label] | lea Ra(tmp_reg), aword [=>label]
@ -7232,8 +7230,8 @@ static int32_t ir_emit_arguments(ir_ctx *ctx, ir_ref def, ir_insn *insn, ir_reg
|.endif |.endif
} else if (val_insn->op == IR_FUNC || val_insn->op == IR_SYM) { } else if (val_insn->op == IR_FUNC || val_insn->op == IR_SYM) {
void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ? void *addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, val_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, val_insn->val.name));
if (sizeof(void*) == 4) { if (sizeof(void*) == 4) {
| mov aword [Ra(IR_REG_RSP)+stack_offset], ((ptrdiff_t)addr) | mov aword [Ra(IR_REG_RSP)+stack_offset], ((ptrdiff_t)addr)
|.if X64 |.if X64
@ -7352,8 +7350,8 @@ static void ir_emit_call(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;
@ -7501,8 +7499,8 @@ static void ir_emit_tailcall(ir_ctx *ctx, ir_ref def, ir_insn *insn)
IR_ASSERT(addr_insn->type == IR_ADDR); IR_ASSERT(addr_insn->type == IR_ADDR);
if (addr_insn->op == IR_FUNC) { if (addr_insn->op == IR_FUNC) {
addr = (ctx->loader && ctx->loader->resolve_sym_name) ? addr = (ctx->loader && ctx->loader->resolve_sym_name) ?
ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.i32)) : ctx->loader->resolve_sym_name(ctx->loader, ir_get_str(ctx, addr_insn->val.name)) :
ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.i32)); ir_resolve_sym_name(ir_get_str(ctx, addr_insn->val.name));
} else { } else {
IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR); IR_ASSERT(addr_insn->op == IR_ADDR || addr_insn->op == IR_FUNC_ADDR);
addr = (void*)addr_insn->val.addr; addr = (void*)addr_insn->val.addr;
@ -8941,6 +8939,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
dasm_setup(&data.dasm_state, dasm_actions); dasm_setup(&data.dasm_state, dasm_actions);
/* labels for each block + for each constant + rodata label + jmp_table label + for each entry */ /* 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 + ctx->entries_count); dasm_growpc(&data.dasm_state, ctx->cfg_blocks_count + 1 + ctx->consts_count + 1 + 1 + 1 + ctx->entries_count);
data.emit_constants = ir_bitset_malloc(ctx->consts_count);
if ((ctx->flags & IR_GEN_ENDBR) && (ctx->flags & IR_START_BR_TARGET)) { if ((ctx->flags & IR_GEN_ENDBR) && (ctx->flags & IR_START_BR_TARGET)) {
|.if X64 |.if X64
@ -9319,6 +9318,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
ir_emit_trunc(ctx, i, insn); ir_emit_trunc(ctx, i, insn);
break; break;
case IR_BITCAST: case IR_BITCAST:
case IR_PROTO:
ir_emit_bitcast(ctx, i, insn); ir_emit_bitcast(ctx, i, insn);
break; break;
case IR_INT2FP: case IR_INT2FP:
@ -9536,6 +9536,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
break; break;
default: default:
IR_ASSERT(0 && "NIY rule/instruction"); IR_ASSERT(0 && "NIY rule/instruction");
ir_mem_free(data.emit_constants);
dasm_free(&data.dasm_state); dasm_free(&data.dasm_state);
ctx->data = NULL; ctx->data = NULL;
ctx->status = IR_ERROR_UNSUPPORTED_CODE_RULE; ctx->status = IR_ERROR_UNSUPPORTED_CODE_RULE;
@ -9552,95 +9553,95 @@ next_block:;
if (data.rodata_label) { if (data.rodata_label) {
|.rodata |.rodata
} }
for (i = IR_UNUSED + 1, insn = ctx->ir_base - i; i < ctx->consts_count; i++, insn--) { IR_BITSET_FOREACH(data.emit_constants, ir_bitset_len(ctx->consts_count), i) {
if (insn->const_flags & IR_CONST_EMIT) { insn = &ctx->ir_base[-i];
if (IR_IS_TYPE_FP(insn->type)) { if (IR_IS_TYPE_FP(insn->type)) {
int label = ctx->cfg_blocks_count + i; int label = ctx->cfg_blocks_count + i;
if (!data.rodata_label) { if (!data.rodata_label) {
data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2; data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
|.rodata |.rodata
|=>data.rodata_label: |=>data.rodata_label:
} }
if (insn->type == IR_DOUBLE) { if (insn->type == IR_DOUBLE) {
|.align 8
|=>label:
|.dword insn->val.u32, insn->val.u32_hi
} else {
IR_ASSERT(insn->type == IR_FLOAT);
|.align 4
|=>label:
|.dword insn->val.u32
}
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.i32);
int i = 0;
if (!data.rodata_label) {
data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
|.rodata
|=>data.rodata_label:
}
|.align 8 |.align 8
|=>label: |=>label:
while (str[i]) { |.dword insn->val.u32, insn->val.u32_hi
char c = str[i];
if (c == '\\') {
if (str[i+1] == '\\') {
i++;
c = '\\';
} else if (str[i+1] == '\'') {
i++;
c = '\'';
} else if (str[i+1] == '"') {
i++;
c = '"';
} else if (str[i+1] == 'a') {
i++;
c = '\a';
} else if (str[i+1] == 'b') {
i++;
c = '\b';
} else if (str[i+1] == 'e') {
i++;
c = 27; /* '\e'; */
} else if (str[i+1] == 'f') {
i++;
c = '\f';
} else if (str[i+1] == 'n') {
i++;
c = '\n';
} else if (str[i+1] == 'r') {
i++;
c = '\r';
} else if (str[i+1] == 't') {
i++;
c = '\t';
} else if (str[i+1] == 'v') {
i++;
c = '\v';
} else if (str[i+1] == '?') {
i++;
c = 0x3f;
}
}
|.byte c
i++;
}
|.byte 0
} else { } else {
IR_ASSERT(0); IR_ASSERT(insn->type == IR_FLOAT);
|.align 4
|=>label:
|.dword insn->val.u32
} }
} else if (insn->op == IR_STR) {
int label = ctx->cfg_blocks_count + i;
const char *str = ir_get_str(ctx, insn->val.str);
int i = 0;
if (!data.rodata_label) {
data.rodata_label = ctx->cfg_blocks_count + ctx->consts_count + 2;
|.rodata
|=>data.rodata_label:
}
|.align 8
|=>label:
while (str[i]) {
char c = str[i];
if (c == '\\') {
if (str[i+1] == '\\') {
i++;
c = '\\';
} else if (str[i+1] == '\'') {
i++;
c = '\'';
} else if (str[i+1] == '"') {
i++;
c = '"';
} else if (str[i+1] == 'a') {
i++;
c = '\a';
} else if (str[i+1] == 'b') {
i++;
c = '\b';
} else if (str[i+1] == 'e') {
i++;
c = 27; /* '\e'; */
} else if (str[i+1] == 'f') {
i++;
c = '\f';
} else if (str[i+1] == 'n') {
i++;
c = '\n';
} else if (str[i+1] == 'r') {
i++;
c = '\r';
} else if (str[i+1] == 't') {
i++;
c = '\t';
} else if (str[i+1] == 'v') {
i++;
c = '\v';
} else if (str[i+1] == '?') {
i++;
c = 0x3f;
}
}
|.byte c
i++;
}
|.byte 0
} else {
IR_ASSERT(0);
} }
} } IR_BITSET_FOREACH_END();
if (data.rodata_label) { if (data.rodata_label) {
|.code |.code
} }
ir_mem_free(data.emit_constants);
if (ctx->status) { if (ctx->status) {
dasm_free(&data.dasm_state); dasm_free(&data.dasm_state);
@ -9660,7 +9661,6 @@ next_block:;
if (ctx->code_buffer != NULL) { if (ctx->code_buffer != NULL) {
if (IR_ALIGNED_SIZE(size, 16) > ctx->code_buffer_size) { if (IR_ALIGNED_SIZE(size, 16) > ctx->code_buffer_size) {
dasm_free(&data.dasm_state);
ctx->data = NULL; ctx->data = NULL;
ctx->status = IR_ERROR_CODE_MEM_OVERFLOW; ctx->status = IR_ERROR_CODE_MEM_OVERFLOW;
return NULL; return NULL;

View File

@ -16,7 +16,7 @@ Windows-x86_64
uint32_t c_8 = 8; uint32_t c_8 = 8;
int64_t c_9 = 9; int64_t c_9 = 9;
int64_t c_10 = 0x100000000; int64_t c_10 = 0x100000000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n"; uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -16,7 +16,7 @@ Windows-x86_64
double c_8 = 0.8; double c_8 = 0.8;
double c_9 = 0.9; double c_9 = 0.9;
double c_10 = 0.0; double c_10 = 0.0;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n"; uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -10,7 +10,7 @@ Windows-x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ Windows-x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ Windows-x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "p1", 1); int32_t p_1 = PARAM(l_1, "p1", 1);

View File

@ -19,7 +19,7 @@ Windows-x86_64
char zero = 0; char zero = 0;
uint32_t len = 7; uint32_t len = 7;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uintptr_t a_0, s_0 = ALLOCA(l_1, len); uintptr_t a_0, s_0 = ALLOCA(l_1, len);
s_1 = STORE(s_0, a_0, h); s_1 = STORE(s_0, a_0, h);

View File

@ -18,7 +18,7 @@ Windows-x86_64
char nl = '\n'; char nl = '\n';
char zero = 0; char zero = 0;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uint64_t var_1 = VAR(l_1, "str"); uint64_t var_1 = VAR(l_1, "str");
uintptr_t a_0 = VADDR(var_1); uintptr_t a_0 = VADDR(var_1);

View File

@ -6,7 +6,7 @@ Windows-x86_64
-S -S
--CODE-- --CODE--
{ {
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n"; uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t p_1 = PARAM(l_1, "p_1", 1); int32_t p_1 = PARAM(l_1, "p_1", 1);

View File

@ -10,7 +10,7 @@ Windows-x86_64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -40,7 +40,7 @@ Windows-x86_64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_15); l_1 = START(l_15);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ Windows-x86_64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -39,7 +39,7 @@ Windows-x86_64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_17); l_1 = START(l_17);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -9,7 +9,7 @@ Windows-x86_64
int32_t c_0 = 0; int32_t c_0 = 0;
int32_t c_1 = 1; int32_t c_1 = 1;
int32_t c_10000 = 10000; int32_t c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%d\n"; uintptr_t format = "%d\n";
l_1 = START(l_6); l_1 = START(l_6);
int32_t lo_1 = COPY(c_0); int32_t lo_1 = COPY(c_0);
@ -36,7 +36,7 @@ Windows-x86_64
int32_t c_4 = 0; int32_t c_4 = 0;
int32_t c_5 = 1; int32_t c_5 = 1;
int32_t c_6 = 10000; int32_t c_6 = 10000;
uintptr_t c_7 = func(printf, 4); uintptr_t c_7 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_8 = "%d\n"; uintptr_t c_8 = "%d\n";
l_1 = START(l_14); l_1 = START(l_14);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ Windows-x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4); char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4);

View File

@ -16,7 +16,7 @@ aarch64
uint32_t c_8 = 8; uint32_t c_8 = 8;
int64_t c_9 = 9; int64_t c_9 = 9;
int64_t c_10 = 0x100000000; int64_t c_10 = 0x100000000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n"; uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -16,7 +16,7 @@ aarch64
double c_8 = 0.8; double c_8 = 0.8;
double c_9 = 0.9; double c_9 = 0.9;
double c_10 = 0.0; double c_10 = 0.0;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n"; uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -10,7 +10,7 @@ aarch64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ aarch64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ aarch64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "p1", 1); int32_t p_1 = PARAM(l_1, "p1", 1);

View File

@ -19,7 +19,7 @@ aarch64
char zero = 0; char zero = 0;
uint32_t len = 7; uint32_t len = 7;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uintptr_t a_0, s_0 = ALLOCA(l_1, len); uintptr_t a_0, s_0 = ALLOCA(l_1, len);
s_1 = STORE(s_0, a_0, h); s_1 = STORE(s_0, a_0, h);

View File

@ -18,7 +18,7 @@ aarch64
char nl = '\n'; char nl = '\n';
char zero = 0; char zero = 0;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uint64_t var_1 = VAR(l_1, "str"); uint64_t var_1 = VAR(l_1, "str");
uintptr_t a_0 = VADDR(var_1); uintptr_t a_0 = VADDR(var_1);

View File

@ -6,7 +6,7 @@ aarch64
-S -S
--CODE-- --CODE--
{ {
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n"; uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t p_1 = PARAM(l_1, "p_1", 1); int32_t p_1 = PARAM(l_1, "p_1", 1);

View File

@ -10,7 +10,7 @@ aarch64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -40,7 +40,7 @@ aarch64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_15); l_1 = START(l_15);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ aarch64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -39,7 +39,7 @@ aarch64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_17); l_1 = START(l_17);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -9,7 +9,7 @@ aarch64
int32_t c_0 = 0; int32_t c_0 = 0;
int32_t c_1 = 1; int32_t c_1 = 1;
int32_t c_10000 = 10000; int32_t c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%d\n"; uintptr_t format = "%d\n";
l_1 = START(l_6); l_1 = START(l_6);
int32_t lo_1 = COPY(c_0); int32_t lo_1 = COPY(c_0);
@ -36,7 +36,7 @@ aarch64
int32_t c_4 = 0; int32_t c_4 = 0;
int32_t c_5 = 1; int32_t c_5 = 1;
int32_t c_6 = 10000; int32_t c_6 = 10000;
uintptr_t c_7 = func(printf, 4); uintptr_t c_7 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_8 = "%d\n"; uintptr_t c_8 = "%d\n";
l_1 = START(l_14); l_1 = START(l_14);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ aarch64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4); char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4);

View File

@ -16,7 +16,7 @@ x86
uint32_t c_8 = 8; uint32_t c_8 = 8;
int32_t c_9 = 9; int32_t c_9 = 9;
int32_t c_10 = 10; int32_t c_10 = 10;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n"; uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -16,7 +16,7 @@ x86
double c_8 = 0.8; double c_8 = 0.8;
double c_9 = 0.9; double c_9 = 0.9;
double c_10 = 0.0; double c_10 = 0.0;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n"; uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -10,7 +10,7 @@ x86
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ x86
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ x86
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "p1", 1); int32_t p_1 = PARAM(l_1, "p1", 1);

View File

@ -19,7 +19,7 @@ x86
char zero = 0; char zero = 0;
uint32_t len = 7; uint32_t len = 7;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uintptr_t a_0, s_0 = ALLOCA(l_1, len); uintptr_t a_0, s_0 = ALLOCA(l_1, len);
s_1 = STORE(s_0, a_0, h); s_1 = STORE(s_0, a_0, h);

View File

@ -18,7 +18,7 @@ x86
char nl = '\n'; char nl = '\n';
char zero = 0; char zero = 0;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uint64_t var_1 = VAR(l_1, "str"); uint64_t var_1 = VAR(l_1, "str");
uintptr_t a_0 = VADDR(var_1); uintptr_t a_0 = VADDR(var_1);

View File

@ -6,7 +6,7 @@ x86
-S -S
--CODE-- --CODE--
{ {
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n"; uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t p_1 = PARAM(l_1, "p_1", 1); int32_t p_1 = PARAM(l_1, "p_1", 1);

View File

@ -10,7 +10,7 @@ x86
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -40,7 +40,7 @@ x86
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_15); l_1 = START(l_15);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ x86
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -39,7 +39,7 @@ x86
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_17); l_1 = START(l_17);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -9,7 +9,7 @@ x86
int32_t c_0 = 0; int32_t c_0 = 0;
int32_t c_1 = 1; int32_t c_1 = 1;
int32_t c_10000 = 10000; int32_t c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%d\n"; uintptr_t format = "%d\n";
l_1 = START(l_6); l_1 = START(l_6);
int32_t lo_1 = COPY(c_0); int32_t lo_1 = COPY(c_0);
@ -36,7 +36,7 @@ x86
int32_t c_4 = 0; int32_t c_4 = 0;
int32_t c_5 = 1; int32_t c_5 = 1;
int32_t c_6 = 10000; int32_t c_6 = 10000;
uintptr_t c_7 = func(printf, 4); uintptr_t c_7 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_8 = "%d\n"; uintptr_t c_8 = "%d\n";
l_1 = START(l_14); l_1 = START(l_14);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -12,7 +12,7 @@ TAILCALL for functions with stack argumnts is not implemented
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4); char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4);

View File

@ -16,7 +16,7 @@ x86_64
uint32_t c_8 = 8; uint32_t c_8 = 8;
int64_t c_9 = 9; int64_t c_9 = 9;
int64_t c_10 = 0x100000000; int64_t c_10 = 0x100000000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n"; uintptr_t fmt = "%d %d %d %lld 0x%llx %d %d %d %lld 0x%llx\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -16,7 +16,7 @@ x86_64
double c_8 = 0.8; double c_8 = 0.8;
double c_9 = 0.9; double c_9 = 0.9;
double c_10 = 0.0; double c_10 = 0.0;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n"; uintptr_t fmt = "%g %g %g %g %g %g %g %g %g %g\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10); int32_t d_2, l_2 = CALL/11(l_1, f, fmt, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8, c_9, c_10);

View File

@ -10,7 +10,7 @@ x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);

View File

@ -10,7 +10,7 @@ x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "p1", 1); int32_t p_1 = PARAM(l_1, "p1", 1);

View File

@ -9,7 +9,7 @@ x86_64
uintptr_t c_1 = 0; uintptr_t c_1 = 0;
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d %d!\n"; uintptr_t c_6 = "hello %d %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t p_1 = PARAM(l_1, "x", 0); int32_t p_1 = PARAM(l_1, "x", 0);

View File

@ -19,7 +19,7 @@ x86_64
char zero = 0; char zero = 0;
uint32_t len = 7; uint32_t len = 7;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uintptr_t a_0, s_0 = ALLOCA(l_1, len); uintptr_t a_0, s_0 = ALLOCA(l_1, len);
s_1 = STORE(s_0, a_0, h); s_1 = STORE(s_0, a_0, h);

View File

@ -18,7 +18,7 @@ x86_64
char nl = '\n'; char nl = '\n';
char zero = 0; char zero = 0;
uintptr_t one = 1; uintptr_t one = 1;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
l_1 = START(l_4); l_1 = START(l_4);
uint64_t var_1 = VAR(l_1, "str"); uint64_t var_1 = VAR(l_1, "str");
uintptr_t a_0 = VADDR(var_1); uintptr_t a_0 = VADDR(var_1);

View File

@ -6,7 +6,7 @@ x86_64
-S -S
--CODE-- --CODE--
{ {
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n"; uintptr_t fmt = "%d %d %d %d %d %d %d %d %d %d\n";
l_1 = START(l_3); l_1 = START(l_3);
int32_t p_1 = PARAM(l_1, "p_1", 1); int32_t p_1 = PARAM(l_1, "p_1", 1);

View File

@ -6,7 +6,7 @@ x86_64
-S -S
--CODE-- --CODE--
{ {
uintptr_t fn = func(printf, 4); uintptr_t fn = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "hello\n"; uintptr_t format = "hello\n";
l_1 = START(l_3); l_1 = START(l_3);
double x = PARAM(l_1, "x", 1); double x = PARAM(l_1, "x", 1);

View File

@ -6,7 +6,7 @@ x86_64
-S -S
--CODE-- --CODE--
{ {
uintptr_t fn = func(printf, 4); uintptr_t fn = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "hello\n"; uintptr_t format = "hello\n";
l_1 = START(l_3); l_1 = START(l_3);
double x = PARAM(l_1, "x", 1); double x = PARAM(l_1, "x", 1);

View File

@ -10,7 +10,7 @@ x86_64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -40,7 +40,7 @@ x86_64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_15); l_1 = START(l_15);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ x86_64
double c_0 = 0; double c_0 = 0;
double c_1 = 1; double c_1 = 1;
double c_10000 = 10000; double c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%g\n"; uintptr_t format = "%g\n";
l_1 = START(l_6); l_1 = START(l_6);
double lo_1 = COPY(c_0); double lo_1 = COPY(c_0);
@ -39,7 +39,7 @@ x86_64
double c_5 = 0; double c_5 = 0;
double c_6 = 1; double c_6 = 1;
double c_7 = 10000; double c_7 = 10000;
uintptr_t c_8 = func(printf, 4); uintptr_t c_8 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_9 = "%g\n"; uintptr_t c_9 = "%g\n";
l_1 = START(l_17); l_1 = START(l_17);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -9,7 +9,7 @@ x86_64
int32_t c_0 = 0; int32_t c_0 = 0;
int32_t c_1 = 1; int32_t c_1 = 1;
int32_t c_10000 = 10000; int32_t c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%d\n"; uintptr_t format = "%d\n";
l_1 = START(l_6); l_1 = START(l_6);
int32_t lo_1 = COPY(c_0); int32_t lo_1 = COPY(c_0);
@ -36,7 +36,7 @@ x86_64
int32_t c_4 = 0; int32_t c_4 = 0;
int32_t c_5 = 1; int32_t c_5 = 1;
int32_t c_6 = 10000; int32_t c_6 = 10000;
uintptr_t c_7 = func(printf, 4); uintptr_t c_7 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_8 = "%d\n"; uintptr_t c_8 = "%d\n";
l_1 = START(l_14); l_1 = START(l_14);
l_2 = END(l_1); l_2 = END(l_1);

View File

@ -10,7 +10,7 @@ x86_64
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4); char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4);

View File

@ -8,7 +8,7 @@ FibI
int32_t c_1 = 1; int32_t c_1 = 1;
int32_t c_100 = 100; int32_t c_100 = 100;
int32_t c_10000 = 10000; int32_t c_10000 = 10000;
uintptr_t f = func(printf, 4); uintptr_t f = func printf(uintptr_t, ...): int32_t;
uintptr_t format = "%d\n"; uintptr_t format = "%d\n";
l_1 = START(l_6); l_1 = START(l_6);
int32_t lo_1 = COPY(c_0); int32_t lo_1 = COPY(c_0);

View File

@ -4,7 +4,7 @@ Floating point constants
--save --save
--CODE-- --CODE--
{ {
uintptr_t c_1 = func(printf, 4); uintptr_t c_1 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_2 = "fmt\n"; uintptr_t c_2 = "fmt\n";
double c_3 = 16.5; double c_3 = 16.5;
float c_4 = 13.4; float c_4 = 13.4;
@ -23,7 +23,7 @@ Floating point constants
uintptr_t c_1 = 0; uintptr_t c_1 = 0;
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_4 = func(printf, 4); uintptr_t c_4 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_5 = "fmt\n"; uintptr_t c_5 = "fmt\n";
double c_6 = 16.5; double c_6 = 16.5;
float c_7 = 13.4; float c_7 = 13.4;

View File

@ -8,7 +8,7 @@ Simple CALL
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4); int32_t d_2, l_2 = CALL/2(l_1, c_5, c_6, c_4);
@ -20,5 +20,5 @@ define i32 @test()
%d2 = call i32 (...) @printf(ptr @.str6, i32 42) %d2 = call i32 (...) @printf(ptr @.str6, i32 42)
ret i32 %d2 ret i32 %d2
} }
declare void @printf() declare i32 @printf(ptr, ...)
@.str6 = private unnamed_addr constant [12 x i8] c"hello %d!\0A\00" @.str6 = private unnamed_addr constant [12 x i8] c"hello %d!\0A\00"

View File

@ -8,7 +8,7 @@ Simple TAILCALL
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 42; int32_t c_4 = 42;
uintptr_t c_5 = func(printf, 4); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
uintptr_t c_6 = "hello %d!\n"; uintptr_t c_6 = "hello %d!\n";
l_1 = START(l_4); l_1 = START(l_4);
char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4); char d_2, l_2 = TAILCALL/2(l_1, c_5, c_6, c_4);
@ -20,5 +20,5 @@ define i8 @test()
%d2 = tail call i8 (...) @printf(ptr @.str6, i32 42) %d2 = tail call i8 (...) @printf(ptr @.str6, i32 42)
ret i8 %d2 ret i8 %d2
} }
declare void @printf() declare i32 @printf(ptr, ...)
@.str6 = private unnamed_addr constant [12 x i8] c"hello %d!\0A\00" @.str6 = private unnamed_addr constant [12 x i8] c"hello %d!\0A\00"

View File

@ -41,23 +41,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 1; int8_t c_4 = 1;
uintptr_t c_5 = func(ctlz8); uintptr_t c_5 = func ctlz8(int8_t): int32_t;
int8_t c_6 = 96; int8_t c_6 = 96;
int8_t c_7 = -128; int8_t c_7 = -128;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 1; int16_t c_10 = 1;
uintptr_t c_11 = func(ctlz16); uintptr_t c_11 = func ctlz16(int16_t): int32_t;
int16_t c_12 = 1536; int16_t c_12 = 1536;
int16_t c_13 = -32768; int16_t c_13 = -32768;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 1; int32_t c_15 = 1;
uintptr_t c_16 = func(ctlz32); uintptr_t c_16 = func ctlz32(int32_t): int32_t;
int32_t c_17 = 393216; int32_t c_17 = 393216;
int32_t c_18 = -2147483648; int32_t c_18 = -2147483648;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 1; int64_t c_20 = 1;
uintptr_t c_21 = func(ctlz64); uintptr_t c_21 = func ctlz64(int64_t): int32_t;
int64_t c_22 = 25769803776; int64_t c_22 = 25769803776;
int64_t c_23 = -9223372036854775808; int64_t c_23 = -9223372036854775808;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -43,23 +43,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 1; int8_t c_4 = 1;
uintptr_t c_5 = func(ctlz8); uintptr_t c_5 = func ctlz8(int8_t): int32_t;
int8_t c_6 = 96; int8_t c_6 = 96;
int8_t c_7 = -128; int8_t c_7 = -128;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 1; int16_t c_10 = 1;
uintptr_t c_11 = func(ctlz16); uintptr_t c_11 = func ctlz16(int16_t): int32_t;
int16_t c_12 = 1536; int16_t c_12 = 1536;
int16_t c_13 = -32768; int16_t c_13 = -32768;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 1; int32_t c_15 = 1;
uintptr_t c_16 = func(ctlz32); uintptr_t c_16 = func ctlz32(int32_t): int32_t;
int32_t c_17 = 393216; int32_t c_17 = 393216;
int32_t c_18 = -2147483648; int32_t c_18 = -2147483648;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 1; int64_t c_20 = 1;
uintptr_t c_21 = func(ctlz64); uintptr_t c_21 = func ctlz64(int64_t): int32_t;
int64_t c_22 = 25769803776; int64_t c_22 = 25769803776;
int64_t c_23 = -9223372036854775808; int64_t c_23 = -9223372036854775808;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -41,23 +41,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 0; int8_t c_4 = 0;
uintptr_t c_5 = func(ctpop8); uintptr_t c_5 = func ctpop8(int8_t): int32_t;
int8_t c_6 = 85; int8_t c_6 = 85;
int8_t c_7 = -1; int8_t c_7 = -1;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 0; int16_t c_10 = 0;
uintptr_t c_11 = func(ctpop16); uintptr_t c_11 = func ctpop16(int16_t): int32_t;
int16_t c_12 = 21845; int16_t c_12 = 21845;
int16_t c_13 = -1; int16_t c_13 = -1;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 0; int32_t c_15 = 0;
uintptr_t c_16 = func(ctpop32); uintptr_t c_16 = func ctpop32(int32_t): int32_t;
int32_t c_17 = 1431655765; int32_t c_17 = 1431655765;
int32_t c_18 = -1; int32_t c_18 = -1;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 0; int64_t c_20 = 0;
uintptr_t c_21 = func(ctpop64); uintptr_t c_21 = func ctpop64(int64_t): int32_t;
int64_t c_22 = 6148914691236517205; int64_t c_22 = 6148914691236517205;
int64_t c_23 = -1; int64_t c_23 = -1;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -43,23 +43,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 0; int8_t c_4 = 0;
uintptr_t c_5 = func(ctpop8); uintptr_t c_5 = func ctpop8(int8_t): int32_t;
int8_t c_6 = 85; int8_t c_6 = 85;
int8_t c_7 = -1; int8_t c_7 = -1;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 0; int16_t c_10 = 0;
uintptr_t c_11 = func(ctpop16); uintptr_t c_11 = func ctpop16(int16_t): int32_t;
int16_t c_12 = 21845; int16_t c_12 = 21845;
int16_t c_13 = -1; int16_t c_13 = -1;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 0; int32_t c_15 = 0;
uintptr_t c_16 = func(ctpop32); uintptr_t c_16 = func ctpop32(int32_t): int32_t;
int32_t c_17 = 1431655765; int32_t c_17 = 1431655765;
int32_t c_18 = -1; int32_t c_18 = -1;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 0; int64_t c_20 = 0;
uintptr_t c_21 = func(ctpop64); uintptr_t c_21 = func ctpop64(int64_t): int32_t;
int64_t c_22 = 6148914691236517205; int64_t c_22 = 6148914691236517205;
int64_t c_23 = -1; int64_t c_23 = -1;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -41,23 +41,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 1; int8_t c_4 = 1;
uintptr_t c_5 = func(cttz8); uintptr_t c_5 = func cttz8(int8_t): int32_t;
int8_t c_6 = 96; int8_t c_6 = 96;
int8_t c_7 = -128; int8_t c_7 = -128;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 1; int16_t c_10 = 1;
uintptr_t c_11 = func(cttz16); uintptr_t c_11 = func cttz16(int16_t): int32_t;
int16_t c_12 = 1536; int16_t c_12 = 1536;
int16_t c_13 = -32768; int16_t c_13 = -32768;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 1; int32_t c_15 = 1;
uintptr_t c_16 = func(cttz32); uintptr_t c_16 = func cttz32(int32_t): int32_t;
int32_t c_17 = 393216; int32_t c_17 = 393216;
int32_t c_18 = -2147483648; int32_t c_18 = -2147483648;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 1; int64_t c_20 = 1;
uintptr_t c_21 = func(cttz64); uintptr_t c_21 = func cttz64(int64_t): int32_t;
int64_t c_22 = 25769803776; int64_t c_22 = 25769803776;
int64_t c_23 = -9223372036854775808; int64_t c_23 = -9223372036854775808;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -43,23 +43,23 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int8_t c_4 = 1; int8_t c_4 = 1;
uintptr_t c_5 = func(cttz8); uintptr_t c_5 = func cttz8(int8_t): int32_t;
int8_t c_6 = 96; int8_t c_6 = 96;
int8_t c_7 = -128; int8_t c_7 = -128;
uintptr_t c_8 = "u8 : %2d %2d %2d\n"; uintptr_t c_8 = "u8 : %2d %2d %2d\n";
uintptr_t c_9 = func(printf); uintptr_t c_9 = func printf(uintptr_t, ...): int32_t;
int16_t c_10 = 1; int16_t c_10 = 1;
uintptr_t c_11 = func(cttz16); uintptr_t c_11 = func cttz16(int16_t): int32_t;
int16_t c_12 = 1536; int16_t c_12 = 1536;
int16_t c_13 = -32768; int16_t c_13 = -32768;
uintptr_t c_14 = "u16: %2d %2d %2d\n"; uintptr_t c_14 = "u16: %2d %2d %2d\n";
int32_t c_15 = 1; int32_t c_15 = 1;
uintptr_t c_16 = func(cttz32); uintptr_t c_16 = func cttz32(int32_t): int32_t;
int32_t c_17 = 393216; int32_t c_17 = 393216;
int32_t c_18 = -2147483648; int32_t c_18 = -2147483648;
uintptr_t c_19 = "u32: %2d %2d %2d\n"; uintptr_t c_19 = "u32: %2d %2d %2d\n";
int64_t c_20 = 1; int64_t c_20 = 1;
uintptr_t c_21 = func(cttz64); uintptr_t c_21 = func cttz64(int64_t): int32_t;
int64_t c_22 = 25769803776; int64_t c_22 = 25769803776;
int64_t c_23 = -9223372036854775808; int64_t c_23 = -9223372036854775808;
uintptr_t c_24 = "u64: %2d %2d %2d\n"; uintptr_t c_24 = "u64: %2d %2d %2d\n";

View File

@ -155,39 +155,39 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_4 = "eq: "; uintptr_t c_4 = "eq: ";
uintptr_t c_5 = func(printf); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
double c_6 = -inf; double c_6 = -inf;
uintptr_t c_7 = func(eq); uintptr_t c_7 = func eq(double, double): int32_t;
uintptr_t c_8 = "%d"; uintptr_t c_8 = "%d";
double c_9 = 0; double c_9 = 0;
double c_10 = 10.5; double c_10 = 10.5;
double c_11 = inf; double c_11 = inf;
double c_12 = nan; double c_12 = nan;
int32_t c_13 = 95; int32_t c_13 = 95;
uintptr_t c_14 = func(putchar); uintptr_t c_14 = func putchar(int32_t): int32_t;
int32_t c_15 = 10; int32_t c_15 = 10;
uintptr_t c_16 = "ueq: "; uintptr_t c_16 = "ueq: ";
uintptr_t c_17 = func(ueq); uintptr_t c_17 = func ueq(double, double): int32_t;
uintptr_t c_18 = "ne: "; uintptr_t c_18 = "ne: ";
uintptr_t c_19 = func(ne); uintptr_t c_19 = func ne(double, double): int32_t;
uintptr_t c_20 = "une: "; uintptr_t c_20 = "une: ";
uintptr_t c_21 = func(une); uintptr_t c_21 = func une(double, double): int32_t;
uintptr_t c_22 = "gt: "; uintptr_t c_22 = "gt: ";
uintptr_t c_23 = func(gt); uintptr_t c_23 = func gt(double, double): int32_t;
uintptr_t c_24 = "ugt: "; uintptr_t c_24 = "ugt: ";
uintptr_t c_25 = func(ugt); uintptr_t c_25 = func ugt(double, double): int32_t;
uintptr_t c_26 = "ge: "; uintptr_t c_26 = "ge: ";
uintptr_t c_27 = func(ge); uintptr_t c_27 = func ge(double, double): int32_t;
uintptr_t c_28 = "uge: "; uintptr_t c_28 = "uge: ";
uintptr_t c_29 = func(uge); uintptr_t c_29 = func uge(double, double): int32_t;
uintptr_t c_30 = "lt: "; uintptr_t c_30 = "lt: ";
uintptr_t c_31 = func(lt); uintptr_t c_31 = func lt(double, double): int32_t;
uintptr_t c_32 = "ult: "; uintptr_t c_32 = "ult: ";
uintptr_t c_33 = func(ult); uintptr_t c_33 = func ult(double, double): int32_t;
uintptr_t c_34 = "le: "; uintptr_t c_34 = "le: ";
uintptr_t c_35 = func(le); uintptr_t c_35 = func le(double, double): int32_t;
uintptr_t c_36 = "ule: "; uintptr_t c_36 = "ule: ";
uintptr_t c_37 = func(ule); uintptr_t c_37 = func ule(double, double): int32_t;
int32_t c_38 = 0; int32_t c_38 = 0;
l_1 = START(l_1274); l_1 = START(l_1274);
int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4); int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4);

View File

@ -179,39 +179,39 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_4 = "eq: "; uintptr_t c_4 = "eq: ";
uintptr_t c_5 = func(printf); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
double c_6 = -inf; double c_6 = -inf;
uintptr_t c_7 = func(eq); uintptr_t c_7 = func eq(double, double): int32_t;
uintptr_t c_8 = "%d"; uintptr_t c_8 = "%d";
double c_9 = 0; double c_9 = 0;
double c_10 = 10.5; double c_10 = 10.5;
double c_11 = inf; double c_11 = inf;
double c_12 = nan; double c_12 = nan;
int32_t c_13 = 95; int32_t c_13 = 95;
uintptr_t c_14 = func(putchar); uintptr_t c_14 = func putchar(int32_t): int32_t;
int32_t c_15 = 10; int32_t c_15 = 10;
uintptr_t c_16 = "ueq: "; uintptr_t c_16 = "ueq: ";
uintptr_t c_17 = func(ueq); uintptr_t c_17 = func ueq(double, double): int32_t;
uintptr_t c_18 = "ne: "; uintptr_t c_18 = "ne: ";
uintptr_t c_19 = func(ne); uintptr_t c_19 = func ne(double, double): int32_t;
uintptr_t c_20 = "une: "; uintptr_t c_20 = "une: ";
uintptr_t c_21 = func(une); uintptr_t c_21 = func une(double, double): int32_t;
uintptr_t c_22 = "gt: "; uintptr_t c_22 = "gt: ";
uintptr_t c_23 = func(gt); uintptr_t c_23 = func gt(double, double): int32_t;
uintptr_t c_24 = "ugt: "; uintptr_t c_24 = "ugt: ";
uintptr_t c_25 = func(ugt); uintptr_t c_25 = func ugt(double, double): int32_t;
uintptr_t c_26 = "ge: "; uintptr_t c_26 = "ge: ";
uintptr_t c_27 = func(ge); uintptr_t c_27 = func ge(double, double): int32_t;
uintptr_t c_28 = "uge: "; uintptr_t c_28 = "uge: ";
uintptr_t c_29 = func(uge); uintptr_t c_29 = func uge(double, double): int32_t;
uintptr_t c_30 = "lt: "; uintptr_t c_30 = "lt: ";
uintptr_t c_31 = func(lt); uintptr_t c_31 = func lt(double, double): int32_t;
uintptr_t c_32 = "ult: "; uintptr_t c_32 = "ult: ";
uintptr_t c_33 = func(ult); uintptr_t c_33 = func ult(double, double): int32_t;
uintptr_t c_34 = "le: "; uintptr_t c_34 = "le: ";
uintptr_t c_35 = func(le); uintptr_t c_35 = func le(double, double): int32_t;
uintptr_t c_36 = "ule: "; uintptr_t c_36 = "ule: ";
uintptr_t c_37 = func(ule); uintptr_t c_37 = func ule(double, double): int32_t;
int32_t c_38 = 0; int32_t c_38 = 0;
l_1 = START(l_1274); l_1 = START(l_1274);
int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4); int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4);

View File

@ -11,7 +11,7 @@ func eq(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -34,7 +34,7 @@ func ueq(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -57,7 +57,7 @@ func ne(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -80,7 +80,7 @@ func une(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -103,7 +103,7 @@ func gt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -126,7 +126,7 @@ func ugt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -149,7 +149,7 @@ func ge(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -172,7 +172,7 @@ func uge(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -195,7 +195,7 @@ func lt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -218,7 +218,7 @@ func ult(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -241,7 +241,7 @@ func le(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -264,7 +264,7 @@ func ule(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -287,12 +287,12 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_4 = "eq: "; uintptr_t c_4 = "eq: ";
uintptr_t c_5 = func(printf); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
double c_6 = -inf; double c_6 = -inf;
uintptr_t c_7 = func(eq); uintptr_t c_7 = func eq(double, double): int32_t;
int32_t c_8 = 0; int32_t c_8 = 0;
int32_t c_9 = 48; int32_t c_9 = 48;
uintptr_t c_10 = func(putchar); uintptr_t c_10 = func putchar(int32_t): int32_t;
double c_11 = 0; double c_11 = 0;
double c_12 = 10.5; double c_12 = 10.5;
double c_13 = inf; double c_13 = inf;
@ -300,27 +300,27 @@ func main(void): int32_t
int32_t c_15 = 95; int32_t c_15 = 95;
int32_t c_16 = 10; int32_t c_16 = 10;
uintptr_t c_17 = "ueq: "; uintptr_t c_17 = "ueq: ";
uintptr_t c_18 = func(ueq); uintptr_t c_18 = func ueq(double, double): int32_t;
uintptr_t c_19 = "ne: "; uintptr_t c_19 = "ne: ";
uintptr_t c_20 = func(ne); uintptr_t c_20 = func ne(double, double): int32_t;
uintptr_t c_21 = "une: "; uintptr_t c_21 = "une: ";
uintptr_t c_22 = func(une); uintptr_t c_22 = func une(double, double): int32_t;
uintptr_t c_23 = "gt: "; uintptr_t c_23 = "gt: ";
uintptr_t c_24 = func(gt); uintptr_t c_24 = func gt(double, double): int32_t;
uintptr_t c_25 = "ugt: "; uintptr_t c_25 = "ugt: ";
uintptr_t c_26 = func(ugt); uintptr_t c_26 = func ugt(double, double): int32_t;
uintptr_t c_27 = "ge: "; uintptr_t c_27 = "ge: ";
uintptr_t c_28 = func(ge); uintptr_t c_28 = func ge(double, double): int32_t;
uintptr_t c_29 = "uge: "; uintptr_t c_29 = "uge: ";
uintptr_t c_30 = func(uge); uintptr_t c_30 = func uge(double, double): int32_t;
uintptr_t c_31 = "lt: "; uintptr_t c_31 = "lt: ";
uintptr_t c_32 = func(lt); uintptr_t c_32 = func lt(double, double): int32_t;
uintptr_t c_33 = "ult: "; uintptr_t c_33 = "ult: ";
uintptr_t c_34 = func(ult); uintptr_t c_34 = func ult(double, double): int32_t;
uintptr_t c_35 = "le: "; uintptr_t c_35 = "le: ";
uintptr_t c_36 = func(le); uintptr_t c_36 = func le(double, double): int32_t;
uintptr_t c_37 = "ule: "; uintptr_t c_37 = "ule: ";
uintptr_t c_38 = func(ule); uintptr_t c_38 = func ule(double, double): int32_t;
l_1 = START(l_3074); l_1 = START(l_3074);
int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4); int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4);
int32_t d_3, l_3 = CALL/2(l_2, c_7, c_6, c_6); int32_t d_3, l_3 = CALL/2(l_2, c_7, c_6, c_6);

View File

@ -11,7 +11,7 @@ func eq(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -34,7 +34,7 @@ func ueq(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -57,7 +57,7 @@ func ne(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -80,7 +80,7 @@ func une(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -103,7 +103,7 @@ func gt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -126,7 +126,7 @@ func ugt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -149,7 +149,7 @@ func ge(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -172,7 +172,7 @@ func uge(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -195,7 +195,7 @@ func lt(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -218,7 +218,7 @@ func ult(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -241,7 +241,7 @@ func le(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -264,7 +264,7 @@ func ule(double, double): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
int32_t c_4 = 51; int32_t c_4 = 51;
uintptr_t c_5 = func(putchar); uintptr_t c_5 = func putchar(int32_t): int32_t;
int32_t c_6 = 1; int32_t c_6 = 1;
int32_t c_7 = 0; int32_t c_7 = 0;
l_1 = START(l_13); l_1 = START(l_13);
@ -287,12 +287,12 @@ func main(void): int32_t
bool c_2 = 0; bool c_2 = 0;
bool c_3 = 1; bool c_3 = 1;
uintptr_t c_4 = "eq: "; uintptr_t c_4 = "eq: ";
uintptr_t c_5 = func(printf); uintptr_t c_5 = func printf(uintptr_t, ...): int32_t;
double c_6 = -inf; double c_6 = -inf;
uintptr_t c_7 = func(eq); uintptr_t c_7 = func eq(double, double): int32_t;
int32_t c_8 = 0; int32_t c_8 = 0;
int32_t c_9 = 48; int32_t c_9 = 48;
uintptr_t c_10 = func(putchar); uintptr_t c_10 = func putchar(int32_t): int32_t;
double c_11 = 0; double c_11 = 0;
double c_12 = 10.5; double c_12 = 10.5;
double c_13 = inf; double c_13 = inf;
@ -300,27 +300,27 @@ func main(void): int32_t
int32_t c_15 = 95; int32_t c_15 = 95;
int32_t c_16 = 10; int32_t c_16 = 10;
uintptr_t c_17 = "ueq: "; uintptr_t c_17 = "ueq: ";
uintptr_t c_18 = func(ueq); uintptr_t c_18 = func ueq(double, double): int32_t;
uintptr_t c_19 = "ne: "; uintptr_t c_19 = "ne: ";
uintptr_t c_20 = func(ne); uintptr_t c_20 = func ne(double, double): int32_t;
uintptr_t c_21 = "une: "; uintptr_t c_21 = "une: ";
uintptr_t c_22 = func(une); uintptr_t c_22 = func une(double, double): int32_t;
uintptr_t c_23 = "gt: "; uintptr_t c_23 = "gt: ";
uintptr_t c_24 = func(gt); uintptr_t c_24 = func gt(double, double): int32_t;
uintptr_t c_25 = "ugt: "; uintptr_t c_25 = "ugt: ";
uintptr_t c_26 = func(ugt); uintptr_t c_26 = func ugt(double, double): int32_t;
uintptr_t c_27 = "ge: "; uintptr_t c_27 = "ge: ";
uintptr_t c_28 = func(ge); uintptr_t c_28 = func ge(double, double): int32_t;
uintptr_t c_29 = "uge: "; uintptr_t c_29 = "uge: ";
uintptr_t c_30 = func(uge); uintptr_t c_30 = func uge(double, double): int32_t;
uintptr_t c_31 = "lt: "; uintptr_t c_31 = "lt: ";
uintptr_t c_32 = func(lt); uintptr_t c_32 = func lt(double, double): int32_t;
uintptr_t c_33 = "ult: "; uintptr_t c_33 = "ult: ";
uintptr_t c_34 = func(ult); uintptr_t c_34 = func ult(double, double): int32_t;
uintptr_t c_35 = "le: "; uintptr_t c_35 = "le: ";
uintptr_t c_36 = func(le); uintptr_t c_36 = func le(double, double): int32_t;
uintptr_t c_37 = "ule: "; uintptr_t c_37 = "ule: ";
uintptr_t c_38 = func(ule); uintptr_t c_38 = func ule(double, double): int32_t;
l_1 = START(l_3074); l_1 = START(l_3074);
int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4); int32_t d_2, l_2 = CALL/1(l_1, c_5, c_4);
int32_t d_3, l_3 = CALL/2(l_2, c_7, c_6, c_6); int32_t d_3, l_3 = CALL/2(l_2, c_7, c_6, c_6);

View File

@ -44,9 +44,9 @@ func main(void): int32_t
int32_t c_8 = 4; int32_t c_8 = 4;
int32_t c_9 = 5; int32_t c_9 = 5;
int32_t c_10 = 6; int32_t c_10 = 6;
uintptr_t c_11 = func(sum, 4); uintptr_t c_11 = func sum(int32_t, ...): int32_t;
uintptr_t c_12 = "sum %d\n"; uintptr_t c_12 = "sum %d\n";
uintptr_t c_13 = func(printf, 4); uintptr_t c_13 = func printf(uintptr_t, ...): int32_t;
int32_t c_14 = 0; int32_t c_14 = 0;
int32_t c_15 = 8; int32_t c_15 = 8;
int32_t c_16 = 9; int32_t c_16 = 9;

View File

@ -49,9 +49,9 @@ func main(void): int32_t
double c_12 = 8.0; double c_12 = 8.0;
double c_13 = 9.0; double c_13 = 9.0;
double c_14 = 10.0; double c_14 = 10.0;
uintptr_t sum = func(sum, 4); uintptr_t sum = func sum(int32_t, ...): double;
uintptr_t str = "sum %g\n"; uintptr_t str = "sum %g\n";
uintptr_t printf = func(printf, 4); uintptr_t printf = func printf(uintptr_t, ...): int32_t;
int32_t ret = 0; int32_t ret = 0;
l_1 = START(l_7); l_1 = START(l_7);
double d_2, l_2 = CALL/11(l_1, sum, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13, c_14); double d_2, l_2 = CALL/11(l_1, sum, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13, c_14);

View File

@ -49,9 +49,9 @@ func main(void): int32_t
float c_12 = 8.0; float c_12 = 8.0;
float c_13 = 9.0; float c_13 = 9.0;
float c_14 = 10.0; float c_14 = 10.0;
uintptr_t sum = func(sum, 4); uintptr_t sum = func sum(int32_t, ...): float;
uintptr_t str = "sum %g\n"; uintptr_t str = "sum %g\n";
uintptr_t printf = func(printf, 4); uintptr_t printf = func printf(uintptr_t, ...): int32_t;
int32_t ret = 0; int32_t ret = 0;
l_1 = START(l_8); l_1 = START(l_8);
float d_2, l_2 = CALL/11(l_1, sum, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13, c_14); float d_2, l_2 = CALL/11(l_1, sum, c_4, c_5, c_6, c_7, c_8, c_9, c_10, c_11, c_12, c_13, c_14);

View File

@ -89,9 +89,9 @@ func main(void): int32_t
int32_t c_8 = 4; int32_t c_8 = 4;
int32_t c_9 = 5; int32_t c_9 = 5;
int32_t c_10 = 6; int32_t c_10 = 6;
uintptr_t c_11 = func(sum, 4); uintptr_t c_11 = func sum(int32_t, ...): int32_t;
uintptr_t c_12 = "sum %d\n"; uintptr_t c_12 = "sum %d\n";
uintptr_t c_13 = func(printf, 4); uintptr_t c_13 = func printf(uintptr_t, ...): int32_t;
int32_t c_14 = 0; int32_t c_14 = 0;
int32_t c_15 = 8; int32_t c_15 = 8;
int32_t c_16 = 9; int32_t c_16 = 9;

View File

@ -109,9 +109,9 @@ func main(void): int32_t
int32_t c_8 = 4; int32_t c_8 = 4;
int32_t c_9 = 5; int32_t c_9 = 5;
int32_t c_10 = 6; int32_t c_10 = 6;
uintptr_t c_11 = func(sum, 4); uintptr_t c_11 = func sum(int32_t, ...): int32_t;
uintptr_t c_12 = "sum %d\n"; uintptr_t c_12 = "sum %d\n";
uintptr_t c_13 = func(printf, 4); uintptr_t c_13 = func printf(uintptr_t, ...): int32_t;
int32_t c_14 = 0; int32_t c_14 = 0;
int32_t c_15 = 8; int32_t c_15 = 8;
int32_t c_16 = 9; int32_t c_16 = 9;

View File

@ -134,9 +134,9 @@ func main(void): int32_t
int32_t c_8 = 4; int32_t c_8 = 4;
int32_t c_9 = 5; int32_t c_9 = 5;
int32_t c_10 = 6; int32_t c_10 = 6;
uintptr_t c_11 = func(sum, 4); uintptr_t c_11 = func sum(int32_t, ...): double;
uintptr_t c_12 = "sum %d\n"; uintptr_t c_12 = "sum %d\n";
uintptr_t c_13 = func(printf, 4); uintptr_t c_13 = func printf(uintptr_t, ...): int32_t;
int32_t c_14 = 0; int32_t c_14 = 0;
int32_t c_15 = 8; int32_t c_15 = 8;
int32_t c_16 = 9; int32_t c_16 = 9;