/src/php-src/ext/opcache/jit/ir/ir_private.h
Line | Count | Source |
1 | | /* |
2 | | * IR - Lightweight JIT Compilation Framework |
3 | | * (Common data structures and non public definitions) |
4 | | * This file is part of the IR Project distributed under the MIT-style LICENSE. |
5 | | * Authors: Dmitry Stogov <dmitry@php.net> |
6 | | */ |
7 | | |
8 | | #ifndef IR_PRIVATE_H |
9 | | #define IR_PRIVATE_H |
10 | | #include <string.h> |
11 | | #include <stdlib.h> |
12 | | #include <stddef.h> |
13 | | |
14 | | #ifdef IR_DEBUG |
15 | | # include <assert.h> |
16 | 0 | # define IR_ASSERT(x) assert(x) |
17 | | #else |
18 | | # define IR_ASSERT(x) |
19 | | #endif |
20 | | |
21 | | #ifdef _WIN32 |
22 | | # include <intrin.h> |
23 | | # ifdef _M_X64 |
24 | | # pragma intrinsic(_BitScanForward64) |
25 | | # pragma intrinsic(_BitScanReverse64) |
26 | | # endif |
27 | | # pragma intrinsic(_BitScanForward) |
28 | | # pragma intrinsic(_BitScanReverse) |
29 | | #endif |
30 | | |
31 | | #ifdef __has_builtin |
32 | | # if __has_builtin(__builtin_expect) |
33 | 5.38M | # define EXPECTED(condition) __builtin_expect(!!(condition), 1) |
34 | 18.0M | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0) |
35 | | # endif |
36 | | # if __has_attribute(__aligned__) |
37 | | # define IR_SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment))) |
38 | | # endif |
39 | | # if __has_attribute(__fallthrough__) |
40 | 109k | # define IR_FALLTHROUGH __attribute__((__fallthrough__)) |
41 | | # endif |
42 | | #elif defined(_WIN32) |
43 | | # define IR_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl |
44 | | #else /* GCC prior to 10 or non-clang/msvc compilers */ |
45 | | #define __has_builtin(x) 0 |
46 | | #endif |
47 | | #ifndef EXPECTED |
48 | | # define EXPECTED(condition) (condition) |
49 | | # define UNEXPECTED(condition) (condition) |
50 | | #endif |
51 | | #ifndef IR_SET_ALIGNED |
52 | | # define IR_SET_ALIGNED(alignment, decl) decl |
53 | | #endif |
54 | | #ifndef IR_FALLTHROUGH |
55 | | # define IR_FALLTHROUGH ((void)0) |
56 | | #endif |
57 | | |
58 | | /*** Helper routines ***/ |
59 | | |
60 | | #define IR_ALIGNED_SIZE(size, alignment) \ |
61 | 1.19M | (((size) + ((alignment) - 1)) & ~((alignment) - 1)) |
62 | | |
63 | 24.4k | #define IR_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
64 | 1.14M | #define IR_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
65 | | |
66 | 9.08k | #define IR_IS_POWER_OF_TWO(x) ((x) && (!((x) & ((x) - 1)))) |
67 | | |
68 | 6.99k | #define IR_LOG2(x) ir_ntzl(x) |
69 | | |
70 | | IR_ALWAYS_INLINE uint8_t ir_rol8(uint8_t op1, uint8_t op2) |
71 | 0 | { |
72 | 0 | return (op1 << op2) | (op1 >> (8 - op2)); |
73 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_rol8 Unexecuted instantiation: ir_check.c:ir_rol8 Unexecuted instantiation: ir_dump.c:ir_rol8 Unexecuted instantiation: ir_emit.c:ir_rol8 Unexecuted instantiation: ir_gcm.c:ir_rol8 Unexecuted instantiation: ir_gdb.c:ir_rol8 Unexecuted instantiation: ir_patch.c:ir_rol8 Unexecuted instantiation: ir_ra.c:ir_rol8 Unexecuted instantiation: ir_ra_simple.c:ir_rol8 Unexecuted instantiation: ir_save.c:ir_rol8 Unexecuted instantiation: ir_sccp.c:ir_rol8 Unexecuted instantiation: ir_strtab.c:ir_rol8 Unexecuted instantiation: ir.c:ir_rol8 |
74 | | |
75 | | IR_ALWAYS_INLINE uint16_t ir_rol16(uint16_t op1, uint16_t op2) |
76 | 0 | { |
77 | 0 | return (op1 << op2) | (op1 >> (16 - op2)); |
78 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_rol16 Unexecuted instantiation: ir_check.c:ir_rol16 Unexecuted instantiation: ir_dump.c:ir_rol16 Unexecuted instantiation: ir_emit.c:ir_rol16 Unexecuted instantiation: ir_gcm.c:ir_rol16 Unexecuted instantiation: ir_gdb.c:ir_rol16 Unexecuted instantiation: ir_patch.c:ir_rol16 Unexecuted instantiation: ir_ra.c:ir_rol16 Unexecuted instantiation: ir_ra_simple.c:ir_rol16 Unexecuted instantiation: ir_save.c:ir_rol16 Unexecuted instantiation: ir_sccp.c:ir_rol16 Unexecuted instantiation: ir_strtab.c:ir_rol16 Unexecuted instantiation: ir.c:ir_rol16 |
79 | | |
80 | | IR_ALWAYS_INLINE uint32_t ir_rol32(uint32_t op1, uint32_t op2) |
81 | 0 | { |
82 | 0 | return (op1 << op2) | (op1 >> (32 - op2)); |
83 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_rol32 Unexecuted instantiation: ir_check.c:ir_rol32 Unexecuted instantiation: ir_dump.c:ir_rol32 Unexecuted instantiation: ir_emit.c:ir_rol32 Unexecuted instantiation: ir_gcm.c:ir_rol32 Unexecuted instantiation: ir_gdb.c:ir_rol32 Unexecuted instantiation: ir_patch.c:ir_rol32 Unexecuted instantiation: ir_ra.c:ir_rol32 Unexecuted instantiation: ir_ra_simple.c:ir_rol32 Unexecuted instantiation: ir_save.c:ir_rol32 Unexecuted instantiation: ir_sccp.c:ir_rol32 Unexecuted instantiation: ir_strtab.c:ir_rol32 Unexecuted instantiation: ir.c:ir_rol32 |
84 | | |
85 | | IR_ALWAYS_INLINE uint64_t ir_rol64(uint64_t op1, uint64_t op2) |
86 | 0 | { |
87 | 0 | return (op1 << op2) | (op1 >> (64 - op2)); |
88 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_rol64 Unexecuted instantiation: ir_check.c:ir_rol64 Unexecuted instantiation: ir_dump.c:ir_rol64 Unexecuted instantiation: ir_emit.c:ir_rol64 Unexecuted instantiation: ir_gcm.c:ir_rol64 Unexecuted instantiation: ir_gdb.c:ir_rol64 Unexecuted instantiation: ir_patch.c:ir_rol64 Unexecuted instantiation: ir_ra.c:ir_rol64 Unexecuted instantiation: ir_ra_simple.c:ir_rol64 Unexecuted instantiation: ir_save.c:ir_rol64 Unexecuted instantiation: ir_sccp.c:ir_rol64 Unexecuted instantiation: ir_strtab.c:ir_rol64 Unexecuted instantiation: ir.c:ir_rol64 |
89 | | |
90 | | IR_ALWAYS_INLINE uint8_t ir_ror8(uint8_t op1, uint8_t op2) |
91 | 0 | { |
92 | 0 | return (op1 >> op2) | (op1 << (8 - op2)); |
93 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_ror8 Unexecuted instantiation: ir_check.c:ir_ror8 Unexecuted instantiation: ir_dump.c:ir_ror8 Unexecuted instantiation: ir_emit.c:ir_ror8 Unexecuted instantiation: ir_gcm.c:ir_ror8 Unexecuted instantiation: ir_gdb.c:ir_ror8 Unexecuted instantiation: ir_patch.c:ir_ror8 Unexecuted instantiation: ir_ra.c:ir_ror8 Unexecuted instantiation: ir_ra_simple.c:ir_ror8 Unexecuted instantiation: ir_save.c:ir_ror8 Unexecuted instantiation: ir_sccp.c:ir_ror8 Unexecuted instantiation: ir_strtab.c:ir_ror8 Unexecuted instantiation: ir.c:ir_ror8 |
94 | | |
95 | | IR_ALWAYS_INLINE uint16_t ir_ror16(uint16_t op1, uint16_t op2) |
96 | 0 | { |
97 | 0 | return (op1 >> op2) | (op1 << (16 - op2)); |
98 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_ror16 Unexecuted instantiation: ir_check.c:ir_ror16 Unexecuted instantiation: ir_dump.c:ir_ror16 Unexecuted instantiation: ir_emit.c:ir_ror16 Unexecuted instantiation: ir_gcm.c:ir_ror16 Unexecuted instantiation: ir_gdb.c:ir_ror16 Unexecuted instantiation: ir_patch.c:ir_ror16 Unexecuted instantiation: ir_ra.c:ir_ror16 Unexecuted instantiation: ir_ra_simple.c:ir_ror16 Unexecuted instantiation: ir_save.c:ir_ror16 Unexecuted instantiation: ir_sccp.c:ir_ror16 Unexecuted instantiation: ir_strtab.c:ir_ror16 Unexecuted instantiation: ir.c:ir_ror16 |
99 | | |
100 | | IR_ALWAYS_INLINE uint32_t ir_ror32(uint32_t op1, uint32_t op2) |
101 | 0 | { |
102 | 0 | return (op1 >> op2) | (op1 << (32 - op2)); |
103 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_ror32 Unexecuted instantiation: ir_check.c:ir_ror32 Unexecuted instantiation: ir_dump.c:ir_ror32 Unexecuted instantiation: ir_emit.c:ir_ror32 Unexecuted instantiation: ir_gcm.c:ir_ror32 Unexecuted instantiation: ir_gdb.c:ir_ror32 Unexecuted instantiation: ir_patch.c:ir_ror32 Unexecuted instantiation: ir_ra.c:ir_ror32 Unexecuted instantiation: ir_ra_simple.c:ir_ror32 Unexecuted instantiation: ir_save.c:ir_ror32 Unexecuted instantiation: ir_sccp.c:ir_ror32 Unexecuted instantiation: ir_strtab.c:ir_ror32 Unexecuted instantiation: ir.c:ir_ror32 |
104 | | |
105 | | IR_ALWAYS_INLINE uint64_t ir_ror64(uint64_t op1, uint64_t op2) |
106 | 0 | { |
107 | 0 | return (op1 >> op2) | (op1 << (64 - op2)); |
108 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_ror64 Unexecuted instantiation: ir_check.c:ir_ror64 Unexecuted instantiation: ir_dump.c:ir_ror64 Unexecuted instantiation: ir_emit.c:ir_ror64 Unexecuted instantiation: ir_gcm.c:ir_ror64 Unexecuted instantiation: ir_gdb.c:ir_ror64 Unexecuted instantiation: ir_patch.c:ir_ror64 Unexecuted instantiation: ir_ra.c:ir_ror64 Unexecuted instantiation: ir_ra_simple.c:ir_ror64 Unexecuted instantiation: ir_save.c:ir_ror64 Unexecuted instantiation: ir_sccp.c:ir_ror64 Unexecuted instantiation: ir_strtab.c:ir_ror64 Unexecuted instantiation: ir.c:ir_ror64 |
109 | | |
110 | | /* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */ |
111 | | IR_ALWAYS_INLINE uint32_t ir_ntz(uint32_t num) |
112 | 253k | { |
113 | 253k | #if (defined(__GNUC__) || __has_builtin(__builtin_ctz)) |
114 | 253k | return __builtin_ctz(num); |
115 | | #elif defined(_WIN32) |
116 | | uint32_t index; |
117 | | |
118 | | if (!_BitScanForward(&index, num)) { |
119 | | /* undefined behavior */ |
120 | | return 32; |
121 | | } |
122 | | |
123 | | return index; |
124 | | #else |
125 | | int n; |
126 | | |
127 | | if (num == 0) return 32; |
128 | | |
129 | | n = 1; |
130 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} |
131 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} |
132 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} |
133 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} |
134 | | return n - (num & 1); |
135 | | #endif |
136 | 253k | } Unexecuted instantiation: ir_cfg.c:ir_ntz Unexecuted instantiation: ir_check.c:ir_ntz Unexecuted instantiation: ir_dump.c:ir_ntz Line | Count | Source | 112 | 24 | { | 113 | 24 | #if (defined(__GNUC__) || __has_builtin(__builtin_ctz)) | 114 | 24 | return __builtin_ctz(num); | 115 | | #elif defined(_WIN32) | 116 | | uint32_t index; | 117 | | | 118 | | if (!_BitScanForward(&index, num)) { | 119 | | /* undefined behavior */ | 120 | | return 32; | 121 | | } | 122 | | | 123 | | return index; | 124 | | #else | 125 | | int n; | 126 | | | 127 | | if (num == 0) return 32; | 128 | | | 129 | | n = 1; | 130 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 131 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 132 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 133 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 134 | | return n - (num & 1); | 135 | | #endif | 136 | 24 | } |
Unexecuted instantiation: ir_gcm.c:ir_ntz Unexecuted instantiation: ir_gdb.c:ir_ntz Unexecuted instantiation: ir_patch.c:ir_ntz Line | Count | Source | 112 | 253k | { | 113 | 253k | #if (defined(__GNUC__) || __has_builtin(__builtin_ctz)) | 114 | 253k | return __builtin_ctz(num); | 115 | | #elif defined(_WIN32) | 116 | | uint32_t index; | 117 | | | 118 | | if (!_BitScanForward(&index, num)) { | 119 | | /* undefined behavior */ | 120 | | return 32; | 121 | | } | 122 | | | 123 | | return index; | 124 | | #else | 125 | | int n; | 126 | | | 127 | | if (num == 0) return 32; | 128 | | | 129 | | n = 1; | 130 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 131 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 132 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 133 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 134 | | return n - (num & 1); | 135 | | #endif | 136 | 253k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_ntz Unexecuted instantiation: ir_save.c:ir_ntz Unexecuted instantiation: ir_sccp.c:ir_ntz Unexecuted instantiation: ir_strtab.c:ir_ntz Unexecuted instantiation: ir.c:ir_ntz |
137 | | |
138 | | /* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */ |
139 | | IR_ALWAYS_INLINE uint32_t ir_ntzl(uint64_t num) |
140 | 2.50M | { |
141 | | // Note that the _WIN64 case should come before __has_builtin() below so that |
142 | | // clang-cl on Windows will use the uint64_t version, not the "long" uint32_t |
143 | | // version. |
144 | | #if defined(_WIN64) |
145 | | unsigned long index; |
146 | | |
147 | | if (!_BitScanForward64(&index, num)) { |
148 | | /* undefined behavior */ |
149 | | return 64; |
150 | | } |
151 | | |
152 | | return (uint32_t) index; |
153 | | #elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) |
154 | | return __builtin_ctzl(num); |
155 | | #else |
156 | | uint32_t n; |
157 | | |
158 | | if (num == 0) return 64; |
159 | | |
160 | | n = 1; |
161 | | if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;} |
162 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} |
163 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} |
164 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} |
165 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} |
166 | | return n - (uint32_t)(num & 1); |
167 | | #endif |
168 | 2.50M | } Line | Count | Source | 140 | 534k | { | 141 | | // Note that the _WIN64 case should come before __has_builtin() below so that | 142 | | // clang-cl on Windows will use the uint64_t version, not the "long" uint32_t | 143 | | // version. | 144 | | #if defined(_WIN64) | 145 | | unsigned long index; | 146 | | | 147 | | if (!_BitScanForward64(&index, num)) { | 148 | | /* undefined behavior */ | 149 | | return 64; | 150 | | } | 151 | | | 152 | | return (uint32_t) index; | 153 | | #elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) | 154 | | return __builtin_ctzl(num); | 155 | | #else | 156 | | uint32_t n; | 157 | | | 158 | | if (num == 0) return 64; | 159 | | | 160 | | n = 1; | 161 | | if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;} | 162 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 163 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 164 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 165 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 166 | | return n - (uint32_t)(num & 1); | 167 | | #endif | 168 | 534k | } |
Unexecuted instantiation: ir_check.c:ir_ntzl Unexecuted instantiation: ir_dump.c:ir_ntzl Line | Count | Source | 140 | 7.25k | { | 141 | | // Note that the _WIN64 case should come before __has_builtin() below so that | 142 | | // clang-cl on Windows will use the uint64_t version, not the "long" uint32_t | 143 | | // version. | 144 | | #if defined(_WIN64) | 145 | | unsigned long index; | 146 | | | 147 | | if (!_BitScanForward64(&index, num)) { | 148 | | /* undefined behavior */ | 149 | | return 64; | 150 | | } | 151 | | | 152 | | return (uint32_t) index; | 153 | | #elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) | 154 | | return __builtin_ctzl(num); | 155 | | #else | 156 | | uint32_t n; | 157 | | | 158 | | if (num == 0) return 64; | 159 | | | 160 | | n = 1; | 161 | | if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;} | 162 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 163 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 164 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 165 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 166 | | return n - (uint32_t)(num & 1); | 167 | | #endif | 168 | 7.25k | } |
Unexecuted instantiation: ir_gcm.c:ir_ntzl Unexecuted instantiation: ir_gdb.c:ir_ntzl Unexecuted instantiation: ir_patch.c:ir_ntzl Line | Count | Source | 140 | 325 | { | 141 | | // Note that the _WIN64 case should come before __has_builtin() below so that | 142 | | // clang-cl on Windows will use the uint64_t version, not the "long" uint32_t | 143 | | // version. | 144 | | #if defined(_WIN64) | 145 | | unsigned long index; | 146 | | | 147 | | if (!_BitScanForward64(&index, num)) { | 148 | | /* undefined behavior */ | 149 | | return 64; | 150 | | } | 151 | | | 152 | | return (uint32_t) index; | 153 | | #elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) | 154 | | return __builtin_ctzl(num); | 155 | | #else | 156 | | uint32_t n; | 157 | | | 158 | | if (num == 0) return 64; | 159 | | | 160 | | n = 1; | 161 | | if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;} | 162 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 163 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 164 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 165 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 166 | | return n - (uint32_t)(num & 1); | 167 | | #endif | 168 | 325 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_ntzl Unexecuted instantiation: ir_save.c:ir_ntzl Line | Count | Source | 140 | 1.96M | { | 141 | | // Note that the _WIN64 case should come before __has_builtin() below so that | 142 | | // clang-cl on Windows will use the uint64_t version, not the "long" uint32_t | 143 | | // version. | 144 | | #if defined(_WIN64) | 145 | | unsigned long index; | 146 | | | 147 | | if (!_BitScanForward64(&index, num)) { | 148 | | /* undefined behavior */ | 149 | | return 64; | 150 | | } | 151 | | | 152 | | return (uint32_t) index; | 153 | | #elif (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) | 154 | | return __builtin_ctzl(num); | 155 | | #else | 156 | | uint32_t n; | 157 | | | 158 | | if (num == 0) return 64; | 159 | | | 160 | | n = 1; | 161 | | if ((num & 0xffffffff) == 0) {n += 32; num = num >> 32;} | 162 | | if ((num & 0x0000ffff) == 0) {n += 16; num = num >> 16;} | 163 | | if ((num & 0x000000ff) == 0) {n += 8; num = num >> 8;} | 164 | | if ((num & 0x0000000f) == 0) {n += 4; num = num >> 4;} | 165 | | if ((num & 0x00000003) == 0) {n += 2; num = num >> 2;} | 166 | | return n - (uint32_t)(num & 1); | 167 | | #endif | 168 | 1.96M | } |
Unexecuted instantiation: ir_strtab.c:ir_ntzl Unexecuted instantiation: ir.c:ir_ntzl |
169 | | |
170 | | /* Number of leading zero bits (Undefined for zero) */ |
171 | | IR_ALWAYS_INLINE int ir_nlz(uint32_t num) |
172 | 0 | { |
173 | 0 | #if (defined(__GNUC__) || __has_builtin(__builtin_clz)) |
174 | 0 | return __builtin_clz(num); |
175 | 0 | #elif defined(_WIN32) |
176 | 0 | uint32_t index; |
177 | 0 |
|
178 | 0 | if (!_BitScanReverse(&index, num)) { |
179 | 0 | /* undefined behavior */ |
180 | 0 | return 32; |
181 | 0 | } |
182 | 0 |
|
183 | 0 | return (int) (32 - 1) - index; |
184 | 0 | #else |
185 | 0 | uint32_t x; |
186 | 0 | uint32_t n; |
187 | 0 |
|
188 | 0 | n = 32; |
189 | 0 | x = num >> 16; if (x != 0) {n -= 16; num = x;} |
190 | 0 | x = num >> 8; if (x != 0) {n -= 8; num = x;} |
191 | 0 | x = num >> 4; if (x != 0) {n -= 4; num = x;} |
192 | 0 | x = num >> 2; if (x != 0) {n -= 2; num = x;} |
193 | 0 | x = num >> 1; if (x != 0) return n - 2; |
194 | 0 | return n - num; |
195 | 0 | #endif |
196 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_nlz Unexecuted instantiation: ir_check.c:ir_nlz Unexecuted instantiation: ir_dump.c:ir_nlz Unexecuted instantiation: ir_emit.c:ir_nlz Unexecuted instantiation: ir_gcm.c:ir_nlz Unexecuted instantiation: ir_gdb.c:ir_nlz Unexecuted instantiation: ir_patch.c:ir_nlz Unexecuted instantiation: ir_ra.c:ir_nlz Unexecuted instantiation: ir_ra_simple.c:ir_nlz Unexecuted instantiation: ir_save.c:ir_nlz Unexecuted instantiation: ir_sccp.c:ir_nlz Unexecuted instantiation: ir_strtab.c:ir_nlz Unexecuted instantiation: ir.c:ir_nlz |
197 | | |
198 | | IR_ALWAYS_INLINE int ir_nlzl(uint64_t num) |
199 | 0 | { |
200 | 0 | #if (defined(__GNUC__) || __has_builtin(__builtin_clzll)) |
201 | 0 | return __builtin_clzll(num); |
202 | 0 | #elif defined(_WIN64) |
203 | 0 | unsigned long index; |
204 | 0 |
|
205 | 0 | if (!_BitScanReverse64(&index, num)) { |
206 | 0 | /* undefined behavior */ |
207 | 0 | return 64; |
208 | 0 | } |
209 | 0 |
|
210 | 0 | return (int) (64 - 1) - index; |
211 | 0 | #else |
212 | 0 | uint64_t x; |
213 | 0 | uint32_t n; |
214 | 0 |
|
215 | 0 | n = 64; |
216 | 0 | x = num >> 32; if (x != 0) {n -= 32; num = x;} |
217 | 0 | x = num >> 16; if (x != 0) {n -= 16; num = x;} |
218 | 0 | x = num >> 8; if (x != 0) {n -= 8; num = x;} |
219 | 0 | x = num >> 4; if (x != 0) {n -= 4; num = x;} |
220 | 0 | x = num >> 2; if (x != 0) {n -= 2; num = x;} |
221 | 0 | x = num >> 1; if (x != 0) return n - 2; |
222 | 0 | return n - (uint32_t)num; |
223 | 0 | #endif |
224 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_nlzl Unexecuted instantiation: ir_check.c:ir_nlzl Unexecuted instantiation: ir_dump.c:ir_nlzl Unexecuted instantiation: ir_emit.c:ir_nlzl Unexecuted instantiation: ir_gcm.c:ir_nlzl Unexecuted instantiation: ir_gdb.c:ir_nlzl Unexecuted instantiation: ir_patch.c:ir_nlzl Unexecuted instantiation: ir_ra.c:ir_nlzl Unexecuted instantiation: ir_ra_simple.c:ir_nlzl Unexecuted instantiation: ir_save.c:ir_nlzl Unexecuted instantiation: ir_sccp.c:ir_nlzl Unexecuted instantiation: ir_strtab.c:ir_nlzl Unexecuted instantiation: ir.c:ir_nlzl |
225 | | |
226 | | /*** Helper data types ***/ |
227 | | |
228 | | /* Arena */ |
229 | | struct _ir_arena { |
230 | | char *ptr; |
231 | | char *end; |
232 | | ir_arena *prev; |
233 | | }; |
234 | | |
235 | | IR_ALWAYS_INLINE ir_arena* ir_arena_create(size_t size) |
236 | 9.97k | { |
237 | 9.97k | ir_arena *arena; |
238 | | |
239 | 9.97k | IR_ASSERT(size >= IR_ALIGNED_SIZE(sizeof(ir_arena), 8)); |
240 | 9.97k | arena = (ir_arena*)ir_mem_malloc(size); |
241 | 9.97k | if (UNEXPECTED(!arena))return NULL; |
242 | 9.97k | arena->ptr = (char*) arena + IR_ALIGNED_SIZE(sizeof(ir_arena), 8); |
243 | 9.97k | arena->end = (char*) arena + size; |
244 | 9.97k | arena->prev = NULL; |
245 | 9.97k | return arena; |
246 | 9.97k | } Unexecuted instantiation: ir_cfg.c:ir_arena_create ir_check.c:ir_arena_create Line | Count | Source | 236 | 32 | { | 237 | 32 | ir_arena *arena; | 238 | | | 239 | 32 | IR_ASSERT(size >= IR_ALIGNED_SIZE(sizeof(ir_arena), 8)); | 240 | 32 | arena = (ir_arena*)ir_mem_malloc(size); | 241 | 32 | if (UNEXPECTED(!arena))return NULL; | 242 | 32 | arena->ptr = (char*) arena + IR_ALIGNED_SIZE(sizeof(ir_arena), 8); | 243 | 32 | arena->end = (char*) arena + size; | 244 | | arena->prev = NULL; | 245 | 32 | return arena; | 246 | 32 | } |
Unexecuted instantiation: ir_dump.c:ir_arena_create Unexecuted instantiation: ir_emit.c:ir_arena_create Unexecuted instantiation: ir_gcm.c:ir_arena_create Unexecuted instantiation: ir_gdb.c:ir_arena_create Unexecuted instantiation: ir_patch.c:ir_arena_create Line | Count | Source | 236 | 9.93k | { | 237 | 9.93k | ir_arena *arena; | 238 | | | 239 | 9.93k | IR_ASSERT(size >= IR_ALIGNED_SIZE(sizeof(ir_arena), 8)); | 240 | 9.93k | arena = (ir_arena*)ir_mem_malloc(size); | 241 | 9.93k | if (UNEXPECTED(!arena))return NULL; | 242 | 9.93k | arena->ptr = (char*) arena + IR_ALIGNED_SIZE(sizeof(ir_arena), 8); | 243 | 9.93k | arena->end = (char*) arena + size; | 244 | | arena->prev = NULL; | 245 | 9.93k | return arena; | 246 | 9.93k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_arena_create Unexecuted instantiation: ir_save.c:ir_arena_create Unexecuted instantiation: ir_sccp.c:ir_arena_create Unexecuted instantiation: ir_strtab.c:ir_arena_create Unexecuted instantiation: ir.c:ir_arena_create |
247 | | |
248 | | IR_ALWAYS_INLINE void ir_arena_free(ir_arena *arena) |
249 | 9.97k | { |
250 | 10.1k | do { |
251 | 10.1k | ir_arena *prev = arena->prev; |
252 | 10.1k | ir_mem_free(arena); |
253 | 10.1k | arena = prev; |
254 | 10.1k | } while (arena); |
255 | 9.97k | } Unexecuted instantiation: ir_cfg.c:ir_arena_free Line | Count | Source | 249 | 32 | { | 250 | 34 | do { | 251 | 34 | ir_arena *prev = arena->prev; | 252 | 34 | ir_mem_free(arena); | 253 | 34 | arena = prev; | 254 | 34 | } while (arena); | 255 | 32 | } |
Unexecuted instantiation: ir_dump.c:ir_arena_free Unexecuted instantiation: ir_emit.c:ir_arena_free Unexecuted instantiation: ir_gcm.c:ir_arena_free Unexecuted instantiation: ir_gdb.c:ir_arena_free Unexecuted instantiation: ir_patch.c:ir_arena_free Unexecuted instantiation: ir_ra.c:ir_arena_free Unexecuted instantiation: ir_ra_simple.c:ir_arena_free Unexecuted instantiation: ir_save.c:ir_arena_free Unexecuted instantiation: ir_sccp.c:ir_arena_free Unexecuted instantiation: ir_strtab.c:ir_arena_free Line | Count | Source | 249 | 9.93k | { | 250 | 10.1k | do { | 251 | 10.1k | ir_arena *prev = arena->prev; | 252 | 10.1k | ir_mem_free(arena); | 253 | 10.1k | arena = prev; | 254 | 10.1k | } while (arena); | 255 | 9.93k | } |
|
256 | | |
257 | | IR_ALWAYS_INLINE void* ir_arena_alloc_aligned(ir_arena **arena_ptr, size_t size, size_t align) |
258 | 1.05M | { |
259 | 1.05M | ir_arena *arena = *arena_ptr; |
260 | 1.05M | char *ptr; |
261 | | |
262 | 1.05M | if (align < 8) { |
263 | 0 | align = 8; |
264 | 0 | } |
265 | 1.05M | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)arena->ptr, align); |
266 | 1.05M | if (EXPECTED((ptrdiff_t)size <= (ptrdiff_t)(arena->end - ptr))) { |
267 | 1.05M | arena->ptr = ptr + size; |
268 | 1.05M | } else { |
269 | 184 | size_t hdr_size = IR_ALIGNED_SIZE(sizeof(ir_arena), align); |
270 | 184 | size_t arena_size = |
271 | 184 | UNEXPECTED((size + hdr_size) > (size_t)(arena->end - (char*) arena)) ? |
272 | 0 | (size + hdr_size) : |
273 | 184 | (size_t)(arena->end - (char*)arena); |
274 | 184 | ir_arena *new_arena; |
275 | | |
276 | 184 | if (align > 16) arena_size += IR_ALIGNED_SIZE(align, 16); |
277 | 184 | new_arena = (ir_arena*)ir_mem_malloc(arena_size); |
278 | 184 | if (UNEXPECTED(!new_arena)) return NULL; |
279 | 184 | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)new_arena + sizeof(ir_arena), align); |
280 | 184 | new_arena->ptr = (char*) ptr + size; |
281 | 184 | new_arena->end = (char*) new_arena + arena_size; |
282 | 184 | new_arena->prev = arena; |
283 | 184 | *arena_ptr = new_arena; |
284 | 184 | } |
285 | | |
286 | 1.05M | return (void*) ptr; |
287 | 1.05M | } Unexecuted instantiation: ir_cfg.c:ir_arena_alloc_aligned ir_check.c:ir_arena_alloc_aligned Line | Count | Source | 258 | 66 | { | 259 | 66 | ir_arena *arena = *arena_ptr; | 260 | 66 | char *ptr; | 261 | | | 262 | 66 | if (align < 8) { | 263 | 0 | align = 8; | 264 | 0 | } | 265 | 66 | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)arena->ptr, align); | 266 | 66 | if (EXPECTED((ptrdiff_t)size <= (ptrdiff_t)(arena->end - ptr))) { | 267 | 64 | arena->ptr = ptr + size; | 268 | 64 | } else { | 269 | 2 | size_t hdr_size = IR_ALIGNED_SIZE(sizeof(ir_arena), align); | 270 | 2 | size_t arena_size = | 271 | 2 | UNEXPECTED((size + hdr_size) > (size_t)(arena->end - (char*) arena)) ? | 272 | 0 | (size + hdr_size) : | 273 | 2 | (size_t)(arena->end - (char*)arena); | 274 | 2 | ir_arena *new_arena; | 275 | | | 276 | 2 | if (align > 16) arena_size += IR_ALIGNED_SIZE(align, 16); | 277 | 2 | new_arena = (ir_arena*)ir_mem_malloc(arena_size); | 278 | 2 | if (UNEXPECTED(!new_arena)) return NULL; | 279 | 2 | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)new_arena + sizeof(ir_arena), align); | 280 | 2 | new_arena->ptr = (char*) ptr + size; | 281 | 2 | new_arena->end = (char*) new_arena + arena_size; | 282 | 2 | new_arena->prev = arena; | 283 | 2 | *arena_ptr = new_arena; | 284 | 2 | } | 285 | | | 286 | 66 | return (void*) ptr; | 287 | 66 | } |
Unexecuted instantiation: ir_dump.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_emit.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_gcm.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_gdb.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_patch.c:ir_arena_alloc_aligned ir_ra.c:ir_arena_alloc_aligned Line | Count | Source | 258 | 1.05M | { | 259 | 1.05M | ir_arena *arena = *arena_ptr; | 260 | 1.05M | char *ptr; | 261 | | | 262 | 1.05M | if (align < 8) { | 263 | 0 | align = 8; | 264 | 0 | } | 265 | 1.05M | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)arena->ptr, align); | 266 | 1.05M | if (EXPECTED((ptrdiff_t)size <= (ptrdiff_t)(arena->end - ptr))) { | 267 | 1.05M | arena->ptr = ptr + size; | 268 | 1.05M | } else { | 269 | 182 | size_t hdr_size = IR_ALIGNED_SIZE(sizeof(ir_arena), align); | 270 | 182 | size_t arena_size = | 271 | 182 | UNEXPECTED((size + hdr_size) > (size_t)(arena->end - (char*) arena)) ? | 272 | 0 | (size + hdr_size) : | 273 | 182 | (size_t)(arena->end - (char*)arena); | 274 | 182 | ir_arena *new_arena; | 275 | | | 276 | 182 | if (align > 16) arena_size += IR_ALIGNED_SIZE(align, 16); | 277 | 182 | new_arena = (ir_arena*)ir_mem_malloc(arena_size); | 278 | 182 | if (UNEXPECTED(!new_arena)) return NULL; | 279 | 182 | ptr = (char*)IR_ALIGNED_SIZE((uintptr_t)new_arena + sizeof(ir_arena), align); | 280 | 182 | new_arena->ptr = (char*) ptr + size; | 281 | 182 | new_arena->end = (char*) new_arena + arena_size; | 282 | 182 | new_arena->prev = arena; | 283 | 182 | *arena_ptr = new_arena; | 284 | 182 | } | 285 | | | 286 | 1.05M | return (void*) ptr; | 287 | 1.05M | } |
Unexecuted instantiation: ir_ra_simple.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_save.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_sccp.c:ir_arena_alloc_aligned Unexecuted instantiation: ir_strtab.c:ir_arena_alloc_aligned Unexecuted instantiation: ir.c:ir_arena_alloc_aligned |
288 | | |
289 | | IR_ALWAYS_INLINE void* ir_arena_alloc(ir_arena **arena_ptr, size_t size) |
290 | 1.05M | { |
291 | 1.05M | return ir_arena_alloc_aligned(arena_ptr, size, 8); |
292 | 1.05M | } Unexecuted instantiation: ir_cfg.c:ir_arena_alloc ir_check.c:ir_arena_alloc Line | Count | Source | 290 | 66 | { | 291 | 66 | return ir_arena_alloc_aligned(arena_ptr, size, 8); | 292 | 66 | } |
Unexecuted instantiation: ir_dump.c:ir_arena_alloc Unexecuted instantiation: ir_emit.c:ir_arena_alloc Unexecuted instantiation: ir_gcm.c:ir_arena_alloc Unexecuted instantiation: ir_gdb.c:ir_arena_alloc Unexecuted instantiation: ir_patch.c:ir_arena_alloc Line | Count | Source | 290 | 1.05M | { | 291 | 1.05M | return ir_arena_alloc_aligned(arena_ptr, size, 8); | 292 | 1.05M | } |
Unexecuted instantiation: ir_ra_simple.c:ir_arena_alloc Unexecuted instantiation: ir_save.c:ir_arena_alloc Unexecuted instantiation: ir_sccp.c:ir_arena_alloc Unexecuted instantiation: ir_strtab.c:ir_arena_alloc Unexecuted instantiation: ir.c:ir_arena_alloc |
293 | | |
294 | | IR_ALWAYS_INLINE void* ir_arena_checkpoint(ir_arena *arena) |
295 | 0 | { |
296 | 0 | return arena->ptr; |
297 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_arena_checkpoint Unexecuted instantiation: ir_check.c:ir_arena_checkpoint Unexecuted instantiation: ir_dump.c:ir_arena_checkpoint Unexecuted instantiation: ir_emit.c:ir_arena_checkpoint Unexecuted instantiation: ir_gcm.c:ir_arena_checkpoint Unexecuted instantiation: ir_gdb.c:ir_arena_checkpoint Unexecuted instantiation: ir_patch.c:ir_arena_checkpoint Unexecuted instantiation: ir_ra.c:ir_arena_checkpoint Unexecuted instantiation: ir_ra_simple.c:ir_arena_checkpoint Unexecuted instantiation: ir_save.c:ir_arena_checkpoint Unexecuted instantiation: ir_sccp.c:ir_arena_checkpoint Unexecuted instantiation: ir_strtab.c:ir_arena_checkpoint Unexecuted instantiation: ir.c:ir_arena_checkpoint |
298 | | |
299 | | IR_ALWAYS_INLINE void ir_arena_release(ir_arena **arena_ptr, void *checkpoint) |
300 | 0 | { |
301 | 0 | ir_arena *arena = *arena_ptr; |
302 | 0 |
|
303 | 0 | while (UNEXPECTED((char*)checkpoint > arena->end) || |
304 | 0 | UNEXPECTED((char*)checkpoint <= (char*)arena)) { |
305 | 0 | ir_arena *prev = arena->prev; |
306 | 0 | ir_mem_free(arena); |
307 | 0 | *arena_ptr = arena = prev; |
308 | 0 | } |
309 | 0 | IR_ASSERT((char*)checkpoint > (char*)arena && (char*)checkpoint <= arena->end); |
310 | 0 | arena->ptr = (char*)checkpoint; |
311 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_arena_release Unexecuted instantiation: ir_check.c:ir_arena_release Unexecuted instantiation: ir_dump.c:ir_arena_release Unexecuted instantiation: ir_emit.c:ir_arena_release Unexecuted instantiation: ir_gcm.c:ir_arena_release Unexecuted instantiation: ir_gdb.c:ir_arena_release Unexecuted instantiation: ir_patch.c:ir_arena_release Unexecuted instantiation: ir_ra.c:ir_arena_release Unexecuted instantiation: ir_ra_simple.c:ir_arena_release Unexecuted instantiation: ir_save.c:ir_arena_release Unexecuted instantiation: ir_sccp.c:ir_arena_release Unexecuted instantiation: ir_strtab.c:ir_arena_release Unexecuted instantiation: ir.c:ir_arena_release |
312 | | |
313 | | /* Bitsets */ |
314 | | #if defined(IR_TARGET_X86) |
315 | | # define IR_BITSET_BITS 32 |
316 | | # define IR_BITSET_ONE 1U |
317 | | # define ir_bitset_base_t uint32_t |
318 | | # define ir_bitset_ntz ir_ntz |
319 | | #else |
320 | 16.4M | # define IR_BITSET_BITS 64 |
321 | | # ifdef _M_X64 /* MSVC*/ |
322 | | # define IR_BITSET_ONE 1ui64 |
323 | | # else |
324 | 6.84M | # define IR_BITSET_ONE 1UL |
325 | | # endif |
326 | 2.29M | # define ir_bitset_base_t uint64_t |
327 | 2.49M | # define ir_bitset_ntz ir_ntzl |
328 | | #endif |
329 | | |
330 | | typedef ir_bitset_base_t *ir_bitset; |
331 | | |
332 | | IR_ALWAYS_INLINE uint32_t ir_bitset_len(uint32_t n) |
333 | 121k | { |
334 | 121k | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; |
335 | 121k | } Line | Count | Source | 333 | 49.8k | { | 334 | 49.8k | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; | 335 | 49.8k | } |
Line | Count | Source | 333 | 100 | { | 334 | 100 | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; | 335 | 100 | } |
Unexecuted instantiation: ir_dump.c:ir_bitset_len Line | Count | Source | 333 | 19.8k | { | 334 | 19.8k | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; | 335 | 19.8k | } |
Unexecuted instantiation: ir_gcm.c:ir_bitset_len Unexecuted instantiation: ir_gdb.c:ir_bitset_len Unexecuted instantiation: ir_patch.c:ir_bitset_len Line | Count | Source | 333 | 11.4k | { | 334 | 11.4k | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; | 335 | 11.4k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_bitset_len Unexecuted instantiation: ir_save.c:ir_bitset_len Line | Count | Source | 333 | 39.7k | { | 334 | 39.7k | return (n + (IR_BITSET_BITS - 1)) / IR_BITSET_BITS; | 335 | 39.7k | } |
Unexecuted instantiation: ir_strtab.c:ir_bitset_len Unexecuted instantiation: ir.c:ir_bitset_len |
336 | | |
337 | | IR_ALWAYS_INLINE ir_bitset ir_bitset_malloc(uint32_t n) |
338 | 70.1k | { |
339 | 70.1k | return ir_mem_calloc(ir_bitset_len(n), IR_BITSET_BITS / 8); |
340 | 70.1k | } ir_cfg.c:ir_bitset_malloc Line | Count | Source | 338 | 29.8k | { | 339 | | return ir_mem_calloc(ir_bitset_len(n), IR_BITSET_BITS / 8); | 340 | 29.8k | } |
Unexecuted instantiation: ir_check.c:ir_bitset_malloc Unexecuted instantiation: ir_dump.c:ir_bitset_malloc ir_emit.c:ir_bitset_malloc Line | Count | Source | 338 | 9.93k | { | 339 | | return ir_mem_calloc(ir_bitset_len(n), IR_BITSET_BITS / 8); | 340 | 9.93k | } |
Unexecuted instantiation: ir_gcm.c:ir_bitset_malloc Unexecuted instantiation: ir_gdb.c:ir_bitset_malloc Unexecuted instantiation: ir_patch.c:ir_bitset_malloc Line | Count | Source | 338 | 10.4k | { | 339 | | return ir_mem_calloc(ir_bitset_len(n), IR_BITSET_BITS / 8); | 340 | 10.4k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_bitset_malloc Unexecuted instantiation: ir_save.c:ir_bitset_malloc ir_sccp.c:ir_bitset_malloc Line | Count | Source | 338 | 19.8k | { | 339 | | return ir_mem_calloc(ir_bitset_len(n), IR_BITSET_BITS / 8); | 340 | 19.8k | } |
Unexecuted instantiation: ir_strtab.c:ir_bitset_malloc Unexecuted instantiation: ir.c:ir_bitset_malloc |
341 | | |
342 | | IR_ALWAYS_INLINE void ir_bitset_incl(ir_bitset set, uint32_t n) |
343 | 1.60M | { |
344 | 1.60M | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); |
345 | 1.60M | } Line | Count | Source | 343 | 1.55M | { | 344 | 1.55M | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 345 | 1.55M | } |
ir_check.c:ir_bitset_incl Line | Count | Source | 343 | 612 | { | 344 | 612 | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 345 | 612 | } |
Unexecuted instantiation: ir_dump.c:ir_bitset_incl Line | Count | Source | 343 | 735 | { | 344 | 735 | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 345 | 735 | } |
Unexecuted instantiation: ir_gcm.c:ir_bitset_incl Unexecuted instantiation: ir_gdb.c:ir_bitset_incl Unexecuted instantiation: ir_patch.c:ir_bitset_incl Line | Count | Source | 343 | 42.9k | { | 344 | 42.9k | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 345 | 42.9k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_bitset_incl Unexecuted instantiation: ir_save.c:ir_bitset_incl Line | Count | Source | 343 | 9.98k | { | 344 | 9.98k | set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 345 | 9.98k | } |
Unexecuted instantiation: ir_strtab.c:ir_bitset_incl Unexecuted instantiation: ir.c:ir_bitset_incl |
346 | | |
347 | | IR_ALWAYS_INLINE void ir_bitset_excl(ir_bitset set, uint32_t n) |
348 | 164k | { |
349 | 164k | set[n / IR_BITSET_BITS] &= ~(IR_BITSET_ONE << (n % IR_BITSET_BITS)); |
350 | 164k | } Line | Count | Source | 348 | 164k | { | 349 | 164k | set[n / IR_BITSET_BITS] &= ~(IR_BITSET_ONE << (n % IR_BITSET_BITS)); | 350 | 164k | } |
Unexecuted instantiation: ir_check.c:ir_bitset_excl Unexecuted instantiation: ir_dump.c:ir_bitset_excl Unexecuted instantiation: ir_emit.c:ir_bitset_excl Unexecuted instantiation: ir_gcm.c:ir_bitset_excl Unexecuted instantiation: ir_gdb.c:ir_bitset_excl Unexecuted instantiation: ir_patch.c:ir_bitset_excl Unexecuted instantiation: ir_ra.c:ir_bitset_excl Unexecuted instantiation: ir_ra_simple.c:ir_bitset_excl Unexecuted instantiation: ir_save.c:ir_bitset_excl Unexecuted instantiation: ir_sccp.c:ir_bitset_excl Unexecuted instantiation: ir_strtab.c:ir_bitset_excl Unexecuted instantiation: ir.c:ir_bitset_excl |
351 | | |
352 | | IR_ALWAYS_INLINE bool ir_bitset_in(const ir_bitset set, uint32_t n) |
353 | 1.94M | { |
354 | 1.94M | return (set[(n / IR_BITSET_BITS)] & (IR_BITSET_ONE << (n % IR_BITSET_BITS))) != 0; |
355 | 1.94M | } Line | Count | Source | 353 | 1.89M | { | 354 | 1.89M | return (set[(n / IR_BITSET_BITS)] & (IR_BITSET_ONE << (n % IR_BITSET_BITS))) != 0; | 355 | 1.89M | } |
Line | Count | Source | 353 | 612 | { | 354 | 612 | return (set[(n / IR_BITSET_BITS)] & (IR_BITSET_ONE << (n % IR_BITSET_BITS))) != 0; | 355 | 612 | } |
Unexecuted instantiation: ir_dump.c:ir_bitset_in Unexecuted instantiation: ir_emit.c:ir_bitset_in Unexecuted instantiation: ir_gcm.c:ir_bitset_in Unexecuted instantiation: ir_gdb.c:ir_bitset_in Unexecuted instantiation: ir_patch.c:ir_bitset_in Line | Count | Source | 353 | 42.6k | { | 354 | 42.6k | return (set[(n / IR_BITSET_BITS)] & (IR_BITSET_ONE << (n % IR_BITSET_BITS))) != 0; | 355 | 42.6k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_bitset_in Unexecuted instantiation: ir_save.c:ir_bitset_in Unexecuted instantiation: ir_sccp.c:ir_bitset_in Unexecuted instantiation: ir_strtab.c:ir_bitset_in Unexecuted instantiation: ir.c:ir_bitset_in |
356 | | |
357 | | IR_ALWAYS_INLINE void ir_bitset_clear(ir_bitset set, uint32_t len) |
358 | 4.19k | { |
359 | 4.19k | memset(set, 0, len * (IR_BITSET_BITS / 8)); |
360 | 4.19k | } Line | Count | Source | 358 | 3.21k | { | 359 | 3.21k | memset(set, 0, len * (IR_BITSET_BITS / 8)); | 360 | 3.21k | } |
Unexecuted instantiation: ir_check.c:ir_bitset_clear Unexecuted instantiation: ir_dump.c:ir_bitset_clear Unexecuted instantiation: ir_emit.c:ir_bitset_clear Unexecuted instantiation: ir_gcm.c:ir_bitset_clear Unexecuted instantiation: ir_gdb.c:ir_bitset_clear Unexecuted instantiation: ir_patch.c:ir_bitset_clear Line | Count | Source | 358 | 973 | { | 359 | 973 | memset(set, 0, len * (IR_BITSET_BITS / 8)); | 360 | 973 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_bitset_clear Unexecuted instantiation: ir_save.c:ir_bitset_clear Unexecuted instantiation: ir_sccp.c:ir_bitset_clear Unexecuted instantiation: ir_strtab.c:ir_bitset_clear Unexecuted instantiation: ir.c:ir_bitset_clear |
361 | | |
362 | | IR_ALWAYS_INLINE void ir_bitset_fill(ir_bitset set, uint32_t len) |
363 | 0 | { |
364 | 0 | memset(set, 0xff, len * (IR_BITSET_BITS / 8)); |
365 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_fill Unexecuted instantiation: ir_check.c:ir_bitset_fill Unexecuted instantiation: ir_dump.c:ir_bitset_fill Unexecuted instantiation: ir_emit.c:ir_bitset_fill Unexecuted instantiation: ir_gcm.c:ir_bitset_fill Unexecuted instantiation: ir_gdb.c:ir_bitset_fill Unexecuted instantiation: ir_patch.c:ir_bitset_fill Unexecuted instantiation: ir_ra.c:ir_bitset_fill Unexecuted instantiation: ir_ra_simple.c:ir_bitset_fill Unexecuted instantiation: ir_save.c:ir_bitset_fill Unexecuted instantiation: ir_sccp.c:ir_bitset_fill Unexecuted instantiation: ir_strtab.c:ir_bitset_fill Unexecuted instantiation: ir.c:ir_bitset_fill |
366 | | |
367 | | IR_ALWAYS_INLINE bool ir_bitset_empty(const ir_bitset set, uint32_t len) |
368 | 0 | { |
369 | 0 | uint32_t i; |
370 | 0 | for (i = 0; i < len; i++) { |
371 | 0 | if (set[i]) { |
372 | 0 | return 0; |
373 | 0 | } |
374 | 0 | } |
375 | 0 | return 1; |
376 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_empty Unexecuted instantiation: ir_check.c:ir_bitset_empty Unexecuted instantiation: ir_dump.c:ir_bitset_empty Unexecuted instantiation: ir_emit.c:ir_bitset_empty Unexecuted instantiation: ir_gcm.c:ir_bitset_empty Unexecuted instantiation: ir_gdb.c:ir_bitset_empty Unexecuted instantiation: ir_patch.c:ir_bitset_empty Unexecuted instantiation: ir_ra.c:ir_bitset_empty Unexecuted instantiation: ir_ra_simple.c:ir_bitset_empty Unexecuted instantiation: ir_save.c:ir_bitset_empty Unexecuted instantiation: ir_sccp.c:ir_bitset_empty Unexecuted instantiation: ir_strtab.c:ir_bitset_empty Unexecuted instantiation: ir.c:ir_bitset_empty |
377 | | |
378 | | IR_ALWAYS_INLINE bool ir_bitset_equal(const ir_bitset set1, const ir_bitset set2, uint32_t len) |
379 | 0 | { |
380 | 0 | return memcmp(set1, set2, len * (IR_BITSET_BITS / 8)) == 0; |
381 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_equal Unexecuted instantiation: ir_check.c:ir_bitset_equal Unexecuted instantiation: ir_dump.c:ir_bitset_equal Unexecuted instantiation: ir_emit.c:ir_bitset_equal Unexecuted instantiation: ir_gcm.c:ir_bitset_equal Unexecuted instantiation: ir_gdb.c:ir_bitset_equal Unexecuted instantiation: ir_patch.c:ir_bitset_equal Unexecuted instantiation: ir_ra.c:ir_bitset_equal Unexecuted instantiation: ir_ra_simple.c:ir_bitset_equal Unexecuted instantiation: ir_save.c:ir_bitset_equal Unexecuted instantiation: ir_sccp.c:ir_bitset_equal Unexecuted instantiation: ir_strtab.c:ir_bitset_equal Unexecuted instantiation: ir.c:ir_bitset_equal |
382 | | |
383 | | IR_ALWAYS_INLINE void ir_bitset_copy(ir_bitset set1, const ir_bitset set2, uint32_t len) |
384 | 0 | { |
385 | 0 | memcpy(set1, set2, len * (IR_BITSET_BITS / 8)); |
386 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_copy Unexecuted instantiation: ir_check.c:ir_bitset_copy Unexecuted instantiation: ir_dump.c:ir_bitset_copy Unexecuted instantiation: ir_emit.c:ir_bitset_copy Unexecuted instantiation: ir_gcm.c:ir_bitset_copy Unexecuted instantiation: ir_gdb.c:ir_bitset_copy Unexecuted instantiation: ir_patch.c:ir_bitset_copy Unexecuted instantiation: ir_ra.c:ir_bitset_copy Unexecuted instantiation: ir_ra_simple.c:ir_bitset_copy Unexecuted instantiation: ir_save.c:ir_bitset_copy Unexecuted instantiation: ir_sccp.c:ir_bitset_copy Unexecuted instantiation: ir_strtab.c:ir_bitset_copy Unexecuted instantiation: ir.c:ir_bitset_copy |
387 | | |
388 | | IR_ALWAYS_INLINE void ir_bitset_intersection(ir_bitset set1, const ir_bitset set2, uint32_t len) |
389 | 0 | { |
390 | 0 | uint32_t i; |
391 | |
|
392 | 0 | for (i = 0; i < len; i++) { |
393 | 0 | set1[i] &= set2[i]; |
394 | 0 | } |
395 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_intersection Unexecuted instantiation: ir_check.c:ir_bitset_intersection Unexecuted instantiation: ir_dump.c:ir_bitset_intersection Unexecuted instantiation: ir_emit.c:ir_bitset_intersection Unexecuted instantiation: ir_gcm.c:ir_bitset_intersection Unexecuted instantiation: ir_gdb.c:ir_bitset_intersection Unexecuted instantiation: ir_patch.c:ir_bitset_intersection Unexecuted instantiation: ir_ra.c:ir_bitset_intersection Unexecuted instantiation: ir_ra_simple.c:ir_bitset_intersection Unexecuted instantiation: ir_save.c:ir_bitset_intersection Unexecuted instantiation: ir_sccp.c:ir_bitset_intersection Unexecuted instantiation: ir_strtab.c:ir_bitset_intersection Unexecuted instantiation: ir.c:ir_bitset_intersection |
396 | | |
397 | | IR_ALWAYS_INLINE void ir_bitset_union(ir_bitset set1, const ir_bitset set2, uint32_t len) |
398 | 13 | { |
399 | 13 | uint32_t i; |
400 | | |
401 | 39 | for (i = 0; i < len; i++) { |
402 | 26 | set1[i] |= set2[i]; |
403 | 26 | } |
404 | 13 | } Line | Count | Source | 398 | 13 | { | 399 | 13 | uint32_t i; | 400 | | | 401 | 39 | for (i = 0; i < len; i++) { | 402 | 26 | set1[i] |= set2[i]; | 403 | 26 | } | 404 | 13 | } |
Unexecuted instantiation: ir_check.c:ir_bitset_union Unexecuted instantiation: ir_dump.c:ir_bitset_union Unexecuted instantiation: ir_emit.c:ir_bitset_union Unexecuted instantiation: ir_gcm.c:ir_bitset_union Unexecuted instantiation: ir_gdb.c:ir_bitset_union Unexecuted instantiation: ir_patch.c:ir_bitset_union Unexecuted instantiation: ir_ra.c:ir_bitset_union Unexecuted instantiation: ir_ra_simple.c:ir_bitset_union Unexecuted instantiation: ir_save.c:ir_bitset_union Unexecuted instantiation: ir_sccp.c:ir_bitset_union Unexecuted instantiation: ir_strtab.c:ir_bitset_union Unexecuted instantiation: ir.c:ir_bitset_union |
405 | | |
406 | | IR_ALWAYS_INLINE void ir_bitset_difference(ir_bitset set1, const ir_bitset set2, uint32_t len) |
407 | 0 | { |
408 | 0 | uint32_t i; |
409 | |
|
410 | 0 | for (i = 0; i < len; i++) { |
411 | 0 | set1[i] = set1[i] & ~set2[i]; |
412 | 0 | } |
413 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_difference Unexecuted instantiation: ir_check.c:ir_bitset_difference Unexecuted instantiation: ir_dump.c:ir_bitset_difference Unexecuted instantiation: ir_emit.c:ir_bitset_difference Unexecuted instantiation: ir_gcm.c:ir_bitset_difference Unexecuted instantiation: ir_gdb.c:ir_bitset_difference Unexecuted instantiation: ir_patch.c:ir_bitset_difference Unexecuted instantiation: ir_ra.c:ir_bitset_difference Unexecuted instantiation: ir_ra_simple.c:ir_bitset_difference Unexecuted instantiation: ir_save.c:ir_bitset_difference Unexecuted instantiation: ir_sccp.c:ir_bitset_difference Unexecuted instantiation: ir_strtab.c:ir_bitset_difference Unexecuted instantiation: ir.c:ir_bitset_difference |
414 | | |
415 | | IR_ALWAYS_INLINE bool ir_bitset_is_subset(const ir_bitset set1, const ir_bitset set2, uint32_t len) |
416 | 0 | { |
417 | 0 | uint32_t i; |
418 | 0 |
|
419 | 0 | for (i = 0; i < len; i++) { |
420 | 0 | if (set1[i] & ~set2[i]) { |
421 | 0 | return 0; |
422 | 0 | } |
423 | 0 | } |
424 | 0 | return 1; |
425 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_is_subset Unexecuted instantiation: ir_check.c:ir_bitset_is_subset Unexecuted instantiation: ir_dump.c:ir_bitset_is_subset Unexecuted instantiation: ir_emit.c:ir_bitset_is_subset Unexecuted instantiation: ir_gcm.c:ir_bitset_is_subset Unexecuted instantiation: ir_gdb.c:ir_bitset_is_subset Unexecuted instantiation: ir_patch.c:ir_bitset_is_subset Unexecuted instantiation: ir_ra.c:ir_bitset_is_subset Unexecuted instantiation: ir_ra_simple.c:ir_bitset_is_subset Unexecuted instantiation: ir_save.c:ir_bitset_is_subset Unexecuted instantiation: ir_sccp.c:ir_bitset_is_subset Unexecuted instantiation: ir_strtab.c:ir_bitset_is_subset Unexecuted instantiation: ir.c:ir_bitset_is_subset |
426 | | |
427 | | IR_ALWAYS_INLINE int ir_bitset_first(const ir_bitset set, uint32_t len) |
428 | 0 | { |
429 | 0 | uint32_t i; |
430 | |
|
431 | 0 | for (i = 0; i < len; i++) { |
432 | 0 | if (set[i]) { |
433 | 0 | return IR_BITSET_BITS * i + ir_bitset_ntz(set[i]); |
434 | 0 | } |
435 | 0 | } |
436 | 0 | return -1; /* empty set */ |
437 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_first Unexecuted instantiation: ir_check.c:ir_bitset_first Unexecuted instantiation: ir_dump.c:ir_bitset_first Unexecuted instantiation: ir_emit.c:ir_bitset_first Unexecuted instantiation: ir_gcm.c:ir_bitset_first Unexecuted instantiation: ir_gdb.c:ir_bitset_first Unexecuted instantiation: ir_patch.c:ir_bitset_first Unexecuted instantiation: ir_ra.c:ir_bitset_first Unexecuted instantiation: ir_ra_simple.c:ir_bitset_first Unexecuted instantiation: ir_save.c:ir_bitset_first Unexecuted instantiation: ir_sccp.c:ir_bitset_first Unexecuted instantiation: ir_strtab.c:ir_bitset_first Unexecuted instantiation: ir.c:ir_bitset_first |
438 | | |
439 | | IR_ALWAYS_INLINE int ir_bitset_last(const ir_bitset set, uint32_t len) |
440 | 0 | { |
441 | 0 | uint32_t i = len; |
442 | 0 |
|
443 | 0 | while (i > 0) { |
444 | 0 | i--; |
445 | 0 | if (set[i]) { |
446 | 0 | uint32_t j = IR_BITSET_BITS * i - 1; |
447 | 0 | ir_bitset_base_t x = set[i]; |
448 | 0 | do { |
449 | 0 | x = x >> 1; |
450 | 0 | j++; |
451 | 0 | } while (x != 0); |
452 | 0 | return j; |
453 | 0 | } |
454 | 0 | } |
455 | 0 | return -1; /* empty set */ |
456 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_last Unexecuted instantiation: ir_check.c:ir_bitset_last Unexecuted instantiation: ir_dump.c:ir_bitset_last Unexecuted instantiation: ir_emit.c:ir_bitset_last Unexecuted instantiation: ir_gcm.c:ir_bitset_last Unexecuted instantiation: ir_gdb.c:ir_bitset_last Unexecuted instantiation: ir_patch.c:ir_bitset_last Unexecuted instantiation: ir_ra.c:ir_bitset_last Unexecuted instantiation: ir_ra_simple.c:ir_bitset_last Unexecuted instantiation: ir_save.c:ir_bitset_last Unexecuted instantiation: ir_sccp.c:ir_bitset_last Unexecuted instantiation: ir_strtab.c:ir_bitset_last Unexecuted instantiation: ir.c:ir_bitset_last |
457 | | |
458 | | IR_ALWAYS_INLINE int ir_bitset_pop_first(ir_bitset set, uint32_t len) |
459 | 0 | { |
460 | 0 | uint32_t i; |
461 | |
|
462 | 0 | for (i = 0; i < len; i++) { |
463 | 0 | ir_bitset_base_t x = set[i]; |
464 | |
|
465 | 0 | if (x) { |
466 | 0 | int bit = IR_BITSET_BITS * i + ir_bitset_ntz(x); |
467 | 0 | set[i] = x & (x - 1); |
468 | 0 | return bit; |
469 | 0 | } |
470 | 0 | } |
471 | 0 | return -1; /* empty set */ |
472 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitset_pop_first Unexecuted instantiation: ir_check.c:ir_bitset_pop_first Unexecuted instantiation: ir_dump.c:ir_bitset_pop_first Unexecuted instantiation: ir_emit.c:ir_bitset_pop_first Unexecuted instantiation: ir_gcm.c:ir_bitset_pop_first Unexecuted instantiation: ir_gdb.c:ir_bitset_pop_first Unexecuted instantiation: ir_patch.c:ir_bitset_pop_first Unexecuted instantiation: ir_ra.c:ir_bitset_pop_first Unexecuted instantiation: ir_ra_simple.c:ir_bitset_pop_first Unexecuted instantiation: ir_save.c:ir_bitset_pop_first Unexecuted instantiation: ir_sccp.c:ir_bitset_pop_first Unexecuted instantiation: ir_strtab.c:ir_bitset_pop_first Unexecuted instantiation: ir.c:ir_bitset_pop_first |
473 | | |
474 | 19.8k | #define IR_BITSET_FOREACH(set, len, bit) do { \ |
475 | 19.8k | ir_bitset _set = (set); \ |
476 | 19.8k | uint32_t _i, _len = (len); \ |
477 | 64.4k | for (_i = 0; _i < _len; _set++, _i++) { \ |
478 | 44.5k | ir_bitset_base_t _x = *_set; \ |
479 | 362k | while (_x) { \ |
480 | 317k | (bit) = IR_BITSET_BITS * _i + ir_bitset_ntz(_x); \ |
481 | 317k | _x &= _x - 1; |
482 | | |
483 | 9.93k | #define IR_BITSET_FOREACH_DIFFERENCE(set1, set2, len, bit) do { \ |
484 | 9.93k | ir_bitset _set1 = (set1); \ |
485 | 9.93k | ir_bitset _set2 = (set2); \ |
486 | 9.93k | uint32_t _i, _len = (len); \ |
487 | 44.1k | for (_i = 0; _i < _len; _i++) { \ |
488 | 34.1k | ir_bitset_base_t _x = _set1[_i] & ~_set2[_i]; \ |
489 | 34.2k | while (_x) { \ |
490 | 13 | (bit) = IR_BITSET_BITS * _i + ir_bitset_ntz(_x); \ |
491 | 13 | _x &= _x - 1; |
492 | | |
493 | | #define IR_BITSET_FOREACH_END() \ |
494 | 317k | } \ |
495 | 78.7k | } \ |
496 | 29.8k | } while (0) |
497 | | |
498 | | /* Sparse Set */ |
499 | | typedef struct _ir_sparse_set { |
500 | | uint32_t size; |
501 | | uint32_t len; |
502 | | uint32_t *data; |
503 | | } ir_sparse_set; |
504 | | |
505 | 38.0k | #define IR_SPARSE_SET_DENSE(set, n) (set)->data[n] |
506 | 90.7k | #define IR_SPARSE_SET_SPARSE(set, n) (set)->data[-1 - ((int32_t)(n))] |
507 | | |
508 | | IR_ALWAYS_INLINE void ir_sparse_set_init(ir_sparse_set *set, uint32_t size) |
509 | 6.95k | { |
510 | 6.95k | size_t alloc_size = (size_t)size * 2 * sizeof(*set->data); |
511 | | |
512 | 6.95k | set->size = size; |
513 | 6.95k | set->len = 0; |
514 | 6.95k | IR_ASSERT(!size || alloc_size / size == 2 * sizeof(*set->data)); |
515 | 6.95k | set->data = (uint32_t*)ir_mem_malloc(alloc_size) + size; |
516 | 6.95k | #ifdef IR_DEBUG |
517 | | /* initialize sparse part to avoid valgrind warnings */ |
518 | 6.95k | memset(&IR_SPARSE_SET_SPARSE(set, size - 1), 0, size * sizeof(uint32_t)); |
519 | 6.95k | #endif |
520 | 6.95k | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_init Unexecuted instantiation: ir_check.c:ir_sparse_set_init Unexecuted instantiation: ir_dump.c:ir_sparse_set_init Unexecuted instantiation: ir_emit.c:ir_sparse_set_init ir_gcm.c:ir_sparse_set_init Line | Count | Source | 509 | 6.95k | { | 510 | 6.95k | size_t alloc_size = (size_t)size * 2 * sizeof(*set->data); | 511 | | | 512 | 6.95k | set->size = size; | 513 | 6.95k | set->len = 0; | 514 | 6.95k | IR_ASSERT(!size || alloc_size / size == 2 * sizeof(*set->data)); | 515 | 6.95k | set->data = (uint32_t*)ir_mem_malloc(alloc_size) + size; | 516 | 6.95k | #ifdef IR_DEBUG | 517 | | /* initialize sparse part to avoid valgrind warnings */ | 518 | 6.95k | memset(&IR_SPARSE_SET_SPARSE(set, size - 1), 0, size * sizeof(uint32_t)); | 519 | 6.95k | #endif | 520 | 6.95k | } |
Unexecuted instantiation: ir_gdb.c:ir_sparse_set_init Unexecuted instantiation: ir_patch.c:ir_sparse_set_init Unexecuted instantiation: ir_ra.c:ir_sparse_set_init Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_init Unexecuted instantiation: ir_save.c:ir_sparse_set_init Unexecuted instantiation: ir_sccp.c:ir_sparse_set_init Unexecuted instantiation: ir_strtab.c:ir_sparse_set_init Unexecuted instantiation: ir.c:ir_sparse_set_init |
521 | | |
522 | | IR_ALWAYS_INLINE void ir_sparse_set_clear(ir_sparse_set *set) |
523 | 40.6k | { |
524 | 40.6k | set->len = 0; |
525 | 40.6k | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_clear Unexecuted instantiation: ir_check.c:ir_sparse_set_clear Unexecuted instantiation: ir_dump.c:ir_sparse_set_clear Unexecuted instantiation: ir_emit.c:ir_sparse_set_clear ir_gcm.c:ir_sparse_set_clear Line | Count | Source | 523 | 40.6k | { | 524 | 40.6k | set->len = 0; | 525 | 40.6k | } |
Unexecuted instantiation: ir_gdb.c:ir_sparse_set_clear Unexecuted instantiation: ir_patch.c:ir_sparse_set_clear Unexecuted instantiation: ir_ra.c:ir_sparse_set_clear Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_clear Unexecuted instantiation: ir_save.c:ir_sparse_set_clear Unexecuted instantiation: ir_sccp.c:ir_sparse_set_clear Unexecuted instantiation: ir_strtab.c:ir_sparse_set_clear Unexecuted instantiation: ir.c:ir_sparse_set_clear |
526 | | |
527 | | IR_ALWAYS_INLINE void ir_sparse_set_free(ir_sparse_set *set) |
528 | 6.95k | { |
529 | 6.95k | ir_mem_free(set->data - set->size); |
530 | 6.95k | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_free Unexecuted instantiation: ir_check.c:ir_sparse_set_free Unexecuted instantiation: ir_dump.c:ir_sparse_set_free Unexecuted instantiation: ir_emit.c:ir_sparse_set_free ir_gcm.c:ir_sparse_set_free Line | Count | Source | 528 | 6.95k | { | 529 | | ir_mem_free(set->data - set->size); | 530 | 6.95k | } |
Unexecuted instantiation: ir_gdb.c:ir_sparse_set_free Unexecuted instantiation: ir_patch.c:ir_sparse_set_free Unexecuted instantiation: ir_ra.c:ir_sparse_set_free Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_free Unexecuted instantiation: ir_save.c:ir_sparse_set_free Unexecuted instantiation: ir_sccp.c:ir_sparse_set_free Unexecuted instantiation: ir_strtab.c:ir_sparse_set_free Unexecuted instantiation: ir.c:ir_sparse_set_free |
531 | | |
532 | | IR_ALWAYS_INLINE bool ir_sparse_set_empty(const ir_sparse_set *set) |
533 | 0 | { |
534 | 0 | return set->len == 0; |
535 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_empty Unexecuted instantiation: ir_check.c:ir_sparse_set_empty Unexecuted instantiation: ir_dump.c:ir_sparse_set_empty Unexecuted instantiation: ir_emit.c:ir_sparse_set_empty Unexecuted instantiation: ir_gcm.c:ir_sparse_set_empty Unexecuted instantiation: ir_gdb.c:ir_sparse_set_empty Unexecuted instantiation: ir_patch.c:ir_sparse_set_empty Unexecuted instantiation: ir_ra.c:ir_sparse_set_empty Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_empty Unexecuted instantiation: ir_save.c:ir_sparse_set_empty Unexecuted instantiation: ir_sccp.c:ir_sparse_set_empty Unexecuted instantiation: ir_strtab.c:ir_sparse_set_empty Unexecuted instantiation: ir.c:ir_sparse_set_empty |
536 | | |
537 | | IR_ALWAYS_INLINE bool ir_sparse_set_in(const ir_sparse_set *set, uint32_t n) |
538 | 74.2k | { |
539 | 74.2k | uint32_t idx = IR_SPARSE_SET_SPARSE(set, n); |
540 | | |
541 | 74.2k | return idx < set->len && IR_SPARSE_SET_DENSE(set, idx) == n; |
542 | 74.2k | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_in Unexecuted instantiation: ir_check.c:ir_sparse_set_in Unexecuted instantiation: ir_dump.c:ir_sparse_set_in Unexecuted instantiation: ir_emit.c:ir_sparse_set_in ir_gcm.c:ir_sparse_set_in Line | Count | Source | 538 | 74.2k | { | 539 | 74.2k | uint32_t idx = IR_SPARSE_SET_SPARSE(set, n); | 540 | | | 541 | 74.2k | return idx < set->len && IR_SPARSE_SET_DENSE(set, idx) == n; | 542 | 74.2k | } |
Unexecuted instantiation: ir_gdb.c:ir_sparse_set_in Unexecuted instantiation: ir_patch.c:ir_sparse_set_in Unexecuted instantiation: ir_ra.c:ir_sparse_set_in Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_in Unexecuted instantiation: ir_save.c:ir_sparse_set_in Unexecuted instantiation: ir_sccp.c:ir_sparse_set_in Unexecuted instantiation: ir_strtab.c:ir_sparse_set_in Unexecuted instantiation: ir.c:ir_sparse_set_in |
543 | | |
544 | | IR_ALWAYS_INLINE void ir_sparse_set_add(ir_sparse_set *set, uint32_t n) |
545 | 9.59k | { |
546 | 9.59k | uint32_t idx; |
547 | | |
548 | 9.59k | IR_ASSERT(!ir_sparse_set_in(set, n)); |
549 | 9.59k | idx = set->len++; |
550 | 9.59k | IR_SPARSE_SET_DENSE(set, idx) = n; |
551 | 9.59k | IR_SPARSE_SET_SPARSE(set, n) = idx; |
552 | 9.59k | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_add Unexecuted instantiation: ir_check.c:ir_sparse_set_add Unexecuted instantiation: ir_dump.c:ir_sparse_set_add Unexecuted instantiation: ir_emit.c:ir_sparse_set_add ir_gcm.c:ir_sparse_set_add Line | Count | Source | 545 | 9.59k | { | 546 | 9.59k | uint32_t idx; | 547 | | | 548 | 9.59k | IR_ASSERT(!ir_sparse_set_in(set, n)); | 549 | 9.59k | idx = set->len++; | 550 | 9.59k | IR_SPARSE_SET_DENSE(set, idx) = n; | 551 | 9.59k | IR_SPARSE_SET_SPARSE(set, n) = idx; | 552 | 9.59k | } |
Unexecuted instantiation: ir_gdb.c:ir_sparse_set_add Unexecuted instantiation: ir_patch.c:ir_sparse_set_add Unexecuted instantiation: ir_ra.c:ir_sparse_set_add Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_add Unexecuted instantiation: ir_save.c:ir_sparse_set_add Unexecuted instantiation: ir_sccp.c:ir_sparse_set_add Unexecuted instantiation: ir_strtab.c:ir_sparse_set_add Unexecuted instantiation: ir.c:ir_sparse_set_add |
553 | | |
554 | | IR_ALWAYS_INLINE void ir_sparse_set_del(ir_sparse_set *set, uint32_t n) |
555 | 0 | { |
556 | 0 | uint32_t last; |
557 | 0 |
|
558 | 0 | IR_ASSERT(ir_sparse_set_in(set, n)); |
559 | 0 | last = IR_SPARSE_SET_DENSE(set, set->len - 1); |
560 | 0 | if (last != n) { |
561 | 0 | uint32_t idx = IR_SPARSE_SET_SPARSE(set, n); |
562 | 0 |
|
563 | 0 | IR_SPARSE_SET_DENSE(set, idx) = last; |
564 | 0 | IR_SPARSE_SET_SPARSE(set, last) = idx; |
565 | 0 |
|
566 | 0 | } |
567 | 0 | set->len--; |
568 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_del Unexecuted instantiation: ir_check.c:ir_sparse_set_del Unexecuted instantiation: ir_dump.c:ir_sparse_set_del Unexecuted instantiation: ir_emit.c:ir_sparse_set_del Unexecuted instantiation: ir_gcm.c:ir_sparse_set_del Unexecuted instantiation: ir_gdb.c:ir_sparse_set_del Unexecuted instantiation: ir_patch.c:ir_sparse_set_del Unexecuted instantiation: ir_ra.c:ir_sparse_set_del Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_del Unexecuted instantiation: ir_save.c:ir_sparse_set_del Unexecuted instantiation: ir_sccp.c:ir_sparse_set_del Unexecuted instantiation: ir_strtab.c:ir_sparse_set_del Unexecuted instantiation: ir.c:ir_sparse_set_del |
569 | | |
570 | | IR_ALWAYS_INLINE uint32_t ir_sparse_set_pop(ir_sparse_set *set) |
571 | 0 | { |
572 | 0 | if (set->len > 0) { |
573 | 0 | set->len--; |
574 | 0 | return IR_SPARSE_SET_DENSE(set, set->len); |
575 | 0 | } |
576 | 0 | return -1; /* empty set */ |
577 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_sparse_set_pop Unexecuted instantiation: ir_check.c:ir_sparse_set_pop Unexecuted instantiation: ir_dump.c:ir_sparse_set_pop Unexecuted instantiation: ir_emit.c:ir_sparse_set_pop Unexecuted instantiation: ir_gcm.c:ir_sparse_set_pop Unexecuted instantiation: ir_gdb.c:ir_sparse_set_pop Unexecuted instantiation: ir_patch.c:ir_sparse_set_pop Unexecuted instantiation: ir_ra.c:ir_sparse_set_pop Unexecuted instantiation: ir_ra_simple.c:ir_sparse_set_pop Unexecuted instantiation: ir_save.c:ir_sparse_set_pop Unexecuted instantiation: ir_sccp.c:ir_sparse_set_pop Unexecuted instantiation: ir_strtab.c:ir_sparse_set_pop Unexecuted instantiation: ir.c:ir_sparse_set_pop |
578 | | |
579 | 2.06k | #define IR_SPARSE_SET_FOREACH(set, bit) do { \ |
580 | 2.06k | ir_sparse_set *_set = (set); \ |
581 | 2.06k | uint32_t _i, _len = _set->len; \ |
582 | 2.06k | uint32_t *_p = _set->data; \ |
583 | 7.48k | for (_i = 0; _i < _len; _p++, _i++) { \ |
584 | 5.41k | (bit) = *_p; \ |
585 | | |
586 | | #define IR_SPARSE_SET_FOREACH_END() \ |
587 | 5.41k | } \ |
588 | 2.06k | } while (0) |
589 | | |
590 | | /* Bit Queue */ |
591 | | typedef struct _ir_bitqueue { |
592 | | uint32_t len; |
593 | | uint32_t pos; |
594 | | ir_bitset set; |
595 | | } ir_bitqueue; |
596 | | |
597 | | IR_ALWAYS_INLINE void ir_bitqueue_init(ir_bitqueue *q, uint32_t n) |
598 | 26.7k | { |
599 | 26.7k | q->len = ir_bitset_len(n); |
600 | 26.7k | q->pos = q->len - 1; |
601 | 26.7k | q->set = ir_bitset_malloc(n); |
602 | 26.7k | } ir_cfg.c:ir_bitqueue_init Line | Count | Source | 598 | 6.87k | { | 599 | 6.87k | q->len = ir_bitset_len(n); | 600 | 6.87k | q->pos = q->len - 1; | 601 | 6.87k | q->set = ir_bitset_malloc(n); | 602 | 6.87k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_init Unexecuted instantiation: ir_dump.c:ir_bitqueue_init Unexecuted instantiation: ir_emit.c:ir_bitqueue_init Unexecuted instantiation: ir_gcm.c:ir_bitqueue_init Unexecuted instantiation: ir_gdb.c:ir_bitqueue_init Unexecuted instantiation: ir_patch.c:ir_bitqueue_init Unexecuted instantiation: ir_ra.c:ir_bitqueue_init Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_init Unexecuted instantiation: ir_save.c:ir_bitqueue_init ir_sccp.c:ir_bitqueue_init Line | Count | Source | 598 | 19.8k | { | 599 | 19.8k | q->len = ir_bitset_len(n); | 600 | 19.8k | q->pos = q->len - 1; | 601 | 19.8k | q->set = ir_bitset_malloc(n); | 602 | 19.8k | } |
Unexecuted instantiation: ir_strtab.c:ir_bitqueue_init Unexecuted instantiation: ir.c:ir_bitqueue_init |
603 | | |
604 | | IR_ALWAYS_INLINE void ir_bitqueue_grow(ir_bitqueue *q, uint32_t n) |
605 | 0 | { |
606 | 0 | uint32_t len = ir_bitset_len(n); |
607 | 0 | IR_ASSERT(len >= q->len); |
608 | 0 | if (len > q->len) { |
609 | 0 | q->set = ir_mem_realloc(q->set, len * (IR_BITSET_BITS / 8)); |
610 | 0 | memset(q->set + q->len, 0, (len - q->len) * (IR_BITSET_BITS / 8)); |
611 | 0 | q->len = len; |
612 | 0 | } |
613 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitqueue_grow Unexecuted instantiation: ir_check.c:ir_bitqueue_grow Unexecuted instantiation: ir_dump.c:ir_bitqueue_grow Unexecuted instantiation: ir_emit.c:ir_bitqueue_grow Unexecuted instantiation: ir_gcm.c:ir_bitqueue_grow Unexecuted instantiation: ir_gdb.c:ir_bitqueue_grow Unexecuted instantiation: ir_patch.c:ir_bitqueue_grow Unexecuted instantiation: ir_ra.c:ir_bitqueue_grow Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_grow Unexecuted instantiation: ir_save.c:ir_bitqueue_grow Unexecuted instantiation: ir_sccp.c:ir_bitqueue_grow Unexecuted instantiation: ir_strtab.c:ir_bitqueue_grow Unexecuted instantiation: ir.c:ir_bitqueue_grow |
614 | | |
615 | | IR_ALWAYS_INLINE void ir_bitqueue_free(ir_bitqueue *q) |
616 | 26.7k | { |
617 | 26.7k | ir_mem_free(q->set); |
618 | 26.7k | } ir_cfg.c:ir_bitqueue_free Line | Count | Source | 616 | 6.87k | { | 617 | | ir_mem_free(q->set); | 618 | 6.87k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_free Unexecuted instantiation: ir_dump.c:ir_bitqueue_free Unexecuted instantiation: ir_emit.c:ir_bitqueue_free Unexecuted instantiation: ir_gcm.c:ir_bitqueue_free Unexecuted instantiation: ir_gdb.c:ir_bitqueue_free Unexecuted instantiation: ir_patch.c:ir_bitqueue_free Unexecuted instantiation: ir_ra.c:ir_bitqueue_free Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_free Unexecuted instantiation: ir_save.c:ir_bitqueue_free ir_sccp.c:ir_bitqueue_free Line | Count | Source | 616 | 19.8k | { | 617 | | ir_mem_free(q->set); | 618 | 19.8k | } |
Unexecuted instantiation: ir_strtab.c:ir_bitqueue_free Unexecuted instantiation: ir.c:ir_bitqueue_free |
619 | | |
620 | | IR_ALWAYS_INLINE void ir_bitqueue_clear(ir_bitqueue *q) |
621 | 0 | { |
622 | 0 | q->pos = q->len - 1; |
623 | 0 | ir_bitset_clear(q->set, q->len); |
624 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_bitqueue_clear Unexecuted instantiation: ir_check.c:ir_bitqueue_clear Unexecuted instantiation: ir_dump.c:ir_bitqueue_clear Unexecuted instantiation: ir_emit.c:ir_bitqueue_clear Unexecuted instantiation: ir_gcm.c:ir_bitqueue_clear Unexecuted instantiation: ir_gdb.c:ir_bitqueue_clear Unexecuted instantiation: ir_patch.c:ir_bitqueue_clear Unexecuted instantiation: ir_ra.c:ir_bitqueue_clear Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_clear Unexecuted instantiation: ir_save.c:ir_bitqueue_clear Unexecuted instantiation: ir_sccp.c:ir_bitqueue_clear Unexecuted instantiation: ir_strtab.c:ir_bitqueue_clear Unexecuted instantiation: ir.c:ir_bitqueue_clear |
625 | | |
626 | | IR_ALWAYS_INLINE int ir_bitqueue_pop(ir_bitqueue *q) |
627 | 2.21M | { |
628 | 2.21M | uint32_t i = q->pos; |
629 | 2.21M | ir_bitset_base_t x, *p = q->set + i; |
630 | 2.26M | do { |
631 | 2.26M | x = *p; |
632 | 2.26M | if (x) { |
633 | 2.18M | int bit = IR_BITSET_BITS * i + ir_bitset_ntz(x); |
634 | 2.18M | *p = x & (x - 1); |
635 | 2.18M | q->pos = i; |
636 | 2.18M | return bit; |
637 | 2.18M | } |
638 | 87.0k | p++; |
639 | 87.0k | i++; |
640 | 87.0k | } while (i < q->len); |
641 | 36.6k | q->pos = q->len - 1; |
642 | 36.6k | return -1; /* empty set */ |
643 | 2.21M | } Line | Count | Source | 627 | 224k | { | 628 | 224k | uint32_t i = q->pos; | 629 | 224k | ir_bitset_base_t x, *p = q->set + i; | 630 | 225k | do { | 631 | 225k | x = *p; | 632 | 225k | if (x) { | 633 | 217k | int bit = IR_BITSET_BITS * i + ir_bitset_ntz(x); | 634 | 217k | *p = x & (x - 1); | 635 | 217k | q->pos = i; | 636 | 217k | return bit; | 637 | 217k | } | 638 | 8.01k | p++; | 639 | 8.01k | i++; | 640 | 8.01k | } while (i < q->len); | 641 | 6.87k | q->pos = q->len - 1; | 642 | 6.87k | return -1; /* empty set */ | 643 | 224k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_pop Unexecuted instantiation: ir_dump.c:ir_bitqueue_pop Unexecuted instantiation: ir_emit.c:ir_bitqueue_pop Unexecuted instantiation: ir_gcm.c:ir_bitqueue_pop Unexecuted instantiation: ir_gdb.c:ir_bitqueue_pop Unexecuted instantiation: ir_patch.c:ir_bitqueue_pop Unexecuted instantiation: ir_ra.c:ir_bitqueue_pop Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_pop Unexecuted instantiation: ir_save.c:ir_bitqueue_pop ir_sccp.c:ir_bitqueue_pop Line | Count | Source | 627 | 1.99M | { | 628 | 1.99M | uint32_t i = q->pos; | 629 | 1.99M | ir_bitset_base_t x, *p = q->set + i; | 630 | 2.04M | do { | 631 | 2.04M | x = *p; | 632 | 2.04M | if (x) { | 633 | 1.96M | int bit = IR_BITSET_BITS * i + ir_bitset_ntz(x); | 634 | 1.96M | *p = x & (x - 1); | 635 | 1.96M | q->pos = i; | 636 | 1.96M | return bit; | 637 | 1.96M | } | 638 | 79.0k | p++; | 639 | 79.0k | i++; | 640 | 79.0k | } while (i < q->len); | 641 | 29.8k | q->pos = q->len - 1; | 642 | 29.8k | return -1; /* empty set */ | 643 | 1.99M | } |
Unexecuted instantiation: ir_strtab.c:ir_bitqueue_pop Unexecuted instantiation: ir.c:ir_bitqueue_pop |
644 | | |
645 | | IR_ALWAYS_INLINE void ir_bitqueue_add(ir_bitqueue *q, uint32_t n) |
646 | 3.12M | { |
647 | 3.12M | uint32_t i = n / IR_BITSET_BITS; |
648 | 3.12M | q->set[i] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); |
649 | 3.12M | if (i < q->pos) { |
650 | 7.67k | q->pos = i; |
651 | 7.67k | } |
652 | 3.12M | } Line | Count | Source | 646 | 315k | { | 647 | 315k | uint32_t i = n / IR_BITSET_BITS; | 648 | 315k | q->set[i] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 649 | 315k | if (i < q->pos) { | 650 | 757 | q->pos = i; | 651 | 757 | } | 652 | 315k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_add Unexecuted instantiation: ir_dump.c:ir_bitqueue_add Unexecuted instantiation: ir_emit.c:ir_bitqueue_add Unexecuted instantiation: ir_gcm.c:ir_bitqueue_add Unexecuted instantiation: ir_gdb.c:ir_bitqueue_add Unexecuted instantiation: ir_patch.c:ir_bitqueue_add Unexecuted instantiation: ir_ra.c:ir_bitqueue_add Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_add Unexecuted instantiation: ir_save.c:ir_bitqueue_add ir_sccp.c:ir_bitqueue_add Line | Count | Source | 646 | 2.81M | { | 647 | 2.81M | uint32_t i = n / IR_BITSET_BITS; | 648 | 2.81M | q->set[i] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); | 649 | 2.81M | if (i < q->pos) { | 650 | 6.91k | q->pos = i; | 651 | 6.91k | } | 652 | 2.81M | } |
Unexecuted instantiation: ir_strtab.c:ir_bitqueue_add Unexecuted instantiation: ir.c:ir_bitqueue_add |
653 | | |
654 | | IR_ALWAYS_INLINE void ir_bitqueue_del(ir_bitqueue *q, uint32_t n) |
655 | 164k | { |
656 | 164k | ir_bitset_excl(q->set, n); |
657 | 164k | } Line | Count | Source | 655 | 164k | { | 656 | 164k | ir_bitset_excl(q->set, n); | 657 | 164k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_del Unexecuted instantiation: ir_dump.c:ir_bitqueue_del Unexecuted instantiation: ir_emit.c:ir_bitqueue_del Unexecuted instantiation: ir_gcm.c:ir_bitqueue_del Unexecuted instantiation: ir_gdb.c:ir_bitqueue_del Unexecuted instantiation: ir_patch.c:ir_bitqueue_del Unexecuted instantiation: ir_ra.c:ir_bitqueue_del Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_del Unexecuted instantiation: ir_save.c:ir_bitqueue_del Unexecuted instantiation: ir_sccp.c:ir_bitqueue_del Unexecuted instantiation: ir_strtab.c:ir_bitqueue_del Unexecuted instantiation: ir.c:ir_bitqueue_del |
658 | | |
659 | | IR_ALWAYS_INLINE bool ir_bitqueue_in(const ir_bitqueue *q, uint32_t n) |
660 | 15.4k | { |
661 | 15.4k | return ir_bitset_in(q->set, n); |
662 | 15.4k | } Line | Count | Source | 660 | 15.4k | { | 661 | 15.4k | return ir_bitset_in(q->set, n); | 662 | 15.4k | } |
Unexecuted instantiation: ir_check.c:ir_bitqueue_in Unexecuted instantiation: ir_dump.c:ir_bitqueue_in Unexecuted instantiation: ir_emit.c:ir_bitqueue_in Unexecuted instantiation: ir_gcm.c:ir_bitqueue_in Unexecuted instantiation: ir_gdb.c:ir_bitqueue_in Unexecuted instantiation: ir_patch.c:ir_bitqueue_in Unexecuted instantiation: ir_ra.c:ir_bitqueue_in Unexecuted instantiation: ir_ra_simple.c:ir_bitqueue_in Unexecuted instantiation: ir_save.c:ir_bitqueue_in Unexecuted instantiation: ir_sccp.c:ir_bitqueue_in Unexecuted instantiation: ir_strtab.c:ir_bitqueue_in Unexecuted instantiation: ir.c:ir_bitqueue_in |
663 | | |
664 | | /* Dynamic array of numeric references */ |
665 | | typedef struct _ir_array { |
666 | | ir_ref *refs; |
667 | | uint32_t size; |
668 | | } ir_array; |
669 | | |
670 | | void ir_array_grow(ir_array *a, uint32_t size); |
671 | | void ir_array_insert(ir_array *a, uint32_t i, ir_ref val); |
672 | | void ir_array_remove(ir_array *a, uint32_t i); |
673 | | |
674 | | IR_ALWAYS_INLINE void ir_array_init(ir_array *a, uint32_t size) |
675 | 76.9k | { |
676 | 76.9k | a->refs = ir_mem_malloc(size * sizeof(ir_ref)); |
677 | 76.9k | a->size = size; |
678 | 76.9k | } Line | Count | Source | 675 | 22.9k | { | 676 | | a->refs = ir_mem_malloc(size * sizeof(ir_ref)); | 677 | 22.9k | a->size = size; | 678 | 22.9k | } |
Unexecuted instantiation: ir_check.c:ir_array_init Unexecuted instantiation: ir_dump.c:ir_array_init Unexecuted instantiation: ir_emit.c:ir_array_init Line | Count | Source | 675 | 23.8k | { | 676 | | a->refs = ir_mem_malloc(size * sizeof(ir_ref)); | 677 | 23.8k | a->size = size; | 678 | 23.8k | } |
Unexecuted instantiation: ir_gdb.c:ir_array_init Unexecuted instantiation: ir_patch.c:ir_array_init Line | Count | Source | 675 | 30.1k | { | 676 | | a->refs = ir_mem_malloc(size * sizeof(ir_ref)); | 677 | 30.1k | a->size = size; | 678 | 30.1k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_init Unexecuted instantiation: ir_save.c:ir_array_init Unexecuted instantiation: ir_sccp.c:ir_array_init Unexecuted instantiation: ir_strtab.c:ir_array_init Unexecuted instantiation: ir.c:ir_array_init |
679 | | |
680 | | IR_ALWAYS_INLINE void ir_array_free(ir_array *a) |
681 | 76.9k | { |
682 | 76.9k | ir_mem_free(a->refs); |
683 | 76.9k | a->refs = NULL; |
684 | 76.9k | a->size = 0; |
685 | 76.9k | } Line | Count | Source | 681 | 22.9k | { | 682 | 22.9k | ir_mem_free(a->refs); | 683 | | a->refs = NULL; | 684 | 22.9k | a->size = 0; | 685 | 22.9k | } |
Unexecuted instantiation: ir_check.c:ir_array_free Unexecuted instantiation: ir_dump.c:ir_array_free Unexecuted instantiation: ir_emit.c:ir_array_free Line | Count | Source | 681 | 23.8k | { | 682 | 23.8k | ir_mem_free(a->refs); | 683 | | a->refs = NULL; | 684 | 23.8k | a->size = 0; | 685 | 23.8k | } |
Unexecuted instantiation: ir_gdb.c:ir_array_free Unexecuted instantiation: ir_patch.c:ir_array_free Line | Count | Source | 681 | 30.1k | { | 682 | 30.1k | ir_mem_free(a->refs); | 683 | | a->refs = NULL; | 684 | 30.1k | a->size = 0; | 685 | 30.1k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_free Unexecuted instantiation: ir_save.c:ir_array_free Unexecuted instantiation: ir_sccp.c:ir_array_free Unexecuted instantiation: ir_strtab.c:ir_array_free Unexecuted instantiation: ir.c:ir_array_free |
686 | | |
687 | | IR_ALWAYS_INLINE uint32_t ir_array_size(const ir_array *a) |
688 | 1.17M | { |
689 | 1.17M | return a->size; |
690 | 1.17M | } Line | Count | Source | 688 | 1.17M | { | 689 | 1.17M | return a->size; | 690 | 1.17M | } |
Unexecuted instantiation: ir_check.c:ir_array_size Unexecuted instantiation: ir_dump.c:ir_array_size Unexecuted instantiation: ir_emit.c:ir_array_size Unexecuted instantiation: ir_gcm.c:ir_array_size Unexecuted instantiation: ir_gdb.c:ir_array_size Unexecuted instantiation: ir_patch.c:ir_array_size Line | Count | Source | 688 | 646 | { | 689 | 646 | return a->size; | 690 | 646 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_size Unexecuted instantiation: ir_save.c:ir_array_size Unexecuted instantiation: ir_sccp.c:ir_array_size Unexecuted instantiation: ir_strtab.c:ir_array_size Unexecuted instantiation: ir.c:ir_array_size |
691 | | |
692 | | IR_ALWAYS_INLINE ir_ref ir_array_get(const ir_array *a, uint32_t i) |
693 | 0 | { |
694 | 0 | return (i < a->size) ? a->refs[i] : IR_UNUSED; |
695 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_array_get Unexecuted instantiation: ir_check.c:ir_array_get Unexecuted instantiation: ir_dump.c:ir_array_get Unexecuted instantiation: ir_emit.c:ir_array_get Unexecuted instantiation: ir_gcm.c:ir_array_get Unexecuted instantiation: ir_gdb.c:ir_array_get Unexecuted instantiation: ir_patch.c:ir_array_get Unexecuted instantiation: ir_ra.c:ir_array_get Unexecuted instantiation: ir_ra_simple.c:ir_array_get Unexecuted instantiation: ir_save.c:ir_array_get Unexecuted instantiation: ir_sccp.c:ir_array_get Unexecuted instantiation: ir_strtab.c:ir_array_get Unexecuted instantiation: ir.c:ir_array_get |
696 | | |
697 | | IR_ALWAYS_INLINE ir_ref ir_array_at(const ir_array *a, uint32_t i) |
698 | 2.81M | { |
699 | 2.81M | IR_ASSERT(i < a->size); |
700 | 2.81M | return a->refs[i]; |
701 | 2.81M | } Line | Count | Source | 698 | 856k | { | 699 | 856k | IR_ASSERT(i < a->size); | 700 | 856k | return a->refs[i]; | 701 | 856k | } |
Unexecuted instantiation: ir_check.c:ir_array_at Unexecuted instantiation: ir_dump.c:ir_array_at Unexecuted instantiation: ir_emit.c:ir_array_at Line | Count | Source | 698 | 1.03M | { | 699 | 1.03M | IR_ASSERT(i < a->size); | 700 | 1.03M | return a->refs[i]; | 701 | 1.03M | } |
Unexecuted instantiation: ir_gdb.c:ir_array_at Unexecuted instantiation: ir_patch.c:ir_array_at Line | Count | Source | 698 | 926k | { | 699 | 926k | IR_ASSERT(i < a->size); | 700 | 926k | return a->refs[i]; | 701 | 926k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_at Unexecuted instantiation: ir_save.c:ir_array_at Unexecuted instantiation: ir_sccp.c:ir_array_at Unexecuted instantiation: ir_strtab.c:ir_array_at Unexecuted instantiation: ir.c:ir_array_at |
702 | | |
703 | | IR_ALWAYS_INLINE void ir_array_set(ir_array *a, uint32_t i, ir_ref val) |
704 | 304k | { |
705 | 304k | if (i >= a->size) { |
706 | 0 | ir_array_grow(a, i + 1); |
707 | 0 | } |
708 | 304k | a->refs[i] = val; |
709 | 304k | } Line | Count | Source | 704 | 3.21k | { | 705 | 3.21k | if (i >= a->size) { | 706 | 0 | ir_array_grow(a, i + 1); | 707 | 0 | } | 708 | 3.21k | a->refs[i] = val; | 709 | 3.21k | } |
Unexecuted instantiation: ir_check.c:ir_array_set Unexecuted instantiation: ir_dump.c:ir_array_set Unexecuted instantiation: ir_emit.c:ir_array_set Line | Count | Source | 704 | 6.32k | { | 705 | 6.32k | if (i >= a->size) { | 706 | 0 | ir_array_grow(a, i + 1); | 707 | 0 | } | 708 | 6.32k | a->refs[i] = val; | 709 | 6.32k | } |
Unexecuted instantiation: ir_gdb.c:ir_array_set Unexecuted instantiation: ir_patch.c:ir_array_set Line | Count | Source | 704 | 295k | { | 705 | 295k | if (i >= a->size) { | 706 | 0 | ir_array_grow(a, i + 1); | 707 | 0 | } | 708 | 295k | a->refs[i] = val; | 709 | 295k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_set Unexecuted instantiation: ir_save.c:ir_array_set Unexecuted instantiation: ir_sccp.c:ir_array_set Unexecuted instantiation: ir_strtab.c:ir_array_set Unexecuted instantiation: ir.c:ir_array_set |
710 | | |
711 | | IR_ALWAYS_INLINE void ir_array_set_unchecked(ir_array *a, uint32_t i, ir_ref val) |
712 | 1.91M | { |
713 | 1.91M | IR_ASSERT(i < a->size); |
714 | 1.91M | a->refs[i] = val; |
715 | 1.91M | } ir_cfg.c:ir_array_set_unchecked Line | Count | Source | 712 | 502k | { | 713 | 502k | IR_ASSERT(i < a->size); | 714 | 502k | a->refs[i] = val; | 715 | 502k | } |
Unexecuted instantiation: ir_check.c:ir_array_set_unchecked Unexecuted instantiation: ir_dump.c:ir_array_set_unchecked Unexecuted instantiation: ir_emit.c:ir_array_set_unchecked ir_gcm.c:ir_array_set_unchecked Line | Count | Source | 712 | 1.03M | { | 713 | 1.03M | IR_ASSERT(i < a->size); | 714 | 1.03M | a->refs[i] = val; | 715 | 1.03M | } |
Unexecuted instantiation: ir_gdb.c:ir_array_set_unchecked Unexecuted instantiation: ir_patch.c:ir_array_set_unchecked ir_ra.c:ir_array_set_unchecked Line | Count | Source | 712 | 383k | { | 713 | 383k | IR_ASSERT(i < a->size); | 714 | 383k | a->refs[i] = val; | 715 | 383k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_array_set_unchecked Unexecuted instantiation: ir_save.c:ir_array_set_unchecked Unexecuted instantiation: ir_sccp.c:ir_array_set_unchecked Unexecuted instantiation: ir_strtab.c:ir_array_set_unchecked Unexecuted instantiation: ir.c:ir_array_set_unchecked |
716 | | |
717 | | /* List/Stack of numeric references */ |
718 | | typedef struct _ir_list { |
719 | | ir_array a; |
720 | | uint32_t len; |
721 | | } ir_list; |
722 | | |
723 | | uint32_t ir_list_find(const ir_list *l, ir_ref val); |
724 | | void ir_list_insert(ir_list *l, uint32_t i, ir_ref val); |
725 | | void ir_list_remove(ir_list *l, uint32_t i); |
726 | | |
727 | | IR_ALWAYS_INLINE void ir_list_init(ir_list *l, uint32_t size) |
728 | 76.9k | { |
729 | 76.9k | ir_array_init(&l->a, size); |
730 | 76.9k | l->len = 0; |
731 | 76.9k | } Line | Count | Source | 728 | 22.9k | { | 729 | 22.9k | ir_array_init(&l->a, size); | 730 | 22.9k | l->len = 0; | 731 | 22.9k | } |
Unexecuted instantiation: ir_check.c:ir_list_init Unexecuted instantiation: ir_dump.c:ir_list_init Unexecuted instantiation: ir_emit.c:ir_list_init Line | Count | Source | 728 | 23.8k | { | 729 | 23.8k | ir_array_init(&l->a, size); | 730 | 23.8k | l->len = 0; | 731 | 23.8k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_init Unexecuted instantiation: ir_patch.c:ir_list_init Line | Count | Source | 728 | 30.1k | { | 729 | 30.1k | ir_array_init(&l->a, size); | 730 | 30.1k | l->len = 0; | 731 | 30.1k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_init Unexecuted instantiation: ir_save.c:ir_list_init Unexecuted instantiation: ir_sccp.c:ir_list_init Unexecuted instantiation: ir_strtab.c:ir_list_init Unexecuted instantiation: ir.c:ir_list_init |
732 | | |
733 | | IR_ALWAYS_INLINE void ir_list_free(ir_list *l) |
734 | 76.9k | { |
735 | 76.9k | ir_array_free(&l->a); |
736 | 76.9k | l->len = 0; |
737 | 76.9k | } Line | Count | Source | 734 | 22.9k | { | 735 | 22.9k | ir_array_free(&l->a); | 736 | 22.9k | l->len = 0; | 737 | 22.9k | } |
Unexecuted instantiation: ir_check.c:ir_list_free Unexecuted instantiation: ir_dump.c:ir_list_free Unexecuted instantiation: ir_emit.c:ir_list_free Line | Count | Source | 734 | 23.8k | { | 735 | 23.8k | ir_array_free(&l->a); | 736 | 23.8k | l->len = 0; | 737 | 23.8k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_free Unexecuted instantiation: ir_patch.c:ir_list_free Line | Count | Source | 734 | 30.1k | { | 735 | 30.1k | ir_array_free(&l->a); | 736 | 30.1k | l->len = 0; | 737 | 30.1k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_free Unexecuted instantiation: ir_save.c:ir_list_free Unexecuted instantiation: ir_sccp.c:ir_list_free Unexecuted instantiation: ir_strtab.c:ir_list_free Unexecuted instantiation: ir.c:ir_list_free |
738 | | |
739 | | IR_ALWAYS_INLINE void ir_list_clear(ir_list *l) |
740 | 2.07k | { |
741 | 2.07k | l->len = 0; |
742 | 2.07k | } Unexecuted instantiation: ir_check.c:ir_list_clear Unexecuted instantiation: ir_dump.c:ir_list_clear Unexecuted instantiation: ir_emit.c:ir_list_clear Line | Count | Source | 740 | 2.06k | { | 741 | 2.06k | l->len = 0; | 742 | 2.06k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_clear Unexecuted instantiation: ir_patch.c:ir_list_clear Unexecuted instantiation: ir_ra.c:ir_list_clear Unexecuted instantiation: ir_ra_simple.c:ir_list_clear Unexecuted instantiation: ir_save.c:ir_list_clear Unexecuted instantiation: ir_sccp.c:ir_list_clear Unexecuted instantiation: ir_strtab.c:ir_list_clear Unexecuted instantiation: ir.c:ir_list_clear |
743 | | |
744 | | IR_ALWAYS_INLINE uint32_t ir_list_len(const ir_list *l) |
745 | 1.91M | { |
746 | 1.91M | return l->len; |
747 | 1.91M | } Line | Count | Source | 745 | 1.08M | { | 746 | 1.08M | return l->len; | 747 | 1.08M | } |
Unexecuted instantiation: ir_check.c:ir_list_len Unexecuted instantiation: ir_dump.c:ir_list_len Unexecuted instantiation: ir_emit.c:ir_list_len Line | Count | Source | 745 | 60.6k | { | 746 | 60.6k | return l->len; | 747 | 60.6k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_len Unexecuted instantiation: ir_patch.c:ir_list_len Line | Count | Source | 745 | 766k | { | 746 | 766k | return l->len; | 747 | 766k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_len Unexecuted instantiation: ir_save.c:ir_list_len Unexecuted instantiation: ir_sccp.c:ir_list_len Unexecuted instantiation: ir_strtab.c:ir_list_len Unexecuted instantiation: ir.c:ir_list_len |
748 | | |
749 | | IR_ALWAYS_INLINE uint32_t ir_list_capasity(const ir_list *l) |
750 | 1.17M | { |
751 | 1.17M | return ir_array_size(&l->a); |
752 | 1.17M | } ir_cfg.c:ir_list_capasity Line | Count | Source | 750 | 1.17M | { | 751 | 1.17M | return ir_array_size(&l->a); | 752 | 1.17M | } |
Unexecuted instantiation: ir_check.c:ir_list_capasity Unexecuted instantiation: ir_dump.c:ir_list_capasity Unexecuted instantiation: ir_emit.c:ir_list_capasity Unexecuted instantiation: ir_gcm.c:ir_list_capasity Unexecuted instantiation: ir_gdb.c:ir_list_capasity Unexecuted instantiation: ir_patch.c:ir_list_capasity Line | Count | Source | 750 | 646 | { | 751 | 646 | return ir_array_size(&l->a); | 752 | 646 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_capasity Unexecuted instantiation: ir_save.c:ir_list_capasity Unexecuted instantiation: ir_sccp.c:ir_list_capasity Unexecuted instantiation: ir_strtab.c:ir_list_capasity Unexecuted instantiation: ir.c:ir_list_capasity |
753 | | |
754 | | IR_ALWAYS_INLINE void ir_list_push(ir_list *l, ir_ref val) |
755 | 304k | { |
756 | 304k | ir_array_set(&l->a, l->len++, val); |
757 | 304k | } Line | Count | Source | 755 | 3.21k | { | 756 | 3.21k | ir_array_set(&l->a, l->len++, val); | 757 | 3.21k | } |
Unexecuted instantiation: ir_check.c:ir_list_push Unexecuted instantiation: ir_dump.c:ir_list_push Unexecuted instantiation: ir_emit.c:ir_list_push Line | Count | Source | 755 | 6.32k | { | 756 | 6.32k | ir_array_set(&l->a, l->len++, val); | 757 | 6.32k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_push Unexecuted instantiation: ir_patch.c:ir_list_push Line | Count | Source | 755 | 295k | { | 756 | 295k | ir_array_set(&l->a, l->len++, val); | 757 | 295k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_push Unexecuted instantiation: ir_save.c:ir_list_push Unexecuted instantiation: ir_sccp.c:ir_list_push Unexecuted instantiation: ir_strtab.c:ir_list_push Unexecuted instantiation: ir.c:ir_list_push |
758 | | |
759 | | IR_ALWAYS_INLINE void ir_list_push_unchecked(ir_list *l, ir_ref val) |
760 | 1.91M | { |
761 | 1.91M | ir_array_set_unchecked(&l->a, l->len++, val); |
762 | 1.91M | } ir_cfg.c:ir_list_push_unchecked Line | Count | Source | 760 | 502k | { | 761 | 502k | ir_array_set_unchecked(&l->a, l->len++, val); | 762 | 502k | } |
Unexecuted instantiation: ir_check.c:ir_list_push_unchecked Unexecuted instantiation: ir_dump.c:ir_list_push_unchecked Unexecuted instantiation: ir_emit.c:ir_list_push_unchecked ir_gcm.c:ir_list_push_unchecked Line | Count | Source | 760 | 1.03M | { | 761 | 1.03M | ir_array_set_unchecked(&l->a, l->len++, val); | 762 | 1.03M | } |
Unexecuted instantiation: ir_gdb.c:ir_list_push_unchecked Unexecuted instantiation: ir_patch.c:ir_list_push_unchecked ir_ra.c:ir_list_push_unchecked Line | Count | Source | 760 | 383k | { | 761 | 383k | ir_array_set_unchecked(&l->a, l->len++, val); | 762 | 383k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_push_unchecked Unexecuted instantiation: ir_save.c:ir_list_push_unchecked Unexecuted instantiation: ir_sccp.c:ir_list_push_unchecked Unexecuted instantiation: ir_strtab.c:ir_list_push_unchecked Unexecuted instantiation: ir.c:ir_list_push_unchecked |
763 | | |
764 | | IR_ALWAYS_INLINE ir_ref ir_list_pop(ir_list *l) |
765 | 845k | { |
766 | 845k | IR_ASSERT(l->len > 0); |
767 | 845k | return ir_array_at(&l->a, --l->len); |
768 | 845k | } Line | Count | Source | 765 | 505k | { | 766 | 505k | IR_ASSERT(l->len > 0); | 767 | 505k | return ir_array_at(&l->a, --l->len); | 768 | 505k | } |
Unexecuted instantiation: ir_check.c:ir_list_pop Unexecuted instantiation: ir_dump.c:ir_list_pop Unexecuted instantiation: ir_emit.c:ir_list_pop Line | Count | Source | 765 | 43.7k | { | 766 | 43.7k | IR_ASSERT(l->len > 0); | 767 | 43.7k | return ir_array_at(&l->a, --l->len); | 768 | 43.7k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_pop Unexecuted instantiation: ir_patch.c:ir_list_pop Line | Count | Source | 765 | 295k | { | 766 | 295k | IR_ASSERT(l->len > 0); | 767 | 295k | return ir_array_at(&l->a, --l->len); | 768 | 295k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_pop Unexecuted instantiation: ir_save.c:ir_list_pop Unexecuted instantiation: ir_sccp.c:ir_list_pop Unexecuted instantiation: ir_strtab.c:ir_list_pop Unexecuted instantiation: ir.c:ir_list_pop |
769 | | |
770 | | IR_ALWAYS_INLINE ir_ref ir_list_peek(const ir_list *l) |
771 | 350k | { |
772 | 350k | IR_ASSERT(l->len > 0); |
773 | 350k | return ir_array_at(&l->a, l->len - 1); |
774 | 350k | } Line | Count | Source | 771 | 350k | { | 772 | 350k | IR_ASSERT(l->len > 0); | 773 | 350k | return ir_array_at(&l->a, l->len - 1); | 774 | 350k | } |
Unexecuted instantiation: ir_check.c:ir_list_peek Unexecuted instantiation: ir_dump.c:ir_list_peek Unexecuted instantiation: ir_emit.c:ir_list_peek Unexecuted instantiation: ir_gcm.c:ir_list_peek Unexecuted instantiation: ir_gdb.c:ir_list_peek Unexecuted instantiation: ir_patch.c:ir_list_peek Unexecuted instantiation: ir_ra.c:ir_list_peek Unexecuted instantiation: ir_ra_simple.c:ir_list_peek Unexecuted instantiation: ir_save.c:ir_list_peek Unexecuted instantiation: ir_sccp.c:ir_list_peek Unexecuted instantiation: ir_strtab.c:ir_list_peek Unexecuted instantiation: ir.c:ir_list_peek |
775 | | |
776 | | IR_ALWAYS_INLINE ir_ref ir_list_at(const ir_list *l, uint32_t i) |
777 | 1.62M | { |
778 | 1.62M | IR_ASSERT(i < l->len); |
779 | 1.62M | return ir_array_at(&l->a, i); |
780 | 1.62M | } Unexecuted instantiation: ir_cfg.c:ir_list_at Unexecuted instantiation: ir_check.c:ir_list_at Unexecuted instantiation: ir_dump.c:ir_list_at Unexecuted instantiation: ir_emit.c:ir_list_at Line | Count | Source | 777 | 992k | { | 778 | 992k | IR_ASSERT(i < l->len); | 779 | 992k | return ir_array_at(&l->a, i); | 780 | 992k | } |
Unexecuted instantiation: ir_gdb.c:ir_list_at Unexecuted instantiation: ir_patch.c:ir_list_at Line | Count | Source | 777 | 630k | { | 778 | 630k | IR_ASSERT(i < l->len); | 779 | 630k | return ir_array_at(&l->a, i); | 780 | 630k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_list_at Unexecuted instantiation: ir_save.c:ir_list_at Unexecuted instantiation: ir_sccp.c:ir_list_at Unexecuted instantiation: ir_strtab.c:ir_list_at Unexecuted instantiation: ir.c:ir_list_at |
781 | | |
782 | | IR_ALWAYS_INLINE void ir_list_set(ir_list *l, uint32_t i, ir_ref val) |
783 | 0 | { |
784 | 0 | IR_ASSERT(i < l->len); |
785 | 0 | ir_array_set_unchecked(&l->a, i, val); |
786 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_list_set Unexecuted instantiation: ir_check.c:ir_list_set Unexecuted instantiation: ir_dump.c:ir_list_set Unexecuted instantiation: ir_emit.c:ir_list_set Unexecuted instantiation: ir_gcm.c:ir_list_set Unexecuted instantiation: ir_gdb.c:ir_list_set Unexecuted instantiation: ir_patch.c:ir_list_set Unexecuted instantiation: ir_ra.c:ir_list_set Unexecuted instantiation: ir_ra_simple.c:ir_list_set Unexecuted instantiation: ir_save.c:ir_list_set Unexecuted instantiation: ir_sccp.c:ir_list_set Unexecuted instantiation: ir_strtab.c:ir_list_set Unexecuted instantiation: ir.c:ir_list_set |
787 | | |
788 | | /* Doesn't preserve order */ |
789 | | IR_ALWAYS_INLINE void ir_list_del(ir_list *l, uint32_t i) |
790 | 0 | { |
791 | 0 | IR_ASSERT(i < l->len); |
792 | 0 | l->len--; |
793 | 0 | ir_array_set_unchecked(&l->a, i, ir_array_at(&l->a, l->len)); |
794 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_list_del Unexecuted instantiation: ir_check.c:ir_list_del Unexecuted instantiation: ir_dump.c:ir_list_del Unexecuted instantiation: ir_emit.c:ir_list_del Unexecuted instantiation: ir_gcm.c:ir_list_del Unexecuted instantiation: ir_gdb.c:ir_list_del Unexecuted instantiation: ir_patch.c:ir_list_del Unexecuted instantiation: ir_ra.c:ir_list_del Unexecuted instantiation: ir_ra_simple.c:ir_list_del Unexecuted instantiation: ir_save.c:ir_list_del Unexecuted instantiation: ir_sccp.c:ir_list_del Unexecuted instantiation: ir_strtab.c:ir_list_del Unexecuted instantiation: ir.c:ir_list_del |
795 | | |
796 | | IR_ALWAYS_INLINE bool ir_list_contains(const ir_list *l, ir_ref val) |
797 | 0 | { |
798 | 0 | return ir_list_find(l, val) != (uint32_t)-1; |
799 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_list_contains Unexecuted instantiation: ir_check.c:ir_list_contains Unexecuted instantiation: ir_dump.c:ir_list_contains Unexecuted instantiation: ir_emit.c:ir_list_contains Unexecuted instantiation: ir_gcm.c:ir_list_contains Unexecuted instantiation: ir_gdb.c:ir_list_contains Unexecuted instantiation: ir_patch.c:ir_list_contains Unexecuted instantiation: ir_ra.c:ir_list_contains Unexecuted instantiation: ir_ra_simple.c:ir_list_contains Unexecuted instantiation: ir_save.c:ir_list_contains Unexecuted instantiation: ir_sccp.c:ir_list_contains Unexecuted instantiation: ir_strtab.c:ir_list_contains Unexecuted instantiation: ir.c:ir_list_contains |
800 | | |
801 | | /* Worklist (unique list) */ |
802 | | typedef struct _ir_worklist { |
803 | | ir_list l; |
804 | | ir_bitset visited; |
805 | | } ir_worklist; |
806 | | |
807 | | IR_ALWAYS_INLINE void ir_worklist_init(ir_worklist *w, uint32_t size) |
808 | 13.3k | { |
809 | 13.3k | ir_list_init(&w->l, size); |
810 | 13.3k | w->visited = ir_bitset_malloc(size); |
811 | 13.3k | } ir_cfg.c:ir_worklist_init Line | Count | Source | 808 | 13.0k | { | 809 | 13.0k | ir_list_init(&w->l, size); | 810 | 13.0k | w->visited = ir_bitset_malloc(size); | 811 | 13.0k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_init Unexecuted instantiation: ir_dump.c:ir_worklist_init Unexecuted instantiation: ir_emit.c:ir_worklist_init Unexecuted instantiation: ir_gcm.c:ir_worklist_init Unexecuted instantiation: ir_gdb.c:ir_worklist_init Unexecuted instantiation: ir_patch.c:ir_worklist_init Line | Count | Source | 808 | 323 | { | 809 | 323 | ir_list_init(&w->l, size); | 810 | 323 | w->visited = ir_bitset_malloc(size); | 811 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_init Unexecuted instantiation: ir_save.c:ir_worklist_init Unexecuted instantiation: ir_sccp.c:ir_worklist_init Unexecuted instantiation: ir_strtab.c:ir_worklist_init Unexecuted instantiation: ir.c:ir_worklist_init |
812 | | |
813 | | IR_ALWAYS_INLINE void ir_worklist_free(ir_worklist *w) |
814 | 13.3k | { |
815 | 13.3k | ir_list_free(&w->l); |
816 | 13.3k | ir_mem_free(w->visited); |
817 | 13.3k | } ir_cfg.c:ir_worklist_free Line | Count | Source | 814 | 13.0k | { | 815 | 13.0k | ir_list_free(&w->l); | 816 | | ir_mem_free(w->visited); | 817 | 13.0k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_free Unexecuted instantiation: ir_dump.c:ir_worklist_free Unexecuted instantiation: ir_emit.c:ir_worklist_free Unexecuted instantiation: ir_gcm.c:ir_worklist_free Unexecuted instantiation: ir_gdb.c:ir_worklist_free Unexecuted instantiation: ir_patch.c:ir_worklist_free Line | Count | Source | 814 | 323 | { | 815 | 323 | ir_list_free(&w->l); | 816 | | ir_mem_free(w->visited); | 817 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_free Unexecuted instantiation: ir_save.c:ir_worklist_free Unexecuted instantiation: ir_sccp.c:ir_worklist_free Unexecuted instantiation: ir_strtab.c:ir_worklist_free Unexecuted instantiation: ir.c:ir_worklist_free |
818 | | |
819 | | IR_ALWAYS_INLINE uint32_t ir_worklist_len(const ir_worklist *w) |
820 | 573k | { |
821 | 573k | return ir_list_len(&w->l); |
822 | 573k | } Line | Count | Source | 820 | 573k | { | 821 | 573k | return ir_list_len(&w->l); | 822 | 573k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_len Unexecuted instantiation: ir_dump.c:ir_worklist_len Unexecuted instantiation: ir_emit.c:ir_worklist_len Unexecuted instantiation: ir_gcm.c:ir_worklist_len Unexecuted instantiation: ir_gdb.c:ir_worklist_len Unexecuted instantiation: ir_patch.c:ir_worklist_len Line | Count | Source | 820 | 323 | { | 821 | 323 | return ir_list_len(&w->l); | 822 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_len Unexecuted instantiation: ir_save.c:ir_worklist_len Unexecuted instantiation: ir_sccp.c:ir_worklist_len Unexecuted instantiation: ir_strtab.c:ir_worklist_len Unexecuted instantiation: ir.c:ir_worklist_len |
823 | | |
824 | | IR_ALWAYS_INLINE uint32_t ir_worklist_capasity(const ir_worklist *w) |
825 | 679k | { |
826 | 679k | return ir_list_capasity(&w->l); |
827 | 679k | } ir_cfg.c:ir_worklist_capasity Line | Count | Source | 825 | 678k | { | 826 | 678k | return ir_list_capasity(&w->l); | 827 | 678k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_capasity Unexecuted instantiation: ir_dump.c:ir_worklist_capasity Unexecuted instantiation: ir_emit.c:ir_worklist_capasity Unexecuted instantiation: ir_gcm.c:ir_worklist_capasity Unexecuted instantiation: ir_gdb.c:ir_worklist_capasity Unexecuted instantiation: ir_patch.c:ir_worklist_capasity ir_ra.c:ir_worklist_capasity Line | Count | Source | 825 | 323 | { | 826 | 323 | return ir_list_capasity(&w->l); | 827 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_capasity Unexecuted instantiation: ir_save.c:ir_worklist_capasity Unexecuted instantiation: ir_sccp.c:ir_worklist_capasity Unexecuted instantiation: ir_strtab.c:ir_worklist_capasity Unexecuted instantiation: ir.c:ir_worklist_capasity |
828 | | |
829 | | IR_ALWAYS_INLINE void ir_worklist_clear(ir_worklist *w) |
830 | 4 | { |
831 | 4 | ir_list_clear(&w->l); |
832 | 4 | ir_bitset_clear(w->visited, ir_bitset_len(ir_worklist_capasity(w))); |
833 | 4 | } ir_cfg.c:ir_worklist_clear Line | Count | Source | 830 | 4 | { | 831 | 4 | ir_list_clear(&w->l); | 832 | 4 | ir_bitset_clear(w->visited, ir_bitset_len(ir_worklist_capasity(w))); | 833 | 4 | } |
Unexecuted instantiation: ir_check.c:ir_worklist_clear Unexecuted instantiation: ir_dump.c:ir_worklist_clear Unexecuted instantiation: ir_emit.c:ir_worklist_clear Unexecuted instantiation: ir_gcm.c:ir_worklist_clear Unexecuted instantiation: ir_gdb.c:ir_worklist_clear Unexecuted instantiation: ir_patch.c:ir_worklist_clear Unexecuted instantiation: ir_ra.c:ir_worklist_clear Unexecuted instantiation: ir_ra_simple.c:ir_worklist_clear Unexecuted instantiation: ir_save.c:ir_worklist_clear Unexecuted instantiation: ir_sccp.c:ir_worklist_clear Unexecuted instantiation: ir_strtab.c:ir_worklist_clear Unexecuted instantiation: ir.c:ir_worklist_clear |
834 | | |
835 | | IR_ALWAYS_INLINE bool ir_worklist_push(ir_worklist *w, ir_ref val) |
836 | 675k | { |
837 | 675k | IR_ASSERT(val >= 0 && (uint32_t)val < ir_worklist_capasity(w)); |
838 | 675k | if (ir_bitset_in(w->visited, val)) { |
839 | 178k | return 0; |
840 | 178k | } |
841 | 497k | ir_bitset_incl(w->visited, val); |
842 | 497k | IR_ASSERT(ir_list_len(&w->l) < ir_list_capasity(&w->l)); |
843 | 497k | ir_list_push_unchecked(&w->l, val); |
844 | 497k | return 1; |
845 | 497k | } ir_cfg.c:ir_worklist_push Line | Count | Source | 836 | 675k | { | 837 | 675k | IR_ASSERT(val >= 0 && (uint32_t)val < ir_worklist_capasity(w)); | 838 | 675k | if (ir_bitset_in(w->visited, val)) { | 839 | 178k | return 0; | 840 | 178k | } | 841 | 497k | ir_bitset_incl(w->visited, val); | 842 | 497k | IR_ASSERT(ir_list_len(&w->l) < ir_list_capasity(&w->l)); | 843 | 497k | ir_list_push_unchecked(&w->l, val); | 844 | 497k | return 1; | 845 | 497k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_push Unexecuted instantiation: ir_dump.c:ir_worklist_push Unexecuted instantiation: ir_emit.c:ir_worklist_push Unexecuted instantiation: ir_gcm.c:ir_worklist_push Unexecuted instantiation: ir_gdb.c:ir_worklist_push Unexecuted instantiation: ir_patch.c:ir_worklist_push Line | Count | Source | 836 | 323 | { | 837 | 323 | IR_ASSERT(val >= 0 && (uint32_t)val < ir_worklist_capasity(w)); | 838 | 323 | if (ir_bitset_in(w->visited, val)) { | 839 | 0 | return 0; | 840 | 0 | } | 841 | 323 | ir_bitset_incl(w->visited, val); | 842 | 323 | IR_ASSERT(ir_list_len(&w->l) < ir_list_capasity(&w->l)); | 843 | 323 | ir_list_push_unchecked(&w->l, val); | 844 | 323 | return 1; | 845 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_push Unexecuted instantiation: ir_save.c:ir_worklist_push Unexecuted instantiation: ir_sccp.c:ir_worklist_push Unexecuted instantiation: ir_strtab.c:ir_worklist_push Unexecuted instantiation: ir.c:ir_worklist_push |
846 | | |
847 | | IR_ALWAYS_INLINE ir_ref ir_worklist_pop(ir_worklist *w) |
848 | 502k | { |
849 | 502k | return ir_list_pop(&w->l); |
850 | 502k | } Line | Count | Source | 848 | 502k | { | 849 | 502k | return ir_list_pop(&w->l); | 850 | 502k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_pop Unexecuted instantiation: ir_dump.c:ir_worklist_pop Unexecuted instantiation: ir_emit.c:ir_worklist_pop Unexecuted instantiation: ir_gcm.c:ir_worklist_pop Unexecuted instantiation: ir_gdb.c:ir_worklist_pop Unexecuted instantiation: ir_patch.c:ir_worklist_pop Line | Count | Source | 848 | 323 | { | 849 | 323 | return ir_list_pop(&w->l); | 850 | 323 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_worklist_pop Unexecuted instantiation: ir_save.c:ir_worklist_pop Unexecuted instantiation: ir_sccp.c:ir_worklist_pop Unexecuted instantiation: ir_strtab.c:ir_worklist_pop Unexecuted instantiation: ir.c:ir_worklist_pop |
851 | | |
852 | | IR_ALWAYS_INLINE ir_ref ir_worklist_peek(const ir_worklist *w) |
853 | 350k | { |
854 | 350k | return ir_list_peek(&w->l); |
855 | 350k | } ir_cfg.c:ir_worklist_peek Line | Count | Source | 853 | 350k | { | 854 | 350k | return ir_list_peek(&w->l); | 855 | 350k | } |
Unexecuted instantiation: ir_check.c:ir_worklist_peek Unexecuted instantiation: ir_dump.c:ir_worklist_peek Unexecuted instantiation: ir_emit.c:ir_worklist_peek Unexecuted instantiation: ir_gcm.c:ir_worklist_peek Unexecuted instantiation: ir_gdb.c:ir_worklist_peek Unexecuted instantiation: ir_patch.c:ir_worklist_peek Unexecuted instantiation: ir_ra.c:ir_worklist_peek Unexecuted instantiation: ir_ra_simple.c:ir_worklist_peek Unexecuted instantiation: ir_save.c:ir_worklist_peek Unexecuted instantiation: ir_sccp.c:ir_worklist_peek Unexecuted instantiation: ir_strtab.c:ir_worklist_peek Unexecuted instantiation: ir.c:ir_worklist_peek |
856 | | |
857 | | /* IR Hash Table */ |
858 | 146 | #define IR_INVALID_IDX 0xffffffff |
859 | 29 | #define IR_INVALID_VAL 0x80000000 |
860 | | |
861 | | typedef struct _ir_hashtab_bucket { |
862 | | uint32_t key; |
863 | | ir_ref val; |
864 | | uint32_t next; |
865 | | } ir_hashtab_bucket; |
866 | | |
867 | | typedef struct _ir_hashtab { |
868 | | void *data; |
869 | | uint32_t mask; |
870 | | uint32_t size; |
871 | | uint32_t count; |
872 | | uint32_t pos; |
873 | | } ir_hashtab; |
874 | | |
875 | | void ir_hashtab_init(ir_hashtab *tab, uint32_t size); |
876 | | void ir_hashtab_free(ir_hashtab *tab); |
877 | | ir_ref ir_hashtab_find(const ir_hashtab *tab, uint32_t key); |
878 | | bool ir_hashtab_add(ir_hashtab *tab, uint32_t key, ir_ref val); |
879 | | void ir_hashtab_key_sort(ir_hashtab *tab); |
880 | | |
881 | | /* IR Addr Table */ |
882 | | typedef struct _ir_addrtab_bucket { |
883 | | uint64_t key; |
884 | | ir_ref val; |
885 | | uint32_t next; |
886 | | } ir_addrtab_bucket; |
887 | | |
888 | | void ir_addrtab_init(ir_hashtab *tab, uint32_t size); |
889 | | void ir_addrtab_free(ir_hashtab *tab); |
890 | | ir_ref ir_addrtab_find(const ir_hashtab *tab, uint64_t key); |
891 | | void ir_addrtab_set(ir_hashtab *tab, uint64_t key, ir_ref val); |
892 | | |
893 | | /*** IR Type info ***/ |
894 | | extern const uint8_t ir_type_flags[IR_LAST_TYPE]; |
895 | | extern const char *ir_type_name[IR_LAST_TYPE]; |
896 | | extern const char *ir_type_cname[IR_LAST_TYPE]; |
897 | | extern const uint8_t ir_type_size[IR_LAST_TYPE]; |
898 | | |
899 | 0 | #define IR_VECTOR_SIZE(t) (ir_type_size[IR_VECTOR_BASE_TYPE(t)] * IR_VECTOR_LENGTH(t)) |
900 | | #define IR_MAKE_VECTOR_TYPE(base, length) ir_make_vector_type(base, length) |
901 | | |
902 | | IR_ALWAYS_INLINE ir_type ir_make_vector_type(ir_type base, uint8_t length) |
903 | 0 | { |
904 | 0 | IR_ASSERT(IR_IS_TYPE_SCALAR(base) && length > 0 && length <= 64 && (length & (length - 1)) == 0); |
905 | 0 |
|
906 | 0 | if (base == IR_CHAR) { |
907 | 0 | base = IR_I8; |
908 | 0 | } |
909 | 0 | return base | ((ir_ntz(length) + 1) << 4); |
910 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_make_vector_type Unexecuted instantiation: ir_check.c:ir_make_vector_type Unexecuted instantiation: ir_dump.c:ir_make_vector_type Unexecuted instantiation: ir_emit.c:ir_make_vector_type Unexecuted instantiation: ir_gcm.c:ir_make_vector_type Unexecuted instantiation: ir_gdb.c:ir_make_vector_type Unexecuted instantiation: ir_patch.c:ir_make_vector_type Unexecuted instantiation: ir_ra.c:ir_make_vector_type Unexecuted instantiation: ir_ra_simple.c:ir_make_vector_type Unexecuted instantiation: ir_save.c:ir_make_vector_type Unexecuted instantiation: ir_sccp.c:ir_make_vector_type Unexecuted instantiation: ir_strtab.c:ir_make_vector_type Unexecuted instantiation: ir.c:ir_make_vector_type |
911 | | |
912 | | IR_ALWAYS_INLINE uint32_t ir_get_type_size(ir_type type) |
913 | 7.34k | { |
914 | 7.34k | #if IR_SIMD |
915 | 7.34k | if (IR_IS_TYPE_VECTOR(type)) return IR_VECTOR_SIZE(type); |
916 | 7.34k | #endif |
917 | 7.34k | return ir_type_size[type]; |
918 | 7.34k | } Unexecuted instantiation: ir_cfg.c:ir_get_type_size Unexecuted instantiation: ir_check.c:ir_get_type_size Unexecuted instantiation: ir_dump.c:ir_get_type_size ir_emit.c:ir_get_type_size Line | Count | Source | 913 | 472 | { | 914 | 472 | #if IR_SIMD | 915 | 472 | if (IR_IS_TYPE_VECTOR(type)) return IR_VECTOR_SIZE(type); | 916 | 472 | #endif | 917 | 472 | return ir_type_size[type]; | 918 | 472 | } |
Unexecuted instantiation: ir_gcm.c:ir_get_type_size Unexecuted instantiation: ir_gdb.c:ir_get_type_size Unexecuted instantiation: ir_patch.c:ir_get_type_size Line | Count | Source | 913 | 650 | { | 914 | 650 | #if IR_SIMD | 915 | 650 | if (IR_IS_TYPE_VECTOR(type)) return IR_VECTOR_SIZE(type); | 916 | 650 | #endif | 917 | 650 | return ir_type_size[type]; | 918 | 650 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_get_type_size Unexecuted instantiation: ir_save.c:ir_get_type_size ir_sccp.c:ir_get_type_size Line | Count | Source | 913 | 8 | { | 914 | 8 | #if IR_SIMD | 915 | 8 | if (IR_IS_TYPE_VECTOR(type)) return IR_VECTOR_SIZE(type); | 916 | 8 | #endif | 917 | 8 | return ir_type_size[type]; | 918 | 8 | } |
Unexecuted instantiation: ir_strtab.c:ir_get_type_size Line | Count | Source | 913 | 6.21k | { | 914 | 6.21k | #if IR_SIMD | 915 | 6.21k | if (IR_IS_TYPE_VECTOR(type)) return IR_VECTOR_SIZE(type); | 916 | 6.21k | #endif | 917 | 6.21k | return ir_type_size[type]; | 918 | 6.21k | } |
|
919 | | |
920 | | /*** IR OP info ***/ |
921 | | extern const uint32_t ir_op_flags[IR_LAST_OP]; |
922 | | extern const char *ir_op_name[IR_LAST_OP]; |
923 | | |
924 | | void ir_print_escaped_str(const char *s, size_t len, FILE *f); |
925 | | |
926 | 134k | #define IR_IS_CONST_OP(op) ((op) > IR_NOP && (op) <= IR_C_FLOAT) |
927 | 191k | #define IR_IS_FOLDABLE_OP(op) ((op) <= IR_LAST_FOLDABLE_OP) |
928 | 976k | #define IR_IS_SYM_CONST(op) ((op) == IR_STR || (op) == IR_SYM || (op) == IR_FUNC || (op) == IR_LABEL) |
929 | | |
930 | | ir_ref ir_const_ex(ir_ctx *ctx, ir_val val, uint8_t type, uint32_t optx); |
931 | | |
932 | | IR_ALWAYS_INLINE bool ir_const_is_true(const ir_insn *v) |
933 | 52 | { |
934 | 52 | if (IR_IS_SYM_CONST(v->op)) { |
935 | 0 | return 1; |
936 | 52 | } else if (v->type == IR_BOOL) { |
937 | 43 | return v->val.b; |
938 | 43 | } else if (IR_IS_TYPE_INT(v->type)) { |
939 | 9 | return v->val.i64 != 0; |
940 | 9 | } else if (v->type == IR_DOUBLE) { |
941 | 0 | return v->val.d != 0.0; |
942 | 0 | } else { |
943 | 0 | IR_ASSERT(v->type == IR_FLOAT); |
944 | 0 | return v->val.f != 0.0; |
945 | 0 | } |
946 | 0 | return 0; |
947 | 52 | } Unexecuted instantiation: ir_cfg.c:ir_const_is_true Unexecuted instantiation: ir_check.c:ir_const_is_true Unexecuted instantiation: ir_dump.c:ir_const_is_true Unexecuted instantiation: ir_emit.c:ir_const_is_true Unexecuted instantiation: ir_gcm.c:ir_const_is_true Unexecuted instantiation: ir_gdb.c:ir_const_is_true Unexecuted instantiation: ir_patch.c:ir_const_is_true Unexecuted instantiation: ir_ra.c:ir_const_is_true Unexecuted instantiation: ir_ra_simple.c:ir_const_is_true Unexecuted instantiation: ir_save.c:ir_const_is_true ir_sccp.c:ir_const_is_true Line | Count | Source | 933 | 43 | { | 934 | 43 | if (IR_IS_SYM_CONST(v->op)) { | 935 | 0 | return 1; | 936 | 43 | } else if (v->type == IR_BOOL) { | 937 | 43 | return v->val.b; | 938 | 43 | } else if (IR_IS_TYPE_INT(v->type)) { | 939 | 0 | return v->val.i64 != 0; | 940 | 0 | } else if (v->type == IR_DOUBLE) { | 941 | 0 | return v->val.d != 0.0; | 942 | 0 | } else { | 943 | 0 | IR_ASSERT(v->type == IR_FLOAT); | 944 | 0 | return v->val.f != 0.0; | 945 | 0 | } | 946 | 0 | return 0; | 947 | 43 | } |
Unexecuted instantiation: ir_strtab.c:ir_const_is_true Line | Count | Source | 933 | 9 | { | 934 | 9 | if (IR_IS_SYM_CONST(v->op)) { | 935 | 0 | return 1; | 936 | 9 | } else if (v->type == IR_BOOL) { | 937 | 0 | return v->val.b; | 938 | 9 | } else if (IR_IS_TYPE_INT(v->type)) { | 939 | 9 | return v->val.i64 != 0; | 940 | 9 | } else if (v->type == IR_DOUBLE) { | 941 | 0 | return v->val.d != 0.0; | 942 | 0 | } else { | 943 | 0 | IR_ASSERT(v->type == IR_FLOAT); | 944 | 0 | return v->val.f != 0.0; | 945 | 0 | } | 946 | 0 | return 0; | 947 | 9 | } |
|
948 | | |
949 | | IR_ALWAYS_INLINE bool ir_ref_is_true(const ir_ctx *ctx, ir_ref ref) |
950 | 467 | { |
951 | 467 | if (ref == IR_TRUE) { |
952 | 80 | return 1; |
953 | 387 | } else if (ref == IR_FALSE) { |
954 | 378 | return 0; |
955 | 378 | } else { |
956 | 9 | IR_ASSERT(IR_IS_CONST_REF(ref)); |
957 | 9 | return ir_const_is_true(&ctx->ir_base[ref]); |
958 | 9 | } |
959 | 467 | } Unexecuted instantiation: ir_cfg.c:ir_ref_is_true Unexecuted instantiation: ir_check.c:ir_ref_is_true Unexecuted instantiation: ir_dump.c:ir_ref_is_true Line | Count | Source | 950 | 163 | { | 951 | 163 | if (ref == IR_TRUE) { | 952 | 0 | return 1; | 953 | 163 | } else if (ref == IR_FALSE) { | 954 | 163 | return 0; | 955 | 163 | } else { | 956 | 0 | IR_ASSERT(IR_IS_CONST_REF(ref)); | 957 | 0 | return ir_const_is_true(&ctx->ir_base[ref]); | 958 | 0 | } | 959 | 163 | } |
Unexecuted instantiation: ir_gcm.c:ir_ref_is_true Unexecuted instantiation: ir_gdb.c:ir_ref_is_true Unexecuted instantiation: ir_patch.c:ir_ref_is_true Unexecuted instantiation: ir_ra.c:ir_ref_is_true Unexecuted instantiation: ir_ra_simple.c:ir_ref_is_true Unexecuted instantiation: ir_save.c:ir_ref_is_true Line | Count | Source | 950 | 10 | { | 951 | 10 | if (ref == IR_TRUE) { | 952 | 3 | return 1; | 953 | 7 | } else if (ref == IR_FALSE) { | 954 | 7 | return 0; | 955 | 7 | } else { | 956 | 0 | IR_ASSERT(IR_IS_CONST_REF(ref)); | 957 | 0 | return ir_const_is_true(&ctx->ir_base[ref]); | 958 | 0 | } | 959 | 10 | } |
Unexecuted instantiation: ir_strtab.c:ir_ref_is_true Line | Count | Source | 950 | 294 | { | 951 | 294 | if (ref == IR_TRUE) { | 952 | 77 | return 1; | 953 | 217 | } else if (ref == IR_FALSE) { | 954 | 208 | return 0; | 955 | 208 | } else { | 956 | 9 | IR_ASSERT(IR_IS_CONST_REF(ref)); | 957 | 9 | return ir_const_is_true(&ctx->ir_base[ref]); | 958 | 9 | } | 959 | 294 | } |
|
960 | | |
961 | | IR_ALWAYS_INLINE bool ir_neg_is_safe(ir_type type, int64_t val) |
962 | 0 | { |
963 | 0 | return val != (INT64_MIN >> ((8 - ir_type_size[type]) * 8)); |
964 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_neg_is_safe Unexecuted instantiation: ir_check.c:ir_neg_is_safe Unexecuted instantiation: ir_dump.c:ir_neg_is_safe Unexecuted instantiation: ir_emit.c:ir_neg_is_safe Unexecuted instantiation: ir_gcm.c:ir_neg_is_safe Unexecuted instantiation: ir_gdb.c:ir_neg_is_safe Unexecuted instantiation: ir_patch.c:ir_neg_is_safe Unexecuted instantiation: ir_ra.c:ir_neg_is_safe Unexecuted instantiation: ir_ra_simple.c:ir_neg_is_safe Unexecuted instantiation: ir_save.c:ir_neg_is_safe Unexecuted instantiation: ir_sccp.c:ir_neg_is_safe Unexecuted instantiation: ir_strtab.c:ir_neg_is_safe Unexecuted instantiation: ir.c:ir_neg_is_safe |
965 | | |
966 | | /* Clear the "uvisible" high bits */ |
967 | | IR_ALWAYS_INLINE uint64_t ir_fix_unsigned(ir_type type, uint64_t val) |
968 | 11.9k | { |
969 | 11.9k | uint64_t shift; |
970 | | |
971 | 11.9k | shift = (8 - ir_type_size[type]) * 8; |
972 | 11.9k | return (val << shift) >> shift; |
973 | 11.9k | } Unexecuted instantiation: ir_cfg.c:ir_fix_unsigned Unexecuted instantiation: ir_check.c:ir_fix_unsigned Unexecuted instantiation: ir_dump.c:ir_fix_unsigned Unexecuted instantiation: ir_emit.c:ir_fix_unsigned Unexecuted instantiation: ir_gcm.c:ir_fix_unsigned Unexecuted instantiation: ir_gdb.c:ir_fix_unsigned Unexecuted instantiation: ir_patch.c:ir_fix_unsigned Unexecuted instantiation: ir_ra.c:ir_fix_unsigned Unexecuted instantiation: ir_ra_simple.c:ir_fix_unsigned Unexecuted instantiation: ir_save.c:ir_fix_unsigned Unexecuted instantiation: ir_sccp.c:ir_fix_unsigned Unexecuted instantiation: ir_strtab.c:ir_fix_unsigned Line | Count | Source | 968 | 11.9k | { | 969 | 11.9k | uint64_t shift; | 970 | | | 971 | 11.9k | shift = (8 - ir_type_size[type]) * 8; | 972 | 11.9k | return (val << shift) >> shift; | 973 | 11.9k | } |
|
974 | | |
975 | | /* Sign extend the value into the "uvisible" high bits */ |
976 | | IR_ALWAYS_INLINE uint64_t ir_fix_signed(ir_type type, uint64_t val) |
977 | 0 | { |
978 | 0 | uint64_t shift; |
979 | |
|
980 | 0 | shift = (8 - ir_type_size[type]) * 8; |
981 | 0 | return (int64_t)(val << shift) >> shift; |
982 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_fix_signed Unexecuted instantiation: ir_check.c:ir_fix_signed Unexecuted instantiation: ir_dump.c:ir_fix_signed Unexecuted instantiation: ir_emit.c:ir_fix_signed Unexecuted instantiation: ir_gcm.c:ir_fix_signed Unexecuted instantiation: ir_gdb.c:ir_fix_signed Unexecuted instantiation: ir_patch.c:ir_fix_signed Unexecuted instantiation: ir_ra.c:ir_fix_signed Unexecuted instantiation: ir_ra_simple.c:ir_fix_signed Unexecuted instantiation: ir_save.c:ir_fix_signed Unexecuted instantiation: ir_sccp.c:ir_fix_signed Unexecuted instantiation: ir_strtab.c:ir_fix_signed Unexecuted instantiation: ir.c:ir_fix_signed |
983 | | |
984 | | IR_ALWAYS_INLINE uint64_t ir_fix_int(ir_type type, uint64_t val) |
985 | 237 | { |
986 | 237 | IR_ASSERT(IR_IS_TYPE_INT(type)); |
987 | 237 | if (IR_IS_TYPE_SIGNED(type)) { |
988 | 0 | return ir_fix_signed(type, val); |
989 | 237 | } else { |
990 | 237 | return ir_fix_unsigned(type, val); |
991 | 237 | } |
992 | 237 | } Unexecuted instantiation: ir_cfg.c:ir_fix_int Unexecuted instantiation: ir_check.c:ir_fix_int Unexecuted instantiation: ir_dump.c:ir_fix_int Unexecuted instantiation: ir_emit.c:ir_fix_int Unexecuted instantiation: ir_gcm.c:ir_fix_int Unexecuted instantiation: ir_gdb.c:ir_fix_int Unexecuted instantiation: ir_patch.c:ir_fix_int Unexecuted instantiation: ir_ra.c:ir_fix_int Unexecuted instantiation: ir_ra_simple.c:ir_fix_int Unexecuted instantiation: ir_save.c:ir_fix_int Unexecuted instantiation: ir_sccp.c:ir_fix_int Unexecuted instantiation: ir_strtab.c:ir_fix_int Line | Count | Source | 985 | 237 | { | 986 | 237 | IR_ASSERT(IR_IS_TYPE_INT(type)); | 987 | 237 | if (IR_IS_TYPE_SIGNED(type)) { | 988 | 0 | return ir_fix_signed(type, val); | 989 | 237 | } else { | 990 | 237 | return ir_fix_unsigned(type, val); | 991 | 237 | } | 992 | 237 | } |
|
993 | | |
994 | | /* IR OP flags */ |
995 | 0 | #define IR_OP_FLAG_OPERANDS_SHIFT 3 |
996 | | |
997 | 14.0M | #define IR_OP_FLAG_EDGES_MASK 0x03 |
998 | 959k | #define IR_OP_FLAG_VAR_INPUTS 0x04 |
999 | 0 | #define IR_OP_FLAG_OPERANDS_MASK 0x18 |
1000 | | #define IR_OP_FLAG_MEM_MASK ((1<<6)|(1<<7)) |
1001 | | |
1002 | 9.14M | #define IR_OP_FLAG_DATA (1<<8) |
1003 | 5.69M | #define IR_OP_FLAG_CONTROL (1<<9) |
1004 | 6.10M | #define IR_OP_FLAG_MEM (1<<10) |
1005 | 19.4k | #define IR_OP_FLAG_COMMUTATIVE (1<<11) |
1006 | 7.13M | #define IR_OP_FLAG_BB_START (1<<12) |
1007 | 4.47M | #define IR_OP_FLAG_BB_END (1<<13) |
1008 | 189k | #define IR_OP_FLAG_TERMINATOR (1<<14) |
1009 | 1.01M | #define IR_OP_FLAG_PINNED (1<<15) |
1010 | | |
1011 | | #define IR_OP_FLAG_MEM_CALL ((0<<6)|(0<<7)) |
1012 | | #define IR_OP_FLAG_MEM_LOAD ((0<<6)|(1<<7)) /* no side effect (may be removed if not used) */ |
1013 | | #define IR_OP_FLAG_MEM_STORE ((1<<6)|(0<<7)) |
1014 | | #define IR_OP_FLAG_MEM_ALLOC ((1<<6)|(1<<7)) /* no side effect (may be removed if not used) */ |
1015 | | #define IR_OP_FLAG_MEM_MASK ((1<<6)|(1<<7)) |
1016 | | |
1017 | 959k | #define IR_OP_FLAG_NO_SIDE_EFFECT ((0<<6)|(1<<7)) |
1018 | | |
1019 | | |
1020 | 0 | #define IR_OPND_UNUSED 0x0U |
1021 | 5.09M | #define IR_OPND_DATA 0x1U |
1022 | 4.47M | #define IR_OPND_CONTROL 0x2U |
1023 | 0 | #define IR_OPND_LABEL_REF 0x3U |
1024 | 74.1k | #define IR_OPND_CONTROL_DEP 0x4U |
1025 | 2.29k | #define IR_OPND_CONTROL_REF 0x5U |
1026 | 4.70k | #define IR_OPND_CONTROL_GUARD 0x6U |
1027 | 0 | #define IR_OPND_STR 0x7U |
1028 | 0 | #define IR_OPND_NUM 0x8U |
1029 | 0 | #define IR_OPND_OPT 0x9U /* optional number (flags, branch propability, align, size+align) */ |
1030 | 0 | #define IR_OPND_PROTO 0xaU |
1031 | | |
1032 | | #define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \ |
1033 | | ((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28)) |
1034 | | |
1035 | 14.0M | #define IR_INPUT_EDGES_COUNT(flags) (flags & IR_OP_FLAG_EDGES_MASK) |
1036 | 0 | #define IR_OPERANDS_COUNT(flags) ((flags & IR_OP_FLAG_OPERANDS_MASK) >> IR_OP_FLAG_OPERANDS_SHIFT) |
1037 | | |
1038 | 1.91M | #define IR_OP_HAS_VAR_INPUTS(flags) ((flags) & IR_OP_FLAG_VAR_INPUTS) |
1039 | | |
1040 | | #define IR_OPND_KIND(flags, i) \ |
1041 | 9.65M | (((flags) >> (16 + (4 * (((i) > 3) ? 3 : (i))))) & 0xf) |
1042 | | |
1043 | | #define IR_IS_REF_OPND_KIND(kind) \ |
1044 | 0 | ((kind) >= IR_OPND_DATA && (kind) <= IR_OPND_CONTROL_GUARD) |
1045 | | |
1046 | | IR_ALWAYS_INLINE ir_ref ir_operands_count(const ir_ctx *ctx, const ir_insn *insn) |
1047 | 0 | { |
1048 | 0 | uint32_t flags = ir_op_flags[insn->op]; |
1049 | 0 | uint32_t n = IR_OPERANDS_COUNT(flags); |
1050 | |
|
1051 | 0 | if (UNEXPECTED(IR_OP_HAS_VAR_INPUTS(flags))) { |
1052 | | /* MERGE, PHI, CALL, etc */ |
1053 | 0 | n = insn->inputs_count; |
1054 | 0 | } |
1055 | 0 | return n; |
1056 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_operands_count Unexecuted instantiation: ir_check.c:ir_operands_count Unexecuted instantiation: ir_dump.c:ir_operands_count Unexecuted instantiation: ir_emit.c:ir_operands_count Unexecuted instantiation: ir_gcm.c:ir_operands_count Unexecuted instantiation: ir_gdb.c:ir_operands_count Unexecuted instantiation: ir_patch.c:ir_operands_count Unexecuted instantiation: ir_ra.c:ir_operands_count Unexecuted instantiation: ir_ra_simple.c:ir_operands_count Unexecuted instantiation: ir_save.c:ir_operands_count Unexecuted instantiation: ir_sccp.c:ir_operands_count Unexecuted instantiation: ir_strtab.c:ir_operands_count Unexecuted instantiation: ir.c:ir_operands_count |
1057 | | |
1058 | | IR_ALWAYS_INLINE ir_ref ir_input_edges_count(const ir_ctx *ctx, const ir_insn *insn) |
1059 | 10.4M | { |
1060 | 10.4M | uint32_t flags = ir_op_flags[insn->op]; |
1061 | 10.4M | uint32_t n = IR_INPUT_EDGES_COUNT(flags); |
1062 | 10.4M | if (UNEXPECTED(IR_OP_HAS_VAR_INPUTS(flags))) { |
1063 | | /* MERGE, PHI, CALL, etc */ |
1064 | 1.48M | n = insn->inputs_count; |
1065 | 1.48M | } |
1066 | 10.4M | return n; |
1067 | 10.4M | } Unexecuted instantiation: ir_cfg.c:ir_input_edges_count ir_check.c:ir_input_edges_count Line | Count | Source | 1059 | 10.4M | { | 1060 | 10.4M | uint32_t flags = ir_op_flags[insn->op]; | 1061 | 10.4M | uint32_t n = IR_INPUT_EDGES_COUNT(flags); | 1062 | 10.4M | if (UNEXPECTED(IR_OP_HAS_VAR_INPUTS(flags))) { | 1063 | | /* MERGE, PHI, CALL, etc */ | 1064 | 1.48M | n = insn->inputs_count; | 1065 | 1.48M | } | 1066 | 10.4M | return n; | 1067 | 10.4M | } |
Unexecuted instantiation: ir_dump.c:ir_input_edges_count Unexecuted instantiation: ir_emit.c:ir_input_edges_count Unexecuted instantiation: ir_gcm.c:ir_input_edges_count Unexecuted instantiation: ir_gdb.c:ir_input_edges_count Unexecuted instantiation: ir_patch.c:ir_input_edges_count Unexecuted instantiation: ir_ra.c:ir_input_edges_count Unexecuted instantiation: ir_ra_simple.c:ir_input_edges_count Unexecuted instantiation: ir_save.c:ir_input_edges_count Unexecuted instantiation: ir_sccp.c:ir_input_edges_count Unexecuted instantiation: ir_strtab.c:ir_input_edges_count Unexecuted instantiation: ir.c:ir_input_edges_count |
1068 | | |
1069 | | IR_ALWAYS_INLINE uint32_t ir_insn_inputs_to_len(uint32_t inputs_count) |
1070 | 10.0M | { |
1071 | 10.0M | return 1 + (inputs_count >> 2); |
1072 | 10.0M | } Unexecuted instantiation: ir_cfg.c:ir_insn_inputs_to_len ir_check.c:ir_insn_inputs_to_len Line | Count | Source | 1070 | 5.26M | { | 1071 | 5.26M | return 1 + (inputs_count >> 2); | 1072 | 5.26M | } |
Unexecuted instantiation: ir_dump.c:ir_insn_inputs_to_len ir_emit.c:ir_insn_inputs_to_len Line | Count | Source | 1070 | 1.55M | { | 1071 | 1.55M | return 1 + (inputs_count >> 2); | 1072 | 1.55M | } |
ir_gcm.c:ir_insn_inputs_to_len Line | Count | Source | 1070 | 1.43M | { | 1071 | 1.43M | return 1 + (inputs_count >> 2); | 1072 | 1.43M | } |
Unexecuted instantiation: ir_gdb.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_patch.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_ra.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_ra_simple.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_save.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_sccp.c:ir_insn_inputs_to_len Unexecuted instantiation: ir_strtab.c:ir_insn_inputs_to_len ir.c:ir_insn_inputs_to_len Line | Count | Source | 1070 | 1.75M | { | 1071 | 1.75M | return 1 + (inputs_count >> 2); | 1072 | 1.75M | } |
|
1073 | | |
1074 | | IR_ALWAYS_INLINE uint32_t ir_insn_len(const ir_insn *insn) |
1075 | 1.55M | { |
1076 | 1.55M | return ir_insn_inputs_to_len(insn->inputs_count); |
1077 | 1.55M | } Unexecuted instantiation: ir_cfg.c:ir_insn_len Unexecuted instantiation: ir_check.c:ir_insn_len Unexecuted instantiation: ir_dump.c:ir_insn_len Line | Count | Source | 1075 | 1.55M | { | 1076 | 1.55M | return ir_insn_inputs_to_len(insn->inputs_count); | 1077 | 1.55M | } |
Unexecuted instantiation: ir_gcm.c:ir_insn_len Unexecuted instantiation: ir_gdb.c:ir_insn_len Unexecuted instantiation: ir_patch.c:ir_insn_len Unexecuted instantiation: ir_ra.c:ir_insn_len Unexecuted instantiation: ir_ra_simple.c:ir_insn_len Unexecuted instantiation: ir_save.c:ir_insn_len Unexecuted instantiation: ir_sccp.c:ir_insn_len Unexecuted instantiation: ir_strtab.c:ir_insn_len Unexecuted instantiation: ir.c:ir_insn_len |
1078 | | |
1079 | | /*** IR Context Private Flags (ir_ctx->flags2) ***/ |
1080 | 3.21k | #define IR_CFG_HAS_LOOPS (1<<0) |
1081 | 0 | #define IR_IRREDUCIBLE_CFG (1<<1) |
1082 | 0 | #define IR_HAS_ALLOCA (1<<2) |
1083 | 90.8k | #define IR_HAS_CALLS (1<<3) |
1084 | 19.8k | #define IR_OPT_IN_SCCP (1<<4) |
1085 | 11.1M | #define IR_LINEAR (1<<5) |
1086 | 0 | #define IR_HAS_VA_START (1<<6) |
1087 | 0 | #define IR_HAS_VA_COPY (1<<7) |
1088 | 0 | #define IR_HAS_VA_ARG_GP (1<<8) |
1089 | 0 | #define IR_HAS_VA_ARG_FP (1<<9) |
1090 | 0 | #define IR_HAS_FP_RET_SLOT (1<<10) |
1091 | 19.4k | #define IR_16B_FRAME_ALIGNMENT (1<<11) |
1092 | 9.94k | #define IR_HAS_BLOCK_ADDR (1<<12) |
1093 | 160k | #define IR_PREALLOCATED_STACK (1<<13) |
1094 | 17.1k | #define IR_RECURSIVE_TAILCALL (1<<14) |
1095 | 0 | #define IR_HAS_MEMCPY (1<<15) |
1096 | 0 | #define IR_HAS_LONG_CONSTANTS (1<<16) |
1097 | | |
1098 | | /* Temporary: MEM2SSA -> SCCP */ |
1099 | 78.7k | #define IR_MEM2SSA_VARS (1<<25) |
1100 | | |
1101 | | /* Temporary: SCCP -> CFG */ |
1102 | 29.8k | #define IR_CFG_REACHABLE (1<<26) |
1103 | | |
1104 | | /* Temporary: Dominators -> Loops */ |
1105 | 23.0k | #define IR_NO_LOOPS (1<<25) |
1106 | | |
1107 | | /* Temporary: Live Ranges */ |
1108 | 23.6k | #define IR_LR_HAVE_DESSA_MOVES (1<<25) |
1109 | | |
1110 | | /* Temporary: Register Allocator */ |
1111 | 30.4k | #define IR_RA_HAVE_SPLITS (1<<25) |
1112 | 29.8k | #define IR_RA_HAVE_SPILLS (1<<26) |
1113 | | |
1114 | | #define IR_RESERVED_FLAG_1 (1U<<31) |
1115 | | |
1116 | | /*** IR Use Lists ***/ |
1117 | | struct _ir_use_list { |
1118 | | ir_ref refs; /* index in ir_ctx->use_edges[] array */ |
1119 | | ir_ref count; |
1120 | | }; |
1121 | | |
1122 | | void ir_use_list_remove_all(ir_ctx *ctx, ir_ref def, ir_ref use); |
1123 | | void ir_use_list_remove_one(ir_ctx *ctx, ir_ref def, ir_ref use); |
1124 | | void ir_use_list_replace_all(ir_ctx *ctx, ir_ref def, ir_ref use, ir_ref new_use); |
1125 | | void ir_use_list_replace_one(ir_ctx *ctx, ir_ref def, ir_ref use, ir_ref new_use); |
1126 | | bool ir_use_list_add(ir_ctx *ctx, ir_ref def, ir_ref use); |
1127 | | |
1128 | | IR_ALWAYS_INLINE ir_ref ir_next_control(const ir_ctx *ctx, ir_ref ref) |
1129 | 1.12k | { |
1130 | 1.12k | ir_use_list *use_list = &ctx->use_lists[ref]; |
1131 | 1.12k | ir_ref n = use_list->count; |
1132 | 1.12k | ir_ref *p; |
1133 | | |
1134 | 1.12k | IR_ASSERT(ir_op_flags[ctx->ir_base[ref].op] & IR_OP_FLAG_CONTROL); |
1135 | 1.33k | for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) { |
1136 | 1.33k | ir_ref next = *p; |
1137 | 1.33k | ir_insn *insn = &ctx->ir_base[next]; |
1138 | | |
1139 | 1.33k | if ((ir_op_flags[insn->op] & IR_OP_FLAG_CONTROL) && insn->op1 == ref) { |
1140 | 1.12k | return next; |
1141 | 1.12k | } |
1142 | 1.33k | } |
1143 | 0 | IR_ASSERT(0); |
1144 | 0 | return IR_UNUSED; |
1145 | 0 | } Line | Count | Source | 1129 | 743 | { | 1130 | 743 | ir_use_list *use_list = &ctx->use_lists[ref]; | 1131 | 743 | ir_ref n = use_list->count; | 1132 | 743 | ir_ref *p; | 1133 | | | 1134 | 743 | IR_ASSERT(ir_op_flags[ctx->ir_base[ref].op] & IR_OP_FLAG_CONTROL); | 1135 | 945 | for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) { | 1136 | 945 | ir_ref next = *p; | 1137 | 945 | ir_insn *insn = &ctx->ir_base[next]; | 1138 | | | 1139 | 945 | if ((ir_op_flags[insn->op] & IR_OP_FLAG_CONTROL) && insn->op1 == ref) { | 1140 | 743 | return next; | 1141 | 743 | } | 1142 | 945 | } | 1143 | 0 | IR_ASSERT(0); | 1144 | 0 | return IR_UNUSED; | 1145 | 0 | } |
Unexecuted instantiation: ir_check.c:ir_next_control Unexecuted instantiation: ir_dump.c:ir_next_control ir_emit.c:ir_next_control Line | Count | Source | 1129 | 188 | { | 1130 | 188 | ir_use_list *use_list = &ctx->use_lists[ref]; | 1131 | 188 | ir_ref n = use_list->count; | 1132 | 188 | ir_ref *p; | 1133 | | | 1134 | 188 | IR_ASSERT(ir_op_flags[ctx->ir_base[ref].op] & IR_OP_FLAG_CONTROL); | 1135 | 188 | for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) { | 1136 | 188 | ir_ref next = *p; | 1137 | 188 | ir_insn *insn = &ctx->ir_base[next]; | 1138 | | | 1139 | 188 | if ((ir_op_flags[insn->op] & IR_OP_FLAG_CONTROL) && insn->op1 == ref) { | 1140 | 188 | return next; | 1141 | 188 | } | 1142 | 188 | } | 1143 | 0 | IR_ASSERT(0); | 1144 | 0 | return IR_UNUSED; | 1145 | 0 | } |
Unexecuted instantiation: ir_gcm.c:ir_next_control Unexecuted instantiation: ir_gdb.c:ir_next_control Unexecuted instantiation: ir_patch.c:ir_next_control Line | Count | Source | 1129 | 188 | { | 1130 | 188 | ir_use_list *use_list = &ctx->use_lists[ref]; | 1131 | 188 | ir_ref n = use_list->count; | 1132 | 188 | ir_ref *p; | 1133 | | | 1134 | 188 | IR_ASSERT(ir_op_flags[ctx->ir_base[ref].op] & IR_OP_FLAG_CONTROL); | 1135 | 188 | for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) { | 1136 | 188 | ir_ref next = *p; | 1137 | 188 | ir_insn *insn = &ctx->ir_base[next]; | 1138 | | | 1139 | 188 | if ((ir_op_flags[insn->op] & IR_OP_FLAG_CONTROL) && insn->op1 == ref) { | 1140 | 188 | return next; | 1141 | 188 | } | 1142 | 188 | } | 1143 | 0 | IR_ASSERT(0); | 1144 | 0 | return IR_UNUSED; | 1145 | 0 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_next_control Unexecuted instantiation: ir_save.c:ir_next_control ir_sccp.c:ir_next_control Line | Count | Source | 1129 | 7 | { | 1130 | 7 | ir_use_list *use_list = &ctx->use_lists[ref]; | 1131 | 7 | ir_ref n = use_list->count; | 1132 | 7 | ir_ref *p; | 1133 | | | 1134 | 7 | IR_ASSERT(ir_op_flags[ctx->ir_base[ref].op] & IR_OP_FLAG_CONTROL); | 1135 | 11 | for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) { | 1136 | 11 | ir_ref next = *p; | 1137 | 11 | ir_insn *insn = &ctx->ir_base[next]; | 1138 | | | 1139 | 11 | if ((ir_op_flags[insn->op] & IR_OP_FLAG_CONTROL) && insn->op1 == ref) { | 1140 | 7 | return next; | 1141 | 7 | } | 1142 | 11 | } | 1143 | 0 | IR_ASSERT(0); | 1144 | 0 | return IR_UNUSED; | 1145 | 0 | } |
Unexecuted instantiation: ir_strtab.c:ir_next_control Unexecuted instantiation: ir.c:ir_next_control |
1146 | | |
1147 | | /*** Modification helpers ***/ |
1148 | 13.0k | #define MAKE_NOP(_insn) do { \ |
1149 | 13.0k | ir_insn *__insn = _insn; \ |
1150 | 13.0k | __insn->optx = IR_NOP; \ |
1151 | 13.0k | __insn->op1 = __insn->op2 = __insn->op3 = IR_UNUSED; \ |
1152 | 13.0k | } while (0) |
1153 | | |
1154 | 7.27k | #define CLEAR_USES(_ref) do { \ |
1155 | 7.27k | ir_use_list *__use_list = &ctx->use_lists[_ref]; \ |
1156 | 7.27k | __use_list->count = 0; \ |
1157 | 7.27k | } while (0) |
1158 | | |
1159 | 18.6k | #define SWAP_REFS(_ref1, _ref2) do { \ |
1160 | 18.6k | ir_ref _tmp = _ref1; \ |
1161 | 18.6k | _ref1 = _ref2; \ |
1162 | 18.6k | _ref2 = _tmp; \ |
1163 | 18.6k | } while (0) |
1164 | | |
1165 | | #define SWAP_REGS(_reg1, _reg2) do { \ |
1166 | | ir_reg _tmp = _reg1; \ |
1167 | | _reg1 = _reg2; \ |
1168 | | _reg2 = _tmp; \ |
1169 | | } while (0) |
1170 | | |
1171 | 0 | #define SWAP_INSNS(_insn1, _insn2) do { \ |
1172 | 0 | ir_insn *_tmp = _insn1; \ |
1173 | 0 | _insn1 = _insn2; \ |
1174 | 0 | _insn2 = _tmp; \ |
1175 | 0 | } while (0) |
1176 | | |
1177 | | void ir_replace(ir_ctx *ctx, ir_ref ref, ir_ref new_ref); |
1178 | | void ir_update_op(ir_ctx *ctx, ir_ref ref, uint32_t idx, ir_ref new_val); |
1179 | | |
1180 | | /*** Iterative Optimization ***/ |
1181 | | void ir_iter_add_uses(ir_ctx *ctx, ir_ref ref, ir_bitqueue *worklist); |
1182 | | void ir_iter_replace(ir_ctx *ctx, ir_ref ref, ir_ref new_ref, ir_bitqueue *worklist); |
1183 | | void ir_iter_opt(ir_ctx *ctx, ir_bitqueue *worklist); |
1184 | | void ir_iter_cleanup(ir_ctx *ctx); |
1185 | | |
1186 | | /*** IR Basic Blocks info ***/ |
1187 | | #define IR_IS_BB_START(op) \ |
1188 | 1.07M | ((ir_op_flags[op] & IR_OP_FLAG_BB_START) != 0) |
1189 | | |
1190 | | #define IR_IS_BB_MERGE(op) \ |
1191 | | ((op) == IR_MERGE || (op) == IR_LOOP_BEGIN) |
1192 | | |
1193 | | #define IR_IS_BB_END(op) \ |
1194 | 743 | ((ir_op_flags[op] & IR_OP_FLAG_BB_END) != 0) |
1195 | | |
1196 | 10.6k | #define IR_BB_UNREACHABLE (1<<0) |
1197 | 1.85M | #define IR_BB_START (1<<1) |
1198 | 2.36M | #define IR_BB_ENTRY (1<<2) |
1199 | 568k | #define IR_BB_LOOP_HEADER (1<<3) |
1200 | 0 | #define IR_BB_IRREDUCIBLE_LOOP (1<<4) |
1201 | 0 | #define IR_BB_IRREDUCIBLE_ENTRY (1<<5) |
1202 | 174k | #define IR_BB_DESSA_MOVES (1<<6) /* translation out of SSA requires MOVEs */ |
1203 | 3.88M | #define IR_BB_EMPTY (1<<7) |
1204 | 0 | #define IR_BB_PREV_EMPTY_ENTRY (1<<8) |
1205 | 84.2k | #define IR_BB_OSR_ENTRY_LOADS (1<<9) /* OSR Entry-point with register LOADs */ |
1206 | 171k | #define IR_BB_LOOP_WITH_ENTRY (1<<10) /* set together with LOOP_HEADER if there is an ENTRY in the loop */ |
1207 | | |
1208 | | /* The following flags are set by GCM */ |
1209 | 846k | #define IR_BB_HAS_PHI (1<<11) |
1210 | 341k | #define IR_BB_HAS_PI (1<<12) |
1211 | 316k | #define IR_BB_HAS_PARAM (1<<13) |
1212 | 316k | #define IR_BB_HAS_VAR (1<<14) |
1213 | | |
1214 | | /* The following flags are set by BB scheduler */ |
1215 | 230k | #define IR_BB_ALIGN_LOOP (1<<15) |
1216 | | |
1217 | 7.59k | #define IR_BB_DESSA_TMP_INT (1<<16) /* translation out of SSA may need temporary genral purpose register */ |
1218 | 3.79k | #define IR_BB_DESSA_TMP_FP (1<<17) /* translation out of SSA may need temporary floating point register */ |
1219 | | |
1220 | | struct _ir_block { |
1221 | | uint32_t flags; |
1222 | | ir_ref start; /* index of first instruction */ |
1223 | | ir_ref end; /* index of last instruction */ |
1224 | | uint32_t successors; /* index in ir_ctx->cfg_edges[] array */ |
1225 | | uint32_t successors_count; |
1226 | | uint32_t predecessors; /* index in ir_ctx->cfg_edges[] array */ |
1227 | | uint32_t predecessors_count; |
1228 | | union { |
1229 | | uint32_t dom_parent; /* immediate dominator block */ |
1230 | | uint32_t idom; /* immediate dominator block */ |
1231 | | }; |
1232 | | union { |
1233 | | uint32_t dom_depth; /* depth from the root of the dominators tree */ |
1234 | | uint32_t postnum; /* used temporary for iterative Post Ordering */ |
1235 | | }; |
1236 | | uint32_t dom_child; /* first dominated blocks */ |
1237 | | uint32_t dom_next_child; /* next dominated block (linked list) */ |
1238 | | uint32_t loop_header; |
1239 | | union { |
1240 | | uint32_t loop_depth; |
1241 | | uint32_t next_succ; /* used temporary for iterative Post Ordering */ |
1242 | | uint32_t next_loop; /* used temporary for loop nesting tree */ |
1243 | | }; |
1244 | | }; |
1245 | | |
1246 | | void ir_build_prev_refs(ir_ctx *ctx); |
1247 | | uint32_t ir_skip_empty_target_blocks(const ir_ctx *ctx, uint32_t b); |
1248 | | uint32_t ir_next_block(const ir_ctx *ctx, uint32_t b); |
1249 | | void ir_get_true_false_blocks(const ir_ctx *ctx, uint32_t b, uint32_t *true_block, uint32_t *false_block); |
1250 | | |
1251 | | IR_ALWAYS_INLINE uint32_t ir_phi_input_number(const ir_ctx *ctx, const ir_block *bb, uint32_t from) |
1252 | 88.4k | { |
1253 | 88.4k | uint32_t n, *p; |
1254 | | |
1255 | 134k | for (n = 0, p = &ctx->cfg_edges[bb->predecessors]; n < bb->predecessors_count; p++, n++) { |
1256 | 134k | if (*p == from) { |
1257 | 88.4k | return n + 2; /* first input is a reference to MERGE */ |
1258 | 88.4k | } |
1259 | 134k | } |
1260 | 0 | IR_ASSERT(0); |
1261 | 0 | return 0; |
1262 | 0 | } Unexecuted instantiation: ir_cfg.c:ir_phi_input_number Unexecuted instantiation: ir_check.c:ir_phi_input_number Unexecuted instantiation: ir_dump.c:ir_phi_input_number ir_emit.c:ir_phi_input_number Line | Count | Source | 1252 | 3.79k | { | 1253 | 3.79k | uint32_t n, *p; | 1254 | | | 1255 | 4.29k | for (n = 0, p = &ctx->cfg_edges[bb->predecessors]; n < bb->predecessors_count; p++, n++) { | 1256 | 4.29k | if (*p == from) { | 1257 | 3.79k | return n + 2; /* first input is a reference to MERGE */ | 1258 | 3.79k | } | 1259 | 4.29k | } | 1260 | 0 | IR_ASSERT(0); | 1261 | 0 | return 0; | 1262 | 0 | } |
Unexecuted instantiation: ir_gcm.c:ir_phi_input_number Unexecuted instantiation: ir_gdb.c:ir_phi_input_number Unexecuted instantiation: ir_patch.c:ir_phi_input_number ir_ra.c:ir_phi_input_number Line | Count | Source | 1252 | 84.6k | { | 1253 | 84.6k | uint32_t n, *p; | 1254 | | | 1255 | 130k | for (n = 0, p = &ctx->cfg_edges[bb->predecessors]; n < bb->predecessors_count; p++, n++) { | 1256 | 130k | if (*p == from) { | 1257 | 84.6k | return n + 2; /* first input is a reference to MERGE */ | 1258 | 84.6k | } | 1259 | 130k | } | 1260 | 0 | IR_ASSERT(0); | 1261 | 0 | return 0; | 1262 | 0 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_phi_input_number Unexecuted instantiation: ir_save.c:ir_phi_input_number Unexecuted instantiation: ir_sccp.c:ir_phi_input_number Unexecuted instantiation: ir_strtab.c:ir_phi_input_number Unexecuted instantiation: ir.c:ir_phi_input_number |
1263 | | |
1264 | | /*** Folding Engine (see ir.c and ir_fold.h) ***/ |
1265 | | typedef enum _ir_fold_action { |
1266 | | IR_FOLD_DO_RESTART, |
1267 | | IR_FOLD_DO_CSE, |
1268 | | IR_FOLD_DO_EMIT, |
1269 | | IR_FOLD_DO_COPY, |
1270 | | IR_FOLD_DO_CONST |
1271 | | } ir_fold_action; |
1272 | | |
1273 | | ir_ref ir_folding(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3, |
1274 | | const ir_insn *op1_insn, const ir_insn *op2_insn, const ir_insn *op3_insn); |
1275 | | |
1276 | | /*** Alias Analyzes (see ir.c) ***/ |
1277 | | ir_ref ir_find_aliasing_load(const ir_ctx *ctx, ir_ref ref, ir_type type, ir_ref addr); |
1278 | | ir_ref ir_find_aliasing_vload(const ir_ctx *ctx, ir_ref ref, ir_type type, ir_ref var); |
1279 | | ir_ref ir_find_aliasing_store(ir_ctx *ctx, ir_ref ref, ir_ref addr, ir_ref val); |
1280 | | ir_ref ir_find_aliasing_vstore(ir_ctx *ctx, ir_ref ref, ir_ref addr, ir_ref val); |
1281 | | |
1282 | | /*** Predicates (see ir.c) ***/ |
1283 | | ir_ref ir_check_dominating_predicates(const ir_ctx *ctx, ir_ref ref, ir_ref condition); |
1284 | | |
1285 | | /*** IR Live Info ***/ |
1286 | | typedef ir_ref ir_live_pos; |
1287 | | typedef struct _ir_use_pos ir_use_pos; |
1288 | | |
1289 | 2.55M | #define IR_SUB_REFS_COUNT 4 |
1290 | | |
1291 | 191k | #define IR_LOAD_SUB_REF 0 |
1292 | 405k | #define IR_USE_SUB_REF 1 |
1293 | 166k | #define IR_DEF_SUB_REF 2 |
1294 | 35.8k | #define IR_SAVE_SUB_REF 3 |
1295 | | |
1296 | 883k | #define IR_LIVE_POS_TO_REF(pos) ((pos) / IR_SUB_REFS_COUNT) |
1297 | 0 | #define IR_LIVE_POS_TO_SUB_REF(pos) ((pos) % IR_SUB_REFS_COUNT) |
1298 | | |
1299 | | #define IR_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT) |
1300 | | |
1301 | 1.18M | #define IR_START_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT) |
1302 | 191k | #define IR_LOAD_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT + IR_LOAD_SUB_REF) |
1303 | 189k | #define IR_USE_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT + IR_USE_SUB_REF) |
1304 | 166k | #define IR_DEF_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT + IR_DEF_SUB_REF) |
1305 | 32.0k | #define IR_SAVE_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT + IR_SAVE_SUB_REF) |
1306 | 191k | #define IR_END_LIVE_POS_FROM_REF(ref) ((ref) * IR_SUB_REFS_COUNT + IR_SUB_REFS_COUNT) |
1307 | | |
1308 | | /* ir_use_pos.flags bits */ |
1309 | 1.12M | #define IR_USE_MUST_BE_IN_REG (1<<0) |
1310 | 191k | #define IR_USE_SHOULD_BE_IN_REG (1<<1) |
1311 | | #define IR_HINT_TWO_REGS (1<<2) |
1312 | 45.8k | #define IR_HINT_NEEDS_HOLE (1<<3) /* create a fake hole in live ranges to avoid conflict with fxed reg */ |
1313 | | |
1314 | 316k | #define IR_DEF_REUSES_OP1_REG (1<<3) |
1315 | 161k | #define IR_DEF_CONFLICTS_WITH_INPUT_REGS (1<<4) |
1316 | 428k | #define IR_EXTEND_INPUTS_TO_NEXT (1<<5) /* used for SNAPSHOT followed by GUARD */ |
1317 | | |
1318 | 89.1k | #define IR_FUSED_USE (1<<6) |
1319 | 48.1k | #define IR_PHI_USE (1<<7) |
1320 | | |
1321 | 1.12M | #define IR_OP1_MUST_BE_IN_REG (1<<16) |
1322 | 99.5k | #define IR_OP1_SHOULD_BE_IN_REG (1<<17) |
1323 | | #define IR_OP1_HINT_TWO_REGS (1<<18) |
1324 | | #define IR_OP1_HINT_NEEDS_HOLE (1<<19) |
1325 | 1.37M | #define IR_OP2_MUST_BE_IN_REG (1<<20) |
1326 | 271k | #define IR_OP2_SHOULD_BE_IN_REG (1<<21) |
1327 | | #define IR_OP2_HINT_TWO_REGS (1<<22) |
1328 | 133 | #define IR_OP2_HINT_NEEDS_HOLE (1<<23) |
1329 | 1.16M | #define IR_OP3_MUST_BE_IN_REG (1<<24) |
1330 | 133k | #define IR_OP3_SHOULD_BE_IN_REG (1<<25) |
1331 | | #define IR_OP3_HINT_TWO_REGS (1<<26) |
1332 | | #define IR_OP3_HINT_NEEDS_HOLE (1<<27) |
1333 | | |
1334 | 1.04M | #define IR_USE_FLAGS(def_flags, op_num) (((def_flags) >> (12 + (IR_MIN((op_num), 3) * 4))) & 15) |
1335 | | |
1336 | | struct _ir_use_pos { |
1337 | | uint16_t op_num; /* 0 - means result */ |
1338 | | int8_t hint; |
1339 | | uint8_t flags; |
1340 | | ir_ref hint_ref; /* negative references are used for FUSION anf PHI */ |
1341 | | ir_live_pos pos; |
1342 | | ir_use_pos *next; |
1343 | | }; |
1344 | | |
1345 | | struct _ir_live_range { |
1346 | | ir_live_pos start; /* inclusive */ |
1347 | | ir_live_pos end; /* exclusive */ |
1348 | | ir_live_range *next; |
1349 | | }; |
1350 | | |
1351 | | /* ir_live_interval.flags bits (two low bits are reserved for temporary register number) */ |
1352 | 31.6k | #define IR_LIVE_INTERVAL_FIXED (1<<0) |
1353 | 96.6k | #define IR_LIVE_INTERVAL_TEMP (1<<1) |
1354 | 757k | #define IR_LIVE_INTERVAL_HAS_HINT_REGS (1<<2) |
1355 | 670k | #define IR_LIVE_INTERVAL_HAS_HINT_REFS (1<<3) |
1356 | 186k | #define IR_LIVE_INTERVAL_MEM_PARAM (1<<4) /* PARAM passed on stack */ |
1357 | 180k | #define IR_LIVE_INTERVAL_COALESCED (1<<5) |
1358 | 1.57k | #define IR_LIVE_INTERVAL_SPILL_SPECIAL (1<<6) /* spill slot is pre-allocated in a special area (see ir_ctx.spill_reserved_base) */ |
1359 | 9.17k | #define IR_LIVE_INTERVAL_SPILLED (1<<7) |
1360 | 149k | #define IR_LIVE_INTERVAL_SPLIT_CHILD (1<<8) |
1361 | | #define IR_LIVE_INTERVAL_TWO_REGS (1<<9) |
1362 | 0 | #define IR_LIVE_INTERVAL_VAR_MEM_PARAM (1<<10) /* PARAM stack slot reused by VAR used in VSTORE(_, VAR, PARAM) */ |
1363 | | |
1364 | | /* macros to encode and decode stack offset stored in ctx->vregs[] */ |
1365 | 0 | #define IR_VREG_IS_STACK_SLOT(vreg) ((vreg) < 0) |
1366 | 0 | #define IR_VREG_TO_STACK_SLOT(vreg) ((vreg) + 0x40000000) |
1367 | 0 | #define IR_STACK_SLOT_TO_VREG(offset) ((int32_t)0xc0000000 + (offset)) |
1368 | | |
1369 | | struct _ir_live_interval { |
1370 | | uint8_t type; |
1371 | | int8_t reg; |
1372 | | #if IR_X86_I64 |
1373 | | int8_t reg_hi; |
1374 | | #endif |
1375 | | uint16_t flags; |
1376 | | union { |
1377 | | int32_t vreg; |
1378 | | int32_t tmp_ref; |
1379 | | }; |
1380 | | union { |
1381 | | int32_t stack_spill_pos; |
1382 | | ir_ref tmp_op_num; |
1383 | | }; |
1384 | | ir_live_pos end; /* end of the last live range (cahce of ival.range.{next->}end) */ |
1385 | | ir_live_range range; |
1386 | | ir_live_range *current_range; |
1387 | | ir_use_pos *use_pos; |
1388 | | ir_live_interval *next; |
1389 | | ir_live_interval *list_next; /* linked list of active, inactive or unhandled intervals */ |
1390 | | }; |
1391 | | |
1392 | | typedef int (*emit_copy_t)(ir_ctx *ctx, uint8_t type, ir_ref from, ir_ref to, void *data); |
1393 | | |
1394 | | int ir_gen_dessa_moves(ir_ctx *ctx, uint32_t b, emit_copy_t emit_copy, void *data); |
1395 | | |
1396 | | #if defined(IR_REGSET_64BIT) |
1397 | | |
1398 | | /*typedef enum _ir_reg ir_reg;*/ |
1399 | | typedef int8_t ir_reg; |
1400 | | |
1401 | | /*** Register Sets ***/ |
1402 | | #if IR_REGSET_64BIT |
1403 | | typedef uint64_t ir_regset; |
1404 | | #else |
1405 | | typedef uint32_t ir_regset; |
1406 | | #endif |
1407 | | |
1408 | 913k | #define IR_REGSET_EMPTY 0 |
1409 | | |
1410 | | #define IR_REGSET_IS_EMPTY(regset) \ |
1411 | 114k | (regset == IR_REGSET_EMPTY) |
1412 | | |
1413 | | #define IR_REGSET_IS_SINGLETON(regset) \ |
1414 | | (regset && !(regset & (regset - 1))) |
1415 | | |
1416 | | #if IR_REGSET_64BIT |
1417 | | # define IR_REGSET(reg) \ |
1418 | | (1ull << (reg)) |
1419 | | #else |
1420 | | # define IR_REGSET(reg) \ |
1421 | 758k | (1u << (reg)) |
1422 | | #endif |
1423 | | |
1424 | | #if IR_REGSET_64BIT |
1425 | | # define IR_REGSET_INTERVAL(reg1, reg2) \ |
1426 | | (((1ull << ((reg2) - (reg1) + 1)) - 1) << (reg1)) |
1427 | | #else |
1428 | | # define IR_REGSET_INTERVAL(reg1, reg2) \ |
1429 | | (((1u << ((reg2) - (reg1) + 1)) - 1) << (reg1)) |
1430 | | #endif |
1431 | | |
1432 | | #define IR_REGSET_IN(regset, reg) \ |
1433 | 323k | (((regset) & IR_REGSET(reg)) != 0) |
1434 | | |
1435 | | #define IR_REGSET_INCL(regset, reg) \ |
1436 | 323k | (regset) |= IR_REGSET(reg) |
1437 | | |
1438 | | #define IR_REGSET_EXCL(regset, reg) \ |
1439 | 115k | (regset) &= ~IR_REGSET(reg) |
1440 | | |
1441 | | #define IR_REGSET_UNION(set1, set2) \ |
1442 | 8.85k | ((set1) | (set2)) |
1443 | | |
1444 | | #define IR_REGSET_INTERSECTION(set1, set2) \ |
1445 | 209k | ((set1) & (set2)) |
1446 | | |
1447 | | #define IR_REGSET_DIFFERENCE(set1, set2) \ |
1448 | 740k | ((set1) & ~(set2)) |
1449 | | |
1450 | | #if IR_REGSET_64BIT |
1451 | | # define IR_REGSET_FIRST(set) ((ir_reg)ir_ntzl(set)) |
1452 | | # define ir_REGSET_LAST(set) ((ir_reg)(ir_nlzl(set)(set)^63)) |
1453 | | #else |
1454 | 252k | # define IR_REGSET_FIRST(set) ((ir_reg)ir_ntz(set)) |
1455 | | # define IR_REGSET_LAST(set) ((ir_reg)(ir_nlz(set)^31)) |
1456 | | #endif |
1457 | | |
1458 | | IR_ALWAYS_INLINE ir_reg ir_regset_pop_first(ir_regset *set) |
1459 | 104k | { |
1460 | 104k | ir_reg reg; |
1461 | | |
1462 | 104k | IR_ASSERT(!IR_REGSET_IS_EMPTY(*set)); |
1463 | 104k | reg = IR_REGSET_FIRST(*set); |
1464 | 104k | *set = (*set) & ((*set) - 1); |
1465 | 104k | return reg; |
1466 | 104k | } ir_emit.c:ir_regset_pop_first Line | Count | Source | 1459 | 24 | { | 1460 | 24 | ir_reg reg; | 1461 | | | 1462 | 24 | IR_ASSERT(!IR_REGSET_IS_EMPTY(*set)); | 1463 | 24 | reg = IR_REGSET_FIRST(*set); | 1464 | 24 | *set = (*set) & ((*set) - 1); | 1465 | 24 | return reg; | 1466 | 24 | } |
ir_ra.c:ir_regset_pop_first Line | Count | Source | 1459 | 104k | { | 1460 | 104k | ir_reg reg; | 1461 | | | 1462 | 104k | IR_ASSERT(!IR_REGSET_IS_EMPTY(*set)); | 1463 | 104k | reg = IR_REGSET_FIRST(*set); | 1464 | 104k | *set = (*set) & ((*set) - 1); | 1465 | 104k | return reg; | 1466 | 104k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_regset_pop_first |
1467 | | |
1468 | | #define IR_REGSET_FOREACH(set, reg) \ |
1469 | 10.1k | do { \ |
1470 | 10.1k | ir_regset _tmp = (set); \ |
1471 | 114k | while (!IR_REGSET_IS_EMPTY(_tmp)) { \ |
1472 | 104k | reg = ir_regset_pop_first(&_tmp); |
1473 | | |
1474 | | #define IR_REGSET_FOREACH_END() \ |
1475 | 104k | } \ |
1476 | 10.1k | } while (0) |
1477 | | |
1478 | | #endif /* defined(IR_REGSET_64BIT) */ |
1479 | | |
1480 | | /*** Calling Conventions ***/ |
1481 | | #if defined(IR_REGSET_64BIT) |
1482 | | struct _ir_call_conv_dsc { |
1483 | | bool cleanup_stack_by_callee: 1; /* use "retn $size" to return */ |
1484 | | bool pass_struct_by_val: 1; /* pass aggreagate by value, otherwise their copies are passed by ref */ |
1485 | | bool sysv_varargs: 1; /* Use SysV varargs ABI */ |
1486 | | bool shadow_param_regs: 1; /* registers for INT and FP parametrs shadow each other */ |
1487 | | /* (WIN64: 1-st arg is passed in %rcx/%xmm0, 2-nd in %rdx/%xmm1) */ |
1488 | | uint8_t shadow_store_size; /* reserved stack space to keep arguemnts passed in registers (WIN64) */ |
1489 | | uint8_t int_param_regs_count; /* number of registers for INT parameters */ |
1490 | | uint8_t fp_param_regs_count; /* number of registers for FP parameters */ |
1491 | | uint8_t vector_param_regs_count; /* number of registers for SIMD vector parameters */ |
1492 | | int8_t int_ret_reg; /* register to return INT value */ |
1493 | | int8_t int_ret2_reg; /* register to return second INT value (used to return I64 on 32-bit) */ |
1494 | | int8_t fp_ret_reg; /* register to return FP value */ |
1495 | | int8_t fp_ret2_reg; /* register to return second FP value */ |
1496 | | int8_t vector_ret_reg; /* register to return SIMD vector value */ |
1497 | | int8_t vector_ret2_reg; /* register to return second SIMD vector value */ |
1498 | | int8_t fp_varargs_reg; /* register to pass number of fp register arguments into vararg func */ |
1499 | | int8_t scratch_reg; /* pseudo register to reffer srcatch regset (clobbered by call) */ |
1500 | | const int8_t *int_param_regs; /* registers for INT parameters */ |
1501 | | const int8_t *fp_param_regs; /* registers for FP parameters */ |
1502 | | const int8_t *vector_param_regs; /* registers for SIMD vector parameters */ |
1503 | | ir_regset preserved_regs; /* preserved or callee-saved registers */ |
1504 | | }; |
1505 | | |
1506 | | extern const ir_regset ir_scratch_regset[]; |
1507 | | #endif |
1508 | | |
1509 | | typedef struct _ir_call_conv_dsc ir_call_conv_dsc; |
1510 | | |
1511 | | const ir_call_conv_dsc *ir_get_call_conv_dsc(uint32_t flags); |
1512 | | |
1513 | | /*** IR Register Allocation ***/ |
1514 | | /* Flags for ctx->regs[][] (low bits are used for register number itself) */ |
1515 | | typedef struct _ir_reg_alloc_data { |
1516 | | const ir_call_conv_dsc *cc; |
1517 | | int32_t unused_slot_4; |
1518 | | int32_t unused_slot_2; |
1519 | | int32_t unused_slot_1; |
1520 | | ir_live_interval **handled; |
1521 | | } ir_reg_alloc_data; |
1522 | | |
1523 | | int32_t ir_allocate_spill_slot(ir_ctx *ctx, size_t size, size_t align); |
1524 | | void ir_dump_reg(const ir_ctx *ctx, int8_t reg, ir_ref ref, bool store, FILE *f); |
1525 | | |
1526 | | IR_ALWAYS_INLINE void ir_set_alocated_reg(ir_ctx *ctx, ir_ref ref, int op_num, int8_t reg) |
1527 | 817k | { |
1528 | 817k | int8_t *regs = ctx->regs[ref]; |
1529 | | |
1530 | | /* regs[] is not limited by the declared boundary 4, the real boundary checked below */ |
1531 | 817k | IR_ASSERT(op_num >=0 && op_num <= IR_MAX(3, ctx->ir_base[ref].inputs_count)); |
1532 | 817k | regs[op_num] = reg; |
1533 | 817k | } Unexecuted instantiation: ir_cfg.c:ir_set_alocated_reg Unexecuted instantiation: ir_check.c:ir_set_alocated_reg Unexecuted instantiation: ir_dump.c:ir_set_alocated_reg Unexecuted instantiation: ir_emit.c:ir_set_alocated_reg Unexecuted instantiation: ir_gcm.c:ir_set_alocated_reg Unexecuted instantiation: ir_gdb.c:ir_set_alocated_reg Unexecuted instantiation: ir_patch.c:ir_set_alocated_reg ir_ra.c:ir_set_alocated_reg Line | Count | Source | 1527 | 817k | { | 1528 | 817k | int8_t *regs = ctx->regs[ref]; | 1529 | | | 1530 | | /* regs[] is not limited by the declared boundary 4, the real boundary checked below */ | 1531 | 817k | IR_ASSERT(op_num >=0 && op_num <= IR_MAX(3, ctx->ir_base[ref].inputs_count)); | 1532 | 817k | regs[op_num] = reg; | 1533 | 817k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_set_alocated_reg Unexecuted instantiation: ir_save.c:ir_set_alocated_reg Unexecuted instantiation: ir_sccp.c:ir_set_alocated_reg Unexecuted instantiation: ir_strtab.c:ir_set_alocated_reg Unexecuted instantiation: ir.c:ir_set_alocated_reg |
1534 | | |
1535 | | IR_ALWAYS_INLINE void ir_set_alocated_tmp_reg(ir_ctx *ctx, ir_ref ref, int op_num, int8_t reg) |
1536 | 95.9k | { |
1537 | 95.9k | int8_t *regs = ctx->regs[ref]; |
1538 | | |
1539 | 95.9k | if (UNEXPECTED(op_num == 4)) { |
1540 | | /* Used for COND(I64, _, _) and SIMD instructions */ |
1541 | 0 | if (!ctx->tmp_regs) { |
1542 | 0 | ctx->tmp_regs = ir_mem_malloc(ctx->insns_count); |
1543 | 0 | memset(ctx->tmp_regs, -1, ctx->insns_count); |
1544 | 0 | } |
1545 | 0 | ctx->tmp_regs[ref] = reg; |
1546 | 0 | return; |
1547 | 0 | } |
1548 | 95.9k | IR_ASSERT(op_num >= 0 && op_num <= 3); |
1549 | 95.9k | regs[op_num] = reg; |
1550 | 95.9k | } Unexecuted instantiation: ir_cfg.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_check.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_dump.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_emit.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_gcm.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_gdb.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_patch.c:ir_set_alocated_tmp_reg ir_ra.c:ir_set_alocated_tmp_reg Line | Count | Source | 1536 | 95.9k | { | 1537 | 95.9k | int8_t *regs = ctx->regs[ref]; | 1538 | | | 1539 | 95.9k | if (UNEXPECTED(op_num == 4)) { | 1540 | | /* Used for COND(I64, _, _) and SIMD instructions */ | 1541 | 0 | if (!ctx->tmp_regs) { | 1542 | 0 | ctx->tmp_regs = ir_mem_malloc(ctx->insns_count); | 1543 | 0 | memset(ctx->tmp_regs, -1, ctx->insns_count); | 1544 | 0 | } | 1545 | 0 | ctx->tmp_regs[ref] = reg; | 1546 | 0 | return; | 1547 | 0 | } | 1548 | 95.9k | IR_ASSERT(op_num >= 0 && op_num <= 3); | 1549 | 95.9k | regs[op_num] = reg; | 1550 | 95.9k | } |
Unexecuted instantiation: ir_ra_simple.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_save.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_sccp.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir_strtab.c:ir_set_alocated_tmp_reg Unexecuted instantiation: ir.c:ir_set_alocated_tmp_reg |
1551 | | |
1552 | | IR_ALWAYS_INLINE int8_t ir_get_alocated_reg(const ir_ctx *ctx, ir_ref ref, int op_num) |
1553 | 162k | { |
1554 | 162k | int8_t *regs = ctx->regs[ref]; |
1555 | | |
1556 | | /* regs[] is not limited by the declared boundary 4, the real boundary checked below */ |
1557 | 162k | IR_ASSERT(op_num >= 0 && op_num <= IR_MAX(3, ctx->ir_base[ref].inputs_count)); |
1558 | 162k | return regs[op_num]; |
1559 | 162k | } Unexecuted instantiation: ir_cfg.c:ir_get_alocated_reg Unexecuted instantiation: ir_check.c:ir_get_alocated_reg Unexecuted instantiation: ir_dump.c:ir_get_alocated_reg ir_emit.c:ir_get_alocated_reg Line | Count | Source | 1553 | 161k | { | 1554 | 161k | int8_t *regs = ctx->regs[ref]; | 1555 | | | 1556 | | /* regs[] is not limited by the declared boundary 4, the real boundary checked below */ | 1557 | 161k | IR_ASSERT(op_num >= 0 && op_num <= IR_MAX(3, ctx->ir_base[ref].inputs_count)); | 1558 | 161k | return regs[op_num]; | 1559 | 161k | } |
Unexecuted instantiation: ir_gcm.c:ir_get_alocated_reg Unexecuted instantiation: ir_gdb.c:ir_get_alocated_reg Unexecuted instantiation: ir_patch.c:ir_get_alocated_reg ir_ra.c:ir_get_alocated_reg Line | Count | Source | 1553 | 820 | { | 1554 | 820 | int8_t *regs = ctx->regs[ref]; | 1555 | | | 1556 | | /* regs[] is not limited by the declared boundary 4, the real boundary checked below */ | 1557 | 820 | IR_ASSERT(op_num >= 0 && op_num <= IR_MAX(3, ctx->ir_base[ref].inputs_count)); | 1558 | 820 | return regs[op_num]; | 1559 | 820 | } |
Unexecuted instantiation: ir_ra_simple.c:ir_get_alocated_reg Unexecuted instantiation: ir_save.c:ir_get_alocated_reg Unexecuted instantiation: ir_sccp.c:ir_get_alocated_reg Unexecuted instantiation: ir_strtab.c:ir_get_alocated_reg Unexecuted instantiation: ir.c:ir_get_alocated_reg |
1560 | | |
1561 | | /*** IR Target Interface ***/ |
1562 | | |
1563 | | /* ctx->rules[] flags */ |
1564 | 7.03M | #define IR_FUSED (1U<<31) /* Insn is fused into others (code is generated as part of the fusion root) */ |
1565 | 6.08M | #define IR_SKIPPED (1U<<30) /* Insn is skipped (code is not generated) */ |
1566 | 1.75M | #define IR_NO_REG (1U<<29) /* Result doesn't need register (used for TAILCALL) */ |
1567 | 1.28M | #define IR_SIMPLE (1U<<28) /* Insn doesn't have any target constraints */ |
1568 | 0 | #define IR_FUSED_REG (1U<<27) /* Register assignemnt may be stored in ctx->fused_regs instead of ctx->regs */ |
1569 | 1.81M | #define IR_MAY_SWAP (1U<<26) /* Allow swapping operands for better register allocation */ |
1570 | 1.79M | #define IR_MAY_REUSE (1U<<25) /* Result may reuse register of the source */ |
1571 | | #define IR_TWO_REGS (1U<<24) /* Result needs two registers (used for 64-bit integers on x86) */ |
1572 | | |
1573 | 437k | #define IR_STATIC_ALLOCA (IR_SKIPPED | IR_FUSED | IR_SIMPLE | IR_ALLOCA) |
1574 | | |
1575 | 2.32M | #define IR_RULE_MASK 0xffff |
1576 | | |
1577 | | #define IR_MAX_REG_ARGS 64 |
1578 | | |
1579 | | extern const char *ir_rule_name[]; |
1580 | | |
1581 | | typedef struct _ir_tmp_reg { |
1582 | | union { |
1583 | | uint8_t num; |
1584 | | int8_t reg; |
1585 | | }; |
1586 | | uint8_t type; |
1587 | | int8_t start; |
1588 | | int8_t end; |
1589 | | } ir_tmp_reg; |
1590 | | |
1591 | | typedef struct { |
1592 | | int8_t def_reg; |
1593 | | uint8_t tmps_count; |
1594 | | uint8_t hints_count; |
1595 | | ir_tmp_reg tmp_regs[4]; |
1596 | | int8_t hints[IR_MAX_REG_ARGS + 3]; |
1597 | | } ir_target_constraints; |
1598 | | |
1599 | | #define IR_TMP_REG(_num, _type, _start, _end) \ |
1600 | 92.1k | (ir_tmp_reg){.num=(_num), .type=(_type), .start=(_start), .end=(_end)} |
1601 | | #define IR_SCRATCH_REG(_reg, _start, _end) \ |
1602 | 83.2k | (ir_tmp_reg){.reg=(_reg), .type=IR_VOID, .start=(_start), .end=(_end)} |
1603 | | |
1604 | | |
1605 | | int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *constraints); |
1606 | | void ir_set_fused_reg(ir_ctx *ctx, ir_ref root, ir_ref ref, ir_ref op, int8_t reg); |
1607 | | void ir_fix_stack_frame(ir_ctx *ctx); |
1608 | | |
1609 | | /* Utility */ |
1610 | | const ir_proto_t *ir_call_proto(const ir_ctx *ctx, const ir_insn *insn); |
1611 | | |
1612 | | //#define IR_BITSET_LIVENESS |
1613 | | |
1614 | | #endif /* IR_PRIVATE_H */ |