| ... | ... | @@ -269,477 +269,467 @@ static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, |
| 269 | 269 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst *source_instr); |
| 270 | 270 | |
| 271 | 271 | static void destroy_instruction_src(IrInstSrc *inst) { |
| 272 | | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 273 | | const char *name = ir_inst_src_type_str(inst->id); |
| 274 | | #else |
| 275 | | const char *name = nullptr; |
| 276 | | #endif |
| 277 | 272 | switch (inst->id) { |
| 278 | 273 | case IrInstSrcIdInvalid: |
| 279 | 274 | zig_unreachable(); |
| 280 | 275 | case IrInstSrcIdReturn: |
| 281 | | return destroy(reinterpret_cast<IrInstSrcReturn *>(inst), name); |
| 276 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcReturn *>(inst)); |
| 282 | 277 | case IrInstSrcIdConst: |
| 283 | | return destroy(reinterpret_cast<IrInstSrcConst *>(inst), name); |
| 278 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcConst *>(inst)); |
| 284 | 279 | case IrInstSrcIdBinOp: |
| 285 | | return destroy(reinterpret_cast<IrInstSrcBinOp *>(inst), name); |
| 280 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBinOp *>(inst)); |
| 286 | 281 | case IrInstSrcIdMergeErrSets: |
| 287 | | return destroy(reinterpret_cast<IrInstSrcMergeErrSets *>(inst), name); |
| 282 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMergeErrSets *>(inst)); |
| 288 | 283 | case IrInstSrcIdDeclVar: |
| 289 | | return destroy(reinterpret_cast<IrInstSrcDeclVar *>(inst), name); |
| 284 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcDeclVar *>(inst)); |
| 290 | 285 | case IrInstSrcIdCall: |
| 291 | | return destroy(reinterpret_cast<IrInstSrcCall *>(inst), name); |
| 286 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCall *>(inst)); |
| 292 | 287 | case IrInstSrcIdCallExtra: |
| 293 | | return destroy(reinterpret_cast<IrInstSrcCallExtra *>(inst), name); |
| 288 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCallExtra *>(inst)); |
| 294 | 289 | case IrInstSrcIdUnOp: |
| 295 | | return destroy(reinterpret_cast<IrInstSrcUnOp *>(inst), name); |
| 290 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnOp *>(inst)); |
| 296 | 291 | case IrInstSrcIdCondBr: |
| 297 | | return destroy(reinterpret_cast<IrInstSrcCondBr *>(inst), name); |
| 292 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCondBr *>(inst)); |
| 298 | 293 | case IrInstSrcIdBr: |
| 299 | | return destroy(reinterpret_cast<IrInstSrcBr *>(inst), name); |
| 294 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBr *>(inst)); |
| 300 | 295 | case IrInstSrcIdPhi: |
| 301 | | return destroy(reinterpret_cast<IrInstSrcPhi *>(inst), name); |
| 296 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPhi *>(inst)); |
| 302 | 297 | case IrInstSrcIdContainerInitList: |
| 303 | | return destroy(reinterpret_cast<IrInstSrcContainerInitList *>(inst), name); |
| 298 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcContainerInitList *>(inst)); |
| 304 | 299 | case IrInstSrcIdContainerInitFields: |
| 305 | | return destroy(reinterpret_cast<IrInstSrcContainerInitFields *>(inst), name); |
| 300 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcContainerInitFields *>(inst)); |
| 306 | 301 | case IrInstSrcIdUnreachable: |
| 307 | | return destroy(reinterpret_cast<IrInstSrcUnreachable *>(inst), name); |
| 302 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnreachable *>(inst)); |
| 308 | 303 | case IrInstSrcIdElemPtr: |
| 309 | | return destroy(reinterpret_cast<IrInstSrcElemPtr *>(inst), name); |
| 304 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcElemPtr *>(inst)); |
| 310 | 305 | case IrInstSrcIdVarPtr: |
| 311 | | return destroy(reinterpret_cast<IrInstSrcVarPtr *>(inst), name); |
| 306 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVarPtr *>(inst)); |
| 312 | 307 | case IrInstSrcIdLoadPtr: |
| 313 | | return destroy(reinterpret_cast<IrInstSrcLoadPtr *>(inst), name); |
| 308 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcLoadPtr *>(inst)); |
| 314 | 309 | case IrInstSrcIdStorePtr: |
| 315 | | return destroy(reinterpret_cast<IrInstSrcStorePtr *>(inst), name); |
| 310 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcStorePtr *>(inst)); |
| 316 | 311 | case IrInstSrcIdTypeOf: |
| 317 | | return destroy(reinterpret_cast<IrInstSrcTypeOf *>(inst), name); |
| 312 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeOf *>(inst)); |
| 318 | 313 | case IrInstSrcIdFieldPtr: |
| 319 | | return destroy(reinterpret_cast<IrInstSrcFieldPtr *>(inst), name); |
| 314 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldPtr *>(inst)); |
| 320 | 315 | case IrInstSrcIdSetCold: |
| 321 | | return destroy(reinterpret_cast<IrInstSrcSetCold *>(inst), name); |
| 316 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetCold *>(inst)); |
| 322 | 317 | case IrInstSrcIdSetRuntimeSafety: |
| 323 | | return destroy(reinterpret_cast<IrInstSrcSetRuntimeSafety *>(inst), name); |
| 318 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetRuntimeSafety *>(inst)); |
| 324 | 319 | case IrInstSrcIdSetFloatMode: |
| 325 | | return destroy(reinterpret_cast<IrInstSrcSetFloatMode *>(inst), name); |
| 320 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetFloatMode *>(inst)); |
| 326 | 321 | case IrInstSrcIdArrayType: |
| 327 | | return destroy(reinterpret_cast<IrInstSrcArrayType *>(inst), name); |
| 322 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArrayType *>(inst)); |
| 328 | 323 | case IrInstSrcIdSliceType: |
| 329 | | return destroy(reinterpret_cast<IrInstSrcSliceType *>(inst), name); |
| 324 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSliceType *>(inst)); |
| 330 | 325 | case IrInstSrcIdAnyFrameType: |
| 331 | | return destroy(reinterpret_cast<IrInstSrcAnyFrameType *>(inst), name); |
| 326 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAnyFrameType *>(inst)); |
| 332 | 327 | case IrInstSrcIdAsm: |
| 333 | | return destroy(reinterpret_cast<IrInstSrcAsm *>(inst), name); |
| 328 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAsm *>(inst)); |
| 334 | 329 | case IrInstSrcIdSizeOf: |
| 335 | | return destroy(reinterpret_cast<IrInstSrcSizeOf *>(inst), name); |
| 330 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSizeOf *>(inst)); |
| 336 | 331 | case IrInstSrcIdTestNonNull: |
| 337 | | return destroy(reinterpret_cast<IrInstSrcTestNonNull *>(inst), name); |
| 332 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestNonNull *>(inst)); |
| 338 | 333 | case IrInstSrcIdOptionalUnwrapPtr: |
| 339 | | return destroy(reinterpret_cast<IrInstSrcOptionalUnwrapPtr *>(inst), name); |
| 334 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOptionalUnwrapPtr *>(inst)); |
| 340 | 335 | case IrInstSrcIdPopCount: |
| 341 | | return destroy(reinterpret_cast<IrInstSrcPopCount *>(inst), name); |
| 336 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPopCount *>(inst)); |
| 342 | 337 | case IrInstSrcIdClz: |
| 343 | | return destroy(reinterpret_cast<IrInstSrcClz *>(inst), name); |
| 338 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcClz *>(inst)); |
| 344 | 339 | case IrInstSrcIdCtz: |
| 345 | | return destroy(reinterpret_cast<IrInstSrcCtz *>(inst), name); |
| 340 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCtz *>(inst)); |
| 346 | 341 | case IrInstSrcIdBswap: |
| 347 | | return destroy(reinterpret_cast<IrInstSrcBswap *>(inst), name); |
| 342 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBswap *>(inst)); |
| 348 | 343 | case IrInstSrcIdBitReverse: |
| 349 | | return destroy(reinterpret_cast<IrInstSrcBitReverse *>(inst), name); |
| 344 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitReverse *>(inst)); |
| 350 | 345 | case IrInstSrcIdSwitchBr: |
| 351 | | return destroy(reinterpret_cast<IrInstSrcSwitchBr *>(inst), name); |
| 346 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchBr *>(inst)); |
| 352 | 347 | case IrInstSrcIdSwitchVar: |
| 353 | | return destroy(reinterpret_cast<IrInstSrcSwitchVar *>(inst), name); |
| 348 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchVar *>(inst)); |
| 354 | 349 | case IrInstSrcIdSwitchElseVar: |
| 355 | | return destroy(reinterpret_cast<IrInstSrcSwitchElseVar *>(inst), name); |
| 350 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchElseVar *>(inst)); |
| 356 | 351 | case IrInstSrcIdSwitchTarget: |
| 357 | | return destroy(reinterpret_cast<IrInstSrcSwitchTarget *>(inst), name); |
| 352 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchTarget *>(inst)); |
| 358 | 353 | case IrInstSrcIdImport: |
| 359 | | return destroy(reinterpret_cast<IrInstSrcImport *>(inst), name); |
| 354 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcImport *>(inst)); |
| 360 | 355 | case IrInstSrcIdRef: |
| 361 | | return destroy(reinterpret_cast<IrInstSrcRef *>(inst), name); |
| 356 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcRef *>(inst)); |
| 362 | 357 | case IrInstSrcIdCompileErr: |
| 363 | | return destroy(reinterpret_cast<IrInstSrcCompileErr *>(inst), name); |
| 358 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCompileErr *>(inst)); |
| 364 | 359 | case IrInstSrcIdCompileLog: |
| 365 | | return destroy(reinterpret_cast<IrInstSrcCompileLog *>(inst), name); |
| 360 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCompileLog *>(inst)); |
| 366 | 361 | case IrInstSrcIdErrName: |
| 367 | | return destroy(reinterpret_cast<IrInstSrcErrName *>(inst), name); |
| 362 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrName *>(inst)); |
| 368 | 363 | case IrInstSrcIdCImport: |
| 369 | | return destroy(reinterpret_cast<IrInstSrcCImport *>(inst), name); |
| 364 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCImport *>(inst)); |
| 370 | 365 | case IrInstSrcIdCInclude: |
| 371 | | return destroy(reinterpret_cast<IrInstSrcCInclude *>(inst), name); |
| 366 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCInclude *>(inst)); |
| 372 | 367 | case IrInstSrcIdCDefine: |
| 373 | | return destroy(reinterpret_cast<IrInstSrcCDefine *>(inst), name); |
| 368 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCDefine *>(inst)); |
| 374 | 369 | case IrInstSrcIdCUndef: |
| 375 | | return destroy(reinterpret_cast<IrInstSrcCUndef *>(inst), name); |
| 370 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCUndef *>(inst)); |
| 376 | 371 | case IrInstSrcIdEmbedFile: |
| 377 | | return destroy(reinterpret_cast<IrInstSrcEmbedFile *>(inst), name); |
| 372 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEmbedFile *>(inst)); |
| 378 | 373 | case IrInstSrcIdCmpxchg: |
| 379 | | return destroy(reinterpret_cast<IrInstSrcCmpxchg *>(inst), name); |
| 374 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCmpxchg *>(inst)); |
| 380 | 375 | case IrInstSrcIdFence: |
| 381 | | return destroy(reinterpret_cast<IrInstSrcFence *>(inst), name); |
| 376 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFence *>(inst)); |
| 382 | 377 | case IrInstSrcIdTruncate: |
| 383 | | return destroy(reinterpret_cast<IrInstSrcTruncate *>(inst), name); |
| 378 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTruncate *>(inst)); |
| 384 | 379 | case IrInstSrcIdIntCast: |
| 385 | | return destroy(reinterpret_cast<IrInstSrcIntCast *>(inst), name); |
| 380 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntCast *>(inst)); |
| 386 | 381 | case IrInstSrcIdFloatCast: |
| 387 | | return destroy(reinterpret_cast<IrInstSrcFloatCast *>(inst), name); |
| 382 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatCast *>(inst)); |
| 388 | 383 | case IrInstSrcIdErrSetCast: |
| 389 | | return destroy(reinterpret_cast<IrInstSrcErrSetCast *>(inst), name); |
| 384 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrSetCast *>(inst)); |
| 390 | 385 | case IrInstSrcIdFromBytes: |
| 391 | | return destroy(reinterpret_cast<IrInstSrcFromBytes *>(inst), name); |
| 386 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFromBytes *>(inst)); |
| 392 | 387 | case IrInstSrcIdToBytes: |
| 393 | | return destroy(reinterpret_cast<IrInstSrcToBytes *>(inst), name); |
| 388 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcToBytes *>(inst)); |
| 394 | 389 | case IrInstSrcIdIntToFloat: |
| 395 | | return destroy(reinterpret_cast<IrInstSrcIntToFloat *>(inst), name); |
| 390 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToFloat *>(inst)); |
| 396 | 391 | case IrInstSrcIdFloatToInt: |
| 397 | | return destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst), name); |
| 392 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst)); |
| 398 | 393 | case IrInstSrcIdBoolToInt: |
| 399 | | return destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst), name); |
| 394 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst)); |
| 400 | 395 | case IrInstSrcIdIntType: |
| 401 | | return destroy(reinterpret_cast<IrInstSrcIntType *>(inst), name); |
| 396 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntType *>(inst)); |
| 402 | 397 | case IrInstSrcIdVectorType: |
| 403 | | return destroy(reinterpret_cast<IrInstSrcVectorType *>(inst), name); |
| 398 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVectorType *>(inst)); |
| 404 | 399 | case IrInstSrcIdShuffleVector: |
| 405 | | return destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst), name); |
| 400 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst)); |
| 406 | 401 | case IrInstSrcIdSplat: |
| 407 | | return destroy(reinterpret_cast<IrInstSrcSplat *>(inst), name); |
| 402 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSplat *>(inst)); |
| 408 | 403 | case IrInstSrcIdBoolNot: |
| 409 | | return destroy(reinterpret_cast<IrInstSrcBoolNot *>(inst), name); |
| 404 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolNot *>(inst)); |
| 410 | 405 | case IrInstSrcIdMemset: |
| 411 | | return destroy(reinterpret_cast<IrInstSrcMemset *>(inst), name); |
| 406 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemset *>(inst)); |
| 412 | 407 | case IrInstSrcIdMemcpy: |
| 413 | | return destroy(reinterpret_cast<IrInstSrcMemcpy *>(inst), name); |
| 408 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemcpy *>(inst)); |
| 414 | 409 | case IrInstSrcIdSlice: |
| 415 | | return destroy(reinterpret_cast<IrInstSrcSlice *>(inst), name); |
| 410 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSlice *>(inst)); |
| 416 | 411 | case IrInstSrcIdMemberCount: |
| 417 | | return destroy(reinterpret_cast<IrInstSrcMemberCount *>(inst), name); |
| 412 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemberCount *>(inst)); |
| 418 | 413 | case IrInstSrcIdMemberType: |
| 419 | | return destroy(reinterpret_cast<IrInstSrcMemberType *>(inst), name); |
| 414 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemberType *>(inst)); |
| 420 | 415 | case IrInstSrcIdMemberName: |
| 421 | | return destroy(reinterpret_cast<IrInstSrcMemberName *>(inst), name); |
| 416 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemberName *>(inst)); |
| 422 | 417 | case IrInstSrcIdBreakpoint: |
| 423 | | return destroy(reinterpret_cast<IrInstSrcBreakpoint *>(inst), name); |
| 418 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBreakpoint *>(inst)); |
| 424 | 419 | case IrInstSrcIdReturnAddress: |
| 425 | | return destroy(reinterpret_cast<IrInstSrcReturnAddress *>(inst), name); |
| 420 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcReturnAddress *>(inst)); |
| 426 | 421 | case IrInstSrcIdFrameAddress: |
| 427 | | return destroy(reinterpret_cast<IrInstSrcFrameAddress *>(inst), name); |
| 422 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameAddress *>(inst)); |
| 428 | 423 | case IrInstSrcIdFrameHandle: |
| 429 | | return destroy(reinterpret_cast<IrInstSrcFrameHandle *>(inst), name); |
| 424 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameHandle *>(inst)); |
| 430 | 425 | case IrInstSrcIdFrameType: |
| 431 | | return destroy(reinterpret_cast<IrInstSrcFrameType *>(inst), name); |
| 426 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameType *>(inst)); |
| 432 | 427 | case IrInstSrcIdFrameSize: |
| 433 | | return destroy(reinterpret_cast<IrInstSrcFrameSize *>(inst), name); |
| 428 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameSize *>(inst)); |
| 434 | 429 | case IrInstSrcIdAlignOf: |
| 435 | | return destroy(reinterpret_cast<IrInstSrcAlignOf *>(inst), name); |
| 430 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlignOf *>(inst)); |
| 436 | 431 | case IrInstSrcIdOverflowOp: |
| 437 | | return destroy(reinterpret_cast<IrInstSrcOverflowOp *>(inst), name); |
| 432 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOverflowOp *>(inst)); |
| 438 | 433 | case IrInstSrcIdTestErr: |
| 439 | | return destroy(reinterpret_cast<IrInstSrcTestErr *>(inst), name); |
| 434 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestErr *>(inst)); |
| 440 | 435 | case IrInstSrcIdUnwrapErrCode: |
| 441 | | return destroy(reinterpret_cast<IrInstSrcUnwrapErrCode *>(inst), name); |
| 436 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnwrapErrCode *>(inst)); |
| 442 | 437 | case IrInstSrcIdUnwrapErrPayload: |
| 443 | | return destroy(reinterpret_cast<IrInstSrcUnwrapErrPayload *>(inst), name); |
| 438 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnwrapErrPayload *>(inst)); |
| 444 | 439 | case IrInstSrcIdFnProto: |
| 445 | | return destroy(reinterpret_cast<IrInstSrcFnProto *>(inst), name); |
| 440 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFnProto *>(inst)); |
| 446 | 441 | case IrInstSrcIdTestComptime: |
| 447 | | return destroy(reinterpret_cast<IrInstSrcTestComptime *>(inst), name); |
| 442 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestComptime *>(inst)); |
| 448 | 443 | case IrInstSrcIdPtrCast: |
| 449 | | return destroy(reinterpret_cast<IrInstSrcPtrCast *>(inst), name); |
| 444 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrCast *>(inst)); |
| 450 | 445 | case IrInstSrcIdBitCast: |
| 451 | | return destroy(reinterpret_cast<IrInstSrcBitCast *>(inst), name); |
| 446 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitCast *>(inst)); |
| 452 | 447 | case IrInstSrcIdPtrToInt: |
| 453 | | return destroy(reinterpret_cast<IrInstSrcPtrToInt *>(inst), name); |
| 448 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrToInt *>(inst)); |
| 454 | 449 | case IrInstSrcIdIntToPtr: |
| 455 | | return destroy(reinterpret_cast<IrInstSrcIntToPtr *>(inst), name); |
| 450 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToPtr *>(inst)); |
| 456 | 451 | case IrInstSrcIdIntToEnum: |
| 457 | | return destroy(reinterpret_cast<IrInstSrcIntToEnum *>(inst), name); |
| 452 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToEnum *>(inst)); |
| 458 | 453 | case IrInstSrcIdIntToErr: |
| 459 | | return destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst), name); |
| 454 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst)); |
| 460 | 455 | case IrInstSrcIdErrToInt: |
| 461 | | return destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst), name); |
| 456 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst)); |
| 462 | 457 | case IrInstSrcIdCheckSwitchProngs: |
| 463 | | return destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst), name); |
| 458 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst)); |
| 464 | 459 | case IrInstSrcIdCheckStatementIsVoid: |
| 465 | | return destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst), name); |
| 460 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst)); |
| 466 | 461 | case IrInstSrcIdTypeName: |
| 467 | | return destroy(reinterpret_cast<IrInstSrcTypeName *>(inst), name); |
| 462 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeName *>(inst)); |
| 468 | 463 | case IrInstSrcIdTagName: |
| 469 | | return destroy(reinterpret_cast<IrInstSrcTagName *>(inst), name); |
| 464 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTagName *>(inst)); |
| 470 | 465 | case IrInstSrcIdPtrType: |
| 471 | | return destroy(reinterpret_cast<IrInstSrcPtrType *>(inst), name); |
| 466 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrType *>(inst)); |
| 472 | 467 | case IrInstSrcIdDeclRef: |
| 473 | | return destroy(reinterpret_cast<IrInstSrcDeclRef *>(inst), name); |
| 468 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcDeclRef *>(inst)); |
| 474 | 469 | case IrInstSrcIdPanic: |
| 475 | | return destroy(reinterpret_cast<IrInstSrcPanic *>(inst), name); |
| 470 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPanic *>(inst)); |
| 476 | 471 | case IrInstSrcIdFieldParentPtr: |
| 477 | | return destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst), name); |
| 472 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst)); |
| 478 | 473 | case IrInstSrcIdByteOffsetOf: |
| 479 | | return destroy(reinterpret_cast<IrInstSrcByteOffsetOf *>(inst), name); |
| 474 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcByteOffsetOf *>(inst)); |
| 480 | 475 | case IrInstSrcIdBitOffsetOf: |
| 481 | | return destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst), name); |
| 476 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst)); |
| 482 | 477 | case IrInstSrcIdTypeInfo: |
| 483 | | return destroy(reinterpret_cast<IrInstSrcTypeInfo *>(inst), name); |
| 478 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeInfo *>(inst)); |
| 484 | 479 | case IrInstSrcIdType: |
| 485 | | return destroy(reinterpret_cast<IrInstSrcType *>(inst), name); |
| 480 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcType *>(inst)); |
| 486 | 481 | case IrInstSrcIdHasField: |
| 487 | | return destroy(reinterpret_cast<IrInstSrcHasField *>(inst), name); |
| 482 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcHasField *>(inst)); |
| 488 | 483 | case IrInstSrcIdTypeId: |
| 489 | | return destroy(reinterpret_cast<IrInstSrcTypeId *>(inst), name); |
| 484 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeId *>(inst)); |
| 490 | 485 | case IrInstSrcIdSetEvalBranchQuota: |
| 491 | | return destroy(reinterpret_cast<IrInstSrcSetEvalBranchQuota *>(inst), name); |
| 486 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetEvalBranchQuota *>(inst)); |
| 492 | 487 | case IrInstSrcIdAlignCast: |
| 493 | | return destroy(reinterpret_cast<IrInstSrcAlignCast *>(inst), name); |
| 488 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlignCast *>(inst)); |
| 494 | 489 | case IrInstSrcIdImplicitCast: |
| 495 | | return destroy(reinterpret_cast<IrInstSrcImplicitCast *>(inst), name); |
| 490 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcImplicitCast *>(inst)); |
| 496 | 491 | case IrInstSrcIdResolveResult: |
| 497 | | return destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst), name); |
| 492 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst)); |
| 498 | 493 | case IrInstSrcIdResetResult: |
| 499 | | return destroy(reinterpret_cast<IrInstSrcResetResult *>(inst), name); |
| 494 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResetResult *>(inst)); |
| 500 | 495 | case IrInstSrcIdOpaqueType: |
| 501 | | return destroy(reinterpret_cast<IrInstSrcOpaqueType *>(inst), name); |
| 496 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOpaqueType *>(inst)); |
| 502 | 497 | case IrInstSrcIdSetAlignStack: |
| 503 | | return destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst), name); |
| 498 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst)); |
| 504 | 499 | case IrInstSrcIdArgType: |
| 505 | | return destroy(reinterpret_cast<IrInstSrcArgType *>(inst), name); |
| 500 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArgType *>(inst)); |
| 506 | 501 | case IrInstSrcIdTagType: |
| 507 | | return destroy(reinterpret_cast<IrInstSrcTagType *>(inst), name); |
| 502 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTagType *>(inst)); |
| 508 | 503 | case IrInstSrcIdExport: |
| 509 | | return destroy(reinterpret_cast<IrInstSrcExport *>(inst), name); |
| 504 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcExport *>(inst)); |
| 510 | 505 | case IrInstSrcIdErrorReturnTrace: |
| 511 | | return destroy(reinterpret_cast<IrInstSrcErrorReturnTrace *>(inst), name); |
| 506 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrorReturnTrace *>(inst)); |
| 512 | 507 | case IrInstSrcIdErrorUnion: |
| 513 | | return destroy(reinterpret_cast<IrInstSrcErrorUnion *>(inst), name); |
| 508 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrorUnion *>(inst)); |
| 514 | 509 | case IrInstSrcIdAtomicRmw: |
| 515 | | return destroy(reinterpret_cast<IrInstSrcAtomicRmw *>(inst), name); |
| 510 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicRmw *>(inst)); |
| 516 | 511 | case IrInstSrcIdSaveErrRetAddr: |
| 517 | | return destroy(reinterpret_cast<IrInstSrcSaveErrRetAddr *>(inst), name); |
| 512 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSaveErrRetAddr *>(inst)); |
| 518 | 513 | case IrInstSrcIdAddImplicitReturnType: |
| 519 | | return destroy(reinterpret_cast<IrInstSrcAddImplicitReturnType *>(inst), name); |
| 514 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAddImplicitReturnType *>(inst)); |
| 520 | 515 | case IrInstSrcIdFloatOp: |
| 521 | | return destroy(reinterpret_cast<IrInstSrcFloatOp *>(inst), name); |
| 516 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatOp *>(inst)); |
| 522 | 517 | case IrInstSrcIdMulAdd: |
| 523 | | return destroy(reinterpret_cast<IrInstSrcMulAdd *>(inst), name); |
| 518 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMulAdd *>(inst)); |
| 524 | 519 | case IrInstSrcIdAtomicLoad: |
| 525 | | return destroy(reinterpret_cast<IrInstSrcAtomicLoad *>(inst), name); |
| 520 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicLoad *>(inst)); |
| 526 | 521 | case IrInstSrcIdAtomicStore: |
| 527 | | return destroy(reinterpret_cast<IrInstSrcAtomicStore *>(inst), name); |
| 522 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicStore *>(inst)); |
| 528 | 523 | case IrInstSrcIdEnumToInt: |
| 529 | | return destroy(reinterpret_cast<IrInstSrcEnumToInt *>(inst), name); |
| 524 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEnumToInt *>(inst)); |
| 530 | 525 | case IrInstSrcIdCheckRuntimeScope: |
| 531 | | return destroy(reinterpret_cast<IrInstSrcCheckRuntimeScope *>(inst), name); |
| 526 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckRuntimeScope *>(inst)); |
| 532 | 527 | case IrInstSrcIdHasDecl: |
| 533 | | return destroy(reinterpret_cast<IrInstSrcHasDecl *>(inst), name); |
| 528 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcHasDecl *>(inst)); |
| 534 | 529 | case IrInstSrcIdUndeclaredIdent: |
| 535 | | return destroy(reinterpret_cast<IrInstSrcUndeclaredIdent *>(inst), name); |
| 530 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUndeclaredIdent *>(inst)); |
| 536 | 531 | case IrInstSrcIdAlloca: |
| 537 | | return destroy(reinterpret_cast<IrInstSrcAlloca *>(inst), name); |
| 532 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlloca *>(inst)); |
| 538 | 533 | case IrInstSrcIdEndExpr: |
| 539 | | return destroy(reinterpret_cast<IrInstSrcEndExpr *>(inst), name); |
| 534 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEndExpr *>(inst)); |
| 540 | 535 | case IrInstSrcIdUnionInitNamedField: |
| 541 | | return destroy(reinterpret_cast<IrInstSrcUnionInitNamedField *>(inst), name); |
| 536 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnionInitNamedField *>(inst)); |
| 542 | 537 | case IrInstSrcIdSuspendBegin: |
| 543 | | return destroy(reinterpret_cast<IrInstSrcSuspendBegin *>(inst), name); |
| 538 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSuspendBegin *>(inst)); |
| 544 | 539 | case IrInstSrcIdSuspendFinish: |
| 545 | | return destroy(reinterpret_cast<IrInstSrcSuspendFinish *>(inst), name); |
| 540 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSuspendFinish *>(inst)); |
| 546 | 541 | case IrInstSrcIdResume: |
| 547 | | return destroy(reinterpret_cast<IrInstSrcResume *>(inst), name); |
| 542 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResume *>(inst)); |
| 548 | 543 | case IrInstSrcIdAwait: |
| 549 | | return destroy(reinterpret_cast<IrInstSrcAwait *>(inst), name); |
| 544 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAwait *>(inst)); |
| 550 | 545 | case IrInstSrcIdSpillBegin: |
| 551 | | return destroy(reinterpret_cast<IrInstSrcSpillBegin *>(inst), name); |
| 546 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSpillBegin *>(inst)); |
| 552 | 547 | case IrInstSrcIdSpillEnd: |
| 553 | | return destroy(reinterpret_cast<IrInstSrcSpillEnd *>(inst), name); |
| 548 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSpillEnd *>(inst)); |
| 554 | 549 | case IrInstSrcIdCallArgs: |
| 555 | | return destroy(reinterpret_cast<IrInstSrcCallArgs *>(inst), name); |
| 550 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCallArgs *>(inst)); |
| 556 | 551 | } |
| 557 | 552 | zig_unreachable(); |
| 558 | 553 | } |
| 559 | 554 | |
| 560 | 555 | void destroy_instruction_gen(IrInstGen *inst) { |
| 561 | | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 562 | | const char *name = ir_inst_gen_type_str(inst->id); |
| 563 | | #else |
| 564 | | const char *name = nullptr; |
| 565 | | #endif |
| 566 | 556 | switch (inst->id) { |
| 567 | 557 | case IrInstGenIdInvalid: |
| 568 | 558 | zig_unreachable(); |
| 569 | 559 | case IrInstGenIdReturn: |
| 570 | | return destroy(reinterpret_cast<IrInstGenReturn *>(inst), name); |
| 560 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturn *>(inst)); |
| 571 | 561 | case IrInstGenIdConst: |
| 572 | | return destroy(reinterpret_cast<IrInstGenConst *>(inst), name); |
| 562 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenConst *>(inst)); |
| 573 | 563 | case IrInstGenIdBinOp: |
| 574 | | return destroy(reinterpret_cast<IrInstGenBinOp *>(inst), name); |
| 564 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBinOp *>(inst)); |
| 575 | 565 | case IrInstGenIdCast: |
| 576 | | return destroy(reinterpret_cast<IrInstGenCast *>(inst), name); |
| 566 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCast *>(inst)); |
| 577 | 567 | case IrInstGenIdCall: |
| 578 | | return destroy(reinterpret_cast<IrInstGenCall *>(inst), name); |
| 568 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCall *>(inst)); |
| 579 | 569 | case IrInstGenIdCondBr: |
| 580 | | return destroy(reinterpret_cast<IrInstGenCondBr *>(inst), name); |
| 570 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCondBr *>(inst)); |
| 581 | 571 | case IrInstGenIdBr: |
| 582 | | return destroy(reinterpret_cast<IrInstGenBr *>(inst), name); |
| 572 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBr *>(inst)); |
| 583 | 573 | case IrInstGenIdPhi: |
| 584 | | return destroy(reinterpret_cast<IrInstGenPhi *>(inst), name); |
| 574 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPhi *>(inst)); |
| 585 | 575 | case IrInstGenIdUnreachable: |
| 586 | | return destroy(reinterpret_cast<IrInstGenUnreachable *>(inst), name); |
| 576 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnreachable *>(inst)); |
| 587 | 577 | case IrInstGenIdElemPtr: |
| 588 | | return destroy(reinterpret_cast<IrInstGenElemPtr *>(inst), name); |
| 578 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenElemPtr *>(inst)); |
| 589 | 579 | case IrInstGenIdVarPtr: |
| 590 | | return destroy(reinterpret_cast<IrInstGenVarPtr *>(inst), name); |
| 580 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVarPtr *>(inst)); |
| 591 | 581 | case IrInstGenIdReturnPtr: |
| 592 | | return destroy(reinterpret_cast<IrInstGenReturnPtr *>(inst), name); |
| 582 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturnPtr *>(inst)); |
| 593 | 583 | case IrInstGenIdLoadPtr: |
| 594 | | return destroy(reinterpret_cast<IrInstGenLoadPtr *>(inst), name); |
| 584 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenLoadPtr *>(inst)); |
| 595 | 585 | case IrInstGenIdStorePtr: |
| 596 | | return destroy(reinterpret_cast<IrInstGenStorePtr *>(inst), name); |
| 586 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenStorePtr *>(inst)); |
| 597 | 587 | case IrInstGenIdVectorStoreElem: |
| 598 | | return destroy(reinterpret_cast<IrInstGenVectorStoreElem *>(inst), name); |
| 588 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorStoreElem *>(inst)); |
| 599 | 589 | case IrInstGenIdStructFieldPtr: |
| 600 | | return destroy(reinterpret_cast<IrInstGenStructFieldPtr *>(inst), name); |
| 590 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenStructFieldPtr *>(inst)); |
| 601 | 591 | case IrInstGenIdUnionFieldPtr: |
| 602 | | return destroy(reinterpret_cast<IrInstGenUnionFieldPtr *>(inst), name); |
| 592 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnionFieldPtr *>(inst)); |
| 603 | 593 | case IrInstGenIdAsm: |
| 604 | | return destroy(reinterpret_cast<IrInstGenAsm *>(inst), name); |
| 594 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAsm *>(inst)); |
| 605 | 595 | case IrInstGenIdTestNonNull: |
| 606 | | return destroy(reinterpret_cast<IrInstGenTestNonNull *>(inst), name); |
| 596 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTestNonNull *>(inst)); |
| 607 | 597 | case IrInstGenIdOptionalUnwrapPtr: |
| 608 | | return destroy(reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(inst), name); |
| 598 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(inst)); |
| 609 | 599 | case IrInstGenIdPopCount: |
| 610 | | return destroy(reinterpret_cast<IrInstGenPopCount *>(inst), name); |
| 600 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPopCount *>(inst)); |
| 611 | 601 | case IrInstGenIdClz: |
| 612 | | return destroy(reinterpret_cast<IrInstGenClz *>(inst), name); |
| 602 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenClz *>(inst)); |
| 613 | 603 | case IrInstGenIdCtz: |
| 614 | | return destroy(reinterpret_cast<IrInstGenCtz *>(inst), name); |
| 604 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCtz *>(inst)); |
| 615 | 605 | case IrInstGenIdBswap: |
| 616 | | return destroy(reinterpret_cast<IrInstGenBswap *>(inst), name); |
| 606 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBswap *>(inst)); |
| 617 | 607 | case IrInstGenIdBitReverse: |
| 618 | | return destroy(reinterpret_cast<IrInstGenBitReverse *>(inst), name); |
| 608 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBitReverse *>(inst)); |
| 619 | 609 | case IrInstGenIdSwitchBr: |
| 620 | | return destroy(reinterpret_cast<IrInstGenSwitchBr *>(inst), name); |
| 610 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSwitchBr *>(inst)); |
| 621 | 611 | case IrInstGenIdUnionTag: |
| 622 | | return destroy(reinterpret_cast<IrInstGenUnionTag *>(inst), name); |
| 612 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnionTag *>(inst)); |
| 623 | 613 | case IrInstGenIdRef: |
| 624 | | return destroy(reinterpret_cast<IrInstGenRef *>(inst), name); |
| 614 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenRef *>(inst)); |
| 625 | 615 | case IrInstGenIdErrName: |
| 626 | | return destroy(reinterpret_cast<IrInstGenErrName *>(inst), name); |
| 616 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrName *>(inst)); |
| 627 | 617 | case IrInstGenIdCmpxchg: |
| 628 | | return destroy(reinterpret_cast<IrInstGenCmpxchg *>(inst), name); |
| 618 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCmpxchg *>(inst)); |
| 629 | 619 | case IrInstGenIdFence: |
| 630 | | return destroy(reinterpret_cast<IrInstGenFence *>(inst), name); |
| 620 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFence *>(inst)); |
| 631 | 621 | case IrInstGenIdTruncate: |
| 632 | | return destroy(reinterpret_cast<IrInstGenTruncate *>(inst), name); |
| 622 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTruncate *>(inst)); |
| 633 | 623 | case IrInstGenIdShuffleVector: |
| 634 | | return destroy(reinterpret_cast<IrInstGenShuffleVector *>(inst), name); |
| 624 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenShuffleVector *>(inst)); |
| 635 | 625 | case IrInstGenIdSplat: |
| 636 | | return destroy(reinterpret_cast<IrInstGenSplat *>(inst), name); |
| 626 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSplat *>(inst)); |
| 637 | 627 | case IrInstGenIdBoolNot: |
| 638 | | return destroy(reinterpret_cast<IrInstGenBoolNot *>(inst), name); |
| 628 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBoolNot *>(inst)); |
| 639 | 629 | case IrInstGenIdMemset: |
| 640 | | return destroy(reinterpret_cast<IrInstGenMemset *>(inst), name); |
| 630 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMemset *>(inst)); |
| 641 | 631 | case IrInstGenIdMemcpy: |
| 642 | | return destroy(reinterpret_cast<IrInstGenMemcpy *>(inst), name); |
| 632 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMemcpy *>(inst)); |
| 643 | 633 | case IrInstGenIdSlice: |
| 644 | | return destroy(reinterpret_cast<IrInstGenSlice *>(inst), name); |
| 634 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSlice *>(inst)); |
| 645 | 635 | case IrInstGenIdBreakpoint: |
| 646 | | return destroy(reinterpret_cast<IrInstGenBreakpoint *>(inst), name); |
| 636 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBreakpoint *>(inst)); |
| 647 | 637 | case IrInstGenIdReturnAddress: |
| 648 | | return destroy(reinterpret_cast<IrInstGenReturnAddress *>(inst), name); |
| 638 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturnAddress *>(inst)); |
| 649 | 639 | case IrInstGenIdFrameAddress: |
| 650 | | return destroy(reinterpret_cast<IrInstGenFrameAddress *>(inst), name); |
| 640 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameAddress *>(inst)); |
| 651 | 641 | case IrInstGenIdFrameHandle: |
| 652 | | return destroy(reinterpret_cast<IrInstGenFrameHandle *>(inst), name); |
| 642 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameHandle *>(inst)); |
| 653 | 643 | case IrInstGenIdFrameSize: |
| 654 | | return destroy(reinterpret_cast<IrInstGenFrameSize *>(inst), name); |
| 644 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameSize *>(inst)); |
| 655 | 645 | case IrInstGenIdOverflowOp: |
| 656 | | return destroy(reinterpret_cast<IrInstGenOverflowOp *>(inst), name); |
| 646 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOverflowOp *>(inst)); |
| 657 | 647 | case IrInstGenIdTestErr: |
| 658 | | return destroy(reinterpret_cast<IrInstGenTestErr *>(inst), name); |
| 648 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTestErr *>(inst)); |
| 659 | 649 | case IrInstGenIdUnwrapErrCode: |
| 660 | | return destroy(reinterpret_cast<IrInstGenUnwrapErrCode *>(inst), name); |
| 650 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnwrapErrCode *>(inst)); |
| 661 | 651 | case IrInstGenIdUnwrapErrPayload: |
| 662 | | return destroy(reinterpret_cast<IrInstGenUnwrapErrPayload *>(inst), name); |
| 652 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnwrapErrPayload *>(inst)); |
| 663 | 653 | case IrInstGenIdOptionalWrap: |
| 664 | | return destroy(reinterpret_cast<IrInstGenOptionalWrap *>(inst), name); |
| 654 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOptionalWrap *>(inst)); |
| 665 | 655 | case IrInstGenIdErrWrapCode: |
| 666 | | return destroy(reinterpret_cast<IrInstGenErrWrapCode *>(inst), name); |
| 656 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrWrapCode *>(inst)); |
| 667 | 657 | case IrInstGenIdErrWrapPayload: |
| 668 | | return destroy(reinterpret_cast<IrInstGenErrWrapPayload *>(inst), name); |
| 658 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrWrapPayload *>(inst)); |
| 669 | 659 | case IrInstGenIdPtrCast: |
| 670 | | return destroy(reinterpret_cast<IrInstGenPtrCast *>(inst), name); |
| 660 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrCast *>(inst)); |
| 671 | 661 | case IrInstGenIdBitCast: |
| 672 | | return destroy(reinterpret_cast<IrInstGenBitCast *>(inst), name); |
| 662 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBitCast *>(inst)); |
| 673 | 663 | case IrInstGenIdWidenOrShorten: |
| 674 | | return destroy(reinterpret_cast<IrInstGenWidenOrShorten *>(inst), name); |
| 664 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenWidenOrShorten *>(inst)); |
| 675 | 665 | case IrInstGenIdPtrToInt: |
| 676 | | return destroy(reinterpret_cast<IrInstGenPtrToInt *>(inst), name); |
| 666 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrToInt *>(inst)); |
| 677 | 667 | case IrInstGenIdIntToPtr: |
| 678 | | return destroy(reinterpret_cast<IrInstGenIntToPtr *>(inst), name); |
| 668 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToPtr *>(inst)); |
| 679 | 669 | case IrInstGenIdIntToEnum: |
| 680 | | return destroy(reinterpret_cast<IrInstGenIntToEnum *>(inst), name); |
| 670 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToEnum *>(inst)); |
| 681 | 671 | case IrInstGenIdIntToErr: |
| 682 | | return destroy(reinterpret_cast<IrInstGenIntToErr *>(inst), name); |
| 672 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToErr *>(inst)); |
| 683 | 673 | case IrInstGenIdErrToInt: |
| 684 | | return destroy(reinterpret_cast<IrInstGenErrToInt *>(inst), name); |
| 674 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrToInt *>(inst)); |
| 685 | 675 | case IrInstGenIdTagName: |
| 686 | | return destroy(reinterpret_cast<IrInstGenTagName *>(inst), name); |
| 676 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTagName *>(inst)); |
| 687 | 677 | case IrInstGenIdPanic: |
| 688 | | return destroy(reinterpret_cast<IrInstGenPanic *>(inst), name); |
| 678 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPanic *>(inst)); |
| 689 | 679 | case IrInstGenIdFieldParentPtr: |
| 690 | | return destroy(reinterpret_cast<IrInstGenFieldParentPtr *>(inst), name); |
| 680 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFieldParentPtr *>(inst)); |
| 691 | 681 | case IrInstGenIdAlignCast: |
| 692 | | return destroy(reinterpret_cast<IrInstGenAlignCast *>(inst), name); |
| 682 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAlignCast *>(inst)); |
| 693 | 683 | case IrInstGenIdErrorReturnTrace: |
| 694 | | return destroy(reinterpret_cast<IrInstGenErrorReturnTrace *>(inst), name); |
| 684 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrorReturnTrace *>(inst)); |
| 695 | 685 | case IrInstGenIdAtomicRmw: |
| 696 | | return destroy(reinterpret_cast<IrInstGenAtomicRmw *>(inst), name); |
| 686 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicRmw *>(inst)); |
| 697 | 687 | case IrInstGenIdSaveErrRetAddr: |
| 698 | | return destroy(reinterpret_cast<IrInstGenSaveErrRetAddr *>(inst), name); |
| 688 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSaveErrRetAddr *>(inst)); |
| 699 | 689 | case IrInstGenIdFloatOp: |
| 700 | | return destroy(reinterpret_cast<IrInstGenFloatOp *>(inst), name); |
| 690 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFloatOp *>(inst)); |
| 701 | 691 | case IrInstGenIdMulAdd: |
| 702 | | return destroy(reinterpret_cast<IrInstGenMulAdd *>(inst), name); |
| 692 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMulAdd *>(inst)); |
| 703 | 693 | case IrInstGenIdAtomicLoad: |
| 704 | | return destroy(reinterpret_cast<IrInstGenAtomicLoad *>(inst), name); |
| 694 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicLoad *>(inst)); |
| 705 | 695 | case IrInstGenIdAtomicStore: |
| 706 | | return destroy(reinterpret_cast<IrInstGenAtomicStore *>(inst), name); |
| 696 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicStore *>(inst)); |
| 707 | 697 | case IrInstGenIdDeclVar: |
| 708 | | return destroy(reinterpret_cast<IrInstGenDeclVar *>(inst), name); |
| 698 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenDeclVar *>(inst)); |
| 709 | 699 | case IrInstGenIdArrayToVector: |
| 710 | | return destroy(reinterpret_cast<IrInstGenArrayToVector *>(inst), name); |
| 700 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenArrayToVector *>(inst)); |
| 711 | 701 | case IrInstGenIdVectorToArray: |
| 712 | | return destroy(reinterpret_cast<IrInstGenVectorToArray *>(inst), name); |
| 702 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorToArray *>(inst)); |
| 713 | 703 | case IrInstGenIdPtrOfArrayToSlice: |
| 714 | | return destroy(reinterpret_cast<IrInstGenPtrOfArrayToSlice *>(inst), name); |
| 704 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrOfArrayToSlice *>(inst)); |
| 715 | 705 | case IrInstGenIdAssertZero: |
| 716 | | return destroy(reinterpret_cast<IrInstGenAssertZero *>(inst), name); |
| 706 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAssertZero *>(inst)); |
| 717 | 707 | case IrInstGenIdAssertNonNull: |
| 718 | | return destroy(reinterpret_cast<IrInstGenAssertNonNull *>(inst), name); |
| 708 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAssertNonNull *>(inst)); |
| 719 | 709 | case IrInstGenIdResizeSlice: |
| 720 | | return destroy(reinterpret_cast<IrInstGenResizeSlice *>(inst), name); |
| 710 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenResizeSlice *>(inst)); |
| 721 | 711 | case IrInstGenIdAlloca: |
| 722 | | return destroy(reinterpret_cast<IrInstGenAlloca *>(inst), name); |
| 712 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAlloca *>(inst)); |
| 723 | 713 | case IrInstGenIdSuspendBegin: |
| 724 | | return destroy(reinterpret_cast<IrInstGenSuspendBegin *>(inst), name); |
| 714 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSuspendBegin *>(inst)); |
| 725 | 715 | case IrInstGenIdSuspendFinish: |
| 726 | | return destroy(reinterpret_cast<IrInstGenSuspendFinish *>(inst), name); |
| 716 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSuspendFinish *>(inst)); |
| 727 | 717 | case IrInstGenIdResume: |
| 728 | | return destroy(reinterpret_cast<IrInstGenResume *>(inst), name); |
| 718 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenResume *>(inst)); |
| 729 | 719 | case IrInstGenIdAwait: |
| 730 | | return destroy(reinterpret_cast<IrInstGenAwait *>(inst), name); |
| 720 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAwait *>(inst)); |
| 731 | 721 | case IrInstGenIdSpillBegin: |
| 732 | | return destroy(reinterpret_cast<IrInstGenSpillBegin *>(inst), name); |
| 722 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSpillBegin *>(inst)); |
| 733 | 723 | case IrInstGenIdSpillEnd: |
| 734 | | return destroy(reinterpret_cast<IrInstGenSpillEnd *>(inst), name); |
| 724 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSpillEnd *>(inst)); |
| 735 | 725 | case IrInstGenIdVectorExtractElem: |
| 736 | | return destroy(reinterpret_cast<IrInstGenVectorExtractElem *>(inst), name); |
| 726 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorExtractElem *>(inst)); |
| 737 | 727 | case IrInstGenIdBinaryNot: |
| 738 | | return destroy(reinterpret_cast<IrInstGenBinaryNot *>(inst), name); |
| 728 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBinaryNot *>(inst)); |
| 739 | 729 | case IrInstGenIdNegation: |
| 740 | | return destroy(reinterpret_cast<IrInstGenNegation *>(inst), name); |
| 730 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenNegation *>(inst)); |
| 741 | 731 | case IrInstGenIdNegationWrapping: |
| 742 | | return destroy(reinterpret_cast<IrInstGenNegationWrapping *>(inst), name); |
| 732 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenNegationWrapping *>(inst)); |
| 743 | 733 | } |
| 744 | 734 | zig_unreachable(); |
| 745 | 735 | } |
| ... | ... | @@ -760,15 +750,14 @@ static void ira_deref(IrAnalyze *ira) { |
| 760 | 750 | IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i]; |
| 761 | 751 | destroy_instruction_src(pass1_inst); |
| 762 | 752 | } |
| 763 | | destroy(pass1_bb, "IrBasicBlockSrc"); |
| 753 | heap::c_allocator.destroy(pass1_bb); |
| 764 | 754 | } |
| 765 | 755 | ira->old_irb.exec->basic_block_list.deinit(); |
| 766 | 756 | ira->old_irb.exec->tld_list.deinit(); |
| 767 | | // cannot destroy here because of var->owner_exec |
| 768 | | //destroy(ira->old_irb.exec, "IrExecutableSrc"); |
| 757 | heap::c_allocator.destroy(ira->old_irb.exec); |
| 769 | 758 | ira->src_implicit_return_type_list.deinit(); |
| 770 | 759 | ira->resume_stack.deinit(); |
| 771 | | destroy(ira, "IrAnalyze"); |
| 760 | heap::c_allocator.destroy(ira); |
| 772 | 761 | } |
| 773 | 762 | |
| 774 | 763 | static ZigValue *const_ptr_pointee_unchecked_no_isf(CodeGen *g, ZigValue *const_val) { |
| ... | ... | @@ -1017,8 +1006,8 @@ static void ir_ref_var(ZigVar *var) { |
| 1017 | 1006 | static void create_result_ptr(CodeGen *codegen, ZigType *expected_type, |
| 1018 | 1007 | ZigValue **out_result, ZigValue **out_result_ptr) |
| 1019 | 1008 | { |
| 1020 | | ZigValue *result = create_const_vals(1); |
| 1021 | | ZigValue *result_ptr = create_const_vals(1); |
| 1009 | ZigValue *result = codegen->pass1_arena->create<ZigValue>(); |
| 1010 | ZigValue *result_ptr = codegen->pass1_arena->create<ZigValue>(); |
| 1022 | 1011 | result->special = ConstValSpecialUndef; |
| 1023 | 1012 | result->type = expected_type; |
| 1024 | 1013 | result_ptr->special = ConstValSpecialStatic; |
| ... | ... | @@ -1050,14 +1039,11 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| 1050 | 1039 | assert(result->special != ConstValSpecialRuntime); |
| 1051 | 1040 | ZigType *res_type = result->data.x_type; |
| 1052 | 1041 | |
| 1053 | | destroy(result_ptr, "ZigValue"); |
| 1054 | | destroy(result, "ZigValue"); |
| 1055 | | |
| 1056 | 1042 | return res_type; |
| 1057 | 1043 | } |
| 1058 | 1044 | |
| 1059 | 1045 | static IrBasicBlockSrc *ir_create_basic_block(IrBuilderSrc *irb, Scope *scope, const char *name_hint) { |
| 1060 | | IrBasicBlockSrc *result = allocate<IrBasicBlockSrc>(1, "IrBasicBlockSrc"); |
| 1046 | IrBasicBlockSrc *result = heap::c_allocator.create<IrBasicBlockSrc>(); |
| 1061 | 1047 | result->scope = scope; |
| 1062 | 1048 | result->name_hint = name_hint; |
| 1063 | 1049 | result->debug_id = exec_next_debug_id(irb->exec); |
| ... | ... | @@ -1066,7 +1052,7 @@ static IrBasicBlockSrc *ir_create_basic_block(IrBuilderSrc *irb, Scope *scope, c |
| 1066 | 1052 | } |
| 1067 | 1053 | |
| 1068 | 1054 | static IrBasicBlockGen *ir_create_basic_block_gen(IrAnalyze *ira, Scope *scope, const char *name_hint) { |
| 1069 | | IrBasicBlockGen *result = allocate<IrBasicBlockGen>(1, "IrBasicBlockGen"); |
| 1055 | IrBasicBlockGen *result = heap::c_allocator.create<IrBasicBlockGen>(); |
| 1070 | 1056 | result->scope = scope; |
| 1071 | 1057 | result->name_hint = name_hint; |
| 1072 | 1058 | result->debug_id = exec_next_debug_id_gen(ira->new_irb.exec); |
| ... | ... | @@ -1983,12 +1969,7 @@ static constexpr IrInstGenId ir_inst_id(IrInstGenConst *) { |
| 1983 | 1969 | |
| 1984 | 1970 | template<typename T> |
| 1985 | 1971 | static T *ir_create_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1986 | | const char *name = nullptr; |
| 1987 | | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1988 | | T *dummy = nullptr; |
| 1989 | | name = ir_inst_src_type_str(ir_inst_id(dummy)); |
| 1990 | | #endif |
| 1991 | | T *special_instruction = allocate<T>(1, name); |
| 1972 | T *special_instruction = heap::c_allocator.create<T>(); |
| 1992 | 1973 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 1993 | 1974 | special_instruction->base.base.scope = scope; |
| 1994 | 1975 | special_instruction->base.base.source_node = source_node; |
| ... | ... | @@ -1999,29 +1980,19 @@ static T *ir_create_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source |
| 1999 | 1980 | |
| 2000 | 1981 | template<typename T> |
| 2001 | 1982 | static T *ir_create_inst_gen(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 2002 | | const char *name = nullptr; |
| 2003 | | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 2004 | | T *dummy = nullptr; |
| 2005 | | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 2006 | | #endif |
| 2007 | | T *special_instruction = allocate<T>(1, name); |
| 1983 | T *special_instruction = heap::c_allocator.create<T>(); |
| 2008 | 1984 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 2009 | 1985 | special_instruction->base.base.scope = scope; |
| 2010 | 1986 | special_instruction->base.base.source_node = source_node; |
| 2011 | 1987 | special_instruction->base.base.debug_id = exec_next_debug_id_gen(irb->exec); |
| 2012 | 1988 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 2013 | | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); |
| 1989 | special_instruction->base.value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2014 | 1990 | return special_instruction; |
| 2015 | 1991 | } |
| 2016 | 1992 | |
| 2017 | 1993 | template<typename T> |
| 2018 | 1994 | static T *ir_create_inst_noval(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 2019 | | const char *name = nullptr; |
| 2020 | | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 2021 | | T *dummy = nullptr; |
| 2022 | | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 2023 | | #endif |
| 2024 | | T *special_instruction = allocate<T>(1, name); |
| 1995 | T *special_instruction = heap::c_allocator.create<T>(); |
| 2025 | 1996 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 2026 | 1997 | special_instruction->base.base.scope = scope; |
| 2027 | 1998 | special_instruction->base.base.source_node = source_node; |
| ... | ... | @@ -2063,11 +2034,11 @@ static T *ir_build_inst_void(IrBuilderGen *irb, Scope *scope, AstNode *source_no |
| 2063 | 2034 | IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, |
| 2064 | 2035 | ZigType *var_type, const char *name_hint) |
| 2065 | 2036 | { |
| 2066 | | IrInstGenAlloca *alloca_gen = allocate<IrInstGenAlloca>(1); |
| 2037 | IrInstGenAlloca *alloca_gen = heap::c_allocator.create<IrInstGenAlloca>(); |
| 2067 | 2038 | alloca_gen->base.id = IrInstGenIdAlloca; |
| 2068 | 2039 | alloca_gen->base.base.source_node = source_node; |
| 2069 | 2040 | alloca_gen->base.base.scope = scope; |
| 2070 | | alloca_gen->base.value = allocate<ZigValue>(1, "ZigValue"); |
| 2041 | alloca_gen->base.value = g->pass1_arena->create<ZigValue>(); |
| 2071 | 2042 | alloca_gen->base.value->type = get_pointer_to_type(g, var_type, false); |
| 2072 | 2043 | alloca_gen->base.base.ref_count = 1; |
| 2073 | 2044 | alloca_gen->name_hint = name_hint; |
| ... | ... | @@ -2157,7 +2128,7 @@ static IrInstSrc *ir_build_const_undefined(IrBuilderSrc *irb, Scope *scope, AstN |
| 2157 | 2128 | |
| 2158 | 2129 | static IrInstSrc *ir_build_const_uint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 2159 | 2130 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2160 | | const_instruction->value = create_const_vals(1); |
| 2131 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2161 | 2132 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 2162 | 2133 | const_instruction->value->special = ConstValSpecialStatic; |
| 2163 | 2134 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| ... | ... | @@ -2166,7 +2137,7 @@ static IrInstSrc *ir_build_const_uint(IrBuilderSrc *irb, Scope *scope, AstNode * |
| 2166 | 2137 | |
| 2167 | 2138 | static IrInstSrc *ir_build_const_bigint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { |
| 2168 | 2139 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2169 | | const_instruction->value = create_const_vals(1); |
| 2140 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2170 | 2141 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 2171 | 2142 | const_instruction->value->special = ConstValSpecialStatic; |
| 2172 | 2143 | bigint_init_bigint(&const_instruction->value->data.x_bigint, bigint); |
| ... | ... | @@ -2175,7 +2146,7 @@ static IrInstSrc *ir_build_const_bigint(IrBuilderSrc *irb, Scope *scope, AstNode |
| 2175 | 2146 | |
| 2176 | 2147 | static IrInstSrc *ir_build_const_bigfloat(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { |
| 2177 | 2148 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2178 | | const_instruction->value = create_const_vals(1); |
| 2149 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2179 | 2150 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_float; |
| 2180 | 2151 | const_instruction->value->special = ConstValSpecialStatic; |
| 2181 | 2152 | bigfloat_init_bigfloat(&const_instruction->value->data.x_bigfloat, bigfloat); |
| ... | ... | @@ -2191,7 +2162,7 @@ static IrInstSrc *ir_build_const_null(IrBuilderSrc *irb, Scope *scope, AstNode * |
| 2191 | 2162 | |
| 2192 | 2163 | static IrInstSrc *ir_build_const_usize(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 2193 | 2164 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2194 | | const_instruction->value = create_const_vals(1); |
| 2165 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2195 | 2166 | const_instruction->value->type = irb->codegen->builtin_types.entry_usize; |
| 2196 | 2167 | const_instruction->value->special = ConstValSpecialStatic; |
| 2197 | 2168 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| ... | ... | @@ -2202,7 +2173,7 @@ static IrInstSrc *ir_create_const_type(IrBuilderSrc *irb, Scope *scope, AstNode |
| 2202 | 2173 | ZigType *type_entry) |
| 2203 | 2174 | { |
| 2204 | 2175 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2205 | | const_instruction->value = create_const_vals(1); |
| 2176 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2206 | 2177 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 2207 | 2178 | const_instruction->value->special = ConstValSpecialStatic; |
| 2208 | 2179 | const_instruction->value->data.x_type = type_entry; |
| ... | ... | @@ -2219,7 +2190,7 @@ static IrInstSrc *ir_build_const_type(IrBuilderSrc *irb, Scope *scope, AstNode * |
| 2219 | 2190 | |
| 2220 | 2191 | static IrInstSrc *ir_build_const_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigType *import) { |
| 2221 | 2192 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2222 | | const_instruction->value = create_const_vals(1); |
| 2193 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2223 | 2194 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 2224 | 2195 | const_instruction->value->special = ConstValSpecialStatic; |
| 2225 | 2196 | const_instruction->value->data.x_type = import; |
| ... | ... | @@ -2228,7 +2199,7 @@ static IrInstSrc *ir_build_const_import(IrBuilderSrc *irb, Scope *scope, AstNode |
| 2228 | 2199 | |
| 2229 | 2200 | static IrInstSrc *ir_build_const_bool(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, bool value) { |
| 2230 | 2201 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2231 | | const_instruction->value = create_const_vals(1); |
| 2202 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2232 | 2203 | const_instruction->value->type = irb->codegen->builtin_types.entry_bool; |
| 2233 | 2204 | const_instruction->value->special = ConstValSpecialStatic; |
| 2234 | 2205 | const_instruction->value->data.x_bool = value; |
| ... | ... | @@ -2237,7 +2208,7 @@ static IrInstSrc *ir_build_const_bool(IrBuilderSrc *irb, Scope *scope, AstNode * |
| 2237 | 2208 | |
| 2238 | 2209 | static IrInstSrc *ir_build_const_enum_literal(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 2239 | 2210 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2240 | | const_instruction->value = create_const_vals(1); |
| 2211 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2241 | 2212 | const_instruction->value->type = irb->codegen->builtin_types.entry_enum_literal; |
| 2242 | 2213 | const_instruction->value->special = ConstValSpecialStatic; |
| 2243 | 2214 | const_instruction->value->data.x_enum_literal = name; |
| ... | ... | @@ -2246,7 +2217,7 @@ static IrInstSrc *ir_build_const_enum_literal(IrBuilderSrc *irb, Scope *scope, A |
| 2246 | 2217 | |
| 2247 | 2218 | static IrInstSrc *ir_create_const_str_lit(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 2248 | 2219 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 2249 | | const_instruction->value = create_const_vals(1); |
| 2220 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 2250 | 2221 | init_const_str_lit(irb->codegen, const_instruction->value, str); |
| 2251 | 2222 | |
| 2252 | 2223 | return &const_instruction->base; |
| ... | ... | @@ -5244,7 +5215,7 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node, |
| 5244 | 5215 | switch (node->data.return_expr.kind) { |
| 5245 | 5216 | case ReturnKindUnconditional: |
| 5246 | 5217 | { |
| 5247 | | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 5218 | ResultLocReturn *result_loc_ret = heap::c_allocator.create<ResultLocReturn>(); |
| 5248 | 5219 | result_loc_ret->base.id = ResultLocIdReturn; |
| 5249 | 5220 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 5250 | 5221 | |
| ... | ... | @@ -5332,7 +5303,7 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node, |
| 5332 | 5303 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr)); |
| 5333 | 5304 | IrInstSrcSpillBegin *spill_begin = ir_build_spill_begin_src(irb, scope, node, err_val, |
| 5334 | 5305 | SpillIdRetErrCode); |
| 5335 | | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 5306 | ResultLocReturn *result_loc_ret = heap::c_allocator.create<ResultLocReturn>(); |
| 5336 | 5307 | result_loc_ret->base.id = ResultLocIdReturn; |
| 5337 | 5308 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 5338 | 5309 | ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base); |
| ... | ... | @@ -5360,12 +5331,12 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s |
| 5360 | 5331 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime, |
| 5361 | 5332 | bool skip_name_check) |
| 5362 | 5333 | { |
| 5363 | | ZigVar *variable_entry = allocate<ZigVar>(1, "ZigVar"); |
| 5334 | ZigVar *variable_entry = heap::c_allocator.create<ZigVar>(); |
| 5364 | 5335 | variable_entry->parent_scope = parent_scope; |
| 5365 | 5336 | variable_entry->shadowable = is_shadowable; |
| 5366 | 5337 | variable_entry->is_comptime = is_comptime; |
| 5367 | 5338 | variable_entry->src_arg_index = SIZE_MAX; |
| 5368 | | variable_entry->const_value = create_const_vals(1); |
| 5339 | variable_entry->const_value = codegen->pass1_arena->create<ZigValue>(); |
| 5369 | 5340 | |
| 5370 | 5341 | if (is_comptime != nullptr) { |
| 5371 | 5342 | is_comptime->base.ref_count += 1; |
| ... | ... | @@ -5425,15 +5396,12 @@ static ZigVar *ir_create_var(IrBuilderSrc *irb, AstNode *node, Scope *scope, Buf |
| 5425 | 5396 | ZigVar *var = create_local_var(irb->codegen, node, scope, |
| 5426 | 5397 | (is_underscored ? nullptr : name), src_is_const, gen_is_const, |
| 5427 | 5398 | (is_underscored ? true : is_shadowable), is_comptime, false); |
| 5428 | | if (is_comptime != nullptr || gen_is_const) { |
| 5429 | | var->owner_exec = irb->exec; |
| 5430 | | } |
| 5431 | 5399 | assert(var->child_scope); |
| 5432 | 5400 | return var; |
| 5433 | 5401 | } |
| 5434 | 5402 | |
| 5435 | 5403 | static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) { |
| 5436 | | ResultLocPeer *result = allocate<ResultLocPeer>(1, "ResultLocPeer"); |
| 5404 | ResultLocPeer *result = heap::c_allocator.create<ResultLocPeer>(); |
| 5437 | 5405 | result->base.id = ResultLocIdPeer; |
| 5438 | 5406 | result->base.source_instruction = peer_parent->base.source_instruction; |
| 5439 | 5407 | result->parent = peer_parent; |
| ... | ... | @@ -5472,7 +5440,7 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode * |
| 5472 | 5440 | scope_block->is_comptime = ir_build_const_bool(irb, parent_scope, block_node, |
| 5473 | 5441 | ir_should_inline(irb->exec, parent_scope)); |
| 5474 | 5442 | |
| 5475 | | scope_block->peer_parent = allocate<ResultLocPeerParent>(1, "ResultLocPeerParent"); |
| 5443 | scope_block->peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 5476 | 5444 | scope_block->peer_parent->base.id = ResultLocIdPeerParent; |
| 5477 | 5445 | scope_block->peer_parent->base.source_instruction = scope_block->is_comptime; |
| 5478 | 5446 | scope_block->peer_parent->base.allow_write_through_const = result_loc->allow_write_through_const; |
| ... | ... | @@ -5562,7 +5530,7 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode * |
| 5562 | 5530 | // only generate unconditional defers |
| 5563 | 5531 | |
| 5564 | 5532 | ir_mark_gen(ir_build_add_implicit_return_type(irb, child_scope, block_node, result, nullptr)); |
| 5565 | | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 5533 | ResultLocReturn *result_loc_ret = heap::c_allocator.create<ResultLocReturn>(); |
| 5566 | 5534 | result_loc_ret->base.id = ResultLocIdReturn; |
| 5567 | 5535 | ir_build_reset_result(irb, parent_scope, block_node, &result_loc_ret->base); |
| 5568 | 5536 | ir_mark_gen(ir_build_end_expr(irb, parent_scope, block_node, result, &result_loc_ret->base)); |
| ... | ... | @@ -5604,7 +5572,7 @@ static IrInstSrc *ir_gen_assign(IrBuilderSrc *irb, Scope *scope, AstNode *node) |
| 5604 | 5572 | if (lvalue == irb->codegen->invalid_inst_src) |
| 5605 | 5573 | return irb->codegen->invalid_inst_src; |
| 5606 | 5574 | |
| 5607 | | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1, "ResultLocInstruction"); |
| 5575 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 5608 | 5576 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5609 | 5577 | result_loc_inst->base.source_instruction = lvalue; |
| 5610 | 5578 | ir_ref_instruction(lvalue, irb->current_basic_block); |
| ... | ... | @@ -5676,10 +5644,10 @@ static IrInstSrc *ir_gen_bool_or(IrBuilderSrc *irb, Scope *scope, AstNode *node) |
| 5676 | 5644 | |
| 5677 | 5645 | ir_set_cursor_at_end_and_append_block(irb, true_block); |
| 5678 | 5646 | |
| 5679 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2, "IrInstSrc *"); |
| 5647 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 5680 | 5648 | incoming_values[0] = val1; |
| 5681 | 5649 | incoming_values[1] = val2; |
| 5682 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 5650 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 5683 | 5651 | incoming_blocks[0] = post_val1_block; |
| 5684 | 5652 | incoming_blocks[1] = post_val2_block; |
| 5685 | 5653 | |
| ... | ... | @@ -5718,10 +5686,10 @@ static IrInstSrc *ir_gen_bool_and(IrBuilderSrc *irb, Scope *scope, AstNode *node |
| 5718 | 5686 | |
| 5719 | 5687 | ir_set_cursor_at_end_and_append_block(irb, false_block); |
| 5720 | 5688 | |
| 5721 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 5689 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 5722 | 5690 | incoming_values[0] = val1; |
| 5723 | 5691 | incoming_values[1] = val2; |
| 5724 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 5692 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 5725 | 5693 | incoming_blocks[0] = post_val1_block; |
| 5726 | 5694 | incoming_blocks[1] = post_val2_block; |
| 5727 | 5695 | |
| ... | ... | @@ -5731,7 +5699,7 @@ static IrInstSrc *ir_gen_bool_and(IrBuilderSrc *irb, Scope *scope, AstNode *node |
| 5731 | 5699 | static ResultLocPeerParent *ir_build_result_peers(IrBuilderSrc *irb, IrInstSrc *cond_br_inst, |
| 5732 | 5700 | IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 5733 | 5701 | { |
| 5734 | | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 5702 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 5735 | 5703 | peer_parent->base.id = ResultLocIdPeerParent; |
| 5736 | 5704 | peer_parent->base.source_instruction = cond_br_inst; |
| 5737 | 5705 | peer_parent->base.allow_write_through_const = parent->allow_write_through_const; |
| ... | ... | @@ -5809,10 +5777,10 @@ static IrInstSrc *ir_gen_orelse(IrBuilderSrc *irb, Scope *parent_scope, AstNode |
| 5809 | 5777 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 5810 | 5778 | |
| 5811 | 5779 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 5812 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 5780 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 5813 | 5781 | incoming_values[0] = null_result; |
| 5814 | 5782 | incoming_values[1] = unwrapped_payload; |
| 5815 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 5783 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 5816 | 5784 | incoming_blocks[0] = after_null_block; |
| 5817 | 5785 | incoming_blocks[1] = after_ok_block; |
| 5818 | 5786 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | ... | @@ -5966,7 +5934,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 5966 | 5934 | } |
| 5967 | 5935 | scope = scope->parent; |
| 5968 | 5936 | } |
| 5969 | | TldVar *tld_var = allocate<TldVar>(1); |
| 5937 | TldVar *tld_var = heap::c_allocator.create<TldVar>(); |
| 5970 | 5938 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); |
| 5971 | 5939 | tld_var->base.resolution = TldResolutionInvalid; |
| 5972 | 5940 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, |
| ... | ... | @@ -5983,7 +5951,7 @@ static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node, |
| 5983 | 5951 | if (buf_eql_str(variable_name, "_")) { |
| 5984 | 5952 | if (lval == LValPtr) { |
| 5985 | 5953 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, node); |
| 5986 | | const_instruction->value = create_const_vals(1); |
| 5954 | const_instruction->value = irb->codegen->pass1_arena->create<ZigValue>(); |
| 5987 | 5955 | const_instruction->value->type = get_pointer_to_type(irb->codegen, |
| 5988 | 5956 | irb->codegen->builtin_types.entry_void, false); |
| 5989 | 5957 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -6177,7 +6145,7 @@ static IrInstSrc *ir_gen_async_call(IrBuilderSrc *irb, Scope *scope, AstNode *aw |
| 6177 | 6145 | return fn_ref; |
| 6178 | 6146 | |
| 6179 | 6147 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; |
| 6180 | | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 6148 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); |
| 6181 | 6149 | for (size_t i = 0; i < arg_count; i += 1) { |
| 6182 | 6150 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); |
| 6183 | 6151 | IrInstSrc *arg = ir_gen_node(irb, arg_node, scope); |
| ... | ... | @@ -6203,7 +6171,7 @@ static IrInstSrc *ir_gen_fn_call_with_args(IrBuilderSrc *irb, Scope *scope, AstN |
| 6203 | 6171 | |
| 6204 | 6172 | IrInstSrc *fn_type = ir_build_typeof(irb, scope, source_node, fn_ref); |
| 6205 | 6173 | |
| 6206 | | IrInstSrc **args = allocate<IrInstSrc*>(args_len); |
| 6174 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(args_len); |
| 6207 | 6175 | for (size_t i = 0; i < args_len; i += 1) { |
| 6208 | 6176 | AstNode *arg_node = args_ptr[i]; |
| 6209 | 6177 | |
| ... | ... | @@ -6388,7 +6356,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod |
| 6388 | 6356 | } |
| 6389 | 6357 | case BuiltinFnIdCompileLog: |
| 6390 | 6358 | { |
| 6391 | | IrInstSrc **args = allocate<IrInstSrc*>(actual_param_count); |
| 6359 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(actual_param_count); |
| 6392 | 6360 | |
| 6393 | 6361 | for (size_t i = 0; i < actual_param_count; i += 1) { |
| 6394 | 6362 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| ... | ... | @@ -7013,7 +6981,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod |
| 7013 | 6981 | if (dest_type == irb->codegen->invalid_inst_src) |
| 7014 | 6982 | return dest_type; |
| 7015 | 6983 | |
| 7016 | | ResultLocBitCast *result_loc_bit_cast = allocate<ResultLocBitCast>(1); |
| 6984 | ResultLocBitCast *result_loc_bit_cast = heap::c_allocator.create<ResultLocBitCast>(); |
| 7017 | 6985 | result_loc_bit_cast->base.id = ResultLocIdBitCast; |
| 7018 | 6986 | result_loc_bit_cast->base.source_instruction = dest_type; |
| 7019 | 6987 | result_loc_bit_cast->base.allow_write_through_const = result_loc->allow_write_through_const; |
| ... | ... | @@ -7166,7 +7134,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod |
| 7166 | 7134 | |
| 7167 | 7135 | size_t arg_count = node->data.fn_call_expr.params.length - 2; |
| 7168 | 7136 | |
| 7169 | | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 7137 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); |
| 7170 | 7138 | for (size_t i = 0; i < arg_count; i += 1) { |
| 7171 | 7139 | AstNode *arg_node = node->data.fn_call_expr.params.at(i + 2); |
| 7172 | 7140 | args[i] = ir_gen_node(irb, arg_node, scope); |
| ... | ... | @@ -7595,10 +7563,10 @@ static IrInstSrc *ir_gen_if_bool_expr(IrBuilderSrc *irb, Scope *scope, AstNode * |
| 7595 | 7563 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7596 | 7564 | |
| 7597 | 7565 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 7598 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 7566 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 7599 | 7567 | incoming_values[0] = then_expr_result; |
| 7600 | 7568 | incoming_values[1] = else_expr_result; |
| 7601 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 7569 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 7602 | 7570 | incoming_blocks[0] = after_then_block; |
| 7603 | 7571 | incoming_blocks[1] = after_else_block; |
| 7604 | 7572 | |
| ... | ... | @@ -7799,7 +7767,7 @@ static IrInstSrc *ir_gen_union_init_expr(IrBuilderSrc *irb, Scope *scope, AstNod |
| 7799 | 7767 | IrInstSrc *field_ptr = ir_build_field_ptr_instruction(irb, scope, source_node, container_ptr, |
| 7800 | 7768 | field_name, true); |
| 7801 | 7769 | |
| 7802 | | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 7770 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 7803 | 7771 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 7804 | 7772 | result_loc_inst->base.source_instruction = field_ptr; |
| 7805 | 7773 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| ... | ... | @@ -7875,7 +7843,7 @@ static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, As |
| 7875 | 7843 | nullptr); |
| 7876 | 7844 | |
| 7877 | 7845 | size_t field_count = container_init_expr->entries.length; |
| 7878 | | IrInstSrcContainerInitFieldsField *fields = allocate<IrInstSrcContainerInitFieldsField>(field_count); |
| 7846 | IrInstSrcContainerInitFieldsField *fields = heap::c_allocator.allocate<IrInstSrcContainerInitFieldsField>(field_count); |
| 7879 | 7847 | for (size_t i = 0; i < field_count; i += 1) { |
| 7880 | 7848 | AstNode *entry_node = container_init_expr->entries.at(i); |
| 7881 | 7849 | assert(entry_node->type == NodeTypeStructValueField); |
| ... | ... | @@ -7884,7 +7852,7 @@ static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, As |
| 7884 | 7852 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 7885 | 7853 | |
| 7886 | 7854 | IrInstSrc *field_ptr = ir_build_field_ptr(irb, scope, entry_node, container_ptr, name, true); |
| 7887 | | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 7855 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 7888 | 7856 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 7889 | 7857 | result_loc_inst->base.source_instruction = field_ptr; |
| 7890 | 7858 | result_loc_inst->base.allow_write_through_const = true; |
| ... | ... | @@ -7914,14 +7882,14 @@ static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, As |
| 7914 | 7882 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, |
| 7915 | 7883 | nullptr); |
| 7916 | 7884 | |
| 7917 | | IrInstSrc **result_locs = allocate<IrInstSrc *>(item_count); |
| 7885 | IrInstSrc **result_locs = heap::c_allocator.allocate<IrInstSrc *>(item_count); |
| 7918 | 7886 | for (size_t i = 0; i < item_count; i += 1) { |
| 7919 | 7887 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 7920 | 7888 | |
| 7921 | 7889 | IrInstSrc *elem_index = ir_build_const_usize(irb, scope, expr_node, i); |
| 7922 | 7890 | IrInstSrc *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, |
| 7923 | 7891 | elem_index, false, PtrLenSingle, init_array_type_source_node); |
| 7924 | | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 7892 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 7925 | 7893 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 7926 | 7894 | result_loc_inst->base.source_instruction = elem_ptr; |
| 7927 | 7895 | result_loc_inst->base.allow_write_through_const = true; |
| ... | ... | @@ -7947,7 +7915,7 @@ static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, As |
| 7947 | 7915 | } |
| 7948 | 7916 | |
| 7949 | 7917 | static ResultLocVar *ir_build_var_result_loc(IrBuilderSrc *irb, IrInstSrc *alloca, ZigVar *var) { |
| 7950 | | ResultLocVar *result_loc_var = allocate<ResultLocVar>(1); |
| 7918 | ResultLocVar *result_loc_var = heap::c_allocator.create<ResultLocVar>(); |
| 7951 | 7919 | result_loc_var->base.id = ResultLocIdVar; |
| 7952 | 7920 | result_loc_var->base.source_instruction = alloca; |
| 7953 | 7921 | result_loc_var->base.allow_write_through_const = true; |
| ... | ... | @@ -7961,7 +7929,7 @@ static ResultLocVar *ir_build_var_result_loc(IrBuilderSrc *irb, IrInstSrc *alloc |
| 7961 | 7929 | static ResultLocCast *ir_build_cast_result_loc(IrBuilderSrc *irb, IrInstSrc *dest_type, |
| 7962 | 7930 | ResultLoc *parent_result_loc) |
| 7963 | 7931 | { |
| 7964 | | ResultLocCast *result_loc_cast = allocate<ResultLocCast>(1); |
| 7932 | ResultLocCast *result_loc_cast = heap::c_allocator.create<ResultLocCast>(); |
| 7965 | 7933 | result_loc_cast->base.id = ResultLocIdCast; |
| 7966 | 7934 | result_loc_cast->base.source_instruction = dest_type; |
| 7967 | 7935 | result_loc_cast->base.allow_write_through_const = parent_result_loc->allow_write_through_const; |
| ... | ... | @@ -8804,9 +8772,9 @@ static IrInstSrc *ir_gen_asm_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node |
| 8804 | 8772 | nullptr, 0, is_volatile, true); |
| 8805 | 8773 | } |
| 8806 | 8774 | |
| 8807 | | IrInstSrc **input_list = allocate<IrInstSrc *>(asm_expr->input_list.length); |
| 8808 | | IrInstSrc **output_types = allocate<IrInstSrc *>(asm_expr->output_list.length); |
| 8809 | | ZigVar **output_vars = allocate<ZigVar *>(asm_expr->output_list.length); |
| 8775 | IrInstSrc **input_list = heap::c_allocator.allocate<IrInstSrc *>(asm_expr->input_list.length); |
| 8776 | IrInstSrc **output_types = heap::c_allocator.allocate<IrInstSrc *>(asm_expr->output_list.length); |
| 8777 | ZigVar **output_vars = heap::c_allocator.allocate<ZigVar *>(asm_expr->output_list.length); |
| 8810 | 8778 | size_t return_count = 0; |
| 8811 | 8779 | if (!is_volatile && asm_expr->output_list.length == 0) { |
| 8812 | 8780 | add_node_error(irb->codegen, node, |
| ... | ... | @@ -8940,10 +8908,10 @@ static IrInstSrc *ir_gen_if_optional_expr(IrBuilderSrc *irb, Scope *scope, AstNo |
| 8940 | 8908 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 8941 | 8909 | |
| 8942 | 8910 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 8943 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 8911 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 8944 | 8912 | incoming_values[0] = then_expr_result; |
| 8945 | 8913 | incoming_values[1] = else_expr_result; |
| 8946 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 8914 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 8947 | 8915 | incoming_blocks[0] = after_then_block; |
| 8948 | 8916 | incoming_blocks[1] = after_else_block; |
| 8949 | 8917 | |
| ... | ... | @@ -9037,10 +9005,10 @@ static IrInstSrc *ir_gen_if_err_expr(IrBuilderSrc *irb, Scope *scope, AstNode *n |
| 9037 | 9005 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 9038 | 9006 | |
| 9039 | 9007 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 9040 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 9008 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 9041 | 9009 | incoming_values[0] = then_expr_result; |
| 9042 | 9010 | incoming_values[1] = else_expr_result; |
| 9043 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 9011 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 9044 | 9012 | incoming_blocks[0] = after_then_block; |
| 9045 | 9013 | incoming_blocks[1] = after_else_block; |
| 9046 | 9014 | |
| ... | ... | @@ -9133,7 +9101,7 @@ static IrInstSrc *ir_gen_switch_expr(IrBuilderSrc *irb, Scope *scope, AstNode *n |
| 9133 | 9101 | |
| 9134 | 9102 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; |
| 9135 | 9103 | |
| 9136 | | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 9104 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 9137 | 9105 | peer_parent->base.id = ResultLocIdPeerParent; |
| 9138 | 9106 | peer_parent->base.allow_write_through_const = result_loc->allow_write_through_const; |
| 9139 | 9107 | peer_parent->end_bb = end_block; |
| ... | ... | @@ -9295,7 +9263,7 @@ static IrInstSrc *ir_gen_switch_expr(IrBuilderSrc *irb, Scope *scope, AstNode *n |
| 9295 | 9263 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 9296 | 9264 | |
| 9297 | 9265 | IrBasicBlockSrc *prong_block = ir_create_basic_block(irb, scope, "SwitchProng"); |
| 9298 | | IrInstSrc **items = allocate<IrInstSrc *>(prong_item_count); |
| 9266 | IrInstSrc **items = heap::c_allocator.allocate<IrInstSrc *>(prong_item_count); |
| 9299 | 9267 | |
| 9300 | 9268 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 9301 | 9269 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| ... | ... | @@ -9677,10 +9645,10 @@ static IrInstSrc *ir_gen_catch(IrBuilderSrc *irb, Scope *parent_scope, AstNode * |
| 9677 | 9645 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 9678 | 9646 | |
| 9679 | 9647 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 9680 | | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 9648 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 9681 | 9649 | incoming_values[0] = err_result; |
| 9682 | 9650 | incoming_values[1] = unwrapped_payload; |
| 9683 | | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 9651 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); |
| 9684 | 9652 | incoming_blocks[0] = after_err_block; |
| 9685 | 9653 | incoming_blocks[1] = after_ok_block; |
| 9686 | 9654 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | ... | @@ -9747,7 +9715,7 @@ static IrInstSrc *ir_gen_container_decl(IrBuilderSrc *irb, Scope *parent_scope, |
| 9747 | 9715 | scan_decls(irb->codegen, child_scope, child_node); |
| 9748 | 9716 | } |
| 9749 | 9717 | |
| 9750 | | TldContainer *tld_container = allocate<TldContainer>(1); |
| 9718 | TldContainer *tld_container = heap::c_allocator.create<TldContainer>(); |
| 9751 | 9719 | init_tld(&tld_container->base, TldIdContainer, bare_name, VisibModPub, node, parent_scope); |
| 9752 | 9720 | tld_container->type_entry = container_type; |
| 9753 | 9721 | tld_container->decls_scope = child_scope; |
| ... | ... | @@ -9790,7 +9758,7 @@ static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigTyp |
| 9790 | 9758 | } |
| 9791 | 9759 | |
| 9792 | 9760 | err_set_type->data.error_set.err_count = count; |
| 9793 | | err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(count); |
| 9761 | err_set_type->data.error_set.errors = heap::c_allocator.allocate<ErrorTableEntry *>(count); |
| 9794 | 9762 | |
| 9795 | 9763 | bool need_comma = false; |
| 9796 | 9764 | for (uint32_t i = 0; i < set1->data.error_set.err_count; i += 1) { |
| ... | ... | @@ -9837,7 +9805,7 @@ static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstN |
| 9837 | 9805 | err_set_type->abi_align = g->builtin_types.entry_global_error_set->abi_align; |
| 9838 | 9806 | err_set_type->abi_size = g->builtin_types.entry_global_error_set->abi_size; |
| 9839 | 9807 | err_set_type->data.error_set.err_count = 1; |
| 9840 | | err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1); |
| 9808 | err_set_type->data.error_set.errors = heap::c_allocator.create<ErrorTableEntry *>(); |
| 9841 | 9809 | |
| 9842 | 9810 | err_set_type->data.error_set.errors[0] = err_entry; |
| 9843 | 9811 | |
| ... | ... | @@ -9868,16 +9836,16 @@ static IrInstSrc *ir_gen_err_set_decl(IrBuilderSrc *irb, Scope *parent_scope, As |
| 9868 | 9836 | err_set_type->size_in_bits = irb->codegen->builtin_types.entry_global_error_set->size_in_bits; |
| 9869 | 9837 | err_set_type->abi_align = irb->codegen->builtin_types.entry_global_error_set->abi_align; |
| 9870 | 9838 | err_set_type->abi_size = irb->codegen->builtin_types.entry_global_error_set->abi_size; |
| 9871 | | err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(err_count); |
| 9839 | err_set_type->data.error_set.errors = heap::c_allocator.allocate<ErrorTableEntry *>(err_count); |
| 9872 | 9840 | |
| 9873 | 9841 | size_t errors_count = irb->codegen->errors_by_index.length + err_count; |
| 9874 | | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(errors_count, "ErrorTableEntry *"); |
| 9842 | ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count); |
| 9875 | 9843 | |
| 9876 | 9844 | for (uint32_t i = 0; i < err_count; i += 1) { |
| 9877 | 9845 | AstNode *field_node = node->data.err_set_decl.decls.at(i); |
| 9878 | 9846 | AstNode *symbol_node = ast_field_to_symbol_node(field_node); |
| 9879 | 9847 | Buf *err_name = symbol_node->data.symbol_expr.symbol; |
| 9880 | | ErrorTableEntry *err = allocate<ErrorTableEntry>(1); |
| 9848 | ErrorTableEntry *err = heap::c_allocator.create<ErrorTableEntry>(); |
| 9881 | 9849 | err->decl_node = field_node; |
| 9882 | 9850 | buf_init_from_buf(&err->name, err_name); |
| 9883 | 9851 | |
| ... | ... | @@ -9902,7 +9870,7 @@ static IrInstSrc *ir_gen_err_set_decl(IrBuilderSrc *irb, Scope *parent_scope, As |
| 9902 | 9870 | } |
| 9903 | 9871 | errors[err->value] = err; |
| 9904 | 9872 | } |
| 9905 | | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 9873 | heap::c_allocator.deallocate(errors, errors_count); |
| 9906 | 9874 | return ir_build_const_type(irb, parent_scope, node, err_set_type); |
| 9907 | 9875 | } |
| 9908 | 9876 | |
| ... | ... | @@ -9910,7 +9878,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod |
| 9910 | 9878 | assert(node->type == NodeTypeFnProto); |
| 9911 | 9879 | |
| 9912 | 9880 | size_t param_count = node->data.fn_proto.params.length; |
| 9913 | | IrInstSrc **param_types = allocate<IrInstSrc*>(param_count); |
| 9881 | IrInstSrc **param_types = heap::c_allocator.allocate<IrInstSrc*>(param_count); |
| 9914 | 9882 | |
| 9915 | 9883 | bool is_var_args = false; |
| 9916 | 9884 | for (size_t i = 0; i < param_count; i += 1) { |
| ... | ... | @@ -10191,7 +10159,7 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope |
| 10191 | 10159 | } |
| 10192 | 10160 | |
| 10193 | 10161 | static ResultLoc *no_result_loc(void) { |
| 10194 | | ResultLocNone *result_loc_none = allocate<ResultLocNone>(1); |
| 10162 | ResultLocNone *result_loc_none = heap::c_allocator.create<ResultLocNone>(); |
| 10195 | 10163 | result_loc_none->base.id = ResultLocIdNone; |
| 10196 | 10164 | return &result_loc_none->base; |
| 10197 | 10165 | } |
| ... | ... | @@ -10280,7 +10248,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_e |
| 10280 | 10248 | if (!instr_is_unreachable(result)) { |
| 10281 | 10249 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->base.source_node, result, nullptr)); |
| 10282 | 10250 | // no need for save_err_ret_addr because this cannot return error |
| 10283 | | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 10251 | ResultLocReturn *result_loc_ret = heap::c_allocator.create<ResultLocReturn>(); |
| 10284 | 10252 | result_loc_ret->base.id = ResultLocIdReturn; |
| 10285 | 10253 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 10286 | 10254 | ir_mark_gen(ir_build_end_expr(irb, scope, node, result, &result_loc_ret->base)); |
| ... | ... | @@ -10372,7 +10340,7 @@ static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, Ast |
| 10372 | 10340 | if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val))) |
| 10373 | 10341 | return err; |
| 10374 | 10342 | ZigValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val); |
| 10375 | | copy_const_val(child_val, &tmp); |
| 10343 | copy_const_val(codegen, child_val, &tmp); |
| 10376 | 10344 | return ErrorNone; |
| 10377 | 10345 | } |
| 10378 | 10346 | |
| ... | ... | @@ -11522,7 +11490,7 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp |
| 11522 | 11490 | return set1; |
| 11523 | 11491 | } |
| 11524 | 11492 | size_t errors_count = ira->codegen->errors_by_index.length; |
| 11525 | | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(errors_count, "ErrorTableEntry *"); |
| 11493 | ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count); |
| 11526 | 11494 | populate_error_set_table(errors, set1); |
| 11527 | 11495 | ZigList<ErrorTableEntry *> intersection_list = {}; |
| 11528 | 11496 | |
| ... | ... | @@ -11543,7 +11511,7 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp |
| 11543 | 11511 | buf_appendf(&err_set_type->name, "%s%s", comma, buf_ptr(&existing_entry_with_docs->name)); |
| 11544 | 11512 | } |
| 11545 | 11513 | } |
| 11546 | | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 11514 | heap::c_allocator.deallocate(errors, errors_count); |
| 11547 | 11515 | |
| 11548 | 11516 | err_set_type->data.error_set.err_count = intersection_list.length; |
| 11549 | 11517 | err_set_type->data.error_set.errors = intersection_list.items; |
| ... | ... | @@ -11596,7 +11564,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11596 | 11564 | actual_ptr_type->data.pointer.ptr_len == PtrLenC; |
| 11597 | 11565 | if (!ok_null_term_ptrs) { |
| 11598 | 11566 | result.id = ConstCastResultIdPtrSentinel; |
| 11599 | | result.data.bad_ptr_sentinel = allocate_nonzero<ConstCastPtrSentinel>(1); |
| 11567 | result.data.bad_ptr_sentinel = heap::c_allocator.allocate_nonzero<ConstCastPtrSentinel>(1); |
| 11600 | 11568 | result.data.bad_ptr_sentinel->wanted_type = wanted_ptr_type; |
| 11601 | 11569 | result.data.bad_ptr_sentinel->actual_type = actual_ptr_type; |
| 11602 | 11570 | return result; |
| ... | ... | @@ -11612,7 +11580,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11612 | 11580 | (!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile); |
| 11613 | 11581 | if (!ok_cv_qualifiers) { |
| 11614 | 11582 | result.id = ConstCastResultIdCV; |
| 11615 | | result.data.bad_cv = allocate_nonzero<ConstCastBadCV>(1); |
| 11583 | result.data.bad_cv = heap::c_allocator.allocate_nonzero<ConstCastBadCV>(1); |
| 11616 | 11584 | result.data.bad_cv->wanted_type = wanted_ptr_type; |
| 11617 | 11585 | result.data.bad_cv->actual_type = actual_ptr_type; |
| 11618 | 11586 | return result; |
| ... | ... | @@ -11624,7 +11592,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11624 | 11592 | return child; |
| 11625 | 11593 | if (child.id != ConstCastResultIdOk) { |
| 11626 | 11594 | result.id = ConstCastResultIdPointerChild; |
| 11627 | | result.data.pointer_mismatch = allocate_nonzero<ConstCastPointerMismatch>(1); |
| 11595 | result.data.pointer_mismatch = heap::c_allocator.allocate_nonzero<ConstCastPointerMismatch>(1); |
| 11628 | 11596 | result.data.pointer_mismatch->child = child; |
| 11629 | 11597 | result.data.pointer_mismatch->wanted_child = wanted_ptr_type->data.pointer.child_type; |
| 11630 | 11598 | result.data.pointer_mismatch->actual_child = actual_ptr_type->data.pointer.child_type; |
| ... | ... | @@ -11635,7 +11603,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11635 | 11603 | (!wanted_allows_zero && !actual_allows_zero); |
| 11636 | 11604 | if (!ok_allows_zero) { |
| 11637 | 11605 | result.id = ConstCastResultIdBadAllowsZero; |
| 11638 | | result.data.bad_allows_zero = allocate_nonzero<ConstCastBadAllowsZero>(1); |
| 11606 | result.data.bad_allows_zero = heap::c_allocator.allocate_nonzero<ConstCastBadAllowsZero>(1); |
| 11639 | 11607 | result.data.bad_allows_zero->wanted_type = wanted_type; |
| 11640 | 11608 | result.data.bad_allows_zero->actual_type = actual_type; |
| 11641 | 11609 | return result; |
| ... | ... | @@ -11675,7 +11643,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11675 | 11643 | return child; |
| 11676 | 11644 | if (child.id != ConstCastResultIdOk) { |
| 11677 | 11645 | result.id = ConstCastResultIdArrayChild; |
| 11678 | | result.data.array_mismatch = allocate_nonzero<ConstCastArrayMismatch>(1); |
| 11646 | result.data.array_mismatch = heap::c_allocator.allocate_nonzero<ConstCastArrayMismatch>(1); |
| 11679 | 11647 | result.data.array_mismatch->child = child; |
| 11680 | 11648 | result.data.array_mismatch->wanted_child = wanted_type->data.array.child_type; |
| 11681 | 11649 | result.data.array_mismatch->actual_child = actual_type->data.array.child_type; |
| ... | ... | @@ -11686,7 +11654,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11686 | 11654 | const_values_equal(ira->codegen, wanted_type->data.array.sentinel, actual_type->data.array.sentinel)); |
| 11687 | 11655 | if (!ok_null_terminated) { |
| 11688 | 11656 | result.id = ConstCastResultIdSentinelArrays; |
| 11689 | | result.data.sentinel_arrays = allocate_nonzero<ConstCastBadNullTermArrays>(1); |
| 11657 | result.data.sentinel_arrays = heap::c_allocator.allocate_nonzero<ConstCastBadNullTermArrays>(1); |
| 11690 | 11658 | result.data.sentinel_arrays->child = child; |
| 11691 | 11659 | result.data.sentinel_arrays->wanted_type = wanted_type; |
| 11692 | 11660 | result.data.sentinel_arrays->actual_type = actual_type; |
| ... | ... | @@ -11714,7 +11682,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11714 | 11682 | actual_ptr_type->data.pointer.sentinel)); |
| 11715 | 11683 | if (!ok_sentinels) { |
| 11716 | 11684 | result.id = ConstCastResultIdPtrSentinel; |
| 11717 | | result.data.bad_ptr_sentinel = allocate_nonzero<ConstCastPtrSentinel>(1); |
| 11685 | result.data.bad_ptr_sentinel = heap::c_allocator.allocate_nonzero<ConstCastPtrSentinel>(1); |
| 11718 | 11686 | result.data.bad_ptr_sentinel->wanted_type = wanted_ptr_type; |
| 11719 | 11687 | result.data.bad_ptr_sentinel->actual_type = actual_ptr_type; |
| 11720 | 11688 | return result; |
| ... | ... | @@ -11731,7 +11699,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11731 | 11699 | return child; |
| 11732 | 11700 | if (child.id != ConstCastResultIdOk) { |
| 11733 | 11701 | result.id = ConstCastResultIdSliceChild; |
| 11734 | | result.data.slice_mismatch = allocate_nonzero<ConstCastSliceMismatch>(1); |
| 11702 | result.data.slice_mismatch = heap::c_allocator.allocate_nonzero<ConstCastSliceMismatch>(1); |
| 11735 | 11703 | result.data.slice_mismatch->child = child; |
| 11736 | 11704 | result.data.slice_mismatch->actual_child = actual_ptr_type->data.pointer.child_type; |
| 11737 | 11705 | result.data.slice_mismatch->wanted_child = wanted_ptr_type->data.pointer.child_type; |
| ... | ... | @@ -11748,7 +11716,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11748 | 11716 | return child; |
| 11749 | 11717 | if (child.id != ConstCastResultIdOk) { |
| 11750 | 11718 | result.id = ConstCastResultIdOptionalChild; |
| 11751 | | result.data.optional = allocate_nonzero<ConstCastOptionalMismatch>(1); |
| 11719 | result.data.optional = heap::c_allocator.allocate_nonzero<ConstCastOptionalMismatch>(1); |
| 11752 | 11720 | result.data.optional->child = child; |
| 11753 | 11721 | result.data.optional->wanted_child = wanted_type->data.maybe.child_type; |
| 11754 | 11722 | result.data.optional->actual_child = actual_type->data.maybe.child_type; |
| ... | ... | @@ -11764,7 +11732,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11764 | 11732 | return payload_child; |
| 11765 | 11733 | if (payload_child.id != ConstCastResultIdOk) { |
| 11766 | 11734 | result.id = ConstCastResultIdErrorUnionPayload; |
| 11767 | | result.data.error_union_payload = allocate_nonzero<ConstCastErrUnionPayloadMismatch>(1); |
| 11735 | result.data.error_union_payload = heap::c_allocator.allocate_nonzero<ConstCastErrUnionPayloadMismatch>(1); |
| 11768 | 11736 | result.data.error_union_payload->child = payload_child; |
| 11769 | 11737 | result.data.error_union_payload->wanted_payload = wanted_type->data.error_union.payload_type; |
| 11770 | 11738 | result.data.error_union_payload->actual_payload = actual_type->data.error_union.payload_type; |
| ... | ... | @@ -11776,7 +11744,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11776 | 11744 | return error_set_child; |
| 11777 | 11745 | if (error_set_child.id != ConstCastResultIdOk) { |
| 11778 | 11746 | result.id = ConstCastResultIdErrorUnionErrorSet; |
| 11779 | | result.data.error_union_error_set = allocate_nonzero<ConstCastErrUnionErrSetMismatch>(1); |
| 11747 | result.data.error_union_error_set = heap::c_allocator.allocate_nonzero<ConstCastErrUnionErrSetMismatch>(1); |
| 11780 | 11748 | result.data.error_union_error_set->child = error_set_child; |
| 11781 | 11749 | result.data.error_union_error_set->wanted_err_set = wanted_type->data.error_union.err_set_type; |
| 11782 | 11750 | result.data.error_union_error_set->actual_err_set = actual_type->data.error_union.err_set_type; |
| ... | ... | @@ -11810,7 +11778,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11810 | 11778 | } |
| 11811 | 11779 | |
| 11812 | 11780 | size_t errors_count = g->errors_by_index.length; |
| 11813 | | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(errors_count, "ErrorTableEntry *"); |
| 11781 | ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count); |
| 11814 | 11782 | for (uint32_t i = 0; i < container_set->data.error_set.err_count; i += 1) { |
| 11815 | 11783 | ErrorTableEntry *error_entry = container_set->data.error_set.errors[i]; |
| 11816 | 11784 | assert(errors[error_entry->value] == nullptr); |
| ... | ... | @@ -11822,12 +11790,12 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11822 | 11790 | if (error_entry == nullptr) { |
| 11823 | 11791 | if (result.id == ConstCastResultIdOk) { |
| 11824 | 11792 | result.id = ConstCastResultIdErrSet; |
| 11825 | | result.data.error_set_mismatch = allocate<ConstCastErrSetMismatch>(1); |
| 11793 | result.data.error_set_mismatch = heap::c_allocator.create<ConstCastErrSetMismatch>(); |
| 11826 | 11794 | } |
| 11827 | 11795 | result.data.error_set_mismatch->missing_errors.append(contained_error_entry); |
| 11828 | 11796 | } |
| 11829 | 11797 | } |
| 11830 | | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 11798 | heap::c_allocator.deallocate(errors, errors_count); |
| 11831 | 11799 | return result; |
| 11832 | 11800 | } |
| 11833 | 11801 | |
| ... | ... | @@ -11856,7 +11824,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11856 | 11824 | return child; |
| 11857 | 11825 | if (child.id != ConstCastResultIdOk) { |
| 11858 | 11826 | result.id = ConstCastResultIdFnReturnType; |
| 11859 | | result.data.return_type = allocate_nonzero<ConstCastOnly>(1); |
| 11827 | result.data.return_type = heap::c_allocator.allocate_nonzero<ConstCastOnly>(1); |
| 11860 | 11828 | *result.data.return_type = child; |
| 11861 | 11829 | return result; |
| 11862 | 11830 | } |
| ... | ... | @@ -11885,7 +11853,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11885 | 11853 | result.data.fn_arg.arg_index = i; |
| 11886 | 11854 | result.data.fn_arg.actual_param_type = actual_param_info->type; |
| 11887 | 11855 | result.data.fn_arg.expected_param_type = expected_param_info->type; |
| 11888 | | result.data.fn_arg.child = allocate_nonzero<ConstCastOnly>(1); |
| 11856 | result.data.fn_arg.child = heap::c_allocator.allocate_nonzero<ConstCastOnly>(1); |
| 11889 | 11857 | *result.data.fn_arg.child = arg_child; |
| 11890 | 11858 | return result; |
| 11891 | 11859 | } |
| ... | ... | @@ -11906,14 +11874,14 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11906 | 11874 | |
| 11907 | 11875 | if (wanted_type->id == ZigTypeIdInt && actual_type->id == ZigTypeIdInt) { |
| 11908 | 11876 | result.id = ConstCastResultIdIntShorten; |
| 11909 | | result.data.int_shorten = allocate_nonzero<ConstCastIntShorten>(1); |
| 11877 | result.data.int_shorten = heap::c_allocator.allocate_nonzero<ConstCastIntShorten>(1); |
| 11910 | 11878 | result.data.int_shorten->wanted_type = wanted_type; |
| 11911 | 11879 | result.data.int_shorten->actual_type = actual_type; |
| 11912 | 11880 | return result; |
| 11913 | 11881 | } |
| 11914 | 11882 | |
| 11915 | 11883 | result.id = ConstCastResultIdType; |
| 11916 | | result.data.type_mismatch = allocate_nonzero<ConstCastTypeMismatch>(1); |
| 11884 | result.data.type_mismatch = heap::c_allocator.allocate_nonzero<ConstCastTypeMismatch>(1); |
| 11917 | 11885 | result.data.type_mismatch->wanted_type = wanted_type; |
| 11918 | 11886 | result.data.type_mismatch->actual_type = actual_type; |
| 11919 | 11887 | return result; |
| ... | ... | @@ -11922,7 +11890,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 11922 | 11890 | static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t *errors_count) { |
| 11923 | 11891 | size_t old_errors_count = *errors_count; |
| 11924 | 11892 | *errors_count = g->errors_by_index.length; |
| 11925 | | *errors = reallocate(*errors, old_errors_count, *errors_count); |
| 11893 | *errors = heap::c_allocator.reallocate(*errors, old_errors_count, *errors_count); |
| 11926 | 11894 | } |
| 11927 | 11895 | |
| 11928 | 11896 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, |
| ... | ... | @@ -12592,7 +12560,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 12592 | 12560 | return ira->codegen->builtin_types.entry_invalid; |
| 12593 | 12561 | } |
| 12594 | 12562 | |
| 12595 | | free(errors); |
| 12563 | heap::c_allocator.deallocate(errors, errors_count); |
| 12596 | 12564 | |
| 12597 | 12565 | if (convert_to_const_slice) { |
| 12598 | 12566 | if (prev_inst->value->type->id == ZigTypeIdPointer) { |
| ... | ... | @@ -12671,7 +12639,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInst *source_instr, |
| 12671 | 12639 | case CastOpBitCast: |
| 12672 | 12640 | zig_panic("TODO"); |
| 12673 | 12641 | case CastOpNoop: { |
| 12674 | | copy_const_val(const_val, other_val); |
| 12642 | copy_const_val(ira->codegen, const_val, other_val); |
| 12675 | 12643 | const_val->type = new_type; |
| 12676 | 12644 | break; |
| 12677 | 12645 | } |
| ... | ... | @@ -13200,7 +13168,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 13200 | 13168 | if (type_is_invalid(return_ptr->type)) |
| 13201 | 13169 | return ErrorSemanticAnalyzeFail; |
| 13202 | 13170 | |
| 13203 | | IrExecutableSrc *ir_executable = allocate<IrExecutableSrc>(1, "IrExecutableSrc"); |
| 13171 | IrExecutableSrc *ir_executable = heap::c_allocator.create<IrExecutableSrc>(); |
| 13204 | 13172 | ir_executable->source_node = source_node; |
| 13205 | 13173 | ir_executable->parent_exec = parent_exec; |
| 13206 | 13174 | ir_executable->name = exec_name; |
| ... | ... | @@ -13224,7 +13192,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 13224 | 13192 | ir_print_src(codegen, stderr, ir_executable, 2); |
| 13225 | 13193 | fprintf(stderr, "}\n"); |
| 13226 | 13194 | } |
| 13227 | | IrExecutableGen *analyzed_executable = allocate<IrExecutableGen>(1, "IrExecutableGen"); |
| 13195 | IrExecutableGen *analyzed_executable = heap::c_allocator.create<IrExecutableGen>(); |
| 13228 | 13196 | analyzed_executable->source_node = source_node; |
| 13229 | 13197 | analyzed_executable->parent_exec = parent_exec; |
| 13230 | 13198 | analyzed_executable->source_exec = ir_executable; |
| ... | ... | @@ -13425,7 +13393,7 @@ static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, IrInst* source_instr, |
| 13425 | 13393 | source_instr->scope, source_instr->source_node); |
| 13426 | 13394 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 13427 | 13395 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { |
| 13428 | | copy_const_val(const_instruction->base.value, val); |
| 13396 | copy_const_val(ira->codegen, const_instruction->base.value, val); |
| 13429 | 13397 | } else { |
| 13430 | 13398 | const_instruction->base.value->data.x_optional = val; |
| 13431 | 13399 | } |
| ... | ... | @@ -13466,7 +13434,7 @@ static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInst* source_ins |
| 13466 | 13434 | if (val == nullptr) |
| 13467 | 13435 | return ira->codegen->invalid_inst_gen; |
| 13468 | 13436 | |
| 13469 | | ZigValue *err_set_val = create_const_vals(1); |
| 13437 | ZigValue *err_set_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 13470 | 13438 | err_set_val->type = err_set_type; |
| 13471 | 13439 | err_set_val->special = ConstValSpecialStatic; |
| 13472 | 13440 | err_set_val->data.x_err_set = nullptr; |
| ... | ... | @@ -13578,7 +13546,7 @@ static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInst* source_instr, |
| 13578 | 13546 | if (!val) |
| 13579 | 13547 | return ira->codegen->invalid_inst_gen; |
| 13580 | 13548 | |
| 13581 | | ZigValue *err_set_val = create_const_vals(1); |
| 13549 | ZigValue *err_set_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 13582 | 13550 | err_set_val->special = ConstValSpecialStatic; |
| 13583 | 13551 | err_set_val->type = wanted_type->data.error_union.err_set_type; |
| 13584 | 13552 | err_set_val->data.x_err_set = val->data.x_err_set; |
| ... | ... | @@ -13843,7 +13811,7 @@ static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, IrInst* source_instr, |
| 13843 | 13811 | result->value->special = ConstValSpecialStatic; |
| 13844 | 13812 | result->value->type = wanted_type; |
| 13845 | 13813 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); |
| 13846 | | result->value->data.x_union.payload = create_const_vals(1); |
| 13814 | result->value->data.x_union.payload = ira->codegen->pass1_arena->create<ZigValue>(); |
| 13847 | 13815 | result->value->data.x_union.payload->special = ConstValSpecialStatic; |
| 13848 | 13816 | result->value->data.x_union.payload->type = field_type; |
| 13849 | 13817 | return result; |
| ... | ... | @@ -14148,7 +14116,7 @@ static IrInstGen *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInst* source_instr, |
| 14148 | 14116 | if (pointee == nullptr) |
| 14149 | 14117 | return ira->codegen->invalid_inst_gen; |
| 14150 | 14118 | if (pointee->special != ConstValSpecialRuntime) { |
| 14151 | | ZigValue *array_val = create_const_vals(1); |
| 14119 | ZigValue *array_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 14152 | 14120 | array_val->special = ConstValSpecialStatic; |
| 14153 | 14121 | array_val->type = array_type; |
| 14154 | 14122 | array_val->data.x_array.special = ConstArraySpecialNone; |
| ... | ... | @@ -14362,7 +14330,7 @@ static IrInstGen *ir_analyze_array_to_vector(IrAnalyze *ira, IrInst* source_inst |
| 14362 | 14330 | if (instr_is_comptime(array)) { |
| 14363 | 14331 | // arrays and vectors have the same ZigValue representation |
| 14364 | 14332 | IrInstGen *result = ir_const(ira, source_instr, vector_type); |
| 14365 | | copy_const_val(result->value, array->value); |
| 14333 | copy_const_val(ira->codegen, result->value, array->value); |
| 14366 | 14334 | result->value->type = vector_type; |
| 14367 | 14335 | return result; |
| 14368 | 14336 | } |
| ... | ... | @@ -14375,7 +14343,7 @@ static IrInstGen *ir_analyze_vector_to_array(IrAnalyze *ira, IrInst* source_inst |
| 14375 | 14343 | if (instr_is_comptime(vector)) { |
| 14376 | 14344 | // arrays and vectors have the same ZigValue representation |
| 14377 | 14345 | IrInstGen *result = ir_const(ira, source_instr, array_type); |
| 14378 | | copy_const_val(result->value, vector->value); |
| 14346 | copy_const_val(ira->codegen, result->value, vector->value); |
| 14379 | 14347 | result->value->type = array_type; |
| 14380 | 14348 | return result; |
| 14381 | 14349 | } |
| ... | ... | @@ -14675,7 +14643,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 14675 | 14643 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 14676 | 14644 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 14677 | 14645 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 14678 | | copy_const_val(result->value, value->value); |
| 14646 | copy_const_val(ira->codegen, result->value, value->value); |
| 14679 | 14647 | result->value->type = wanted_type; |
| 14680 | 14648 | } else { |
| 14681 | 14649 | float_init_bigint(&result->value->data.x_bigint, value->value); |
| ... | ... | @@ -16508,7 +16476,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 16508 | 16476 | IrInstGen *result = ir_const(ira, &bin_op_instruction->base.base, |
| 16509 | 16477 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); |
| 16510 | 16478 | result->value->data.x_array.data.s_none.elements = |
| 16511 | | create_const_vals(resolved_type->data.vector.len); |
| 16479 | ira->codegen->pass1_arena->allocate<ZigValue>(resolved_type->data.vector.len); |
| 16512 | 16480 | |
| 16513 | 16481 | expand_undef_array(ira->codegen, result->value); |
| 16514 | 16482 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| ... | ... | @@ -16516,7 +16484,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 16516 | 16484 | &op1_val->data.x_array.data.s_none.elements[i], |
| 16517 | 16485 | &op2_val->data.x_array.data.s_none.elements[i], |
| 16518 | 16486 | bin_op_instruction, op_id, one_possible_value); |
| 16519 | | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], cur_res->value); |
| 16487 | copy_const_val(ira->codegen, &result->value->data.x_array.data.s_none.elements[i], cur_res->value); |
| 16520 | 16488 | } |
| 16521 | 16489 | return result; |
| 16522 | 16490 | } |
| ... | ... | @@ -17416,7 +17384,7 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 17416 | 17384 | ZigValue *out_array_val; |
| 17417 | 17385 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); |
| 17418 | 17386 | if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { |
| 17419 | | out_array_val = create_const_vals(1); |
| 17387 | out_array_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 17420 | 17388 | out_array_val->special = ConstValSpecialStatic; |
| 17421 | 17389 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| 17422 | 17390 | |
| ... | ... | @@ -17428,11 +17396,11 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 17428 | 17396 | true, false, PtrLenUnknown, 0, 0, 0, false, |
| 17429 | 17397 | VECTOR_INDEX_NONE, nullptr, sentinel); |
| 17430 | 17398 | result->value->type = get_slice_type(ira->codegen, ptr_type); |
| 17431 | | out_array_val = create_const_vals(1); |
| 17399 | out_array_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 17432 | 17400 | out_array_val->special = ConstValSpecialStatic; |
| 17433 | 17401 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| 17434 | 17402 | |
| 17435 | | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 17403 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 17436 | 17404 | |
| 17437 | 17405 | out_val->data.x_struct.fields[slice_ptr_index]->type = ptr_type; |
| 17438 | 17406 | out_val->data.x_struct.fields[slice_ptr_index]->special = ConstValSpecialStatic; |
| ... | ... | @@ -17449,7 +17417,7 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 17449 | 17417 | } else { |
| 17450 | 17418 | result->value->type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, |
| 17451 | 17419 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); |
| 17452 | | out_array_val = create_const_vals(1); |
| 17420 | out_array_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 17453 | 17421 | out_array_val->special = ConstValSpecialStatic; |
| 17454 | 17422 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| 17455 | 17423 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| ... | ... | @@ -17465,7 +17433,7 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 17465 | 17433 | } |
| 17466 | 17434 | |
| 17467 | 17435 | uint64_t full_len = new_len + ((sentinel != nullptr) ? 1 : 0); |
| 17468 | | out_array_val->data.x_array.data.s_none.elements = create_const_vals(full_len); |
| 17436 | out_array_val->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(full_len); |
| 17469 | 17437 | // TODO handle the buf case here for an optimization |
| 17470 | 17438 | expand_undef_array(ira->codegen, op1_array_val); |
| 17471 | 17439 | expand_undef_array(ira->codegen, op2_array_val); |
| ... | ... | @@ -17473,21 +17441,21 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 17473 | 17441 | size_t next_index = 0; |
| 17474 | 17442 | for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) { |
| 17475 | 17443 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 17476 | | copy_const_val(elem_dest_val, &op1_array_val->data.x_array.data.s_none.elements[i]); |
| 17444 | copy_const_val(ira->codegen, elem_dest_val, &op1_array_val->data.x_array.data.s_none.elements[i]); |
| 17477 | 17445 | elem_dest_val->parent.id = ConstParentIdArray; |
| 17478 | 17446 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 17479 | 17447 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 17480 | 17448 | } |
| 17481 | 17449 | for (size_t i = op2_array_index; i < op2_array_end; i += 1, next_index += 1) { |
| 17482 | 17450 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 17483 | | copy_const_val(elem_dest_val, &op2_array_val->data.x_array.data.s_none.elements[i]); |
| 17451 | copy_const_val(ira->codegen, elem_dest_val, &op2_array_val->data.x_array.data.s_none.elements[i]); |
| 17484 | 17452 | elem_dest_val->parent.id = ConstParentIdArray; |
| 17485 | 17453 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 17486 | 17454 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 17487 | 17455 | } |
| 17488 | 17456 | if (next_index < full_len) { |
| 17489 | 17457 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 17490 | | copy_const_val(elem_dest_val, sentinel); |
| 17458 | copy_const_val(ira->codegen, elem_dest_val, sentinel); |
| 17491 | 17459 | elem_dest_val->parent.id = ConstParentIdArray; |
| 17492 | 17460 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 17493 | 17461 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| ... | ... | @@ -17566,13 +17534,13 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct |
| 17566 | 17534 | // TODO optimize the buf case |
| 17567 | 17535 | expand_undef_array(ira->codegen, array_val); |
| 17568 | 17536 | size_t extra_null_term = (array_type->data.array.sentinel != nullptr) ? 1 : 0; |
| 17569 | | out_val->data.x_array.data.s_none.elements = create_const_vals(new_array_len + extra_null_term); |
| 17537 | out_val->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(new_array_len + extra_null_term); |
| 17570 | 17538 | |
| 17571 | 17539 | uint64_t i = 0; |
| 17572 | 17540 | for (uint64_t x = 0; x < mult_amt; x += 1) { |
| 17573 | 17541 | for (uint64_t y = 0; y < old_array_len; y += 1) { |
| 17574 | 17542 | ZigValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 17575 | | copy_const_val(elem_dest_val, &array_val->data.x_array.data.s_none.elements[y]); |
| 17543 | copy_const_val(ira->codegen, elem_dest_val, &array_val->data.x_array.data.s_none.elements[y]); |
| 17576 | 17544 | elem_dest_val->parent.id = ConstParentIdArray; |
| 17577 | 17545 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| 17578 | 17546 | elem_dest_val->parent.data.p_array.elem_index = i; |
| ... | ... | @@ -17583,7 +17551,7 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct |
| 17583 | 17551 | |
| 17584 | 17552 | if (array_type->data.array.sentinel != nullptr) { |
| 17585 | 17553 | ZigValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 17586 | | copy_const_val(elem_dest_val, array_type->data.array.sentinel); |
| 17554 | copy_const_val(ira->codegen, elem_dest_val, array_type->data.array.sentinel); |
| 17587 | 17555 | elem_dest_val->parent.id = ConstParentIdArray; |
| 17588 | 17556 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| 17589 | 17557 | elem_dest_val->parent.data.p_array.elem_index = i; |
| ... | ... | @@ -17624,14 +17592,14 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 17624 | 17592 | } |
| 17625 | 17593 | |
| 17626 | 17594 | size_t errors_count = ira->codegen->errors_by_index.length; |
| 17627 | | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(errors_count, "ErrorTableEntry *"); |
| 17595 | ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count); |
| 17628 | 17596 | for (uint32_t i = 0, count = op1_type->data.error_set.err_count; i < count; i += 1) { |
| 17629 | 17597 | ErrorTableEntry *error_entry = op1_type->data.error_set.errors[i]; |
| 17630 | 17598 | assert(errors[error_entry->value] == nullptr); |
| 17631 | 17599 | errors[error_entry->value] = error_entry; |
| 17632 | 17600 | } |
| 17633 | 17601 | ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type, instruction->type_name); |
| 17634 | | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 17602 | heap::c_allocator.deallocate(errors, errors_count); |
| 17635 | 17603 | |
| 17636 | 17604 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 17637 | 17605 | } |
| ... | ... | @@ -17730,8 +17698,8 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV |
| 17730 | 17698 | if (var->gen_is_const) { |
| 17731 | 17699 | var->const_value = init_val; |
| 17732 | 17700 | } else { |
| 17733 | | var->const_value = create_const_vals(1); |
| 17734 | | copy_const_val(var->const_value, init_val); |
| 17701 | var->const_value = ira->codegen->pass1_arena->create<ZigValue>(); |
| 17702 | copy_const_val(ira->codegen, var->const_value, init_val); |
| 17735 | 17703 | } |
| 17736 | 17704 | } |
| 17737 | 17705 | } |
| ... | ... | @@ -17905,7 +17873,7 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport |
| 17905 | 17873 | // It's not clear how all the different types are supposed to be handled. |
| 17906 | 17874 | // Need comprehensive tests for exporting one thing in one file and declaring an extern var |
| 17907 | 17875 | // in another file. |
| 17908 | | TldFn *tld_fn = allocate<TldFn>(1); |
| 17876 | TldFn *tld_fn = heap::c_allocator.create<TldFn>(); |
| 17909 | 17877 | tld_fn->base.id = TldIdFn; |
| 17910 | 17878 | tld_fn->base.source_node = instruction->base.base.source_node; |
| 17911 | 17879 | |
| ... | ... | @@ -18134,7 +18102,7 @@ static IrInstGen *ir_analyze_instruction_error_union(IrAnalyze *ira, IrInstSrcEr |
| 18134 | 18102 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 18135 | 18103 | result->value->special = ConstValSpecialLazy; |
| 18136 | 18104 | |
| 18137 | | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1, "LazyValueErrUnionType"); |
| 18105 | LazyValueErrUnionType *lazy_err_union_type = heap::c_allocator.create<LazyValueErrUnionType>(); |
| 18138 | 18106 | lazy_err_union_type->ira = ira; ira_ref(ira); |
| 18139 | 18107 | result->value->data.x_lazy = &lazy_err_union_type->base; |
| 18140 | 18108 | lazy_err_union_type->base.id = LazyValueIdErrUnionType; |
| ... | ... | @@ -18155,7 +18123,7 @@ static IrInstGen *ir_analyze_alloca(IrAnalyze *ira, IrInst *source_inst, ZigType |
| 18155 | 18123 | { |
| 18156 | 18124 | Error err; |
| 18157 | 18125 | |
| 18158 | | ZigValue *pointee = create_const_vals(1); |
| 18126 | ZigValue *pointee = ira->codegen->pass1_arena->create<ZigValue>(); |
| 18159 | 18127 | pointee->special = ConstValSpecialUndef; |
| 18160 | 18128 | pointee->llvm_align = align; |
| 18161 | 18129 | |
| ... | ... | @@ -18236,8 +18204,8 @@ static bool type_can_bit_cast(ZigType *t) { |
| 18236 | 18204 | } |
| 18237 | 18205 | } |
| 18238 | 18206 | |
| 18239 | | static void set_up_result_loc_for_inferred_comptime(IrInstGen *ptr) { |
| 18240 | | ZigValue *undef_child = create_const_vals(1); |
| 18207 | static void set_up_result_loc_for_inferred_comptime(IrAnalyze *ira, IrInstGen *ptr) { |
| 18208 | ZigValue *undef_child = ira->codegen->pass1_arena->create<ZigValue>(); |
| 18241 | 18209 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 18242 | 18210 | undef_child->special = ConstValSpecialUndef; |
| 18243 | 18211 | ptr->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -18283,7 +18251,7 @@ static IrInstGen *ir_resolve_no_result_loc(IrAnalyze *ira, IrInst *suspend_sourc |
| 18283 | 18251 | IrInstGenAlloca *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); |
| 18284 | 18252 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 18285 | 18253 | PtrLenSingle, 0, 0, 0, false); |
| 18286 | | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); |
| 18254 | set_up_result_loc_for_inferred_comptime(ira, &alloca_gen->base); |
| 18287 | 18255 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 18288 | 18256 | if (fn_entry != nullptr && get_scope_typeof(suspend_source_instr->scope) == nullptr) { |
| 18289 | 18257 | fn_entry->alloca_gen_list.append(alloca_gen); |
| ... | ... | @@ -18347,7 +18315,6 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i |
| 18347 | 18315 | ZigVar *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope, |
| 18348 | 18316 | buf_create_from_str(var->name), var->src_is_const, var->gen_is_const, |
| 18349 | 18317 | var->shadowable, var->is_comptime, true); |
| 18350 | | new_var->owner_exec = var->owner_exec; |
| 18351 | 18318 | new_var->align_bytes = var->align_bytes; |
| 18352 | 18319 | |
| 18353 | 18320 | var->next_var = new_var; |
| ... | ... | @@ -18686,15 +18653,15 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18686 | 18653 | if (!val) |
| 18687 | 18654 | return ira->codegen->invalid_inst_gen; |
| 18688 | 18655 | field->is_comptime = true; |
| 18689 | | field->init_val = create_const_vals(1); |
| 18690 | | copy_const_val(field->init_val, val); |
| 18656 | field->init_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 18657 | copy_const_val(ira->codegen, field->init_val, val); |
| 18691 | 18658 | return result_loc; |
| 18692 | 18659 | } |
| 18693 | 18660 | |
| 18694 | 18661 | ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false); |
| 18695 | 18662 | if (instr_is_comptime(result_loc)) { |
| 18696 | 18663 | casted_ptr = ir_const(ira, suspend_source_instr, struct_ptr_type); |
| 18697 | | copy_const_val(casted_ptr->value, result_loc->value); |
| 18664 | copy_const_val(ira->codegen, casted_ptr->value, result_loc->value); |
| 18698 | 18665 | casted_ptr->value->type = struct_ptr_type; |
| 18699 | 18666 | } else { |
| 18700 | 18667 | casted_ptr = result_loc; |
| ... | ... | @@ -18707,8 +18674,8 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18707 | 18674 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 18708 | 18675 | suspend_source_instr->source_node); |
| 18709 | 18676 | struct_val->special = ConstValSpecialStatic; |
| 18710 | | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, |
| 18711 | | old_field_count, new_field_count); |
| 18677 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(ira->codegen, |
| 18678 | struct_val->data.x_struct.fields, old_field_count, new_field_count); |
| 18712 | 18679 | |
| 18713 | 18680 | ZigValue *field_val = struct_val->data.x_struct.fields[old_field_count]; |
| 18714 | 18681 | field_val->special = ConstValSpecialUndef; |
| ... | ... | @@ -19008,10 +18975,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 19008 | 18975 | if (!arg_val) |
| 19009 | 18976 | return false; |
| 19010 | 18977 | } else { |
| 19011 | | arg_val = create_const_runtime(casted_arg->value->type); |
| 18978 | arg_val = create_const_runtime(ira->codegen, casted_arg->value->type); |
| 19012 | 18979 | } |
| 19013 | 18980 | if (arg_part_of_generic_id) { |
| 19014 | | copy_const_val(&generic_id->params[generic_id->param_count], arg_val); |
| 18981 | copy_const_val(ira->codegen, &generic_id->params[generic_id->param_count], arg_val); |
| 19015 | 18982 | generic_id->param_count += 1; |
| 19016 | 18983 | } |
| 19017 | 18984 | |
| ... | ... | @@ -19160,7 +19127,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 19160 | 19127 | if (dest_val == nullptr) |
| 19161 | 19128 | return ira->codegen->invalid_inst_gen; |
| 19162 | 19129 | if (dest_val->special != ConstValSpecialRuntime) { |
| 19163 | | copy_const_val(dest_val, value->value); |
| 19130 | copy_const_val(ira->codegen, dest_val, value->value); |
| 19164 | 19131 | |
| 19165 | 19132 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar && |
| 19166 | 19133 | !ira->new_irb.current_basic_block->must_be_comptime_source_instr) |
| ... | ... | @@ -19395,8 +19362,6 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19395 | 19362 | { |
| 19396 | 19363 | return ira->codegen->invalid_inst_gen; |
| 19397 | 19364 | } |
| 19398 | | destroy(result_ptr, "ZigValue"); |
| 19399 | | result_ptr = nullptr; |
| 19400 | 19365 | |
| 19401 | 19366 | if (inferred_err_set_type != nullptr) { |
| 19402 | 19367 | inferred_err_set_type->data.error_set.incomplete = false; |
| ... | ... | @@ -19404,7 +19369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19404 | 19369 | ErrorTableEntry *err = result->data.x_err_union.error_set->data.x_err_set; |
| 19405 | 19370 | if (err != nullptr) { |
| 19406 | 19371 | inferred_err_set_type->data.error_set.err_count = 1; |
| 19407 | | inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1); |
| 19372 | inferred_err_set_type->data.error_set.errors = heap::c_allocator.create<ErrorTableEntry *>(); |
| 19408 | 19373 | inferred_err_set_type->data.error_set.errors[0] = err; |
| 19409 | 19374 | } |
| 19410 | 19375 | ZigType *fn_inferred_err_set_type = result->type->data.error_union.err_set_type; |
| ... | ... | @@ -19438,12 +19403,12 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19438 | 19403 | |
| 19439 | 19404 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; |
| 19440 | 19405 | |
| 19441 | | IrInstGen **casted_args = allocate<IrInstGen *>(new_fn_arg_count); |
| 19406 | IrInstGen **casted_args = heap::c_allocator.allocate<IrInstGen *>(new_fn_arg_count); |
| 19442 | 19407 | |
| 19443 | 19408 | // Fork a scope of the function with known values for the parameters. |
| 19444 | 19409 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; |
| 19445 | 19410 | ZigFn *impl_fn = create_fn(ira->codegen, fn_proto_node); |
| 19446 | | impl_fn->param_source_nodes = allocate<AstNode *>(new_fn_arg_count); |
| 19411 | impl_fn->param_source_nodes = heap::c_allocator.allocate<AstNode *>(new_fn_arg_count); |
| 19447 | 19412 | buf_init_from_buf(&impl_fn->symbol_name, &fn_entry->symbol_name); |
| 19448 | 19413 | impl_fn->fndef_scope = create_fndef_scope(ira->codegen, impl_fn->body_node, parent_scope, impl_fn); |
| 19449 | 19414 | impl_fn->child_scope = &impl_fn->fndef_scope->base; |
| ... | ... | @@ -19454,10 +19419,10 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19454 | 19419 | |
| 19455 | 19420 | // TODO maybe GenericFnTypeId can be replaced with using the child_scope directly |
| 19456 | 19421 | // as the key in generic_table |
| 19457 | | GenericFnTypeId *generic_id = allocate<GenericFnTypeId>(1); |
| 19422 | GenericFnTypeId *generic_id = heap::c_allocator.create<GenericFnTypeId>(); |
| 19458 | 19423 | generic_id->fn_entry = fn_entry; |
| 19459 | 19424 | generic_id->param_count = 0; |
| 19460 | | generic_id->params = create_const_vals(new_fn_arg_count); |
| 19425 | generic_id->params = ira->codegen->pass1_arena->allocate<ZigValue>(new_fn_arg_count); |
| 19461 | 19426 | size_t next_proto_i = 0; |
| 19462 | 19427 | |
| 19463 | 19428 | if (first_arg_ptr) { |
| ... | ... | @@ -19517,7 +19482,6 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19517 | 19482 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, |
| 19518 | 19483 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 19519 | 19484 | const_instruction->base.value = align_result; |
| 19520 | | destroy(result_ptr, "ZigValue"); |
| 19521 | 19485 | |
| 19522 | 19486 | uint32_t align_bytes = 0; |
| 19523 | 19487 | ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes); |
| ... | ... | @@ -19650,7 +19614,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19650 | 19614 | } |
| 19651 | 19615 | |
| 19652 | 19616 | |
| 19653 | | IrInstGen **casted_args = allocate<IrInstGen *>(call_param_count); |
| 19617 | IrInstGen **casted_args = heap::c_allocator.allocate<IrInstGen *>(call_param_count); |
| 19654 | 19618 | size_t next_arg_index = 0; |
| 19655 | 19619 | if (first_arg_ptr) { |
| 19656 | 19620 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| ... | ... | @@ -19782,7 +19746,7 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins |
| 19782 | 19746 | return ira->codegen->invalid_inst_gen; |
| 19783 | 19747 | new_stack_src = &call_instruction->new_stack->base; |
| 19784 | 19748 | } |
| 19785 | | IrInstGen **args_ptr = allocate<IrInstGen *>(call_instruction->arg_count, "IrInstGen *"); |
| 19749 | IrInstGen **args_ptr = heap::c_allocator.allocate<IrInstGen *>(call_instruction->arg_count); |
| 19786 | 19750 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 19787 | 19751 | args_ptr[i] = call_instruction->args[i]->child; |
| 19788 | 19752 | if (type_is_invalid(args_ptr[i]->value->type)) |
| ... | ... | @@ -19798,7 +19762,7 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins |
| 19798 | 19762 | first_arg_ptr, first_arg_ptr_src, modifier, new_stack, new_stack_src, |
| 19799 | 19763 | call_instruction->is_async_call_builtin, args_ptr, call_instruction->arg_count, ret_ptr, |
| 19800 | 19764 | call_instruction->result_loc); |
| 19801 | | deallocate(args_ptr, call_instruction->arg_count, "IrInstGen *"); |
| 19765 | heap::c_allocator.deallocate(args_ptr, call_instruction->arg_count); |
| 19802 | 19766 | return result; |
| 19803 | 19767 | } |
| 19804 | 19768 | |
| ... | ... | @@ -19918,7 +19882,7 @@ static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCal |
| 19918 | 19882 | |
| 19919 | 19883 | if (is_tuple(args_type)) { |
| 19920 | 19884 | args_len = args_type->data.structure.src_field_count; |
| 19921 | | args_ptr = allocate<IrInstGen *>(args_len, "IrInstGen *"); |
| 19885 | args_ptr = heap::c_allocator.allocate<IrInstGen *>(args_len); |
| 19922 | 19886 | for (size_t i = 0; i < args_len; i += 1) { |
| 19923 | 19887 | TypeStructField *arg_field = args_type->data.structure.fields[i]; |
| 19924 | 19888 | args_ptr[i] = ir_analyze_struct_value_field_value(ira, &instruction->base.base, args, arg_field); |
| ... | ... | @@ -19931,12 +19895,12 @@ static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCal |
| 19931 | 19895 | } |
| 19932 | 19896 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 19933 | 19897 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); |
| 19934 | | deallocate(args_ptr, args_len, "IrInstGen *"); |
| 19898 | heap::c_allocator.deallocate(args_ptr, args_len); |
| 19935 | 19899 | return result; |
| 19936 | 19900 | } |
| 19937 | 19901 | |
| 19938 | 19902 | static IrInstGen *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstSrcCallArgs *instruction) { |
| 19939 | | IrInstGen **args_ptr = allocate<IrInstGen *>(instruction->args_len, "IrInstGen *"); |
| 19903 | IrInstGen **args_ptr = heap::c_allocator.allocate<IrInstGen *>(instruction->args_len); |
| 19940 | 19904 | for (size_t i = 0; i < instruction->args_len; i += 1) { |
| 19941 | 19905 | args_ptr[i] = instruction->args_ptr[i]->child; |
| 19942 | 19906 | if (type_is_invalid(args_ptr[i]->value->type)) |
| ... | ... | @@ -19945,7 +19909,7 @@ static IrInstGen *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstSrcCall |
| 19945 | 19909 | |
| 19946 | 19910 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 19947 | 19911 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); |
| 19948 | | deallocate(args_ptr, instruction->args_len, "IrInstGen *"); |
| 19912 | heap::c_allocator.deallocate(args_ptr, instruction->args_len); |
| 19949 | 19913 | return result; |
| 19950 | 19914 | } |
| 19951 | 19915 | |
| ... | ... | @@ -20020,7 +19984,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 20020 | 19984 | |
| 20021 | 19985 | if (dst_size <= src_size) { |
| 20022 | 19986 | if (src_size == dst_size && types_have_same_zig_comptime_repr(codegen, out_val->type, pointee->type)) { |
| 20023 | | copy_const_val(out_val, pointee); |
| 19987 | copy_const_val(codegen, out_val, pointee); |
| 20024 | 19988 | return ErrorNone; |
| 20025 | 19989 | } |
| 20026 | 19990 | Buf buf = BUF_INIT; |
| ... | ... | @@ -20088,7 +20052,7 @@ static IrInstGen *ir_analyze_optional_type(IrAnalyze *ira, IrInstSrcUnOp *instru |
| 20088 | 20052 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 20089 | 20053 | result->value->special = ConstValSpecialLazy; |
| 20090 | 20054 | |
| 20091 | | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1, "LazyValueOptType"); |
| 20055 | LazyValueOptType *lazy_opt_type = heap::c_allocator.create<LazyValueOptType>(); |
| 20092 | 20056 | lazy_opt_type->ira = ira; ira_ref(ira); |
| 20093 | 20057 | result->value->data.x_lazy = &lazy_opt_type->base; |
| 20094 | 20058 | lazy_opt_type->base.id = LazyValueIdOptType; |
| ... | ... | @@ -20372,7 +20336,7 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 20372 | 20336 | |
| 20373 | 20337 | if (value->value->special != ConstValSpecialRuntime) { |
| 20374 | 20338 | IrInstGen *result = ir_const(ira, &phi_instruction->base.base, nullptr); |
| 20375 | | copy_const_val(result->value, value->value); |
| 20339 | copy_const_val(ira->codegen, result->value, value->value); |
| 20376 | 20340 | return result; |
| 20377 | 20341 | } else { |
| 20378 | 20342 | return value; |
| ... | ... | @@ -20386,7 +20350,7 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 20386 | 20350 | peer_parent->peers.length >= 2) |
| 20387 | 20351 | { |
| 20388 | 20352 | if (peer_parent->resolved_type == nullptr) { |
| 20389 | | IrInstGen **instructions = allocate<IrInstGen *>(peer_parent->peers.length); |
| 20353 | IrInstGen **instructions = heap::c_allocator.allocate<IrInstGen *>(peer_parent->peers.length); |
| 20390 | 20354 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| 20391 | 20355 | ResultLocPeer *this_peer = peer_parent->peers.at(i); |
| 20392 | 20356 | |
| ... | ... | @@ -20759,7 +20723,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20759 | 20723 | if (index == array_len && array_type->data.array.sentinel != nullptr) { |
| 20760 | 20724 | ZigType *elem_type = array_type->data.array.child_type; |
| 20761 | 20725 | IrInstGen *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base.base, elem_type); |
| 20762 | | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel); |
| 20726 | copy_const_val(ira->codegen, sentinel_elem->value, array_type->data.array.sentinel); |
| 20763 | 20727 | return ir_get_ref(ira, &elem_ptr_instruction->base.base, sentinel_elem, true, false); |
| 20764 | 20728 | } |
| 20765 | 20729 | if (index >= array_len) { |
| ... | ... | @@ -20823,7 +20787,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20823 | 20787 | { |
| 20824 | 20788 | if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { |
| 20825 | 20789 | array_ptr_val->data.x_array.special = ConstArraySpecialNone; |
| 20826 | | array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len); |
| 20790 | array_ptr_val->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(array_type->data.array.len); |
| 20827 | 20791 | array_ptr_val->special = ConstValSpecialStatic; |
| 20828 | 20792 | for (size_t i = 0; i < array_type->data.array.len; i += 1) { |
| 20829 | 20793 | ZigValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i]; |
| ... | ... | @@ -20846,11 +20810,11 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 20846 | 20810 | return ira->codegen->invalid_inst_gen; |
| 20847 | 20811 | } |
| 20848 | 20812 | |
| 20849 | | ZigValue *array_init_val = create_const_vals(1); |
| 20813 | ZigValue *array_init_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 20850 | 20814 | array_init_val->special = ConstValSpecialStatic; |
| 20851 | 20815 | array_init_val->type = actual_array_type; |
| 20852 | 20816 | array_init_val->data.x_array.special = ConstArraySpecialNone; |
| 20853 | | array_init_val->data.x_array.data.s_none.elements = create_const_vals(actual_array_type->data.array.len); |
| 20817 | array_init_val->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(actual_array_type->data.array.len); |
| 20854 | 20818 | array_init_val->special = ConstValSpecialStatic; |
| 20855 | 20819 | for (size_t i = 0; i < actual_array_type->data.array.len; i += 1) { |
| 20856 | 20820 | ZigValue *elem_val = &array_init_val->data.x_array.data.s_none.elements[i]; |
| ... | ... | @@ -21176,7 +21140,7 @@ static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_ins |
| 21176 | 21140 | if (field->is_comptime) { |
| 21177 | 21141 | IrInstGen *elem = ir_const(ira, source_instr, field_type); |
| 21178 | 21142 | memoize_field_init_val(ira->codegen, struct_type, field); |
| 21179 | | copy_const_val(elem->value, field->init_val); |
| 21143 | copy_const_val(ira->codegen, elem->value, field->init_val); |
| 21180 | 21144 | return ir_get_ref2(ira, source_instr, elem, field_type, true, false); |
| 21181 | 21145 | } |
| 21182 | 21146 | switch (type_has_one_possible_value(ira->codegen, field_type)) { |
| ... | ... | @@ -21224,7 +21188,7 @@ static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_ins |
| 21224 | 21188 | if (type_is_invalid(struct_val->type)) |
| 21225 | 21189 | return ira->codegen->invalid_inst_gen; |
| 21226 | 21190 | if (initializing && struct_val->special == ConstValSpecialUndef) { |
| 21227 | | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 21191 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(ira->codegen, struct_type->data.structure.src_field_count); |
| 21228 | 21192 | struct_val->special = ConstValSpecialStatic; |
| 21229 | 21193 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { |
| 21230 | 21194 | ZigValue *field_val = struct_val->data.x_struct.fields[i]; |
| ... | ... | @@ -21266,7 +21230,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 21266 | 21230 | ZigType *container_ptr_type = container_ptr->value->type; |
| 21267 | 21231 | ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr); |
| 21268 | 21232 | |
| 21269 | | InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField"); |
| 21233 | InferredStructField *inferred_struct_field = heap::c_allocator.create<InferredStructField>(); |
| 21270 | 21234 | inferred_struct_field->inferred_struct_type = container_type; |
| 21271 | 21235 | inferred_struct_field->field_name = field_name; |
| 21272 | 21236 | |
| ... | ... | @@ -21286,7 +21250,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 21286 | 21250 | } else { |
| 21287 | 21251 | result = ir_const(ira, source_instr, field_ptr_type); |
| 21288 | 21252 | } |
| 21289 | | copy_const_val(result->value, ptr_val); |
| 21253 | copy_const_val(ira->codegen, result->value, ptr_val); |
| 21290 | 21254 | result->value->type = field_ptr_type; |
| 21291 | 21255 | return result; |
| 21292 | 21256 | } |
| ... | ... | @@ -21357,7 +21321,7 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name |
| 21357 | 21321 | return ira->codegen->invalid_inst_gen; |
| 21358 | 21322 | |
| 21359 | 21323 | if (initializing) { |
| 21360 | | ZigValue *payload_val = create_const_vals(1); |
| 21324 | ZigValue *payload_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 21361 | 21325 | payload_val->special = ConstValSpecialUndef; |
| 21362 | 21326 | payload_val->type = field_type; |
| 21363 | 21327 | payload_val->parent.id = ConstParentIdUnion; |
| ... | ... | @@ -21540,7 +21504,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21540 | 21504 | } |
| 21541 | 21505 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| 21542 | 21506 | if (buf_eql_str(field_name, "len")) { |
| 21543 | | ZigValue *len_val = create_const_vals(1); |
| 21507 | ZigValue *len_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 21544 | 21508 | if (container_type->id == ZigTypeIdPointer) { |
| 21545 | 21509 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); |
| 21546 | 21510 | } else { |
| ... | ... | @@ -21586,7 +21550,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21586 | 21550 | bool ptr_is_const = true; |
| 21587 | 21551 | bool ptr_is_volatile = false; |
| 21588 | 21552 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21589 | | create_const_enum(child_type, &field->value), child_type, |
| 21553 | create_const_enum(ira->codegen, child_type, &field->value), child_type, |
| 21590 | 21554 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 21591 | 21555 | } |
| 21592 | 21556 | } |
| ... | ... | @@ -21615,7 +21579,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21615 | 21579 | bool ptr_is_const = true; |
| 21616 | 21580 | bool ptr_is_volatile = false; |
| 21617 | 21581 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21618 | | create_const_enum(enum_type, &field->enum_field->value), enum_type, |
| 21582 | create_const_enum(ira->codegen, enum_type, &field->enum_field->value), enum_type, |
| 21619 | 21583 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 21620 | 21584 | } |
| 21621 | 21585 | } |
| ... | ... | @@ -21633,7 +21597,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21633 | 21597 | if (existing_entry) { |
| 21634 | 21598 | err_entry = existing_entry->value; |
| 21635 | 21599 | } else { |
| 21636 | | err_entry = allocate<ErrorTableEntry>(1); |
| 21600 | err_entry = heap::c_allocator.create<ErrorTableEntry>(); |
| 21637 | 21601 | err_entry->decl_node = field_ptr_instruction->base.base.source_node; |
| 21638 | 21602 | buf_init_from_buf(&err_entry->name, field_name); |
| 21639 | 21603 | size_t error_value_count = ira->codegen->errors_by_index.length; |
| ... | ... | @@ -21660,7 +21624,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21660 | 21624 | } |
| 21661 | 21625 | err_set_type = child_type; |
| 21662 | 21626 | } |
| 21663 | | ZigValue *const_val = create_const_vals(1); |
| 21627 | ZigValue *const_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 21664 | 21628 | const_val->special = ConstValSpecialStatic; |
| 21665 | 21629 | const_val->type = err_set_type; |
| 21666 | 21630 | const_val->data.x_err_set = err_entry; |
| ... | ... | @@ -21674,7 +21638,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21674 | 21638 | bool ptr_is_const = true; |
| 21675 | 21639 | bool ptr_is_volatile = false; |
| 21676 | 21640 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21677 | | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 21641 | create_const_unsigned_negative(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int, |
| 21678 | 21642 | child_type->data.integral.bit_count, false), |
| 21679 | 21643 | ira->codegen->builtin_types.entry_num_lit_int, |
| 21680 | 21644 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | ... | @@ -21696,7 +21660,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21696 | 21660 | bool ptr_is_const = true; |
| 21697 | 21661 | bool ptr_is_volatile = false; |
| 21698 | 21662 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21699 | | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 21663 | create_const_unsigned_negative(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int, |
| 21700 | 21664 | child_type->data.floating.bit_count, false), |
| 21701 | 21665 | ira->codegen->builtin_types.entry_num_lit_int, |
| 21702 | 21666 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | ... | @@ -21723,7 +21687,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21723 | 21687 | return ira->codegen->invalid_inst_gen; |
| 21724 | 21688 | } |
| 21725 | 21689 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21726 | | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 21690 | create_const_unsigned_negative(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int, |
| 21727 | 21691 | get_ptr_align(ira->codegen, child_type), false), |
| 21728 | 21692 | ira->codegen->builtin_types.entry_num_lit_int, |
| 21729 | 21693 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | ... | @@ -21745,7 +21709,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21745 | 21709 | bool ptr_is_const = true; |
| 21746 | 21710 | bool ptr_is_volatile = false; |
| 21747 | 21711 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 21748 | | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 21712 | create_const_unsigned_negative(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int, |
| 21749 | 21713 | child_type->data.array.len, false), |
| 21750 | 21714 | ira->codegen->builtin_types.entry_num_lit_int, |
| 21751 | 21715 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | ... | @@ -22025,7 +21989,7 @@ static IrInstGen *ir_analyze_instruction_slice_type(IrAnalyze *ira, IrInstSrcSli |
| 22025 | 21989 | IrInstGen *result = ir_const(ira, &slice_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 22026 | 21990 | result->value->special = ConstValSpecialLazy; |
| 22027 | 21991 | |
| 22028 | | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1, "LazyValueSliceType"); |
| 21992 | LazyValueSliceType *lazy_slice_type = heap::c_allocator.create<LazyValueSliceType>(); |
| 22029 | 21993 | lazy_slice_type->ira = ira; ira_ref(ira); |
| 22030 | 21994 | result->value->data.x_lazy = &lazy_slice_type->base; |
| 22031 | 21995 | lazy_slice_type->base.id = LazyValueIdSliceType; |
| ... | ... | @@ -22098,8 +22062,8 @@ static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_i |
| 22098 | 22062 | |
| 22099 | 22063 | // TODO validate the output types and variable types |
| 22100 | 22064 | |
| 22101 | | IrInstGen **input_list = allocate<IrInstGen *>(asm_expr->input_list.length); |
| 22102 | | IrInstGen **output_types = allocate<IrInstGen *>(asm_expr->output_list.length); |
| 22065 | IrInstGen **input_list = heap::c_allocator.allocate<IrInstGen *>(asm_expr->input_list.length); |
| 22066 | IrInstGen **output_types = heap::c_allocator.allocate<IrInstGen *>(asm_expr->output_list.length); |
| 22103 | 22067 | |
| 22104 | 22068 | ZigType *return_type = ira->codegen->builtin_types.entry_void; |
| 22105 | 22069 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| ... | ... | @@ -22138,7 +22102,7 @@ static IrInstGen *ir_analyze_instruction_array_type(IrAnalyze *ira, IrInstSrcArr |
| 22138 | 22102 | IrInstGen *result = ir_const(ira, &array_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 22139 | 22103 | result->value->special = ConstValSpecialLazy; |
| 22140 | 22104 | |
| 22141 | | LazyValueArrayType *lazy_array_type = allocate<LazyValueArrayType>(1, "LazyValueArrayType"); |
| 22105 | LazyValueArrayType *lazy_array_type = heap::c_allocator.create<LazyValueArrayType>(); |
| 22142 | 22106 | lazy_array_type->ira = ira; ira_ref(ira); |
| 22143 | 22107 | result->value->data.x_lazy = &lazy_array_type->base; |
| 22144 | 22108 | lazy_array_type->base.id = LazyValueIdArrayType; |
| ... | ... | @@ -22163,7 +22127,7 @@ static IrInstGen *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstSrcSizeOf |
| 22163 | 22127 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 22164 | 22128 | result->value->special = ConstValSpecialLazy; |
| 22165 | 22129 | |
| 22166 | | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1, "LazyValueSizeOf"); |
| 22130 | LazyValueSizeOf *lazy_size_of = heap::c_allocator.create<LazyValueSizeOf>(); |
| 22167 | 22131 | lazy_size_of->ira = ira; ira_ref(ira); |
| 22168 | 22132 | result->value->data.x_lazy = &lazy_size_of->base; |
| 22169 | 22133 | lazy_size_of->base.id = LazyValueIdSizeOf; |
| ... | ... | @@ -22283,7 +22247,7 @@ static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* sou |
| 22283 | 22247 | return ira->codegen->invalid_inst_gen; |
| 22284 | 22248 | case OnePossibleValueNo: |
| 22285 | 22249 | if (!same_comptime_repr) { |
| 22286 | | ZigValue *payload_val = create_const_vals(1); |
| 22250 | ZigValue *payload_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 22287 | 22251 | payload_val->type = child_type; |
| 22288 | 22252 | payload_val->special = ConstValSpecialUndef; |
| 22289 | 22253 | payload_val->parent.id = ConstParentIdOptionalPayload; |
| ... | ... | @@ -22530,7 +22494,7 @@ static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 22530 | 22494 | } |
| 22531 | 22495 | } |
| 22532 | 22496 | |
| 22533 | | IrInstGenSwitchBrCase *cases = allocate<IrInstGenSwitchBrCase>(case_count); |
| 22497 | IrInstGenSwitchBrCase *cases = heap::c_allocator.allocate<IrInstGenSwitchBrCase>(case_count); |
| 22534 | 22498 | for (size_t i = 0; i < case_count; i += 1) { |
| 22535 | 22499 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 22536 | 22500 | IrInstGenSwitchBrCase *new_case = &cases[i]; |
| ... | ... | @@ -22615,7 +22579,7 @@ static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 22615 | 22579 | case ZigTypeIdErrorSet: { |
| 22616 | 22580 | if (pointee_val) { |
| 22617 | 22581 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, nullptr); |
| 22618 | | copy_const_val(result->value, pointee_val); |
| 22582 | copy_const_val(ira->codegen, result->value, pointee_val); |
| 22619 | 22583 | result->value->type = target_type; |
| 22620 | 22584 | return result; |
| 22621 | 22585 | } |
| ... | ... | @@ -22835,7 +22799,7 @@ static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 22835 | 22799 | return target_value_ptr; |
| 22836 | 22800 | } |
| 22837 | 22801 | // Make note of the errors handled by other cases |
| 22838 | | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); |
| 22802 | ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); |
| 22839 | 22803 | // We may not have any case in the switch if this is a lone else |
| 22840 | 22804 | const size_t switch_cases = instruction->switch_br ? instruction->switch_br->case_count : 0; |
| 22841 | 22805 | for (size_t case_i = 0; case_i < switch_cases; case_i += 1) { |
| ... | ... | @@ -22871,7 +22835,7 @@ static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 22871 | 22835 | buf_appendf(&err_set_type->name, "%s,", buf_ptr(&error_entry->name)); |
| 22872 | 22836 | } |
| 22873 | 22837 | } |
| 22874 | | free(errors); |
| 22838 | heap::c_allocator.deallocate(errors, ira->codegen->errors_by_index.length); |
| 22875 | 22839 | |
| 22876 | 22840 | err_set_type->data.error_set.err_count = result_list.length; |
| 22877 | 22841 | err_set_type->data.error_set.errors = result_list.items; |
| ... | ... | @@ -23019,7 +22983,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc |
| 23019 | 22983 | |
| 23020 | 22984 | IrInstGen *first_non_const_instruction = nullptr; |
| 23021 | 22985 | |
| 23022 | | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); |
| 22986 | AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count); |
| 23023 | 22987 | ZigList<IrInstGen *> const_ptrs = {}; |
| 23024 | 22988 | |
| 23025 | 22989 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope) |
| ... | ... | @@ -23090,7 +23054,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc |
| 23090 | 23054 | return ira->codegen->invalid_inst_gen; |
| 23091 | 23055 | |
| 23092 | 23056 | IrInstGen *runtime_inst = ir_const(ira, source_instr, field->init_val->type); |
| 23093 | | copy_const_val(runtime_inst->value, field->init_val); |
| 23057 | copy_const_val(ira->codegen, runtime_inst->value, field->init_val); |
| 23094 | 23058 | |
| 23095 | 23059 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, result_loc, |
| 23096 | 23060 | container_type, true); |
| ... | ... | @@ -23354,7 +23318,7 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa |
| 23354 | 23318 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 23355 | 23319 | } |
| 23356 | 23320 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 23357 | | copy_const_val(result->value, err->cached_error_name_val); |
| 23321 | copy_const_val(ira->codegen, result->value, err->cached_error_name_val); |
| 23358 | 23322 | result->value->type = str_type; |
| 23359 | 23323 | return result; |
| 23360 | 23324 | } |
| ... | ... | @@ -23680,11 +23644,11 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23680 | 23644 | } |
| 23681 | 23645 | } |
| 23682 | 23646 | |
| 23683 | | ZigValue *declaration_array = create_const_vals(1); |
| 23647 | ZigValue *declaration_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23684 | 23648 | declaration_array->special = ConstValSpecialStatic; |
| 23685 | 23649 | declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); |
| 23686 | 23650 | declaration_array->data.x_array.special = ConstArraySpecialNone; |
| 23687 | | declaration_array->data.x_array.data.s_none.elements = create_const_vals(declaration_count); |
| 23651 | declaration_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(declaration_count); |
| 23688 | 23652 | init_const_slice(ira->codegen, out_val, declaration_array, 0, declaration_count, false); |
| 23689 | 23653 | |
| 23690 | 23654 | // Loop through the declarations and generate info. |
| ... | ... | @@ -23706,7 +23670,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23706 | 23670 | declaration_val->special = ConstValSpecialStatic; |
| 23707 | 23671 | declaration_val->type = type_info_declaration_type; |
| 23708 | 23672 | |
| 23709 | | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 23673 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 3); |
| 23710 | 23674 | ZigValue *name = create_const_str_lit(ira->codegen, curr_entry->key)->data.x_ptr.data.ref.pointee; |
| 23711 | 23675 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); |
| 23712 | 23676 | inner_fields[1]->special = ConstValSpecialStatic; |
| ... | ... | @@ -23737,7 +23701,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23737 | 23701 | // 1: Data.Var: type |
| 23738 | 23702 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); |
| 23739 | 23703 | |
| 23740 | | ZigValue *payload = create_const_vals(1); |
| 23704 | ZigValue *payload = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23741 | 23705 | payload->special = ConstValSpecialStatic; |
| 23742 | 23706 | payload->type = ira->codegen->builtin_types.entry_type; |
| 23743 | 23707 | payload->data.x_type = var->const_value->type; |
| ... | ... | @@ -23758,13 +23722,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23758 | 23722 | |
| 23759 | 23723 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; |
| 23760 | 23724 | |
| 23761 | | ZigValue *fn_decl_val = create_const_vals(1); |
| 23725 | ZigValue *fn_decl_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23762 | 23726 | fn_decl_val->special = ConstValSpecialStatic; |
| 23763 | 23727 | fn_decl_val->type = type_info_fn_decl_type; |
| 23764 | 23728 | fn_decl_val->parent.id = ConstParentIdUnion; |
| 23765 | 23729 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; |
| 23766 | 23730 | |
| 23767 | | ZigValue **fn_decl_fields = alloc_const_vals_ptrs(9); |
| 23731 | ZigValue **fn_decl_fields = alloc_const_vals_ptrs(ira->codegen, 9); |
| 23768 | 23732 | fn_decl_val->data.x_struct.fields = fn_decl_fields; |
| 23769 | 23733 | |
| 23770 | 23734 | // fn_type: type |
| ... | ... | @@ -23802,7 +23766,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23802 | 23766 | 0, 0, 0, false); |
| 23803 | 23767 | fn_decl_fields[5]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr)); |
| 23804 | 23768 | if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { |
| 23805 | | fn_decl_fields[5]->data.x_optional = create_const_vals(1); |
| 23769 | fn_decl_fields[5]->data.x_optional = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23806 | 23770 | ZigValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name)->data.x_ptr.data.ref.pointee; |
| 23807 | 23771 | init_const_slice(ira->codegen, fn_decl_fields[5]->data.x_optional, lib_name, 0, |
| 23808 | 23772 | buf_len(fn_node->lib_name), true); |
| ... | ... | @@ -23817,12 +23781,12 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23817 | 23781 | // arg_names: [][] const u8 |
| 23818 | 23782 | ensure_field_index(fn_decl_val->type, "arg_names", 7); |
| 23819 | 23783 | size_t fn_arg_count = fn_entry->variable_list.length; |
| 23820 | | ZigValue *fn_arg_name_array = create_const_vals(1); |
| 23784 | ZigValue *fn_arg_name_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23821 | 23785 | fn_arg_name_array->special = ConstValSpecialStatic; |
| 23822 | 23786 | fn_arg_name_array->type = get_array_type(ira->codegen, |
| 23823 | 23787 | get_slice_type(ira->codegen, u8_ptr), fn_arg_count, nullptr); |
| 23824 | 23788 | fn_arg_name_array->data.x_array.special = ConstArraySpecialNone; |
| 23825 | | fn_arg_name_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); |
| 23789 | fn_arg_name_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); |
| 23826 | 23790 | |
| 23827 | 23791 | init_const_slice(ira->codegen, fn_decl_fields[7], fn_arg_name_array, 0, fn_arg_count, false); |
| 23828 | 23792 | |
| ... | ... | @@ -23849,7 +23813,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 23849 | 23813 | // This is a type. |
| 23850 | 23814 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); |
| 23851 | 23815 | |
| 23852 | | ZigValue *payload = create_const_vals(1); |
| 23816 | ZigValue *payload = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23853 | 23817 | payload->special = ConstValSpecialStatic; |
| 23854 | 23818 | payload->type = ira->codegen->builtin_types.entry_type; |
| 23855 | 23819 | payload->data.x_type = type_entry; |
| ... | ... | @@ -23915,11 +23879,11 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent |
| 23915 | 23879 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 23916 | 23880 | assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown)); |
| 23917 | 23881 | |
| 23918 | | ZigValue *result = create_const_vals(1); |
| 23882 | ZigValue *result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 23919 | 23883 | result->special = ConstValSpecialStatic; |
| 23920 | 23884 | result->type = type_info_pointer_type; |
| 23921 | 23885 | |
| 23922 | | ZigValue **fields = alloc_const_vals_ptrs(7); |
| 23886 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 7); |
| 23923 | 23887 | result->data.x_struct.fields = fields; |
| 23924 | 23888 | |
| 23925 | 23889 | // size: Size |
| ... | ... | @@ -23974,7 +23938,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn |
| 23974 | 23938 | enum_field_val->special = ConstValSpecialStatic; |
| 23975 | 23939 | enum_field_val->type = type_info_enum_field_type; |
| 23976 | 23940 | |
| 23977 | | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 23941 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 23978 | 23942 | inner_fields[1]->special = ConstValSpecialStatic; |
| 23979 | 23943 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 23980 | 23944 | |
| ... | ... | @@ -24020,11 +23984,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24020 | 23984 | break; |
| 24021 | 23985 | case ZigTypeIdInt: |
| 24022 | 23986 | { |
| 24023 | | result = create_const_vals(1); |
| 23987 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24024 | 23988 | result->special = ConstValSpecialStatic; |
| 24025 | 23989 | result->type = ir_type_info_get_type(ira, "Int", nullptr); |
| 24026 | 23990 | |
| 24027 | | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 23991 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 24028 | 23992 | result->data.x_struct.fields = fields; |
| 24029 | 23993 | |
| 24030 | 23994 | // is_signed: bool |
| ... | ... | @@ -24042,11 +24006,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24042 | 24006 | } |
| 24043 | 24007 | case ZigTypeIdFloat: |
| 24044 | 24008 | { |
| 24045 | | result = create_const_vals(1); |
| 24009 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24046 | 24010 | result->special = ConstValSpecialStatic; |
| 24047 | 24011 | result->type = ir_type_info_get_type(ira, "Float", nullptr); |
| 24048 | 24012 | |
| 24049 | | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 24013 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); |
| 24050 | 24014 | result->data.x_struct.fields = fields; |
| 24051 | 24015 | |
| 24052 | 24016 | // bits: u8 |
| ... | ... | @@ -24066,11 +24030,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24066 | 24030 | } |
| 24067 | 24031 | case ZigTypeIdArray: |
| 24068 | 24032 | { |
| 24069 | | result = create_const_vals(1); |
| 24033 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24070 | 24034 | result->special = ConstValSpecialStatic; |
| 24071 | 24035 | result->type = ir_type_info_get_type(ira, "Array", nullptr); |
| 24072 | 24036 | |
| 24073 | | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 24037 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 3); |
| 24074 | 24038 | result->data.x_struct.fields = fields; |
| 24075 | 24039 | |
| 24076 | 24040 | // len: usize |
| ... | ... | @@ -24090,11 +24054,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24090 | 24054 | break; |
| 24091 | 24055 | } |
| 24092 | 24056 | case ZigTypeIdVector: { |
| 24093 | | result = create_const_vals(1); |
| 24057 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24094 | 24058 | result->special = ConstValSpecialStatic; |
| 24095 | 24059 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); |
| 24096 | 24060 | |
| 24097 | | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 24061 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 24098 | 24062 | result->data.x_struct.fields = fields; |
| 24099 | 24063 | |
| 24100 | 24064 | // len: usize |
| ... | ... | @@ -24112,11 +24076,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24112 | 24076 | } |
| 24113 | 24077 | case ZigTypeIdOptional: |
| 24114 | 24078 | { |
| 24115 | | result = create_const_vals(1); |
| 24079 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24116 | 24080 | result->special = ConstValSpecialStatic; |
| 24117 | 24081 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); |
| 24118 | 24082 | |
| 24119 | | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 24083 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); |
| 24120 | 24084 | result->data.x_struct.fields = fields; |
| 24121 | 24085 | |
| 24122 | 24086 | // child: type |
| ... | ... | @@ -24128,11 +24092,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24128 | 24092 | break; |
| 24129 | 24093 | } |
| 24130 | 24094 | case ZigTypeIdAnyFrame: { |
| 24131 | | result = create_const_vals(1); |
| 24095 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24132 | 24096 | result->special = ConstValSpecialStatic; |
| 24133 | 24097 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); |
| 24134 | 24098 | |
| 24135 | | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 24099 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); |
| 24136 | 24100 | result->data.x_struct.fields = fields; |
| 24137 | 24101 | |
| 24138 | 24102 | // child: ?type |
| ... | ... | @@ -24145,11 +24109,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24145 | 24109 | } |
| 24146 | 24110 | case ZigTypeIdEnum: |
| 24147 | 24111 | { |
| 24148 | | result = create_const_vals(1); |
| 24112 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24149 | 24113 | result->special = ConstValSpecialStatic; |
| 24150 | 24114 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); |
| 24151 | 24115 | |
| 24152 | | ZigValue **fields = alloc_const_vals_ptrs(5); |
| 24116 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 5); |
| 24153 | 24117 | result->data.x_struct.fields = fields; |
| 24154 | 24118 | |
| 24155 | 24119 | // layout: ContainerLayout |
| ... | ... | @@ -24171,11 +24135,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24171 | 24135 | } |
| 24172 | 24136 | uint32_t enum_field_count = type_entry->data.enumeration.src_field_count; |
| 24173 | 24137 | |
| 24174 | | ZigValue *enum_field_array = create_const_vals(1); |
| 24138 | ZigValue *enum_field_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24175 | 24139 | enum_field_array->special = ConstValSpecialStatic; |
| 24176 | 24140 | enum_field_array->type = get_array_type(ira->codegen, type_info_enum_field_type, enum_field_count, nullptr); |
| 24177 | 24141 | enum_field_array->data.x_array.special = ConstArraySpecialNone; |
| 24178 | | enum_field_array->data.x_array.data.s_none.elements = create_const_vals(enum_field_count); |
| 24142 | enum_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(enum_field_count); |
| 24179 | 24143 | |
| 24180 | 24144 | init_const_slice(ira->codegen, fields[2], enum_field_array, 0, enum_field_count, false); |
| 24181 | 24145 | |
| ... | ... | @@ -24205,7 +24169,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24205 | 24169 | } |
| 24206 | 24170 | case ZigTypeIdErrorSet: |
| 24207 | 24171 | { |
| 24208 | | result = create_const_vals(1); |
| 24172 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24209 | 24173 | result->special = ConstValSpecialStatic; |
| 24210 | 24174 | result->type = ir_type_info_get_type(ira, "ErrorSet", nullptr); |
| 24211 | 24175 | |
| ... | ... | @@ -24220,15 +24184,15 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24220 | 24184 | if ((err = type_resolve(ira->codegen, type_info_error_type, ResolveStatusSizeKnown))) { |
| 24221 | 24185 | zig_unreachable(); |
| 24222 | 24186 | } |
| 24223 | | ZigValue *slice_val = create_const_vals(1); |
| 24187 | ZigValue *slice_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24224 | 24188 | result->data.x_optional = slice_val; |
| 24225 | 24189 | |
| 24226 | 24190 | uint32_t error_count = type_entry->data.error_set.err_count; |
| 24227 | | ZigValue *error_array = create_const_vals(1); |
| 24191 | ZigValue *error_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24228 | 24192 | error_array->special = ConstValSpecialStatic; |
| 24229 | 24193 | error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr); |
| 24230 | 24194 | error_array->data.x_array.special = ConstArraySpecialNone; |
| 24231 | | error_array->data.x_array.data.s_none.elements = create_const_vals(error_count); |
| 24195 | error_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(error_count); |
| 24232 | 24196 | |
| 24233 | 24197 | init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false); |
| 24234 | 24198 | for (uint32_t error_index = 0; error_index < error_count; error_index++) { |
| ... | ... | @@ -24238,7 +24202,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24238 | 24202 | error_val->special = ConstValSpecialStatic; |
| 24239 | 24203 | error_val->type = type_info_error_type; |
| 24240 | 24204 | |
| 24241 | | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 24205 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 24242 | 24206 | inner_fields[1]->special = ConstValSpecialStatic; |
| 24243 | 24207 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 24244 | 24208 | |
| ... | ... | @@ -24260,11 +24224,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24260 | 24224 | } |
| 24261 | 24225 | case ZigTypeIdErrorUnion: |
| 24262 | 24226 | { |
| 24263 | | result = create_const_vals(1); |
| 24227 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24264 | 24228 | result->special = ConstValSpecialStatic; |
| 24265 | 24229 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); |
| 24266 | 24230 | |
| 24267 | | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 24231 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 24268 | 24232 | result->data.x_struct.fields = fields; |
| 24269 | 24233 | |
| 24270 | 24234 | // error_set: type |
| ... | ... | @@ -24283,11 +24247,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24283 | 24247 | } |
| 24284 | 24248 | case ZigTypeIdUnion: |
| 24285 | 24249 | { |
| 24286 | | result = create_const_vals(1); |
| 24250 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24287 | 24251 | result->special = ConstValSpecialStatic; |
| 24288 | 24252 | result->type = ir_type_info_get_type(ira, "Union", nullptr); |
| 24289 | 24253 | |
| 24290 | | ZigValue **fields = alloc_const_vals_ptrs(4); |
| 24254 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 4); |
| 24291 | 24255 | result->data.x_struct.fields = fields; |
| 24292 | 24256 | |
| 24293 | 24257 | // layout: ContainerLayout |
| ... | ... | @@ -24304,7 +24268,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24304 | 24268 | if (union_decl_node->data.container_decl.auto_enum || |
| 24305 | 24269 | union_decl_node->data.container_decl.init_arg_expr != nullptr) |
| 24306 | 24270 | { |
| 24307 | | ZigValue *tag_type = create_const_vals(1); |
| 24271 | ZigValue *tag_type = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24308 | 24272 | tag_type->special = ConstValSpecialStatic; |
| 24309 | 24273 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| 24310 | 24274 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| ... | ... | @@ -24320,11 +24284,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24320 | 24284 | zig_unreachable(); |
| 24321 | 24285 | uint32_t union_field_count = type_entry->data.unionation.src_field_count; |
| 24322 | 24286 | |
| 24323 | | ZigValue *union_field_array = create_const_vals(1); |
| 24287 | ZigValue *union_field_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24324 | 24288 | union_field_array->special = ConstValSpecialStatic; |
| 24325 | 24289 | union_field_array->type = get_array_type(ira->codegen, type_info_union_field_type, union_field_count, nullptr); |
| 24326 | 24290 | union_field_array->data.x_array.special = ConstArraySpecialNone; |
| 24327 | | union_field_array->data.x_array.data.s_none.elements = create_const_vals(union_field_count); |
| 24291 | union_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(union_field_count); |
| 24328 | 24292 | |
| 24329 | 24293 | init_const_slice(ira->codegen, fields[2], union_field_array, 0, union_field_count, false); |
| 24330 | 24294 | |
| ... | ... | @@ -24337,14 +24301,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24337 | 24301 | union_field_val->special = ConstValSpecialStatic; |
| 24338 | 24302 | union_field_val->type = type_info_union_field_type; |
| 24339 | 24303 | |
| 24340 | | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 24304 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 3); |
| 24341 | 24305 | inner_fields[1]->special = ConstValSpecialStatic; |
| 24342 | 24306 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); |
| 24343 | 24307 | |
| 24344 | 24308 | if (fields[1]->data.x_optional == nullptr) { |
| 24345 | 24309 | inner_fields[1]->data.x_optional = nullptr; |
| 24346 | 24310 | } else { |
| 24347 | | inner_fields[1]->data.x_optional = create_const_vals(1); |
| 24311 | inner_fields[1]->data.x_optional = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24348 | 24312 | make_enum_field_val(ira, inner_fields[1]->data.x_optional, union_field->enum_field, type_info_enum_field_type); |
| 24349 | 24313 | } |
| 24350 | 24314 | |
| ... | ... | @@ -24379,11 +24343,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24379 | 24343 | break; |
| 24380 | 24344 | } |
| 24381 | 24345 | |
| 24382 | | result = create_const_vals(1); |
| 24346 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24383 | 24347 | result->special = ConstValSpecialStatic; |
| 24384 | 24348 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); |
| 24385 | 24349 | |
| 24386 | | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 24350 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 3); |
| 24387 | 24351 | result->data.x_struct.fields = fields; |
| 24388 | 24352 | |
| 24389 | 24353 | // layout: ContainerLayout |
| ... | ... | @@ -24400,11 +24364,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24400 | 24364 | } |
| 24401 | 24365 | uint32_t struct_field_count = type_entry->data.structure.src_field_count; |
| 24402 | 24366 | |
| 24403 | | ZigValue *struct_field_array = create_const_vals(1); |
| 24367 | ZigValue *struct_field_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24404 | 24368 | struct_field_array->special = ConstValSpecialStatic; |
| 24405 | 24369 | struct_field_array->type = get_array_type(ira->codegen, type_info_struct_field_type, struct_field_count, nullptr); |
| 24406 | 24370 | struct_field_array->data.x_array.special = ConstArraySpecialNone; |
| 24407 | | struct_field_array->data.x_array.data.s_none.elements = create_const_vals(struct_field_count); |
| 24371 | struct_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(struct_field_count); |
| 24408 | 24372 | |
| 24409 | 24373 | init_const_slice(ira->codegen, fields[1], struct_field_array, 0, struct_field_count, false); |
| 24410 | 24374 | |
| ... | ... | @@ -24415,7 +24379,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24415 | 24379 | struct_field_val->special = ConstValSpecialStatic; |
| 24416 | 24380 | struct_field_val->type = type_info_struct_field_type; |
| 24417 | 24381 | |
| 24418 | | ZigValue **inner_fields = alloc_const_vals_ptrs(4); |
| 24382 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 4); |
| 24419 | 24383 | inner_fields[1]->special = ConstValSpecialStatic; |
| 24420 | 24384 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); |
| 24421 | 24385 | |
| ... | ... | @@ -24428,7 +24392,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24428 | 24392 | inner_fields[1]->data.x_optional = nullptr; |
| 24429 | 24393 | } else { |
| 24430 | 24394 | size_t byte_offset = struct_field->offset; |
| 24431 | | inner_fields[1]->data.x_optional = create_const_vals(1); |
| 24395 | inner_fields[1]->data.x_optional = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24432 | 24396 | inner_fields[1]->data.x_optional->special = ConstValSpecialStatic; |
| 24433 | 24397 | inner_fields[1]->data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 24434 | 24398 | bigint_init_unsigned(&inner_fields[1]->data.x_optional->data.x_bigint, byte_offset); |
| ... | ... | @@ -24464,11 +24428,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24464 | 24428 | } |
| 24465 | 24429 | case ZigTypeIdFn: |
| 24466 | 24430 | { |
| 24467 | | result = create_const_vals(1); |
| 24431 | result = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24468 | 24432 | result->special = ConstValSpecialStatic; |
| 24469 | 24433 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); |
| 24470 | 24434 | |
| 24471 | | ZigValue **fields = alloc_const_vals_ptrs(5); |
| 24435 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 5); |
| 24472 | 24436 | result->data.x_struct.fields = fields; |
| 24473 | 24437 | |
| 24474 | 24438 | // calling_convention: TypeInfo.CallingConvention |
| ... | ... | @@ -24495,7 +24459,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24495 | 24459 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 24496 | 24460 | fields[3]->data.x_optional = nullptr; |
| 24497 | 24461 | else { |
| 24498 | | ZigValue *return_type = create_const_vals(1); |
| 24462 | ZigValue *return_type = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24499 | 24463 | return_type->special = ConstValSpecialStatic; |
| 24500 | 24464 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 24501 | 24465 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| ... | ... | @@ -24509,11 +24473,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24509 | 24473 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - |
| 24510 | 24474 | (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC); |
| 24511 | 24475 | |
| 24512 | | ZigValue *fn_arg_array = create_const_vals(1); |
| 24476 | ZigValue *fn_arg_array = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24513 | 24477 | fn_arg_array->special = ConstValSpecialStatic; |
| 24514 | 24478 | fn_arg_array->type = get_array_type(ira->codegen, type_info_fn_arg_type, fn_arg_count, nullptr); |
| 24515 | 24479 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; |
| 24516 | | fn_arg_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); |
| 24480 | fn_arg_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); |
| 24517 | 24481 | |
| 24518 | 24482 | init_const_slice(ira->codegen, fields[4], fn_arg_array, 0, fn_arg_count, false); |
| 24519 | 24483 | |
| ... | ... | @@ -24527,7 +24491,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24527 | 24491 | bool arg_is_generic = fn_param_info->type == nullptr; |
| 24528 | 24492 | if (arg_is_generic) assert(is_generic); |
| 24529 | 24493 | |
| 24530 | | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 24494 | ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 3); |
| 24531 | 24495 | inner_fields[0]->special = ConstValSpecialStatic; |
| 24532 | 24496 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; |
| 24533 | 24497 | inner_fields[0]->data.x_bool = arg_is_generic; |
| ... | ... | @@ -24540,7 +24504,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 24540 | 24504 | if (arg_is_generic) |
| 24541 | 24505 | inner_fields[2]->data.x_optional = nullptr; |
| 24542 | 24506 | else { |
| 24543 | | ZigValue *arg_type = create_const_vals(1); |
| 24507 | ZigValue *arg_type = ira->codegen->pass1_arena->create<ZigValue>(); |
| 24544 | 24508 | arg_type->special = ConstValSpecialStatic; |
| 24545 | 24509 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| 24546 | 24510 | arg_type->data.x_type = fn_param_info->type; |
| ... | ... | @@ -24866,7 +24830,7 @@ static IrInstGen *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstSrcType |
| 24866 | 24830 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 24867 | 24831 | } |
| 24868 | 24832 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 24869 | | copy_const_val(result->value, type_entry->cached_const_name_val); |
| 24833 | copy_const_val(ira->codegen, result->value, type_entry->cached_const_name_val); |
| 24870 | 24834 | return result; |
| 24871 | 24835 | } |
| 24872 | 24836 | |
| ... | ... | @@ -24898,7 +24862,6 @@ static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImpo |
| 24898 | 24862 | } |
| 24899 | 24863 | if (type_is_invalid(cimport_result->type)) |
| 24900 | 24864 | return ira->codegen->invalid_inst_gen; |
| 24901 | | destroy(result_ptr, "ZigValue"); |
| 24902 | 24865 | |
| 24903 | 24866 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.base.scope); |
| 24904 | 24867 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, |
| ... | ... | @@ -25577,11 +25540,11 @@ static IrInstGen *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstSrcToByt |
| 25577 | 25540 | return ira->codegen->invalid_inst_gen; |
| 25578 | 25541 | |
| 25579 | 25542 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_slice_type); |
| 25580 | | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 25543 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 25581 | 25544 | |
| 25582 | 25545 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; |
| 25583 | 25546 | ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; |
| 25584 | | copy_const_val(ptr_val, target_ptr_val); |
| 25547 | copy_const_val(ira->codegen, ptr_val, target_ptr_val); |
| 25585 | 25548 | ptr_val->type = dest_ptr_type; |
| 25586 | 25549 | |
| 25587 | 25550 | ZigValue *len_val = result->value->data.x_struct.fields[slice_len_index]; |
| ... | ... | @@ -25868,7 +25831,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr |
| 25868 | 25831 | expand_undef_array(ira->codegen, b_val); |
| 25869 | 25832 | |
| 25870 | 25833 | IrInstGen *result = ir_const(ira, source_instr, result_type); |
| 25871 | | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); |
| 25834 | result->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_mask); |
| 25872 | 25835 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 25873 | 25836 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| 25874 | 25837 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| ... | ... | @@ -25881,7 +25844,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr |
| 25881 | 25844 | ZigValue *src_elem_val = (v >= 0) ? |
| 25882 | 25845 | &a->value->data.x_array.data.s_none.elements[v] : |
| 25883 | 25846 | &b->value->data.x_array.data.s_none.elements[~v]; |
| 25884 | | copy_const_val(result_elem_val, src_elem_val); |
| 25847 | copy_const_val(ira->codegen, result_elem_val, src_elem_val); |
| 25885 | 25848 | |
| 25886 | 25849 | ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr); |
| 25887 | 25850 | } |
| ... | ... | @@ -25901,7 +25864,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr |
| 25901 | 25864 | |
| 25902 | 25865 | IrInstGen *expand_mask = ir_const(ira, &mask->base, |
| 25903 | 25866 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); |
| 25904 | | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); |
| 25867 | expand_mask->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_max); |
| 25905 | 25868 | uint32_t i = 0; |
| 25906 | 25869 | for (; i < len_min; i += 1) |
| 25907 | 25870 | bigint_init_unsigned(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, i); |
| ... | ... | @@ -25971,9 +25934,9 @@ static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *i |
| 25971 | 25934 | return ir_const_undef(ira, &instruction->base.base, return_type); |
| 25972 | 25935 | |
| 25973 | 25936 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 25974 | | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); |
| 25937 | result->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_int); |
| 25975 | 25938 | for (uint32_t i = 0; i < len_int; i += 1) { |
| 25976 | | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val); |
| 25939 | copy_const_val(ira->codegen, &result->value->data.x_array.data.s_none.elements[i], scalar_val); |
| 25977 | 25940 | } |
| 25978 | 25941 | return result; |
| 25979 | 25942 | } |
| ... | ... | @@ -26111,7 +26074,7 @@ static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset |
| 26111 | 26074 | } |
| 26112 | 26075 | |
| 26113 | 26076 | for (size_t i = start; i < end; i += 1) { |
| 26114 | | copy_const_val(&dest_elements[i], byte_val); |
| 26077 | copy_const_val(ira->codegen, &dest_elements[i], byte_val); |
| 26115 | 26078 | } |
| 26116 | 26079 | |
| 26117 | 26080 | return ir_const_void(ira, &instruction->base.base); |
| ... | ... | @@ -26287,7 +26250,7 @@ static IrInstGen *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstSrcMemcpy |
| 26287 | 26250 | // TODO check for noalias violations - this should be generalized to work for any function |
| 26288 | 26251 | |
| 26289 | 26252 | for (size_t i = 0; i < count; i += 1) { |
| 26290 | | copy_const_val(&dest_elements[dest_start + i], &src_elements[src_start + i]); |
| 26253 | copy_const_val(ira->codegen, &dest_elements[dest_start + i], &src_elements[src_start + i]); |
| 26291 | 26254 | } |
| 26292 | 26255 | |
| 26293 | 26256 | return ir_const_void(ira, &instruction->base.base); |
| ... | ... | @@ -26571,7 +26534,7 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 26571 | 26534 | |
| 26572 | 26535 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 26573 | 26536 | ZigValue *out_val = result->value; |
| 26574 | | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 26537 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(ira->codegen, 2); |
| 26575 | 26538 | |
| 26576 | 26539 | ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; |
| 26577 | 26540 | |
| ... | ... | @@ -26866,7 +26829,7 @@ static IrInstGen *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstSrcAlign |
| 26866 | 26829 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 26867 | 26830 | result->value->special = ConstValSpecialLazy; |
| 26868 | 26831 | |
| 26869 | | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1, "LazyValueAlignOf"); |
| 26832 | LazyValueAlignOf *lazy_align_of = heap::c_allocator.create<LazyValueAlignOf>(); |
| 26870 | 26833 | lazy_align_of->ira = ira; ira_ref(ira); |
| 26871 | 26834 | result->value->data.x_lazy = &lazy_align_of->base; |
| 26872 | 26835 | lazy_align_of->base.id = LazyValueIdAlignOf; |
| ... | ... | @@ -27192,7 +27155,7 @@ static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInst* source_inst |
| 27192 | 27155 | return ira->codegen->invalid_inst_gen; |
| 27193 | 27156 | |
| 27194 | 27157 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 27195 | | ZigValue *vals = create_const_vals(2); |
| 27158 | ZigValue *vals = ira->codegen->pass1_arena->allocate<ZigValue>(2); |
| 27196 | 27159 | ZigValue *err_set_val = &vals[0]; |
| 27197 | 27160 | ZigValue *payload_val = &vals[1]; |
| 27198 | 27161 | |
| ... | ... | @@ -27273,7 +27236,7 @@ static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInst* source |
| 27273 | 27236 | if (err_union_val == nullptr) |
| 27274 | 27237 | return ira->codegen->invalid_inst_gen; |
| 27275 | 27238 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 27276 | | ZigValue *vals = create_const_vals(2); |
| 27239 | ZigValue *vals = ira->codegen->pass1_arena->allocate<ZigValue>(2); |
| 27277 | 27240 | ZigValue *err_set_val = &vals[0]; |
| 27278 | 27241 | ZigValue *payload_val = &vals[1]; |
| 27279 | 27242 | |
| ... | ... | @@ -27335,7 +27298,7 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 27335 | 27298 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 27336 | 27299 | result->value->special = ConstValSpecialLazy; |
| 27337 | 27300 | |
| 27338 | | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1, "LazyValueFnType"); |
| 27301 | LazyValueFnType *lazy_fn_type = heap::c_allocator.create<LazyValueFnType>(); |
| 27339 | 27302 | lazy_fn_type->ira = ira; ira_ref(ira); |
| 27340 | 27303 | result->value->data.x_lazy = &lazy_fn_type->base; |
| 27341 | 27304 | lazy_fn_type->base.id = LazyValueIdFnType; |
| ... | ... | @@ -27363,7 +27326,7 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 27363 | 27326 | |
| 27364 | 27327 | size_t param_count = proto_node->data.fn_proto.params.length; |
| 27365 | 27328 | lazy_fn_type->proto_node = proto_node; |
| 27366 | | lazy_fn_type->param_types = allocate<IrInstGen *>(param_count); |
| 27329 | lazy_fn_type->param_types = heap::c_allocator.allocate<IrInstGen *>(param_count); |
| 27367 | 27330 | |
| 27368 | 27331 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { |
| 27369 | 27332 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); |
| ... | ... | @@ -27518,7 +27481,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 27518 | 27481 | } |
| 27519 | 27482 | |
| 27520 | 27483 | size_t field_prev_uses_count = ira->codegen->errors_by_index.length; |
| 27521 | | AstNode **field_prev_uses = allocate<AstNode *>(field_prev_uses_count, "AstNode *"); |
| 27484 | AstNode **field_prev_uses = heap::c_allocator.allocate<AstNode *>(field_prev_uses_count); |
| 27522 | 27485 | |
| 27523 | 27486 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 27524 | 27487 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| ... | ... | @@ -27575,7 +27538,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 27575 | 27538 | } |
| 27576 | 27539 | } |
| 27577 | 27540 | |
| 27578 | | deallocate(field_prev_uses, field_prev_uses_count, "AstNode *"); |
| 27541 | heap::c_allocator.deallocate(field_prev_uses, field_prev_uses_count); |
| 27579 | 27542 | } else if (switch_type->id == ZigTypeIdInt) { |
| 27580 | 27543 | RangeSet rs = {0}; |
| 27581 | 27544 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| ... | ... | @@ -27768,7 +27731,7 @@ static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t alig |
| 27768 | 27731 | } |
| 27769 | 27732 | |
| 27770 | 27733 | IrInstGen *result = ir_const(ira, &target->base, result_type); |
| 27771 | | copy_const_val(result->value, val); |
| 27734 | copy_const_val(ira->codegen, result->value, val); |
| 27772 | 27735 | result->value->type = result_type; |
| 27773 | 27736 | return result; |
| 27774 | 27737 | } |
| ... | ... | @@ -27864,7 +27827,7 @@ static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, IrInst* source_instr, IrIn |
| 27864 | 27827 | InferredStructField *isf = (val->type->id == ZigTypeIdPointer) ? |
| 27865 | 27828 | val->type->data.pointer.inferred_struct_field : nullptr; |
| 27866 | 27829 | if (isf == nullptr) { |
| 27867 | | copy_const_val(result->value, val); |
| 27830 | copy_const_val(ira->codegen, result->value, val); |
| 27868 | 27831 | } else { |
| 27869 | 27832 | // The destination value should have x_ptr struct pointing to underlying struct value |
| 27870 | 27833 | result->value->data.x_ptr.mut = val->data.x_ptr.mut; |
| ... | ... | @@ -28021,7 +27984,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val) |
| 28021 | 27984 | while (gen_i < gen_field_count) { |
| 28022 | 27985 | size_t big_int_byte_count = val->type->data.structure.host_int_bytes[gen_i]; |
| 28023 | 27986 | if (big_int_byte_count > child_buf_len) { |
| 28024 | | child_buf = allocate_nonzero<uint8_t>(big_int_byte_count); |
| 27987 | child_buf = heap::c_allocator.allocate_nonzero<uint8_t>(big_int_byte_count); |
| 28025 | 27988 | child_buf_len = big_int_byte_count; |
| 28026 | 27989 | } |
| 28027 | 27990 | BigInt big_int; |
| ... | ... | @@ -28084,7 +28047,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 28084 | 28047 | |
| 28085 | 28048 | switch (val->data.x_array.special) { |
| 28086 | 28049 | case ConstArraySpecialNone: |
| 28087 | | val->data.x_array.data.s_none.elements = create_const_vals(len); |
| 28050 | val->data.x_array.data.s_none.elements = codegen->pass1_arena->allocate<ZigValue>(len); |
| 28088 | 28051 | for (size_t i = 0; i < len; i++) { |
| 28089 | 28052 | ZigValue *elem = &val->data.x_array.data.s_none.elements[i]; |
| 28090 | 28053 | elem->special = ConstValSpecialStatic; |
| ... | ... | @@ -28170,7 +28133,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 28170 | 28133 | } |
| 28171 | 28134 | case ContainerLayoutExtern: { |
| 28172 | 28135 | size_t src_field_count = val->type->data.structure.src_field_count; |
| 28173 | | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); |
| 28136 | val->data.x_struct.fields = alloc_const_vals_ptrs(codegen, src_field_count); |
| 28174 | 28137 | for (size_t field_i = 0; field_i < src_field_count; field_i += 1) { |
| 28175 | 28138 | ZigValue *field_val = val->data.x_struct.fields[field_i]; |
| 28176 | 28139 | field_val->special = ConstValSpecialStatic; |
| ... | ... | @@ -28187,7 +28150,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 28187 | 28150 | } |
| 28188 | 28151 | case ContainerLayoutPacked: { |
| 28189 | 28152 | size_t src_field_count = val->type->data.structure.src_field_count; |
| 28190 | | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); |
| 28153 | val->data.x_struct.fields = alloc_const_vals_ptrs(codegen, src_field_count); |
| 28191 | 28154 | size_t gen_field_count = val->type->data.structure.gen_field_count; |
| 28192 | 28155 | size_t gen_i = 0; |
| 28193 | 28156 | size_t src_i = 0; |
| ... | ... | @@ -28199,7 +28162,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 28199 | 28162 | while (gen_i < gen_field_count) { |
| 28200 | 28163 | size_t big_int_byte_count = val->type->data.structure.host_int_bytes[gen_i]; |
| 28201 | 28164 | if (big_int_byte_count > child_buf_len) { |
| 28202 | | child_buf = allocate_nonzero<uint8_t>(big_int_byte_count); |
| 28165 | child_buf = heap::c_allocator.allocate_nonzero<uint8_t>(big_int_byte_count); |
| 28203 | 28166 | child_buf_len = big_int_byte_count; |
| 28204 | 28167 | } |
| 28205 | 28168 | BigInt big_int; |
| ... | ... | @@ -28309,7 +28272,7 @@ static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrIn |
| 28309 | 28272 | return ira->codegen->invalid_inst_gen; |
| 28310 | 28273 | |
| 28311 | 28274 | IrInstGen *result = ir_const(ira, source_instr, dest_type); |
| 28312 | | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); |
| 28275 | uint8_t *buf = heap::c_allocator.allocate_nonzero<uint8_t>(src_size_bytes); |
| 28313 | 28276 | buf_write_value_bytes(ira->codegen, buf, val); |
| 28314 | 28277 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) |
| 28315 | 28278 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -28451,7 +28414,7 @@ static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrTy |
| 28451 | 28414 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 28452 | 28415 | result->value->special = ConstValSpecialLazy; |
| 28453 | 28416 | |
| 28454 | | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1, "LazyValuePtrType"); |
| 28417 | LazyValuePtrType *lazy_ptr_type = heap::c_allocator.create<LazyValuePtrType>(); |
| 28455 | 28418 | lazy_ptr_type->ira = ira; ira_ref(ira); |
| 28456 | 28419 | result->value->data.x_lazy = &lazy_ptr_type->base; |
| 28457 | 28420 | lazy_ptr_type->base.id = LazyValueIdPtrType; |
| ... | ... | @@ -29150,11 +29113,11 @@ static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *i |
| 29150 | 29113 | return ir_const_undef(ira, &instruction->base.base, op_type); |
| 29151 | 29114 | |
| 29152 | 29115 | IrInstGen *result = ir_const(ira, &instruction->base.base, op_type); |
| 29153 | | size_t buf_size = int_type->data.integral.bit_count / 8; |
| 29154 | | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); |
| 29116 | const size_t buf_size = int_type->data.integral.bit_count / 8; |
| 29117 | uint8_t *buf = heap::c_allocator.allocate_nonzero<uint8_t>(buf_size); |
| 29155 | 29118 | if (is_vector) { |
| 29156 | 29119 | expand_undef_array(ira->codegen, val); |
| 29157 | | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); |
| 29120 | result->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(op_type->data.vector.len); |
| 29158 | 29121 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { |
| 29159 | 29122 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; |
| 29160 | 29123 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.base.source_node, |
| ... | ... | @@ -29178,7 +29141,7 @@ static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *i |
| 29178 | 29141 | bigint_read_twos_complement(&result->value->data.x_bigint, buf, int_type->data.integral.bit_count, false, |
| 29179 | 29142 | int_type->data.integral.is_signed); |
| 29180 | 29143 | } |
| 29181 | | free(buf); |
| 29144 | heap::c_allocator.deallocate(buf, buf_size); |
| 29182 | 29145 | return result; |
| 29183 | 29146 | } |
| 29184 | 29147 | |
| ... | ... | @@ -29210,8 +29173,8 @@ static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBi |
| 29210 | 29173 | IrInstGen *result = ir_const(ira, &instruction->base.base, int_type); |
| 29211 | 29174 | size_t num_bits = int_type->data.integral.bit_count; |
| 29212 | 29175 | size_t buf_size = (num_bits + 7) / 8; |
| 29213 | | uint8_t *comptime_buf = allocate_nonzero<uint8_t>(buf_size); |
| 29214 | | uint8_t *result_buf = allocate_nonzero<uint8_t>(buf_size); |
| 29176 | uint8_t *comptime_buf = heap::c_allocator.allocate_nonzero<uint8_t>(buf_size); |
| 29177 | uint8_t *result_buf = heap::c_allocator.allocate_nonzero<uint8_t>(buf_size); |
| 29215 | 29178 | memset(comptime_buf,0,buf_size); |
| 29216 | 29179 | memset(result_buf,0,buf_size); |
| 29217 | 29180 | |
| ... | ... | @@ -29897,7 +29860,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen |
| 29897 | 29860 | assert(old_exec->first_err_trace_msg == nullptr); |
| 29898 | 29861 | assert(expected_type == nullptr || !type_is_invalid(expected_type)); |
| 29899 | 29862 | |
| 29900 | | IrAnalyze *ira = allocate<IrAnalyze>(1, "IrAnalyze"); |
| 29863 | IrAnalyze *ira = heap::c_allocator.create<IrAnalyze>(); |
| 29901 | 29864 | ira->ref_count = 1; |
| 29902 | 29865 | old_exec->analysis = ira; |
| 29903 | 29866 | ira->codegen = codegen; |