Compiling a Subset of APL Into a Typed Intermediate Language

We present a compiler and a typed intermediate language for a subset of APL. The intermediate language treats all numeric data as multi-dimensional arrays and the type system makes explicit the ranks of arrays. Primitive operators are polymorphic in rank and in the type of the underlying data operated on. The frontend of the APL compiler deals with much of the gory details of the APL language, including infix resolution, resolution of identity items for reduce operations, resolution of default element values for empty arrays, scalar extensions, and resolution of certain kinds of overloading. We demonstrate the usefulness of the intermediate language by showing that it can be compiled efficiently, using known techniques, such as delayed arrays, into a C-like language. We also demonstrate that the language is sufficiently expressive that some primitive operators, such as APL's inner product operator, which works on arrays of arbitrary dimensions, can be compiled using more primitive operators.

[1]  Clemens Grelck,et al.  Descriptor-Free Representation of Arrays with Dependent Types , 2008, IFL.

[2]  Manuel M. T. Chakravarty,et al.  Accelerating Haskell array codes with multicore GPUs , 2011, DAMP '11.

[3]  Leonidas J. Guibas,et al.  Compilation and delayed evaluation in APL , 1978, POPL.

[4]  Bo Joel Svensson,et al.  Expressive array constructs in an embedded GPU kernel programming language , 2012, DAMP '12.

[5]  Panagiotis Manolios,et al.  An Array-Oriented Language with Static Rank Polymorphism , 2014, ESOP.

[6]  Troels Henriksen,et al.  Bounds Checking: An Instance of Hybrid Analysis , 2014, ARRAY@PLDI.

[7]  Robert Bernecky,et al.  ACORN: APL to C on real numbers , 1990, APL '90.

[8]  Greg Morrisett,et al.  Compiling with Types , 1995 .

[9]  Clemens Grelck,et al.  Dependently typed array programs don't go wrong , 2009, J. Log. Algebraic Methods Program..

[10]  Troels Henriksen,et al.  A T2 graph-reduction approach to fusion , 2013, FHPC '13.

[11]  Manuel M. T. Chakravarty,et al.  Agda Meets Accelerate , 2012, IFL.

[12]  Manuel Carro,et al.  Proceedings of the sixth workshop on Declarative aspects of multicore programming , 2011, POPL 2011.

[13]  J. Gregory Morrisett,et al.  Nikola: embedding compiled GPU functions in Haskell , 2010, Haskell '10.

[14]  Clemens Grelck,et al.  Accelerating APL programs with SAC , 1998, APL.

[15]  Kenneth E. Iverson,et al.  A programming language , 1899, AIEE-IRE '62 (Spring).

[16]  Robert Bernecky Apex: the apl parallel executor , 1997 .

[17]  Simon L. Peyton Jones,et al.  Regular, shape-polymorphic, parallel arrays in Haskell , 2010, ICFP '10.

[18]  Roger Hui,et al.  J for the APL programmer , 1996, APLQ.