Skip to main content

gaia_assembler/backends/windows/
x86.rs

1//! Native x86 backend compiler for Windows
2//! This backend generates native x86 machine code wrapped in a PE container
3
4use crate::{
5    backends::{Backend, GeneratedFiles},
6    config::GaiaConfig,
7    program::GaiaModule,
8};
9use gaia_types::{
10    helpers::{AbiCompatible, ApiCompatible, Architecture, ArtifactType, CompilationTarget},
11    GaiaError, Result,
12};
13use std::collections::HashMap;
14
15/// Native x86 Backend implementation for Windows
16#[derive(Default)]
17pub struct X86Backend {}
18
19impl Backend for X86Backend {
20    fn name(&self) -> &'static str {
21        "Windows (Native x86)"
22    }
23
24    fn primary_target(&self) -> CompilationTarget {
25        CompilationTarget { build: Architecture::X86, host: AbiCompatible::PE, target: ApiCompatible::MicrosoftVisualC }
26    }
27
28    fn artifact_type(&self) -> ArtifactType {
29        ArtifactType::Executable
30    }
31
32    fn match_score(&self, target: &CompilationTarget) -> f32 {
33        if target.build == Architecture::X86 && target.host == AbiCompatible::PE {
34            if target.target == ApiCompatible::MicrosoftVisualC {
35                return 100.0;
36            }
37            return 80.0;
38        }
39        0.0
40    }
41
42    fn generate(&self, _program: &GaiaModule, config: &GaiaConfig) -> Result<GeneratedFiles> {
43        // TODO: Implement x86 (32-bit) instruction generation
44        Err(GaiaError::custom_error("x86 (32-bit) backend not yet fully implemented"))
45    }
46}