@@ -1083,7 +1083,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
10831083        .sparc  = >  if  (target .cpu .has (.sparc , .v9 )) .SPARC32PLUS  else  .SPARC ,
10841084        .sparc64  = >  .SPARCV9 ,
10851085        .ve  = >  .VE ,
1086-         .x86  = >  .@"386" ,
1086+         .x86_16  ,  . x86= >  .@"386" ,
10871087        .x86_64  = >  .X86_64 ,
10881088        .xcore  = >  .XCORE ,
10891089        .xtensa , .xtensaeb  = >  .XTENSA ,
@@ -1154,6 +1154,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
11541154        .ve ,
11551155        .wasm32 ,
11561156        .wasm64 ,
1157+         .x86_16 ,
11571158        .xcore ,
11581159        .xtensa ,
11591160        .xtensaeb ,
@@ -1376,6 +1377,7 @@ pub const Cpu = struct {
13761377        ve ,
13771378        wasm32 ,
13781379        wasm64 ,
1380+         x86_16 ,
13791381        x86 ,
13801382        x86_64 ,
13811383        xcore ,
@@ -1467,15 +1469,15 @@ pub const Cpu = struct {
14671469                .spirv32 , .spirv64  = >  .spirv ,
14681470                .ve  = >  .ve ,
14691471                .wasm32 , .wasm64  = >  .wasm ,
1470-                 .x86 , .x86_64  = >  .x86 ,
1472+                 .x86_16  ,  . x86.x86_64  = >  .x86 ,
14711473                .xcore  = >  .xcore ,
14721474                .xtensa , .xtensaeb  = >  .xtensa ,
14731475            };
14741476        }
14751477
14761478        pub  inline  fn  isX86 (arch : Arch ) bool  {
14771479            return  switch  (arch ) {
1478-                 .x86 , .x86_64  = >  true ,
1480+                 .x86_16  ,  . x86.x86_64  = >  true ,
14791481                else  = >  false ,
14801482            };
14811483        }
@@ -1669,6 +1671,7 @@ pub const Cpu = struct {
16691671                .ve ,
16701672                .wasm32 ,
16711673                .wasm64 ,
1674+                 .x86_16 ,
16721675                .x86 ,
16731676                .x86_64 ,
16741677                .xcore ,
@@ -1789,6 +1792,12 @@ pub const Cpu = struct {
17891792                .x86_interrupt ,
17901793                = >  &.{.x86 },
17911794
1795+                 .x86_16_cdecl ,
1796+                 .x86_16_stdcall ,
1797+                 .x86_16_regparmcall ,
1798+                 .x86_16_interrupt ,
1799+                 = >  &.{.x86_16 },
1800+ 
17921801                .aarch64_aapcs ,
17931802                .aarch64_aapcs_darwin ,
17941803                .aarch64_aapcs_win ,
@@ -1971,6 +1980,7 @@ pub const Cpu = struct {
19711980                .riscv64 , .riscv64be  = >  & riscv .cpu .generic_rv64 ,
19721981                .sparc64  = >  & sparc .cpu .v9 , // SPARC can only be 64-bit from v9 and up. 
19731982                .wasm32 , .wasm64  = >  & wasm .cpu .mvp ,
1983+                 .x86_16  = >  & x86 .cpu .i86 ,
19741984                .x86  = >  & x86 .cpu .i386 ,
19751985                .x86_64  = >  & x86 .cpu .x86_64 ,
19761986                inline  else  = >  | a |  &@field (Target , @tagName (a .family ())).cpu .generic ,
@@ -2237,7 +2247,10 @@ pub fn supportsAddressSpace(
22372247
22382248    return  switch  (address_space ) {
22392249        .generic  = >  true ,
2240-         .fs , .gs , .ss  = >  (arch  ==  .x86_64  or  arch  ==  .x86 ) and  (context  ==  null  or  context  ==  .pointer ),
2250+         .fs , .gs , .ss  = >  (arch  ==  .x86_64  or  arch  ==  .x86  or  arch  ==  .x86_16 ) and  (context  ==  null  or  context  ==  .pointer ),
2251+         // Technically x86 can use segmentation... 
2252+         .far  = >  (arch  ==  .x86_16 ),
2253+ 
22412254        .flash , .flash1 , .flash2 , .flash3 , .flash4 , .flash5  = >  arch  ==  .avr , // TODO this should also check how many flash banks the cpu has 
22422255        .cog , .hub  = >  arch  ==  .propeller ,
22432256        .lut  = >  arch  ==  .propeller  and  std .Target .propeller .featureSetHas (target .cpu .features , .p2 ),
@@ -2800,6 +2813,7 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
28002813    return  switch  (cpu_arch ) {
28012814        .avr ,
28022815        .msp430 ,
2816+         .x86_16 ,
28032817        = >  16 ,
28042818
28052819        .arc ,
@@ -3013,7 +3027,7 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 {
30133027pub  fn  cTypeBitSize (target : * const  Target , c_type : CType ) u16  {
30143028    switch  (target .os .tag ) {
30153029        .freestanding , .other  = >  switch  (target .cpu .arch ) {
3016-             .msp430  = >  switch  (c_type ) {
3030+             .msp430 ,  .x86_16  = >  switch  (c_type ) {
30173031                .char  = >  return  8 ,
30183032                .short , .ushort , .int , .uint  = >  return  16 ,
30193033                .float , .long , .ulong  = >  return  32 ,
@@ -3369,6 +3383,7 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
33693383        std .math .ceilPowerOfTwoAssert (u16 , (cTypeBitSize (target , c_type ) +  7 ) /  8 ),
33703384        @as (u16 , switch  (target .cpu .arch ) {
33713385            .msp430 ,
3386+             .x86_16 ,
33723387            = >  2 ,
33733388
33743389            .arc ,
@@ -3476,7 +3491,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
34763491    return  @min (
34773492        std .math .ceilPowerOfTwoAssert (u16 , (cTypeBitSize (target , c_type ) +  7 ) /  8 ),
34783493        @as (u16 , switch  (target .cpu .arch ) {
3479-             .msp430  = >  2 ,
3494+             .x86_16  ,  . msp430= >  2 ,
34803495
34813496            .arc ,
34823497            .arceb ,
@@ -3548,7 +3563,7 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
35483563    return  switch  (target .cpu .arch ) {
35493564        .avr  = >  1 ,
35503565
3551-         .msp430  = >  2 ,
3566+         .msp430 ,  .x86_16  = >  2 ,
35523567
35533568        .arc ,
35543569        .arceb ,
@@ -3625,6 +3640,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
36253640            .windows , .uefi  = >  .{ .x86_win  =  .{} },
36263641            else  = >  .{ .x86_sysv  =  .{} },
36273642        },
3643+         .x86_16  = >  .{ .x86_16_cdecl  =  .{} },
36283644        .aarch64 , .aarch64_be  = >  if  (target .os .tag .isDarwin ())
36293645            .{ .aarch64_aapcs_darwin  =  .{} }
36303646        else  switch  (target .os .tag ) {
0 commit comments