source: branches/arm/level-0/ARM/arm-symbol.lisp @ 14111

Last change on this file since 14111 was 14111, checked in by gb, 11 years ago

Yet another scheme for subprim calls. Go ahead and laugh.
Details:

  • ba/bla are new pseudo instructions, identical to b/bl except that their operands are subprim names (or addresses).
  • for each subprim name/address referenced in a ba/bla instruction, the assembler generates an:

(ldr pc (:= data-word-containing-subprim-address))

instruction and makes the ba/bla branch to that instruction.

  • this is the only use of the "constant pool" and there are no longer user-visible directives for referencing pc-relative data. (We can load 32-bit integer constants via movw/movt instructions and initialize FPRs to constants via GPRs.)
  • by default, the disassembler hides this and shows ba/bla instructions.

Compared to the scheme of a few days ago, it's about the same speed
(b/bl to LDR vs mov reg/bx reg). If a subprim's called once per function
it's a little bigger; if there's more than one call site, it can be smaller.
(And we don't have to find a temp register.) If we can map the subprims
to addresses within 32MB of the pure area, then purify can turn the PC-relative
branches/bls to the LDR instructions into direct branches/bls to the code.

Compared to the original scheme (branch/bl to mov pc, #n) we don't flush
the pipeline on every call and don't have any constraints on subprimitive
addresses (they don't have to be expressible as ARM constants.)

File size: 4.2 KB
Line 
1;;;-*- Mode: Lisp; Package: CCL -*-
2;;;
3;;;   Copyright (C) 2009 Clozure Associates
4;;;   Copyright (C) 1994-2001 Digitool, Inc
5;;;   This file is part of Clozure CL. 
6;;;
7;;;   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
8;;;   License , known as the LLGPL and distributed with Clozure CL as the
9;;;   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
10;;;   which is distributed with Clozure CL as the file "LGPL".  Where these
11;;;   conflict, the preamble takes precedence. 
12;;;
13;;;   Clozure CL is referenced in the preamble as the "LIBRARY."
14;;;
15;;;   The LLGPL is also available online at
16;;;   http://opensource.franz.com/preamble.html
17
18(in-package "CCL")
19
20(eval-when (:compile-toplevel :execute)
21  (require "ARM-ARCH")
22  (require "ARM-LAPMACROS"))
23
24;;; This assumes that macros & special-operators
25;;; have something that's not FUNCTIONP in their
26;;; function-cells.
27(defarmlapfunction %function ((sym arg_z))
28  (check-nargs 1)
29  (let ((symptr temp0)
30        (symbol temp1)
31        (def arg_z))
32    (cmp sym 'nil)
33    (mov symbol sym)
34    (mov symptr (:$ arm::nil-value))
35    (add symptr symptr (:$ arm::nilsym-offset))
36    (beq @ref)
37    (trap-unless-xtype= sym arm::subtag-symbol)
38    (mov symptr sym)
39    @ref
40    (ldr def (:@ symptr (:$ arm::symbol.fcell)))
41    (extract-typecode imm0 def)
42    (cmp imm0 (:$ arm::subtag-function))
43    (uuo-error-udf (:? ne) symbol)
44    (bx lr)))
45
46
47
48;;; Traps unless sym is NIL or some other symbol.
49;;; On ARM, NIL isn't really a symbol; this function maps from NIL
50;;; to an internal proxy symbol ("nilsym").
51(defarmlapfunction %symbol->symptr ((sym arg_z))
52  (cmp sym 'nil)
53  (addeq sym sym (:$ arm::nilsym-offset))
54  (bxeq lr)
55  (trap-unless-xtype= sym arm::subtag-symbol)
56  (bx lr))
57
58;;; Traps unless symptr is a symbol; returns NIL if symptr
59;;; is NILSYM.
60(defarmlapfunction %symptr->symbol ((symptr arg_z))
61  (mov imm1 (:$ arm::nil-value))
62  (add imm1 imm1 (:$ arm::nilsym-offset))
63  (cmp imm1 symptr)
64  (moveq arg_z 'nil)
65  (bxeq lr)
66  (trap-unless-xtype= symptr arm::subtag-symbol)
67  (bx lr))
68
69(defarmlapfunction %symptr-value ((symptr arg_z))
70  (ba .SPspecref))
71
72(defarmlapfunction %set-symptr-value ((symptr arg_y) (val arg_z))
73  (ba .SPspecset))
74
75(defarmlapfunction %symptr-binding-address ((symptr arg_z))
76  (ldr imm0 (:@ symptr (:$ arm::symbol.binding-index)))
77  (ldr imm2 (:@ arm::rcontext (:$ arm::tcr.tlb-limit)))
78  (ldr imm1 (:@ arm::rcontext (:$ arm::tcr.tlb-pointer)))
79  (cmp imm0 imm2)
80  (bhs @sym)
81  (ldr temp0 (:@ imm1 imm0))
82  (cmp temp0 (:$ arm::subtag-no-thread-local-binding))
83  (unbox-fixnum imm0 imm0)
84  (beq @sym)
85  (vpush1 imm1)
86  (vpush1 imm0)
87  (set-nargs 2)
88  (add temp0 vsp '2)
89  (ba .SPvalues)
90  @sym
91  (mov arg_y '#.arm::symbol.vcell)
92  (vpush1 arg_z)
93  (vpush1 arg_y)
94  (set-nargs 2)
95  (add temp0 vsp '2)
96  (ba .SPvalues))
97
98(defarmlapfunction %tcr-binding-location ((tcr arg_y) (sym arg_z))
99  (ldr imm1 (:@ sym (:$ arm::symbol.binding-index)))
100  (ldr imm2 (:@ tcr (:$ arm::tcr.tlb-limit)))
101  (ldr imm0 (:@ tcr (:$ arm::tcr.tlb-pointer)))
102  (mov arg_z 'nil)
103  (cmp imm1 imm2)
104  (bxhs lr)
105  (ldr  temp0 (:@ imm0 imm1))
106  (cmp  temp0 (:$ arm::subtag-no-thread-local-binding))
107  (bxeq lr)
108  (add arg_z imm0 imm1)
109  (bx lr))
110
111 
112(defarmlapfunction %pname-hash ((str arg_y) (len arg_z))
113  (let ((nextw imm1)
114        (accum imm0)
115        (offset imm2))
116    (cmp len (:$ 0))
117    (mov offset (:$ arm::misc-data-offset))
118    (mov accum (:$ 0))
119    (bxeq lr)
120    @loop
121    (subs len len '1)
122    (ldr nextw (:@ str offset))
123    (add offset offset (:$ 4))
124    (mov accum (:ror accum (:$ 27)))
125    (eor accum accum nextw)
126    (bne @loop)
127    (mov accum (:lsl accum (:$ 5)))
128    (mov arg_z (:lsr accum (:$ (- 5 arm::fixnumshift))))
129    (bx lr)))
130
131(defarmlapfunction %string-hash ((start arg_x) (str arg_y) (len arg_z))
132  (let ((nextw imm1)
133        (accum imm0)
134        (offset imm2))
135    (cmp len (:$ 0))
136    (add offset start (:$ arm::misc-data-offset))
137    (mov accum (:$ 0))
138    (bxeq lr)
139    @loop
140    (subs len len '1)
141    (ldr nextw (:@ str offset))
142    (add offset offset (:$ 4))
143    (mov accum (:ror accum (:$ 27)))
144    (eor accum accum nextw)
145    (bne @loop)
146    (mov accum (:lsl accum (:$ 5)))
147    (mov arg_z (:lsr accum (:$ (- 5 arm::fixnumshift))))
148    (bx lr)))
Note: See TracBrowser for help on using the repository browser.