add the concept of an OS to target info

This commit is contained in:
Folkert de Vries 2022-08-01 23:53:17 +02:00
parent 6f3c8477e6
commit 7df31619dd
6 changed files with 45 additions and 28 deletions

View file

@ -3,7 +3,7 @@ use crate::types::{Env, Types};
use bumpalo::Bump;
use roc_load::{LoadedModule, LoadingProblem, Threading};
use roc_reporting::report::RenderTarget;
use roc_target::{Architecture, TargetInfo};
use roc_target::{Architecture, TargetInfo,OperatingSystem};
use std::fs::File;
use std::io::{self, ErrorKind, Write};
use std::path::{Path, PathBuf};
@ -135,7 +135,7 @@ pub fn load_types(
let types_and_targets = Architecture::iter()
.map(|arch| {
let target_info = arch.into();
let target_info = TargetInfo { architecture: arch.into(), operating_system: OperatingSystem::Unix};
let mut env = Env::new(arena, subs, &mut interns, target_info);
(env.vars_to_types(variables.clone()), target_info)

View file

@ -1711,7 +1711,6 @@ fn arch_to_str(architecture: Architecture) -> &'static str {
Architecture::Aarch64 => "aarch64",
Architecture::Aarch32 => "arm",
Architecture::Wasm32 => "wasm32",
Architecture::Windows64 => todo!(),
}
}
@ -1724,7 +1723,7 @@ fn write_indents(indentations: usize, buf: &mut String) {
fn max_pointer_tagged_variants(architecture: Architecture) -> usize {
match architecture {
// On a 64-bit system, pointers have 3 bits that are unused, so return 2^3 = 8
Architecture::X86_64 | Architecture::Aarch64 | Architecture::Windows64 => 8,
Architecture::X86_64 | Architecture::Aarch64 => 8,
// On a 32-bit system, pointers have 2 bits that are unused, so return 2^4 = 4
Architecture::X86_32 | Architecture::Aarch32 | Architecture::Wasm32 => 4,
}
@ -1734,7 +1733,7 @@ fn max_pointer_tagged_variants(architecture: Architecture) -> usize {
fn tagged_pointer_bitmask(architecture: Architecture) -> u8 {
match architecture {
// On a 64-bit system, pointers have 3 bits that are unused
Architecture::X86_64 | Architecture::Aarch64 | Architecture::Windows64 => 0b0000_0111,
Architecture::X86_64 | Architecture::Aarch64 => 0b0000_0111,
// On a 32-bit system, pointers have 2 bits that are unused
Architecture::X86_32 | Architecture::Aarch32 | Architecture::Wasm32 => 0b0000_0011,
}