llvm-native-core 0.1.5

LLVM-native core semantic engine — IR, CodeGen, X86 MC, Clang frontend pipeline
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
//! X86/X86-64 Target Backend — complete instruction selection, register
//! allocation, calling convention, frame lowering, MC encoding/decoding,
//! and assembly printer for the x86 architecture family.
//! Phase 10 — LLVM.TARGET.X86.1 Court.
//!
//! Clean-room behavioral reconstruction from:
//! - Intel® 64 and IA-32 Architectures Software Developer's Manual
//!   (volumes 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D)
//! - AMD64 Architecture Programmer's Manual (volumes 1-5)
//! - System V Application Binary Interface: AMD64 Architecture Processor
//!   Supplement (with LP64 and ILP32 programming models)
//! - Microsoft x64 Software Conventions
//! - X86-64 ELF ABI Specifications
//! - cdecl/stdcall/fastcall/thiscall/vectorcall calling conventions
//!
//! Zero LLVM source code consultation. All behavior reconstructed from
//! published specifications and black-box oracle interrogation.
//!
//! Architecture coverage:
//! - X86-64 (AMD64, Intel 64, x64): full 64-bit mode
//! - IA-32 (i386, i486, i586, i686): full 32-bit protected mode
//! - X86-16 (8086, 80286): real mode (limited support)
//! - Instruction set extensions: MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
//!   SSE4.2, AVX, AVX2, AVX-512 (F/CD/ER/PF/BW/DQ/VL), FMA, BMI, BMI2,
//!   ADX, SHA, SGX, CET, etc.
//! - Operating modes: 16-bit, 32-bit, 64-bit
//! - Addressing modes: 16-bit, 32-bit, 64-bit with all ModR/M and SIB
//!   combinations

// Staged module declarations — modules are added as their implementation
// files are created. Currently active:

// Phase 10: register info, subtarget, target machine, calling convention,
// instruction info, frame lowering
pub mod x86_calling_conv_deep;
pub mod x86_calling_convention;
pub mod x86_cfi_codegen;
pub mod x86_codegen_prepare;
pub mod x86_coroutine_lowering;
pub mod x86_debug_codegen;
pub mod x86_eh_lowering;
pub mod x86_frame_lowering;
pub mod x86_gc_lowering;
pub mod x86_instr_info;
pub mod x86_isel_table;
pub mod x86_jump_table;
pub mod x86_reg_usage;
pub mod x86_register_info;
pub mod x86_rematerialization;
pub mod x86_retire_control;
pub mod x86_subtarget;
pub mod x86_subtarget_features;
pub mod x86_target_machine;

pub mod x86_addr_mode_legalizer;
pub mod x86_addressing_full;
pub mod x86_alias_analysis;
pub mod x86_amx;
pub mod x86_asm_printer;
pub mod x86_avx10;
pub mod x86_binary_format;
pub mod x86_branch_relaxation;
pub mod x86_call_lowering_ext;
pub mod x86_code_metrics;
pub mod x86_compact_unwind;
pub mod x86_constant_opt;
pub mod x86_constant_pool;
pub mod x86_dag_combine_deep;
pub mod x86_debug_adapter;
pub mod x86_deep_codegen;
pub mod x86_disassembler_full;
pub mod x86_dwarf_debug;
pub mod x86_eh_full;
pub mod x86_evex_encoding;
pub mod x86_expand_reduction;
pub mod x86_fast_isel;
pub mod x86_full_instr_info;
pub mod x86_full_mc_encoder_full;
pub mod x86_fusion_catalog;
pub mod x86_gc_eh_full;
pub mod x86_gc_full;
pub mod x86_global_isel_deep;
pub mod x86_global_isel_full;
pub mod x86_golden_pipeline;
pub mod x86_inst_simplify;
pub mod x86_instr_bundling;
pub mod x86_instr_fixup;
pub mod x86_intrinsics_catalog;
pub mod x86_intrinsics_full;
pub mod x86_isel;
pub mod x86_isel_final;
pub mod x86_isel_golden;
pub mod x86_latency_tables;
pub mod x86_linker_script;
pub mod x86_lld_features;
pub mod x86_lld_full;
pub mod x86_load_store_vectorizer;
pub mod x86_loop_optimizer;
pub mod x86_machine_combine;
pub mod x86_machine_verifier;
pub mod x86_mc_assembler_full;
pub mod x86_mc_decoder;
pub mod x86_mc_disassembler_full;
pub mod x86_mc_encoder;
pub mod x86_mc_instr_info_full;
pub mod x86_mc_target_streamer;
pub mod x86_microarch_full;
pub mod x86_mov_optimizer;
pub mod x86_mtsan_full;
pub mod x86_nop_sled;
pub mod x86_operation_legalizer;
pub mod x86_optimize;
pub mod x86_optimizer_full;
pub mod x86_pass_manager;
pub mod x86_patchable_instr;
pub mod x86_profiling_tools;
pub mod x86_sanitizer_codegen;
pub use x86_sanitizer_codegen::{
    X86ASanInstrumentedAccess, X86ASanShadowOp, X86ASanStackFrame, X86ASanStackVar,
    X86CFITypeCheck, X86LSanAllocRecord, X86LSanLeakReport, X86MSanOrigin, X86MSanOriginKind,
    X86MSanShadowPropagator, X86MSanShadowValue, X86SafeStackConfig, X86SanCodeGen,
    X86SanCodeGenConfig, X86ShadowCallStack, X86TSanEvent, X86TSanEventType, X86TSanMutexState,
    X86TSanShadowCell, X86TSanVectorClock, X86UBSanCheck, X86UBSanErrorKind,
};
pub mod x86_basic_block_utils;
pub mod x86_benchmarks;
pub mod x86_branch_folding_adv;
pub mod x86_frame_lowering_ext;
pub mod x86_hardware_loops;
pub mod x86_interleaved_access;
pub mod x86_sanitizer_runtime;
pub mod x86_schedule_model;
pub mod x86_scheduler_full;
pub mod x86_shuffle_patterns;
pub mod x86_slp_vectorizer_deep;
pub mod x86_spill_optimizer;
pub mod x86_stack_probing;
pub mod x86_tablegen_full;
pub mod x86_tail_call;
pub mod x86_tti_deep;
pub mod x86_type_legalizer;
pub mod x86_vector_narrow;
pub mod x86_vector_widen;
pub mod x86_vectorizer_codegen;
pub mod x86_vex_encoding;
pub mod x86_win64_eh;
pub mod x86_xop_3dnow_encoding;

// Re-export key types for convenience
pub use x86_calling_convention::{X86ArgClass, X86ArgInfo, X86CallFrame, X86CallingConvention};
pub use x86_frame_lowering::{CallConv, X86FrameInfo, X86FrameLowering};
pub use x86_instr_info::{
    OperandType, X86InstrDesc, X86InstrInfo, X86MemOperand, X86Opcode, X86Operand, X86SchedInfo,
};
// pub use x86_reg_pressure::{
//     BlockPressureSet, LoopPressure, PressureChange, PressureDiff, RegPressure, SpillDecision,
//     X86RegPressure,
// };
// pub use x86_reg_scavenger::{RegisterState, ScavengeResult, ScavengeSequence, X86RegScavenger};
pub use x86_reg_usage::{
    analyze_register_usage, get_abi_clobber_list, make_reg_usage_full,
    make_reg_usage_liveness_only, make_x86_32_reg_usage, make_x86_64_reg_usage,
    run_liveness_analysis, CallClobberInfo, CalleeSavedUsage, ClobberList, ClobberListEntry,
    ClobberSource, CrossCallRegUsage, FunctionLiveness, ImplicitRegUsage, RegAllocHint,
    RegAllocHints, RegDef, RegDefUseChain, RegLiveness, RegMask, RegPreservation, RegPressureMax,
    RegPressureSnapshot, RegUsageConfig, RegUsageStats, RegUse, X86RegUsage,
};
pub use x86_register_info::{X86RegisterInfo, X86_32_REG_COUNT, X86_64_REG_COUNT};
pub use x86_subtarget::X86Subtarget;
pub use x86_target_machine::X86TargetMachine;

pub use x86_asm_printer::{AsmSyntax, X86AsmPrinter};
pub use x86_basic_block_utils::{
    compute_block_layout, make_x86_bb_utils, make_x86_bb_utils_analyzed,
    make_x86_bb_utils_dominators_only, AddressTakenAnalysis, AddressTakenBlock, BlockAlignment,
    BlockAlignmentInfo, BlockFrequencyEstimator, BlockLayoutConfig, BlockLayoutResult,
    BranchWeight, BranchWeightManager, BranchWeightMeta, ControlDependenceGraph, DomTreeNode,
    DominanceFrontiers, DominatorTree, EHAnalysis, EHBlockInfo, EHBlockKind, LayoutChain, LoopInfo,
    NaturalLoop, PostDomTreeNode, PostDominatorTree, ReachabilityInfo, X86BBUtils,
};
pub use x86_branch_folding_adv::{
    analyze_cond_to_uncond, build_fallthrough_chains, eliminate_unreachable_blocks,
    find_critical_edges, find_reachable_blocks, find_tail_merge_groups, find_threadable_paths,
    longest_common_suffix, make_x86_branch_folding_adv, make_x86_branch_folding_adv_aggressive,
    make_x86_branch_folding_adv_perf_opt, make_x86_branch_folding_adv_size_opt,
    make_x86_branch_folding_adv_thresholds, propagate_frequencies, BlockChain, BlockFrequency,
    BlockMergeConfig, BlockMergeResult, BranchFoldingStats, BranchLayoutConfig,
    BranchPredictionHint, BranchProbability, BranchRedirectConfig, BranchSimplify,
    CondToUncondResult, ConditionInfo, CriticalEdge, CriticalEdgeBlock, CriticalEdgeConfig,
    CriticalEdgeResult, FallthroughChain, InstrHash, JumpTable, JumpTableEntry, LayoutStrategy,
    MergeablePair, StaticBranchHeuristic, SwitchAnalysis, TailDupCandidate, TailDupConfig,
    TailDupCostModel, TailDupResult, TailMergeCandidate, TailMergeConfig, TailMergeGroup,
    TailMergeResult, TailMergedBlock, ThreadablePath, UnreachableElimConfig, UnreachableElimResult,
    X86BranchFoldingAdv,
};
// pub use x86_call_frame_opt::{
//     make_call_frame_opt_with_config, make_x86_32_call_frame_opt, make_x86_64_call_frame_opt_sysv,
//     make_x86_64_call_frame_opt_win64, run_call_frame_opt, run_call_frame_opt_aggressive,
//     run_call_frame_opt_size, AdjstackAnalysis, AdjstackCancelPair, CallFrameConv,
//     CallFrameOptConfig, CallFrameOptStats, CalleePopAnalysis, CalleePopCallSite, InlineFrameOpt,
//     LoopCallFrame, LoopCallFrameAnalysis, PushPopAnalysis, PushPopPair, ShadowFrameLayout,
//     ShadowStackAnalysis, ShadowStackOp, ShadowStackOpKind, StackAdjustKind, StackAdjustOp,
//     StackFrameState, TailCallFrameReuse, X86CallFrameOpt,
// };
pub use x86_calling_conv_deep::{
    all_calling_convention_names, check_abi_compatibility, make_x86_32_calling_conv_deep,
    make_x86_64_calling_conv_deep, AbiCompatibilityResult, AbiFieldInfo, AbiParamMismatch,
    AbiRegAssignments, ArgClassifyResult, ArgLocation, ByValConfig, CallingConvention,
    EightByteClass, HFADetector, HfaBaseType, InAllocaConfig, RegClass, RetLocation,
    ReturnClassifyResult, StackFrame, StructPassingRule, VaListType, VarArgsConfig,
    X86CallingConvDeep, X86Reg,
};
pub use x86_cfi_codegen::{
    X86CFIBitmaskCheck, X86CFIBitsetTest, X86CFICheckKind, X86CFICheckLowering, X86CFICodeGen,
    X86CFICrossDSOCheck, X86CFIFunctionInstrumentation, X86CFIICallCheck, X86CFIShadow,
    X86CFIShadowStack, X86CFITypeCheckedLoad, X86CFITypeEntry, X86CFITypeTable, X86CFITypeTest,
    X86CFIVCallCheck, X86CFIViolationReport, X86KCFIRegistry, X86KCFITargetEntry,
};
// pub use x86_code_emission::{
//     encode_sleb128, encode_uleb128, generate_alignment_padding, generate_nop_padding,
//     make_code_emission_full, make_code_emission_release, make_x86_32_code_emission,
//     make_x86_64_code_emission, prepare_for_emission, CFIDirective, CodeEmissionConfig,
//     CodeEmissionStats, ConstantIsland, ConstantIslandEntry, DwarfLineProgram, ElfRelocation,
//     ElfSection, ElfSectionFlags, ElfSectionType, ElfSymbol, Lsda, LsdaAction, LsdaCallSite,
//     NOPVariant, SymbolBinding, SymbolType, SymbolVisibility, TargetOs, X86CodeEmission,
//     X86RelocationType, CIE, FDE,
// };
pub use x86_codegen_prepare::{
    make_test_cgp_function, make_x86_32_codegen_prepare, make_x86_64_codegen_prepare,
    run_codegen_prepare, AddrSinkAnalysis, AddressingMode, BitTest, CGPBinOp, CGPBlock, CGPConfig,
    CGPFunction, CGPInst, CGPStats, CGPType, CGPValue, CriticalEdgeSplitter, DbgLocation,
    DebugIntrinsicLowering, DevirtAnalyzer, GEPDecomposer, IcmpPredicate, LargeIntExpander,
    LoadStoreCombiner, LookupTable, MemIntrinsicPattern, MemcpyInfo, MemsetInfo, PhiEliminator,
    SwitchInfo, TypePromotion, VectorExpander, X86CodeGenPrepare,
};
pub use x86_dag_combine_deep::{
    make_x86_dag_combine_deep, make_x86_dag_combine_deep_aggressive,
    make_x86_dag_combine_deep_avx512, make_x86_dag_combine_deep_no_fma, CombineAction, CombineDAG,
    CombineResult, DAGNodeRef, DAGOpcode, NodeFlags, X86CombineStats, X86DAGCombineDeep,
};
pub use x86_debug_codegen::{
    X86DbgValue, X86DebugAttrValue, X86DebugAttribute, X86DebugCodeGen, X86DebugCompileUnit,
    X86DebugDIE, X86DebugFileEntry, X86DebugInlinedSubroutine, X86DebugLexicalBlock,
    X86DebugLineEntry, X86DebugLineTable, X86DebugLocRange, X86DebugLocationExpr,
    X86DebugSubprogram, X86DebugVarLocTracker, X86DebugVariable,
};
pub use x86_dwarf_debug::{
    X86DwarfARange, X86DwarfAbbrev, X86DwarfAddrTable, X86DwarfCompileUnit, X86DwarfExpression,
    X86DwarfFrame, X86DwarfGenerator, X86DwarfLineTable, X86DwarfLocation, X86DwarfRangeList,
    X86DwarfStringTable, X86DwarfSubprogram, X86DwarfTypeUnit,
};
pub use x86_expand_reduction::{
    make_x86_expand_reduction_avx, make_x86_expand_reduction_avx2,
    make_x86_expand_reduction_avx512, make_x86_expand_reduction_conservative,
    make_x86_expand_reduction_sse3, ExpandReductionStats, FastMathFlags, ReductionKind,
    ReductionPlan, ReductionStep, X86ExpandReduction,
};
pub use x86_frame_lowering_ext::{
    alignment_mask, build_stack_map_entry, build_varargs_frame, classify_safe_stack_object,
    demote_sret, generate_realign_epilogue, generate_realign_prologue, generate_segmented_prologue,
    generate_stack_probes, layout_safe_stack, make_frame_lowering_ext_with_config,
    make_x86_32_frame_lowering_ext_cdecl, make_x86_64_frame_lowering_ext_sysv,
    make_x86_64_frame_lowering_ext_win64, needs_stack_clash_protection, AlignInstr,
    CalleeSavedAssignment, CalleeSavedReg, EmergencySpillSlot, EmergencySpillSlotManager,
    FrameAccessConfig, FrameAccessDecision, FrameAccessMode, FrameCallConv, PatchPointConfig,
    ProbeInstr, ProbeKind, RealignEpilogue, RealignPrologue, SafeStackConfig, SafeStackFrame,
    SafeStackObject, SaveRestoreRegion, SegmentedStackConfig, SegmentedStackPrologue,
    ShrinkWrapConfig, ShrinkWrapResult, SlotAllocation, SlotInterferenceGraph, SlotLiveRange,
    SlotMergeConfig, SlotMergeResult, SretDemotionConfig, SretFrameSlot, StackCheckInstr,
    StackClashProtectionConfig, StackMapEntry, StackMapLocKind, StackMapLocation,
    StackRealignConfig, SysVVarArgsFrame, VarArgsFrameResult, Win64VarArgsFrame,
    X86FrameLoweringExt,
};
pub use x86_full_instr_info::{EncodingForm, InstrEncodingInfo, X86FullInstrInfo, X86FullOpcode};
// pub use x86_full_mc_decoder::X86FullMCDecoder;  // module doesn't exist yet
// pub use x86_full_mc_encoder::X86FullMCEncoder;  // module disabled
pub use x86_fusion_catalog::{
    FusionConstraints, FusionEntry, FusionFirstOp, FusionMicroArch, FusionQuery, FusionSecondOp,
    FusionType, MacroFusionConstraint, MacroFusionPair, MicroFusionConstraint, MicroFusionPattern,
    X86FusionCatalog,
};
pub use x86_global_isel_deep::{
    DeepGOpcode, DeepLegalizeAction, DeepRegBank, DeepRegBankCostMatrix, DeepX86Opcode,
    X86DeepFeatures, X86DeepGISelPipeline, X86DeepGlobalISel, X86DeepIRTranslator,
    X86DeepInstructionSelector, X86DeepLegalizer, X86DeepMIRCombiner, X86DeepRegBankSelector,
};
pub use x86_hardware_loops::{
    make_x86_hardware_loops_generic, make_x86_hardware_loops_haswell_tsx,
    make_x86_hardware_loops_skylake, make_x86_hardware_loops_zen4, CETLoopPattern, HWLoopIntrinsic,
    HWLoopLegality, HWLoopLowering, HWLoopMicroArch, HWLoopOptimizationResult, HWLoopStats,
    LoopCounterPattern, LoopCounterPredicate, TSXHLELoop, X86HardwareLoops, ZeroOverheadAction,
    ZeroOverheadAnalysis, ZeroOverheadConfig,
};
pub use x86_inst_simplify::{FoldResult, SimplifyStats, X86InstSimplify};
pub use x86_interleaved_access::{
    make_x86_interleaved_access_avx2, make_x86_interleaved_access_avx512,
    make_x86_interleaved_access_sse2, InterleaveConfig, InterleaveCost, InterleaveElementType,
    InterleaveIsa, InterleaveStats, InterleavedAccessGroup, LoweringSequence, ShuffleStep,
    X86InterleavedAccess,
};
pub use x86_isel::X86InstructionSelector;
pub use x86_linker_script::{
    evaluate_expression, tokenize, BinaryOpKind, EvalContext, EvalResult, Expression, LinkerScript,
    MemoryRegion, ProgramHeaderDef, SectionAttrKind, SectionDef, SectionType, SortStrategy,
    SymbolAssignment, X86LinkerScript,
};
pub use x86_load_store_vectorizer::{
    make_x86_lsv_avx, make_x86_lsv_avx512, make_x86_lsv_conservative, make_x86_lsv_sse,
    AccessChain, AlignmentInfo, MemAccessKind, ScalarMemAccess, VectorizeCandidate,
    X86LSVCostModel, X86LSVStats, X86LoadStoreVectorizer, X86VecWidth,
};
pub use x86_machine_combine::{CombinerStats, X86MachineCombine};
pub use x86_mc_decoder::X86MCDecoder;
pub use x86_mc_encoder::X86MCEncoder;
pub use x86_operation_legalizer::{
    analyze_switch_for_lowering, analyze_vector_type, build_dynamic_stack_alloc_lowering,
    build_jump_table_entries, build_rdtsc_lowering, build_switch_binary_tree,
    build_va_copy_lowering, build_va_end_lowering, build_va_start_lowering, expand_i128_operation,
    expand_rotate, get_custom_lowering_table, get_float_libcall_name, lower_bitreverse,
    lower_ctlz_fallback, lower_ctpop_fallback, lower_cttz_fallback, lower_frame_address,
    lower_overflow_op, lower_prefetch, lower_return_address, make_operation_legalizer_with_config,
    make_win64_operation_legalizer, make_x86_32_operation_legalizer,
    make_x86_64_operation_legalizer, CustomLoweringDescriptor, DynamicStackAllocLowering,
    I128Expansion, LegalizeAction, LegalizeOp, LegalizeResult, LegalizeType,
    OverflowLoweringResult, PrefetchHint, RdtscLowering, SwitchBinaryTree, SwitchLoweringConfig,
    SwitchLoweringDecision, SwitchLoweringKind, VAArgABIConfig, VAStartLowering,
    VectorLegalizationInfo, X86LegalizerConfig, X86LegalizerStats, X86OperationLegalizer,
    X86TargetMode,
};
pub use x86_optimize::{X86OptStats, X86PeepholeOptimizer};
pub use x86_schedule_model::{
    alder_lake_pcore_model, granite_rapids_model, ice_lake_model, instruction_latency,
    instruction_resources, instruction_uops, lookup_itinerary, skylake_client_model, zen3_model,
    zen4_model, zen5_model, InstrItinerary, ProcResource, ReadAdvance, SchedMachineModel,
    SchedModel, WriteLatency, WriteRes, X86SchedModelKind,
};
// pub use x86_seldag_deep::{DAGPattern, DAGPatternCategory, IsaRequirement, X86SelDAGDeep};
// pub use x86_selection_dag::{
//     run_x86_dag_pipeline, run_x86_dag_pipeline_32bit, AddressingModePattern, X86AddressMode,
//     X86CondCode, X86DAGBuilder, X86DAGCombine, X86DAGLegalize, X86DAGNode, X86DAGSchedModel,
//     X86DAGToDAGISel, X86InstrEmitter, X86SelectionDAG, X86ISD,
// };
pub use x86_shuffle_patterns::{
    IsaLevel, ShuffleClass, ShuffleElementType, ShuffleImmType, ShuffleLegalizer, ShuffleMask,
    ShuffleMaskEncoder, UpperBitsBehavior, VectorWidth, X86ShufflePattern, X86ShufflePatterns,
};
pub use x86_slp_vectorizer_deep::{
    make_x86_slp_deep_avx, make_x86_slp_deep_avx512, make_x86_slp_deep_conservative,
    make_x86_slp_deep_sse, SLPBuildContext, SLPCostModel, SLPMultiNodePattern, SLPOpcode,
    SLPReductionKind, SLPTreeNode, ScheduledSLPOp, X86SLPVectorizerDeep,
};
pub use x86_stack_probing::{
    ABISpecific, AllocaConfig, AllocaRecord, AllocaResult, AllocaTracker, CalleeSavedManager,
    CallingConv, ClashSeverity, DynamicStackAllocContext, DynamicStackAllocResult,
    EntryProbeSequence, FrameBuilder, FrameInfo, FrameObject, FrameObjectKind, OutgoingArgManager,
    ProbeEmissionResult, ProbePoint, ProbeStats, ProbeStrategy, ProbingLoop, RealignAlignment,
    RealignmentResult, RedZoneManager, ShadowSpaceManager, StackClashConfig, StackClashResult,
    StackDirection, StackFrameLayout, X86StackProbing, DEFAULT_PROBE_INTERVAL,
    DRAP_REGISTER_ALT_X64, DRAP_REGISTER_X32, DRAP_REGISTER_X64, MAX_FRAME_SIZE_WITHOUT_PROBE,
    MAX_PROBE_INTERVAL, MIN_PROBE_INTERVAL, RED_ZONE_SIZE_SYSV, SHADOW_SPACE_WIN64,
    STACK_ALIGNMENT_SYSV, STACK_ALIGNMENT_WIN64,
};
pub use x86_tablegen_full::{
    X86CallingConvRule, X86ComplexPattern, X86ComplexPatternHandler, X86CustomInserter,
    X86EncodingPrefix, X86EvexTuple, X86ISelDAGPatterns, X86InstrFormat, X86InstrPattern,
    X86InstrTableGenDef, X86OpcodeMap, X86PatFragDef, X86RegisterClassDef, X86RegisterDef,
    X86RegisterDefs, X86SchedWriteRecord, X86TableGenFull, X86TypeInferenceEntry,
};
pub use x86_tti_deep::{X86CostModel, X86TTIDeep};
pub use x86_type_legalizer::{
    compute_type_split, elements_for_register, get_reg_class_for_type, is_type_legal_in_regclass,
    make_type_legalizer_with_avx512, make_type_legalizer_with_soft_float,
    make_x86_32_type_legalizer, make_x86_64_type_legalizer, preferred_vector_width, SplitTypeInfo,
    TypeAction, TypeContext, TypeLegalizeResult, X86RegClass, X86Type, X86TypeLegalizer,
    X86TypeLegalizerConfig, X86TypeLegalizerStats,
};
// pub use x86_vector_combine::{
//     make_x86_vector_combine, make_x86_vector_combine_aggressive,
//     make_x86_vector_combine_conservative, BlendMask, CombineEmittedInstr, CombineEmitter,
//     CombineKind, CombineOperand, CombineShuffleMask, CombineStats, ConstantVector,
//     MachineCombineInstr, X86VectorCombine,
// };
pub use x86_vector_narrow::{
    make_x86_vector_narrow, make_x86_vector_narrow_avx512, make_x86_vector_narrow_sse2,
    MachineNarrowInstr, NarrowEmittedInstr, NarrowEmitter, NarrowKind, NarrowOperand, NarrowResult,
    NarrowStats, NarrowStep, NarrowStrategy, X86VectorNarrow,
};
pub use x86_vector_widen::{
    make_x86_vector_widen, make_x86_vector_widen_avx, make_x86_vector_widen_no_arith,
    AVX512Rounding, AVX512WidenContext, MachineWidenInstr, WidenEmittedInstr, WidenEmitter,
    WidenKind, WidenOperand, WidenOperands, WidenResult, WidenStats, WidenStep, WidenStrategy,
    X86VectorWiden,
};
pub use x86_vectorizer_codegen::{
    make_x86_vectorizer_codegen, make_x86_vectorizer_codegen_avx2,
    make_x86_vectorizer_codegen_avx512, make_x86_vectorizer_codegen_sse2, GatherDescriptor,
    InterleaveGroup, MaskedMemOpKind, MaskedMemoryOp, ReductionOp, ScatterDescriptor, TailStrategy,
    VPRecipe, VPlan, VecCodeGenConfig, VecCodeGenResult, VecCodeGenStats, VecElementType,
    VecFuncABI, VecFuncVariant, VecIsaLevel, VectorPredication, VectorTypeRepr,
    VectorizationFactor, X86VectorizerCodeGen,
};
// pub use x86_vreg_rewriter::{
//     InstrConstraints, OperandConstraint, RewriteResult, RewriteStats, StandardSubRegIdx,
//     SubRegIndex, SubRegMap, VirtRegMap, X86VRegRewriter,
// };

// Additional re-exports from submodules
pub use crate::codegen::{
    MachineBasicBlock as X86MachineBasicBlock, MachineFunction as X86MachineFunction,
    MachineInstr as X86MachineInstr, MachineOperand as X86MachineOperand,
};
pub use crate::codegen_regalloc::RegAllocResult as X86RegAllocResult;
pub use x86_instr_info::{X86InstrFlags, X86InstrKind};
pub use x86_isel_table::{
    AddressPattern, ISelTable, ISelTableEntry, PatCondition, PatNode, PatResult,
};
pub use x86_mc_encoder::{mod_field, prefixes, X86Mode};
pub use x86_microarch_full::X86MicroArchKind;
pub use x86_optimizer_full::X86Optimizer;
pub use x86_register_info::{FLAGS, GPR16, GPR32, GPR64, GPR8, IP, KMASK, MMX, X87, XMM, YMM, ZMM};
// pub use x86_selection_dag::X86CondCode as X86ConditionCode;

/// Type alias for X86ConditionCode.
pub type X86CondCode = X86ConditionCode;

/// X86 condition codes used for conditional branches, moves, and sets.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[allow(non_camel_case_types)]
pub enum X86ConditionCode {
    O,
    NO,
    B,
    AE,
    E,
    NE,
    BE,
    A,
    S,
    NS,
    P,
    NP,
    L,
    GE,
    LE,
    G,
}

pub use x86_subtarget_features::X86IsaFeature;

/// X86 endianness is always little-endian.
pub const X86_ENDIANNESS: &str = "little";

/// X86 stack alignment for various ABIs.
pub const X86_STACK_ALIGNMENT_64: u32 = 16;
pub const X86_STACK_ALIGNMENT_32: u32 = 16; // GCC default on modern 32-bit
pub const X86_RED_ZONE_SIZE_64: u32 = 128;

/// X86 maximum alignment for any type.
pub const X86_MAX_ALIGNMENT: u32 = 64; // AVX-512 requires 64-byte alignment

/// Number of bytes in an X86-64 page.
pub const X86_PAGE_SIZE: u32 = 4096;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_x86_constants() {
        assert_eq!(X86_ENDIANNESS, "little");
        assert_eq!(X86_STACK_ALIGNMENT_64, 16);
        assert_eq!(X86_STACK_ALIGNMENT_32, 16);
        assert_eq!(X86_RED_ZONE_SIZE_64, 128);
        assert_eq!(X86_MAX_ALIGNMENT, 64);
        assert_eq!(X86_PAGE_SIZE, 4096);
    }
}