Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to FOAM (the intermediate language for Aldor) Laurentiu Dragan UWO/ORCCA Programming Languages Group.

Similar presentations


Presentation on theme: "Introduction to FOAM (the intermediate language for Aldor) Laurentiu Dragan UWO/ORCCA Programming Languages Group."— Presentation transcript:

1 Introduction to FOAM (the intermediate language for Aldor) Laurentiu Dragan UWO/ORCCA Programming Languages Group

2 Overview ● What is FOAM ● Short example ● FOAM instructions – Grammar ● Calling Protocols ● Built-in operations ● Semantics of FOAM ● Runtime support ● Optimizations

3 What is FOAM ● First Order Abstract Machine (FOAM) ● Intermediate languages – LIR, MIR, HIR ● FOAM – HIR ● Developed at IBM by Dr. Stephen Watt

4 FOAM Goals ● Platform independence, well-defined semantics – Optimizations done at FOAM level are platform independent ● Efficient mapping to ANSI C and Common Lisp ● Has a structure that allows easy manipulation – FOAM-to-FOAM transformations to optimize the code at FOAM level.

5 Structure ● FOAM unit – compilation unit (source file) ● Each unit: – List of declarations – List of definitions ● Declarations – Special slots: globals, constants ● Definitions: programs, initialization

6 Simple Example ● simple2.as #include "aldor" #include "aldorio" import from Integer; 1; ● simple2.fm ● simple3.c

7 High-level overview of FOAM FOAM.as.fm Built-ins C LISP FORTRAN FOAM Domains (Run- time) PCal l BCal l Import/expo rt

8 FOAM Grammar

9 Unit ● [Unit ] ● ::= [DEnv... ] ● ::= [DFluid... ]

10 Declarations ● ::= [DFmt... ] ● ::= [DDecl... : Decl>] ● ::= [Decl ] ● ::= [GDecl ]

11 Definitions ● ::= [DDef... ] ● ::= [Def ]

12 Commands ● ::= | | one of ● [Seq... ] ● [Goto ] ● [If ] ● [Select... ] ● [Return ]

13 Commands (Contd) ● [Set ] ● [Lose ] ● [PushEnv ] ● [PopEnv ] ● [Protect ] ● [Throw ] ● [Halt ]

14 Expressions ● ::= | one of ● [BVal ] ● [Label ] ● [Cast ] ● [ANew ] ● [RNew ] ● [TRNew ] ● [RCopy ]

15 Expressions (Contd) ● [BCall... ] ● [CCall... ] ● [OCall... ] ● [PCall... ] ● [MFmt ] ● [Values... ] ● [Catch ]

16 Values ● ::= |

17 References ● ::= one of ● [AElt ] ● [RElt ] ● [IRElt ] ● [TRElt ] ● [EElt ] ● [Const ] ● [Glo ]

18 References (Contd) ● [Fluid ] ● [Par ] ● [Loc ] ● [Lex ] ● [Env ] ● [EEnv ] ● [CEnv ] ● [CProg ] ● [EInfo ] ● [PRef ]

19 Data and Types ● ::= Nil | Char | Bool | Byte | HInt | SInt | HInt | SInt | BInt | SFlo | DFlo | Arr | Rec | Prog | Clos | Ptr ● ::= Nil | Char | Bool | Byte | HInt | SInt | BInt | SFlo | DFlo | Arr | Rec | Env | Prog | Clos | Ptr | Word | Arb | NOp

20 FOAM Types ● Primitive Types – Boolean: Bool – Numeric ● Floating Point: SFlo, DFlo ● Integral: Char, Byte, SInt, HInt ● Reference Types – Ptr, Clos, Env, BInt – Arr, Rec, Prog, NOp

21 Programs ● [Prog... ] ● t – the return type ● f – the format of the return type, if t is NOp ● b – contains different flags: generator, side-effects, optimization info ● size – the size of prog including the programs called ● time – estimated running time ● loc - local varibles ● Lex – an array of formats of lexical levels ● C0... c n – commands performed in sequence

22 Protocols ● Describe the interface used for accessing objects ● FOAM_Proto_Foam – natural mapping for FOAM objects ● FOAM_Proto_Other – natural mapping for objects in the hosting system ● FOAM_Proto_Init – initializer of a unit ● FOAM_Proto_C – objects are coming from C ● FOAM_Proto_Lisp – objects are coming from Lisp ● FOAM_Proto_Fortran – objects are coming from FORTRAN

23 Built-in Operations ● Operations on Bool – contains only values true and false – And, Or evaluate both arguments – Examples: true, false, Not, And, Or, EQ, NE ● Operations on Char – can be mapped to native set (EBCDIC, ASCII) – Space, newline, isDigit, EQ, lower, ord, num,...

24 Built-in Operations (Contd) ● Operations on SFlo, DFlo ● Operations on Byte, HInt, SInt, BInt ● Operations on Ptr ● Text Operations: FormatXXX, ScanXXX ● Conversion Operations

25 Semantics of FOAM Programs ● A FOAM program is a set of Units ● One unit is considered to be the starting unit ● The execution starts with the first program of the starting unit ● Only Globals are shared among units ● The order of evaluation of arguments of a call is undefined ● For PCall the order is defined according to the protocol used

26 Runtime Support ● Written in Aldor ● Most of it offers support for domains and categories ● Support for debugging

27 Optimizations ● Aldor compiler uses aggressive optimization to obtain performace close to C code ● Optimizations like: dead variable elimination, procedure integration, constant folding, copy propagation, peephole optimizations, common subexpression elimination. ● As a result of these optimizations the resulted code can be 10s or 100s times faster than unoptimized code


Download ppt "Introduction to FOAM (the intermediate language for Aldor) Laurentiu Dragan UWO/ORCCA Programming Languages Group."

Similar presentations


Ads by Google