@@ -136,6 +136,18 @@ typedef enum _ir_type {
136
136
IR_LAST_TYPE
137
137
} ir_type ;
138
138
139
+ #ifdef IR_64
140
+ # define IR_SIZE_T IR_U64
141
+ # define IR_SSIZE_T IR_I64
142
+ # define IR_UINTPTR_T IR_U64
143
+ # define IR_INTPTR_T IR_I64
144
+ #else
145
+ # define IR_SIZE_T IR_U32
146
+ # define IR_SSIZE_T IR_I32
147
+ # define IR_UINTPTR_T IR_U32
148
+ # define IR_INTPTR_T IR_I32
149
+ #endif
150
+
139
151
/* List of IR opcodes
140
152
* ==================
141
153
*
@@ -252,6 +264,9 @@ typedef enum _ir_type {
252
264
_ (ROL , d2 , def , def , ___ ) /* rotate left */ \
253
265
_ (ROR , d2 , def , def , ___ ) /* rotate right */ \
254
266
_ (BSWAP , d1 , def , ___ , ___ ) /* byte swap */ \
267
+ _ (CTPOP , d1 , def , ___ , ___ ) /* count population */ \
268
+ _ (CTLZ , d1 , def , ___ , ___ ) /* count leading zeros */ \
269
+ _ (CTTZ , d1 , def , ___ , ___ ) /* count trailing zeros */ \
255
270
\
256
271
/* branch-less conditional ops */ \
257
272
_ (MIN , d2C , def , def , ___ ) /* min(op1, op2) */ \
@@ -262,6 +277,7 @@ typedef enum _ir_type {
262
277
_ (PHI , pN , reg , def , def ) /* SSA Phi function */ \
263
278
_ (COPY , d1X1 , def , opt , ___ ) /* COPY (last foldable op) */ \
264
279
_ (PI , p2 , reg , def , ___ ) /* e-SSA Pi constraint ??? */ \
280
+ _ (FRAME_ADDR , d0 , ___ , ___ , ___ ) /* function frame address */ \
265
281
/* (USE, RENAME) */ \
266
282
\
267
283
/* data ops */ \
@@ -290,6 +306,12 @@ typedef enum _ir_type {
290
306
_ (TRAP , x1 , src , ___ , ___ ) /* DebugBreak */ \
291
307
/* memory reference ops (A, H, U, S, TMP, STR, NEW, X, V) ??? */ \
292
308
\
309
+ /* va_args */ \
310
+ _ (VA_START , x2 , src , def , ___ ) /* va_start(va_list) */ \
311
+ _ (VA_END , x2 , src , def , ___ ) /* va_end(va_list) */ \
312
+ _ (VA_COPY , x3 , src , def , def ) /* va_copy(dst, stc) */ \
313
+ _ (VA_ARG , x2 , src , def , ___ ) /* va_arg(va_list) */ \
314
+ \
293
315
/* guards */ \
294
316
_ (GUARD , c3 , src , def , def ) /* IF without second successor */ \
295
317
_ (GUARD_NOT , c3 , src , def , def ) /* IF without second successor */ \
@@ -399,6 +421,7 @@ typedef union _ir_val {
399
421
#define IR_CONST_EMIT (1<<0)
400
422
#define IR_CONST_FASTCALL_FUNC (1<<1)
401
423
#define IR_CONST_VARARG_FUNC (1<<2)
424
+ #define IR_CONST_BUILTIN_FUNC (1<<3)
402
425
403
426
/* IR Instruction */
404
427
typedef struct _ir_insn {
@@ -473,38 +496,18 @@ void ir_strtab_free(ir_strtab *strtab);
473
496
#define IR_SKIP_PROLOGUE (1<<6) /* Don't generate function prologue. */
474
497
#define IR_USE_FRAME_POINTER (1<<7)
475
498
#define IR_PREALLOCATED_STACK (1<<8)
476
- #define IR_HAS_ALLOCA (1<<9)
477
- #define IR_HAS_CALLS (1<<10)
478
- #define IR_NO_STACK_COMBINE (1<<11)
479
- #define IR_START_BR_TARGET (1<<12)
480
- #define IR_ENTRY_BR_TARGET (1<<13)
481
- #define IR_GEN_ENDBR (1<<14)
482
- #define IR_MERGE_EMPTY_ENTRIES (1<<15)
483
-
484
- #define IR_CFG_HAS_LOOPS (1<<16)
485
- #define IR_IRREDUCIBLE_CFG (1<<17)
499
+ #define IR_NO_STACK_COMBINE (1<<9)
500
+ #define IR_START_BR_TARGET (1<<10)
501
+ #define IR_ENTRY_BR_TARGET (1<<11)
502
+ #define IR_GEN_ENDBR (1<<12)
503
+ #define IR_MERGE_EMPTY_ENTRIES (1<<13)
486
504
487
505
#define IR_OPT_FOLDING (1<<18)
488
506
#define IR_OPT_CFG (1<<19) /* merge BBs, by remove END->BEGIN nodes during CFG construction */
489
507
#define IR_OPT_CODEGEN (1<<20)
490
- #define IR_OPT_IN_SCCP (1<<21)
491
- #define IR_LINEAR (1<<22)
492
508
#define IR_GEN_NATIVE (1<<23)
493
509
#define IR_GEN_CODE (1<<24) /* C or LLVM */
494
510
495
- /* Temporary: SCCP -> CFG */
496
- #define IR_SCCP_DONE (1<<25)
497
-
498
- /* Temporary: Dominators -> Loops */
499
- #define IR_NO_LOOPS (1<<25)
500
-
501
- /* Temporary: Live Ranges */
502
- #define IR_LR_HAVE_DESSA_MOVES (1<<25)
503
-
504
- /* Temporary: Register Allocator */
505
- #define IR_RA_HAVE_SPLITS (1<<25)
506
- #define IR_RA_HAVE_SPILLS (1<<26)
507
-
508
511
/* debug related */
509
512
#ifdef IR_DEBUG
510
513
# define IR_DEBUG_SCCP (1<<27)
@@ -537,6 +540,7 @@ struct _ir_ctx {
537
540
ir_ref consts_count ; /* number of constants stored in constants buffer */
538
541
ir_ref consts_limit ; /* size of allocated constants buffer (it's extended when overflow) */
539
542
uint32_t flags ; /* IR context flags (see IR_* defines above) */
543
+ uint32_t flags2 ; /* IR context provate flags (see IR_* defines in ir_private.h) */
540
544
ir_type ret_type ; /* Function return type */
541
545
uint32_t mflags ; /* CPU specific flags (see IR_X86_... macros below) */
542
546
int32_t status ; /* non-zero error code (see IR_ERROR_... macros), app may use negative codes */
@@ -766,6 +770,7 @@ struct _ir_loader {
766
770
uint32_t flags , ir_type ret_type , uint32_t params_count , ir_type * param_types );
767
771
bool (* sym_dcl ) (ir_loader * loader , const char * name , uint32_t flags , size_t size , bool has_data );
768
772
bool (* sym_data ) (ir_loader * loader , ir_type type , uint32_t count , const void * data );
773
+ bool (* sym_data_ref ) (ir_loader * loader , ir_op op , const char * ref );
769
774
bool (* sym_data_end ) (ir_loader * loader );
770
775
bool (* func_init ) (ir_loader * loader , ir_ctx * ctx , const char * name );
771
776
bool (* func_process ) (ir_loader * loader , ir_ctx * ctx , const char * name );
@@ -816,6 +821,7 @@ int ir_patch(const void *code, size_t size, uint32_t jmp_table_size, const void
816
821
# define IR_X86_SSE42 (1<<4)
817
822
# define IR_X86_AVX (1<<5)
818
823
# define IR_X86_AVX2 (1<<6)
824
+ # define IR_X86_BMI1 (1<<7)
819
825
#endif
820
826
821
827
uint32_t ir_cpuinfo (void );
0 commit comments