cgen: support for `$if amd64 {}` and `$if aarch64 {}`

pull/6130/head
Delyan Angelov 2020-08-20 15:28:31 +03:00
parent 6eea13ecc2
commit 8c7bcad6b1
2 changed files with 16 additions and 0 deletions

View File

@ -4355,12 +4355,21 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) string {
'no_bounds_checking' {
return 'CUSTOM_DEFINE_no_bounds_checking'
}
// architectures:
'amd64' {
return '__V_amd64'
}
'aarch64' {
return '__V_aarch64'
}
// bitness:
'x64' {
return 'TARGET_IS_64BIT'
}
'x32' {
return 'TARGET_IS_32BIT'
}
// endianness:
'little_endian' {
return 'TARGET_ORDER_IS_LITTLE'
}

View File

@ -28,6 +28,13 @@ const (
#define __NOINLINE __attribute__((noinline))
#define __IRQHANDLER __attribute__((interrupt))
#if defined(__x86_64__)
#define __V_amd64 1
#endif
#if defined(__aarch64__) || defined(__arm64__)
#define __V_aarch64 1
#endif
// Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too:
#ifdef __GNUC__
#define __V_GCC__