mirror of
https://github.com/danog/ir.git
synced 2024-12-03 10:08:29 +01:00
examples: Add some comments to example files
Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
parent
b5bb5f869a
commit
283f443615
@ -18,10 +18,14 @@ typedef int32_t (*myfunc_t)(int32_t, int32_t);
|
||||
|
||||
void gen_myfunc(ir_ctx *ctx)
|
||||
{
|
||||
/* Function entry start */
|
||||
ir_START();
|
||||
/* Declare function parameters */
|
||||
ir_ref x = ir_PARAM(IR_I32, "x", 1);
|
||||
ir_ref y = ir_PARAM(IR_I32, "y", 2);
|
||||
/* Subtract y from x and save it into a new ref. */
|
||||
ir_ref cr = ir_SUB_I32(x, y);
|
||||
/* Function end */
|
||||
ir_RETURN(cr);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,9 @@ typedef int32_t (*myfunc_t)(void);
|
||||
|
||||
void gen_myfunc(ir_ctx *ctx)
|
||||
{
|
||||
/* Function entry start */
|
||||
ir_START();
|
||||
/* Declare loop counter. */
|
||||
ir_ref i = ir_COPY_I32(ir_CONST_I32(0));
|
||||
ir_ref loop = ir_LOOP_BEGIN(ir_END());
|
||||
ir_ref phi_i_1 = ir_PHI_2(i, IR_UNUSED);
|
||||
@ -32,6 +34,7 @@ void gen_myfunc(ir_ctx *ctx)
|
||||
ir_PHI_SET_OP(phi_i_1, 2, i_2);
|
||||
ir_IF_FALSE(cond);
|
||||
|
||||
/* Function end */
|
||||
ir_RETURN(i_2);
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,17 @@ typedef double (*myfunc_t)(double, double);
|
||||
|
||||
void gen_myfunc(ir_ctx *ctx)
|
||||
{
|
||||
/* Function entry start */
|
||||
ir_START();
|
||||
/* Declare function parameters */
|
||||
ir_ref x = ir_PARAM(IR_DOUBLE, "x", 1);
|
||||
ir_ref y = ir_PARAM(IR_DOUBLE, "y", 2);
|
||||
ir_ref cr0 = ir_SUB_D(x, y);
|
||||
|
||||
ir_ref cr0 = ir_SUB_D(x, y);
|
||||
ir_ref cd = ir_CONST_DOUBLE(.3);
|
||||
cr0 = ir_ADD_D(cr0, cd);
|
||||
|
||||
/* Function end */
|
||||
ir_RETURN(cr0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user