[fpc-devel] Question about Currency support
hi, The tests/test/cg/taddcurr.pp fails for mips now, after some tracing, I've reduced the error to a simpler one: program t; var i,j : currency; begin j := -1.001; i := j / 10.0; writeln(i,' ',j); end. The generated code is: ... .stabn 68,0,6,.Ll2 - main .Ll2: addiu $3,$0,-10010 //load -10010 to a int64 store lui $2,%hi(U_$P$T_$$_J) sw $3,%lo(U_$P$T_$$_J)($2) addiu $2,$0,-1 lui $3,%hi(U_$P$T_$$_J+4) addiu $3,$3,%lo(U_$P$T_$$_J+4) sw $2,($3) .stabn 68,0,7,.Ll3 - main .Ll3: lui $2,%hi(U_$P$T_$$_J) lw $4,%lo(U_$P$T_$$_J)($2) lui $2,%hi(U_$P$T_$$_J+4) addiu $2,$2,%lo(U_$P$T_$$_J+4) lw $5,($2) jal fpc_int64_to_double//convert it to double nop lui $2,%hi(_$T$_Ld1) addiu $2,$2,%lo(_$T$_Ld1) lwc1$f2,($2) div.s $f0,$f0,$f2 // div 1.0, but problem is that f0 contains a double value, here div.s is used lui $2,%hi(_$T$_Ld2) addiu $2,$2,%lo(_$T$_Ld2) lwc1$f2,($2) div.s $f0,$f0,$f2 // should be div 10.0 lui $2,%hi(_$T$_Ld1) addiu $2,$2,%lo(_$T$_Ld1) lwc1$f2,($2) mul.s $f0,$f0,$f2 // mul 1.0 cvt.d.s $f0,$f0 swc1$f0,84($29) swc1$f1,88($29) lw $4,84($29) lw $5,88($29) jal fpc_round_real nop I guess it is related to mips/ncpucvn.pas: tmipseltypeconvnode.first_int_to_real when compared to ncnv.pas, it seems ignore the floatype of resultdef. But using the inherited first_int_to_real is impossible since int64_to_float64/float32 etc. are not implemented(how can the sparc version work if so, it call the inherited one?) BTW, for the statement i := j / 10.0, is that in the div node, resultdef refers to i, left refers to j, and right refers to 10.0? But for the typeconvnode, what is the result/left/right node? In general, is there a way for me to learn about the node generating process? E.g. add print somewhere to show it? Add in each node seems too much... Thanks in advance. Regards Fuxin Zhang ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Question about Currency support
Am 04.06.2012 08:47 schrieb Fuxin Zhang zhan...@lemote.com: BTW, for the statement i := j / 10.0, is that in the div node, resultdef refers to i, left refers to j, and right refers to 10.0? But for the typeconvnode, what is the result/left/right node? AFAIK the tree of that statement will be the following: AssigmentNode Left: Loadnode for i Right: BinaryNode for /: Left: Loadnode for j Right: Constnode for 10.0 Resultdef: floatdef (not necessarily the def of i) If i and the resultdef of the binary node are not the same a typeconvnode will also be added, where: Left: the binary node Right: Nil (AFAIK a typeconvnode doesn't have a right node at all...) Resultdef: the degree if the target type (here the def if i) In general, is there a way for me to learn about the node generating process? E.g. add print somewhere to show it? Add in each node seems too much... AFAIK FPC has an option for this. Call the compiler using -h and check the -v options. One of them should dump the tree to a txt file. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Question about Currency support
Am 04.06.2012 10:22 schrieb Sven Barth pascaldra...@googlemail.com: In general, is there a way for me to learn about the node generating process? E.g. add print somewhere to show it? Add in each node seems too much... AFAIK FPC has an option for this. Call the compiler using -h and check the -v options. One of them should dump the tree to a txt file. Ok, I rechecked: the option is -vp and will trigger the compiler to write a tree.log file. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Question about Currency support
Fuxin Zhang wrote on Mon, 04 Jun 2012: I guess it is related to mips/ncpucvn.pas: tmipseltypeconvnode.first_int_to_real when compared to ncnv.pas, it seems ignore the floatype of resultdef. But using the inherited first_int_to_real is impossible since int64_to_float64/float32 etc. are not implemented(how can the sparc version work if so, it call the inherited one?) Because of the two blocks rtl/linux/system.pp that are bracked with {$if defined(CPUARM) or defined(CPUM68K) or defined(CPUSPARC)}. You should probably add CPUMIPS to them, so it also imports the necessary helpers. BTW, for the statement i := j / 10.0, is that in the div node, It's a slash node, not a div node (a div node represents the div operator). resultdef refers to i, left refers to j, and right refers to 10.0? resultdef refers to whatever the default result type of that division is, which in turn depends on the result types of the arguments (j and 10.0). It will be set by the pass_typecheck method, which is called during parsing. The assignment node will insert a type conversion from this resultdef (which is the resultdef of its right node, the division) to the resultdef of the target of the assignment node (its left node, i in this case). If the types are the same, the typeconversion will be optimized away. In general, the type using which Pascal expressions are evaluated is completely independently from how the result is used afterwards. Currency is a special case because of all the scaling going on though. In addition to the resultdef, there's also the nf_is_currency node flag to determine whether or not the value still has to be scaled. But for the typeconvnode, what is the result/left/right node? There is no right node in a typeconvnode, only a left node (ttypeconvnode inherits from tunarynode, not from binary node). Left is whatever you are converting from, and resultdef (once it has been set from ttypeconvnode.totypedef) is what you are converting to. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] progress of freepascal for mips
You are right, the machine (http://www-03.ibm.com/systems/power/hardware/560/specs.html) doesn't have a MIPS processor, but an IBM's Power6. BTW, does anyone know which Linux distribution runs on that machine?, can FPC be compiled to run on it?. Leonardo M. Ramé http://leonardorame.blogspot.com From: microc...@zoho.com microc...@zoho.com To: fpc-devel@lists.freepascal.org Sent: Saturday, June 2, 2012 3:58 PM Subject: Re: [fpc-devel] progress of freepascal for mips On Sat, 2 Jun 2012 07:04:24 -0700 (PDT) Leonardo M. Ramé martinr...@yahoo.com wrote: Hi, while this interesting discussion about fpc for Linux/MIPS is evolving, we've received an IBM Mips server from a customer (I don't know the model yet) to try to install an hypervisor. Sorry if this has already been answered but I have tons of mail and haven't read them all yet. I am near certain IBM doesn't make any MIPS hardware at all and never has in their history. In the past they've made all sorts of odd things but at the moment all they make is Intel and POWER servers, as far as servers go. MIPS in IBM-speak is millions of instructions per second which is how they describe mainframe performance since they don't publish clock speeds. We need to run at least Windows and Linux servers on it. Do you know if Xen/VMWare or similar hypervisors run on this architecture?. AFAIK, as far as Windows, nothing but Windows CE (not XP, 7, Vista etc) runs on MIPS and I don't think Windows CE will run on server hardware. And all of the virtualization options available are Intel-only except for Oracle's SPARC VM, so no, you don't have any virtualization options except for perhaps QEMU, but so does everyone who has an Intel box, so there isn't anything to offer via virtualization. If I can install an hypervisor, I could create one virtual machine to let the FPC team test the MIPS version on this machine, it can be online 24/7. Virtualization is thin to none on anything but Intel hardware. But there is QEMU and it provides support for various architectures including MIPS. If you install Linux on your MIPS server (if it really is a MIPS server, which I don't think it is, or if it is, it isn't IBM) you can use QEMU like Fuxin Zhang wrote he was using, but then so can everyone else who has an Intel box (everybody) so I don't think it's going to be very helpful. And the guy working on fpc on MIPS, Fuxin, is working for a MIPS manufacturer so I would guess he has all the hardware he needs ;-) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] progress of freepascal for mips
On 04 Jun 2012, at 23:56, Leonardo M. Ramé wrote: You are right, the machine (http://www-03.ibm.com/systems/power/hardware/560/specs.html) doesn't have a MIPS processor, but an IBM's Power6. BTW, does anyone know which Linux distribution runs on that machine? http://www.google.be/search?hl=enq=IBM+Power+560+Express+linux - http://www.acclinet.com/ibm-servers/ibm-power-560-server.asp can FPC be compiled to run on it?. Yes, both under AIX and under Linux (either the ppc32 or the ppc64 version of FPC). Jonas___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] progress of freepascal for mips
From: Jonas Maebe jonas.ma...@elis.ugent.be To: Leonardo M. Ramé martinr...@yahoo.com; FPC developers' list fpc-devel@lists.freepascal.org Sent: Monday, June 4, 2012 7:19 PM Subject: Re: [fpc-devel] progress of freepascal for mips On 04 Jun 2012, at 23:56, Leonardo M. Ramé wrote: You are right, the machine (http://www-03.ibm.com/systems/power/hardware/560/specs.html) doesn't have a MIPS processor, but an IBM's Power6. BTW, does anyone know which Linux distribution runs on that machine? http://www.google.be/search?hl=enq=IBM+Power+560+Express+linux - http://www.acclinet.com/ibm-servers/ibm-power-560-server.asp can FPC be compiled to run on it?. Yes, both under AIX and under Linux (either the ppc32 or the ppc64 version of FPC). That means that there is a native version of FPC or an emulated x86 version? Leonardo M. Ramé http://leonardorame.blogspot.com ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Question about Currency support
In general, the type using which Pascal expressions are evaluated is completely independently from how the result is used afterwards. Currency is a special case because of all the scaling going on though. In addition to the resultdef, there's also the nf_is_currency node flag to determine whether or not the value still has to be scaled. But for the typeconvnode, what is the result/left/right node? There is no right node in a typeconvnode, only a left node (ttypeconvnode inherits from tunarynode, not from binary node). Left is whatever you are converting from, and resultdef (once it has been set from ttypeconvnode.totypedef) is what you are converting to. I see now. another question, after switch to int64_to_floatxx, the code should be correct, but there is another issue that can be reduced to: i : currency; i := 9.99; frac(i) frac(9.99) frac(i) will be 9.88E-001 tests/test/cg/taddcurr.pp still fail with this. in gdb, (gdb) p 9.99 * 1.0 / 1.0 $1 = 9.9867 Is it the test program taddcurr.pp cannot work for non-x86 systems? Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] progress of freepascal for mips
Yes, both under AIX and under Linux (either the ppc32 or the ppc64 version of FPC). #160; That means that there is a native version of FPC or an emulated x86 version? Judging from the source, it should be a native version. Leonardo M. Ram� http://leonardorame.blogspot.com ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] progress of freepascal for mips
On Mon, 4 Jun 2012 14:56:06 -0700 (PDT) Leonardo M. Ramé martinr...@yahoo.com wrote: You are right, the machine (http://www-03.ibm.com/systems/power/hardware/560/specs.html) doesn't have a MIPS processor, but an IBM's Power6. BTW, does anyone know which Linux distribution runs on that machine?, can FPC be compiled to run on it?. Leonardo M. Ramé http://leonardorame.blogspot.com Congrats, that's a nice box. POWER6 is one generation behind but from what I read it can still run the latest version of AIX. The best OS is the one IBM made for it, AIX which is a POSIX UNIX with IBM extensions (and great doc!). You should be able to get a copy without too much difficulty if one isn't already installed. On the same page you linked above, there is a list of some Linux that are certified to run on your box. Running Linux on it would be a horrible waste of a good server. You can probably virtualize Linux and BSD instances under AIX though, as you had mentioned in your first post. If you find you're not happy with the server, just tell me how much it would cost to ship and I'll take it off your hands ;-) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel