[fpc-devel] AArch64 port committed to svn trunk

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Feb 24 00:02:43 CET 2015


Hi,

I've just committed the AArch64 (aka "ARM64") port to trunk. It
currently only supports iOS, but adding Linux support should not be
difficult.

Some notes:
1) Apple's A7 cpu (and possibly also its other or even other
manufacturer's AArch64 cpus) does not support triggering signals in
response to floating point exceptions. The cpu records the fact that an
invalid operation/division by zero/overflow/... happened in a status
register, but it does not raise any signal. The AArch64 specifications
allow this, but it does mean that FPC programs running on this (these)
cpu(s) will not automatically raise fpu exceptions either (except in
case this exception is triggered by a software-implemented routine, such
as cos() or sin()). To check whether you are running on a cpu that does
not support raising fpu signals, you can use code like this:

uses
  math;
var
  fpumask: texceptionmask;
  fpuexc: TFPUException;
begin
  { try to unmask all fpu exceptions }
  fpumask:=SetExceptionMask([]);
  for fpuexc in fpumask do
    writeln(fpuexc,' cannot be unmasked');
end.

Instead, you can use math.ClearExceptions(boolean) to check whether fpu
exceptions have occurred since the last time you called this routine.
Call it with "false" to just clear the current "floating point
exception" state, and with "true" to also raise a Pascal-level exception
if a floating point exception happened in the mean time. In theory, this
routine is cross-platform, but in practice on many platforms (apart from
AArch64, and possibly x86) it doesn't raise pending floating point
exceptions if called with "true" as parameter (to be fixed).

Note that integer exceptions for division-by-zero and overflow are
triggered like on other platforms.

In the future, a code generation switch may be added to instruct the
compiler to insert exception checking code after each floating point
operation that might trigger an exception. Using this switch will
probably result in quite slow floating point code though.

2) inline assembly support for most vector operations has not yet been
implemented

3) you can check whether the current target cpu is AArch64 via {$ifdef
cpuaarch64}. The compiler binary name is ppca64 (or ppcrossa64 if you
don't rename it)

4) support for the 64 bit iPhoneSimulator platform has also been added
(just use -Tiphonesim with a newly compiled ppcx64)

5) (not AArch64-specific) iOS7 and later only ship with the support for
the ASCII code page (and UTF-16 without locale) at the unix level. There
is now an iosxwstr unit that you can use instead of cwstring on both iOS
and (Mac) OS X, which uses the CoreFoundation routines for code page
conversions and locale-aware string comparisons (based on the locale
selected in the System Preferences).

Building an AArch64/iOS cross-compiler is similar to building an ARM/iOS
cross-compiler. Just replace CPU_TARGET=arm with CPU_TARGET=aarch64,
remove any -Cp/-Cf parameters from CROSSOPT and make sure the -XR
parameter points to an iOS 7 or 8 sdk.

Enjoy!


Jonas




More information about the fpc-devel mailing list