[fpc-devel] closing of bug 5042 or general unalignment problems with arm compiler
Roozbeh GHolizadeh
roozbehid at yahoo.com
Mon Apr 24 13:08:37 CEST 2006
Hi.
I've already sent peter an email,but didnt know
mailing list was also availble.I think here is a
better place to discuss.
My wishlist on bug 5042 was adding of something like
__unaligned keyword to fpc.
As you know unalignment access in arm cpus cause
exception and make program terminate.
Having unaligned keyword or directive is a must for
arm compiler.I have several reasons:
1.gcc,ms visual c,and almost all c compiler have
this,so there might be a reason those developers
bothered themself implementing that.
2.It also make compiler code generation easier because
now it know where to generate unalignement
code,instead of currently geussing and somethimes
generate wrong code(bug 5028)and if not unaligned
keyword specified,means do as normal.(it is the same
case in c compilers).
3.With this also no more automatic unaligned/aligned
code generation for packed records,which is also buggy
now(havent had time to report this,but accessing
packed record also sometimes generate errors).
Compiler have to generate unaligned code for packed
record if only it is declared as unaligned.
Peter suggested that you can use move in these cases.
About peter solution,i think following problems exist:
1.Just imagine how to port you current working win32
program-which is almost the case for majarity of wince
developers-to wince.
start your program,try to see if any errors
happen,then convert each assignment by adding move
procedure.
How about the assignment where sizes mismatch?
well now you have to add another temporary variable,do
move on it,assign it to that another one.
How about members of a record (pointer packed
record,which now compiler doesnt know anything about
it)?
Well use move for each member of record,or see if it
is unaligned and do that!
This one simply means,forget about it,and rewrite your
program.
2.Move currently is a procedure which in turn calls
memset from winapi.Well imagine how slow it is.
In a 10000 times loop which you only want to assign a
word(type) to another word;now you have to call memset
10000 times!
but with making that feature compiler only add one
more opcode.
3.Using move can be really hard,in nested structures
and classes.
I think this wishlist/bug report should opened again.
regards
roozbeh
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the fpc-devel
mailing list