check_target.c (9533B)
1 #include <string.h> 2 3 #include "cg/cgtarget.h" 4 #include "core/arena.h" 5 6 typedef struct CheckTarget { 7 CgTarget base; 8 Compiler* c; 9 ObjBuilder* obj; 10 Label next_label; 11 CGLocal next_local; 12 CGScope next_scope; 13 } CheckTarget; 14 15 static CheckTarget* check_of(CgTarget* t) { return (CheckTarget*)t; } 16 17 static void check_func_begin(CgTarget* t, const CGFuncDesc* d) { 18 (void)t; 19 (void)d; 20 } 21 22 static void check_func_end(CgTarget* t) { (void)t; } 23 24 static void check_alias(CgTarget* t, ObjSymId a, ObjSymId b, KitCgTypeId ty) { 25 (void)t; 26 (void)a; 27 (void)b; 28 (void)ty; 29 } 30 31 static CGLocal check_local_id(CgTarget* t) { 32 CheckTarget* x = check_of(t); 33 if (++x->next_local == CG_LOCAL_NONE) ++x->next_local; 34 return x->next_local; 35 } 36 37 static CGLocal check_local(CgTarget* t, const CGLocalDesc* d) { 38 (void)d; 39 return check_local_id(t); 40 } 41 42 static CGLocal check_param(CgTarget* t, const CGParamDesc* d) { 43 (void)d; 44 return check_local_id(t); 45 } 46 47 static void check_local_addr(CgTarget* t, Operand dst, const CGLocalDesc* d, 48 CGLocal s) { 49 (void)t; 50 (void)dst; 51 (void)d; 52 (void)s; 53 } 54 55 static Label check_label_new(CgTarget* t) { 56 CheckTarget* x = check_of(t); 57 if (++x->next_label == LABEL_NONE) ++x->next_label; 58 return x->next_label; 59 } 60 61 static void check_label_place(CgTarget* t, Label l) { 62 (void)t; 63 (void)l; 64 } 65 66 static void check_jump(CgTarget* t, Label l) { 67 (void)t; 68 (void)l; 69 } 70 71 static void check_cmp_branch(CgTarget* t, CmpOp op, Operand a, Operand b, 72 Label l) { 73 (void)t; 74 (void)op; 75 (void)a; 76 (void)b; 77 (void)l; 78 } 79 80 static void check_switch(CgTarget* t, const CGSwitchDesc* d) { 81 (void)t; 82 (void)d; 83 } 84 85 static void check_indirect_branch(CgTarget* t, Operand a, const Label* targets, 86 u32 ntargets) { 87 (void)t; 88 (void)a; 89 (void)targets; 90 (void)ntargets; 91 } 92 93 static void check_load_label_addr(CgTarget* t, Operand dst, Label l) { 94 (void)t; 95 (void)dst; 96 (void)l; 97 } 98 99 static int check_local_static_data_begin(CgTarget* t, 100 const CGLocalStaticDataDesc* d) { 101 (void)t; 102 (void)d; 103 return 1; 104 } 105 106 static void check_local_static_data_write(CgTarget* t, const u8* data, 107 u64 len) { 108 (void)t; 109 (void)data; 110 (void)len; 111 } 112 113 static void check_local_static_data_label_addr(CgTarget* t, Label target, 114 i64 addend, u32 width, 115 u32 address_space) { 116 (void)t; 117 (void)target; 118 (void)addend; 119 (void)width; 120 (void)address_space; 121 } 122 123 static void check_local_static_data_end(CgTarget* t) { (void)t; } 124 125 static CGScope check_scope_begin(CgTarget* t, const CGScopeDesc* d) { 126 CheckTarget* x = check_of(t); 127 (void)d; 128 if (++x->next_scope == CG_SCOPE_NONE) ++x->next_scope; 129 return x->next_scope; 130 } 131 132 static void check_scope_end(CgTarget* t, CGScope s) { 133 (void)t; 134 (void)s; 135 } 136 137 static void check_scope_xfer(CgTarget* t, CGScope s) { 138 (void)t; 139 (void)s; 140 } 141 142 static void check_load_imm(CgTarget* t, Operand dst, i64 imm) { 143 (void)t; 144 (void)dst; 145 (void)imm; 146 } 147 148 static void check_load_const(CgTarget* t, Operand dst, ConstBytes c) { 149 (void)t; 150 (void)dst; 151 (void)c; 152 } 153 154 static void check_copy(CgTarget* t, Operand dst, Operand src) { 155 (void)t; 156 (void)dst; 157 (void)src; 158 } 159 160 static void check_load_store(CgTarget* t, Operand a, Operand b, MemAccess m) { 161 (void)t; 162 (void)a; 163 (void)b; 164 (void)m; 165 } 166 167 static void check_addr_of(CgTarget* t, Operand dst, Operand src) { 168 (void)t; 169 (void)dst; 170 (void)src; 171 } 172 173 static void check_tls_addr_of(CgTarget* t, Operand dst, ObjSymId sym, 174 i64 addend) { 175 (void)t; 176 (void)dst; 177 (void)sym; 178 (void)addend; 179 } 180 181 static void check_aggregate(CgTarget* t, Operand dst, Operand src, 182 AggregateAccess a) { 183 (void)t; 184 (void)dst; 185 (void)src; 186 (void)a; 187 } 188 189 static void check_binop(CgTarget* t, BinOp op, Operand dst, Operand a, 190 Operand b) { 191 (void)t; 192 (void)op; 193 (void)dst; 194 (void)a; 195 (void)b; 196 } 197 198 static void check_unop(CgTarget* t, UnOp op, Operand dst, Operand a) { 199 (void)t; 200 (void)op; 201 (void)dst; 202 (void)a; 203 } 204 205 static void check_cmp(CgTarget* t, CmpOp op, Operand dst, Operand a, 206 Operand b) { 207 (void)t; 208 (void)op; 209 (void)dst; 210 (void)a; 211 (void)b; 212 } 213 214 static void check_convert(CgTarget* t, ConvKind k, Operand dst, Operand src) { 215 (void)t; 216 (void)k; 217 (void)dst; 218 (void)src; 219 } 220 221 static void check_call(CgTarget* t, const CGCallDesc* d) { 222 (void)t; 223 (void)d; 224 } 225 226 static void check_ret(CgTarget* t, CGLocal value) { 227 (void)t; 228 (void)value; 229 } 230 231 static void check_unreachable(CgTarget* t) { (void)t; } 232 233 static void check_alloca(CgTarget* t, Operand dst, Operand size, u32 align) { 234 (void)t; 235 (void)dst; 236 (void)size; 237 (void)align; 238 } 239 240 static void check_va_arg(CgTarget* t, Operand dst, Operand ap, KitCgTypeId ty) { 241 (void)t; 242 (void)dst; 243 (void)ap; 244 (void)ty; 245 } 246 247 static void check_one_operand(CgTarget* t, Operand a) { 248 (void)t; 249 (void)a; 250 } 251 252 static void check_two_operands(CgTarget* t, Operand a, Operand b) { 253 (void)t; 254 (void)a; 255 (void)b; 256 } 257 258 static void check_intrinsic(CgTarget* t, IntrinKind k, Operand* dsts, u32 ndst, 259 const Operand* args, u32 narg) { 260 (void)t; 261 (void)k; 262 (void)dsts; 263 (void)ndst; 264 (void)args; 265 (void)narg; 266 } 267 268 static void check_asm_block(CgTarget* t, const char* tmpl, 269 const AsmConstraint* outs, u32 nout, 270 Operand* out_ops, const AsmConstraint* ins, u32 nin, 271 const Operand* in_ops, const Sym* clobbers, 272 u32 nclob, u32 clobber_abi_sets) { 273 (void)t; 274 (void)tmpl; 275 (void)outs; 276 (void)nout; 277 (void)out_ops; 278 (void)ins; 279 (void)nin; 280 (void)in_ops; 281 (void)clobbers; 282 (void)nclob; 283 (void)clobber_abi_sets; 284 } 285 286 static void check_atomic_load(CgTarget* t, Operand dst, Operand addr, 287 MemAccess m, KitCgMemOrder order) { 288 (void)t; 289 (void)dst; 290 (void)addr; 291 (void)m; 292 (void)order; 293 } 294 295 static void check_atomic_store(CgTarget* t, Operand addr, Operand src, 296 MemAccess m, KitCgMemOrder order) { 297 (void)t; 298 (void)addr; 299 (void)src; 300 (void)m; 301 (void)order; 302 } 303 304 static void check_atomic_rmw(CgTarget* t, KitCgAtomicOp op, Operand dst, 305 Operand addr, Operand val, MemAccess m, 306 KitCgMemOrder order) { 307 (void)t; 308 (void)op; 309 (void)dst; 310 (void)addr; 311 (void)val; 312 (void)m; 313 (void)order; 314 } 315 316 static void check_atomic_cas(CgTarget* t, Operand prior, Operand ok, 317 Operand addr, Operand expected, Operand desired, 318 MemAccess m, KitCgMemOrder success, 319 KitCgMemOrder failure) { 320 (void)t; 321 (void)prior; 322 (void)ok; 323 (void)addr; 324 (void)expected; 325 (void)desired; 326 (void)m; 327 (void)success; 328 (void)failure; 329 } 330 331 static void check_fence(CgTarget* t, KitCgMemOrder order) { 332 (void)t; 333 (void)order; 334 } 335 336 static void check_set_loc(CgTarget* t, SrcLoc loc) { 337 (void)t; 338 (void)loc; 339 } 340 341 static void check_finalize(CgTarget* t) { (void)t; } 342 343 static void check_destroy(CgTarget* t) { (void)t; } 344 345 static CgTarget* check_backend_make(Compiler* c, ObjBuilder* o, 346 const KitCodeOptions* opts) { 347 CheckTarget* x; 348 CgTarget* t; 349 (void)opts; 350 x = arena_new(c->tu, CheckTarget); 351 if (!x) return NULL; 352 memset(x, 0, sizeof *x); 353 x->c = c; 354 x->obj = o; 355 t = &x->base; 356 t->c = c; 357 t->obj = o; 358 359 t->func_begin = check_func_begin; 360 t->func_end = check_func_end; 361 t->alias = check_alias; 362 t->local = check_local; 363 t->local_addr = check_local_addr; 364 t->param = check_param; 365 t->label_new = check_label_new; 366 t->label_place = check_label_place; 367 t->jump = check_jump; 368 t->cmp_branch = check_cmp_branch; 369 t->switch_ = check_switch; 370 t->indirect_branch = check_indirect_branch; 371 t->load_label_addr = check_load_label_addr; 372 t->local_static_data_begin = check_local_static_data_begin; 373 t->local_static_data_write = check_local_static_data_write; 374 t->local_static_data_label_addr = check_local_static_data_label_addr; 375 t->local_static_data_end = check_local_static_data_end; 376 t->scope_begin = check_scope_begin; 377 t->scope_end = check_scope_end; 378 t->break_to = check_scope_xfer; 379 t->continue_to = check_scope_xfer; 380 t->load_imm = check_load_imm; 381 t->load_const = check_load_const; 382 t->copy = check_copy; 383 t->load = check_load_store; 384 t->store = check_load_store; 385 t->addr_of = check_addr_of; 386 t->tls_addr_of = check_tls_addr_of; 387 t->copy_bytes = check_aggregate; 388 t->set_bytes = check_aggregate; 389 t->binop = check_binop; 390 t->unop = check_unop; 391 t->cmp = check_cmp; 392 t->convert = check_convert; 393 t->call = check_call; 394 t->ret = check_ret; 395 t->unreachable = check_unreachable; 396 t->alloca_ = check_alloca; 397 t->va_start_ = check_one_operand; 398 t->va_arg_ = check_va_arg; 399 t->va_end_ = check_one_operand; 400 t->va_copy_ = check_two_operands; 401 t->intrinsic = check_intrinsic; 402 t->asm_block = check_asm_block; 403 t->atomic_load = check_atomic_load; 404 t->atomic_store = check_atomic_store; 405 t->atomic_rmw = check_atomic_rmw; 406 t->atomic_cas = check_atomic_cas; 407 t->fence = check_fence; 408 t->set_loc = check_set_loc; 409 t->finalize = check_finalize; 410 t->destroy = check_destroy; 411 return t; 412 } 413 414 const CGBackend cg_backend_check = { 415 .name = "check", 416 .make = check_backend_make, 417 };