Compiling with Time and Space Constraints Jens Palsberg Purdue University Department of Computer Science Secure Software Systems Group http://www.cs.purdue.edu/people/palsberg Supported by NSF CAREER and ITR awards, and DARPA.
1
Compiling with Time and Space Constraints Jens Palsberg Purdue - - PowerPoint PPT Presentation
Compiling with Time and Space Constraints Jens Palsberg Purdue University Department of Computer Science Secure Software Systems Group http://www.cs.purdue.edu/people/palsberg Supported by NSF CAREER and ITR awards, and DARPA. 1
1
2
3
4
5
6
7
8
9
10
RP 15 15 Local Nonlocal Nonlocal
11
12
Model Extractor Program ZIL Program Model ILP Formulation Target Program CPLEX AMPL ILP ILP Solution (values of all variables in the ILP) Code Generator
13
14
15
16
17
18
skip skip ret skip skip inc intrs iret i_3_1 i_3_2 i_3_0 call T4 djnz v, L3 ld v, 08h i_0_1 i_0_0 ld u, 04h djnz u, L2 ret jp L1 jp START call T8 i_0_5 i_2_3 i_2_2 i_2_1 i_2_0 cp x1, x2 1 1 2 3,4 6 7 5 5 4 3 7 6 4 2 i_0_4 i_1_3 i_1_2 i_1_1 i_1_0 i_0_3 i_0_6 19
# Set Declarations set Banks := { 0, ..., 12, 15 }; # 13, 14 reserved for stack set Instrabs; set Var; set Bin2Instr within (Instrabs × Var × Var); set DjnzInstr within (Instrabs × Var); # Variables var r { Var × Banks } binary; var RPVal { Instrabs × Banks } binary; var Bin2Cost { Bin2Instr } binary; var SetRP { Instrabs } binary; # Objective Function minimize SPACE COST: sum { (i, v1, v2) in Bin2Instr } Bin2Cost[i, v1, v2] + sum { i in Instrabs } 2 * SetRP[i] + ...; # Constraints subject to VAR IN SINGLE BANK { v in Var }: sum { b in Banks } r[v, b] = 1; subject to RP UNIQUE { i in Instrabs }: sum { b in Banks } RPVal[i, b] = 1; subject to DJNZ RESTRICTION { (i, v) in DjnzInstr }: r[v, b] = RPVal[i, b];
20
21
MAIN PROCEDURES HANDLERS
{
; x, y are allotted T4() INTR() ; regs 0, 1 in bank 1
{ {
; u is allotted register ; intrs is allotted register START: ; 0 in bank 2 ; 0 in bank 3 srp 1 cp r0, r1 ; 6b saved srp 2 push RP jp eq, L0 ld r0, 04h ; 6b saved srp 3 call T4 L2: djnz r0, L2 inc r0 ; 6b saved jp L1 ret pop RP L0: call T8
}
iret L1: jp START
} }
T8()
{
; v is allotted register ; 1 in bank 2 srp 2 ld r1, 08h ; 6b saved L3: djnz r1, L3 ret
}
22
23
(i,v1,v2)∈Bin2Instr
(i,v)∈Bin1OrIncrInstr
24
25
26
27
28
29
30
!3 !2 !1 !1 !2 ?2 ?2 ?1 ?1 ?3 e e e e
INIT: START: HANDLER:
31
32
33
34
35
36
Bibliography http://www.cs.purdue.edu/homes/palsberg/paper/icse01.ps.gz Static Checking of Interrupt-driven Software, with Dennis Brylow and Niels Damgaard. In Proceedings of ICSE'01, 23rd International Conference on Software Engineering, pages 47-56, Toronto, May 2001. http://www.cs.purdue.edu/homes/palsberg/paper/naik-palsberg02.ps.gz Compiling with Code-Size Constraints, with Mayur Naik. In Proceedings of LCTES'02, Languages, Compilers, and Tools for Embedded Systems joint with SCOPES'02, Software and Compilers for Embedded Systems, Berlin, Germany, June 2002. http://www.cs.purdue.edu/homes/palsberg/paper/ftrtft02.ps.gz A Typed Interrupt Calculus, with Di Ma. In FTRTFT'02, 7th International Symposium on Formal Techniques in Real-Time and Fault Tolerant Systems, Oldenburg, Germany, September 2002.