v.gen.c: use the __V_architecture macro in v.pref.get_host_arch()
parent
dc1c8820cc
commit
5870751769
|
@ -51,7 +51,7 @@ pub fn pref_arch_to_table_language(pref_arch pref.Arch) Language {
|
||||||
.i386 {
|
.i386 {
|
||||||
Language.i386
|
Language.i386
|
||||||
}
|
}
|
||||||
._auto {
|
._auto, ._max {
|
||||||
Language.v
|
Language.v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ 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 (
|
||||||
|
@ -754,20 +755,16 @@ pub fn cc_from_string(cc_str string) CompilerType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_host_arch() Arch {
|
pub fn get_host_arch() Arch {
|
||||||
$if amd64 {
|
// NB: we can not use `$if arch` here, because V skips cgen for the non
|
||||||
return .amd64
|
// current comptime branches by default, so there is a bootstrapping
|
||||||
|
// 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')
|
||||||
}
|
}
|
||||||
// $if i386 {
|
return Arch(C.__V_architecture)
|
||||||
// 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) {
|
||||||
|
|
Loading…
Reference in New Issue