cgen,builtin: support for 64bit int 1#25236
Conversation
|
Connected to Huly®: V_0.6-24731 |
|
a simple test code: module main
fn main() {
x := []int{len: 4}
for i in 0 .. x.len {
dump(x[i])
}
dump(sizeof(int))
}note that the and the generated C code: //================================== builtin types ================================*/
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || (defined(__riscv_xlen) && __riscv_xlen == 64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)) || defined(__loongarch64)
typedef int64_t vint_t;
#else
typedef int32_t vint_t;
#endif
VV_LOC void main__main(void) {
Array_vint_t x = __new_array_with_default_noscan(4, 0, sizeof(vint_t), 0);
for (vint_t i = 0; i < x.len; ++i) {
_v_dump_expr_vint_t(_S("b.v"), 7, _S("x[i]"), (*(vint_t*)array_get(x, i)));
}
_v_dump_expr_u32(_S("b.v"), 10, _S("sizeof(int)"), sizeof(vint_t));
} |
|
Question: Would it be simpler to force |
That is my first option, but soon I found some problems:
I am still working on find out a better solution for this. |
So something like
|
|
Yes, using |
|
After enabling 64-bit integers in v, do all the C interface function codes need to be adjusted? For example, does |
I think that preferably yes.
I think that using |
|
@medvednikov what do you think? |
|
That might be a separate PR. Not only do the fn defs need to be changed, but we should have a checker error to not allow |
Yes, definitely. |
perhaps a notice first; otherwise it will break a lot of projects |
|
|
|
I'd say a warning rather than a notice. The code will likely fail in unexpected ways if |
|
The usual escalation for such things is notice->warning->error with at least 1 week before each transition, preferably 1 month. |
I do not see how, |
|
Hmm... notice if Because if it's on, using |
|
I believe that most of the conversions for 64-bit TODO:
|
As vlang/v#25236 may change int a platform dependent 32/64 bit integer, all int from a C program should translate to i32 in v.
|
please wait for sometime, fixing... |
Please do not expand the scope of the PR. It was already good as it is, and given its nature, it has to be done in stages. Adding more stuff here, just complicates things a lot, both for you, for me, and for the users of |
* master: cgen: fix option variadic arg passing (fix vlang#25261) (vlang#25273) x.crypto.ascon: improve ascon_generic_hash, cleanup (vlang#25288) cgen: fix generic cast to sumtype of empty struct (fix vlang#25263) (vlang#25290) cgen: fix fixed-array const initializer (fix vlang#25291) (vlang#25293)
Feature required by #25206
This is the first PR to enable 64bit
inton an 64bit system.It can be use with
-d new_intto enable this feature,This will build a new V compiler with this feature enabled.
NOTE: Currently the V compiler itself is working, but some works needed to make
vlibpass all tests.When enable
-d new_int, internalintwill be replaced by avint_tin the compiler.