10 #define IF_GENBIT(bit) (UINT32_C(1) << (bit))
12 static inline unsigned int iflag_test(const iflag_t
*f
, unsigned int bit
)
14 unsigned int index
= bit
/ 32;
15 return f
->field
[index
] & (UINT32_C(1) << (bit
- (index
* 32)));
18 static inline void iflag_set(iflag_t
*f
, unsigned int bit
)
20 unsigned int index
= bit
/ 32;
21 f
->field
[index
] |= (UINT32_C(1) << (bit
- (index
* 32)));
24 static inline void iflag_clear(iflag_t
*f
, unsigned int bit
)
26 unsigned int index
= bit
/ 32;
27 f
->field
[index
] &= ~(UINT32_C(1) << (bit
- (index
* 32)));
30 static inline void iflag_clear_all(iflag_t
*f
)
32 memset(f
, 0, sizeof(*f
));
35 static inline void iflag_set_all(iflag_t
*f
)
37 memset(f
, 0xff, sizeof(*f
));
40 static inline int iflag_cmp(const iflag_t
*a
, const iflag_t
*b
)
44 for (i
= sizeof(a
->field
) / sizeof(a
->field
[0]) - 1; i
>= 0; i
--) {
45 if (a
->field
[i
] == b
->field
[i
])
48 return (a
->field
[i
] > b
->field
[i
]) ? 1 : -1;
54 static inline int iflag_cmp_cpu(const iflag_t
*a
, const iflag_t
*b
)
56 if (a
->field
[3] < b
->field
[3])
58 else if (a
->field
[3] > b
->field
[3])
63 static inline unsigned int iflag_ffs(const iflag_t
*a
)
67 for (i
= 0; i
< sizeof(a
->field
) / sizeof(a
->field
[0]); i
++) {
69 return ilog2_32(a
->field
[i
]) + (i
* 32);
75 #define IF_GEN_HELPER(name, op) \
76 static inline iflag_t iflag_##name(const iflag_t *a, const iflag_t *b) \
81 for (i = 0; i < sizeof(a->field) / sizeof(a->field[0]); i++) \
82 res.field[i] = a->field[i] op b->field[i]; \
90 /* Use this helper to test instruction template flags */
91 #define itemp_has(itemp, bit) iflag_test(&insns_flags[(itemp)->iflag_idx], bit)
94 /* Maximum processor level at moment */
95 #define IF_PLEVEL IF_IA64
96 /* Some helpers which are to work with predefined masks */
107 (IF_GENBIT(IF_AR0) |\
113 #define _itemp_smask(idx) (insns_flags[(idx)].field[0] & IF_SMASK)
114 #define _itemp_armask(idx) (insns_flags[(idx)].field[0] & IF_ARMASK)
115 #define _itemp_arg(idx) ((_itemp_armask(idx) >> IF_AR0) - 1)
117 #define itemp_smask(itemp) _itemp_smask((itemp)->iflag_idx)
118 #define itemp_arg(itemp) _itemp_arg((itemp)->iflag_idx)
119 #define itemp_armask(itemp) _itemp_armask((itemp)->iflag_idx)
121 static inline int iflag_cmp_cpu_level(const iflag_t
*a
, const iflag_t
*b
)
126 iflag_clear(&v1
, IF_CYRIX
);
127 iflag_clear(&v1
, IF_AMD
);
129 iflag_clear(&v2
, IF_CYRIX
);
130 iflag_clear(&v2
, IF_AMD
);
132 if (v1
.field
[3] < v2
.field
[3])
134 else if (v1
.field
[3] > v2
.field
[3])
140 static inline iflag_t
_iflag_pfmask(const iflag_t
*a
)
146 if (iflag_test(a
, IF_CYRIX
))
147 iflag_set(&r
, IF_CYRIX
);
148 if (iflag_test(a
, IF_AMD
))
149 iflag_set(&r
, IF_AMD
);
154 #define iflag_pfmask(itemp) _iflag_pfmask(&insns_flags[(itemp)->iflag_idx])
156 #endif /* NASM_IFLAG_H */