Revert "v.gen.c: use the __V_architecture macro in v.pref.get_host_arch()"

This reverts commit 5452ba4653.
pull/10439/head
Delyan Angelov 2021-06-12 23:15:48 +03:00
parent 339f2cd180
commit dc654b0121
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 14 additions and 11 deletions

View File

@ -51,7 +51,7 @@ pub fn pref_arch_to_table_language(pref_arch pref.Arch) Language {
.i386 { .i386 {
Language.i386 Language.i386
} }
._auto, ._max { ._auto {
Language.v Language.v
} }
} }

View File

@ -67,7 +67,6 @@ pub enum Arch {
rv64 // 64-bit risc-v rv64 // 64-bit risc-v
rv32 // 32-bit risc-v rv32 // 32-bit risc-v
i386 i386
_max
} }
const ( const (
@ -755,16 +754,20 @@ pub fn cc_from_string(cc_str string) CompilerType {
} }
pub fn get_host_arch() Arch { pub fn get_host_arch() Arch {
// NB: we can not use `$if arch` here, because V skips cgen for the non $if amd64 {
// current comptime branches by default, so there is a bootstrapping return .amd64
// problem => the __V_architecture macro is used to resolve it.
// TODO: think about how to solve it for non C backends, perhaps we
// need a comptime `$if native {` too, and/or a mechanism to always
// generate all branches for specific functions?
if C.__V_architecture <= int(Arch._auto) || C.__V_architecture >= int(Arch._max) {
panic('unknown host CPU architecture')
} }
return Arch(C.__V_architecture) // $if i386 {
// return .amd64
// }
// $if arm64 { // requires new vc
$if aarch64 {
return .arm64
}
// $if arm32 {
// return .arm32
// }
panic('unknown host OS')
} }
fn parse_define(mut prefs Preferences, define string) { fn parse_define(mut prefs Preferences, define string) {