~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/offlineasm/backends.rb

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 Apple Inc. All rights reserved.
 
2
#
 
3
# Redistribution and use in source and binary forms, with or without
 
4
# modification, are permitted provided that the following conditions
 
5
# are met:
 
6
# 1. Redistributions of source code must retain the above copyright
 
7
#    notice, this list of conditions and the following disclaimer.
 
8
# 2. Redistributions in binary form must reproduce the above copyright
 
9
#    notice, this list of conditions and the following disclaimer in the
 
10
#    documentation and/or other materials provided with the distribution.
 
11
#
 
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
13
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
14
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
15
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
16
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
17
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
18
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
19
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
20
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
21
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
22
# THE POSSIBILITY OF SUCH DAMAGE.
 
23
 
 
24
require "config"
 
25
require "armv7"
 
26
require "ast"
 
27
require "x86"
 
28
require "cloop"
 
29
 
 
30
BACKENDS =
 
31
    [
 
32
     "X86",
 
33
     "X86_64",
 
34
     "ARMv7",
 
35
     "C_LOOP"
 
36
    ]
 
37
 
 
38
# Keep the set of working backends separate from the set of backends that might be
 
39
# supported. This is great because the BACKENDS list is almost like a reserved
 
40
# words list, in that it causes settings resolution to treat those words specially.
 
41
# Hence this lets us set aside the name of a backend we might want to support in
 
42
# the future while not actually supporting the backend yet.
 
43
WORKING_BACKENDS =
 
44
    [
 
45
     "X86",
 
46
     "X86_64",
 
47
     "ARMv7",
 
48
     "C_LOOP"
 
49
    ]
 
50
 
 
51
BACKEND_PATTERN = Regexp.new('\\A(' + BACKENDS.join(')|(') + ')\\Z')
 
52
 
 
53
class Node
 
54
    def lower(name)
 
55
        begin
 
56
            $activeBackend = name
 
57
            send("lower" + name)
 
58
        rescue => e
 
59
            e.message << "At #{codeOriginString}"
 
60
            raise e
 
61
        end
 
62
    end
 
63
end
 
64
 
 
65
# Overrides for lower() for those nodes that are backend-agnostic
 
66
 
 
67
class Label
 
68
    def lower(name)
 
69
        $asm.putsLabel(self.name[1..-1])
 
70
    end
 
71
end
 
72
 
 
73
class LocalLabel
 
74
    def lower(name)
 
75
        $asm.putsLocalLabel "_offlineasm_#{self.name[1..-1]}"
 
76
    end
 
77
end
 
78
 
 
79
class LabelReference
 
80
    def asmLabel
 
81
        Assembler.labelReference(name[1..-1])
 
82
    end
 
83
    def cLabel
 
84
        Assembler.cLabelReference(name[1..-1])
 
85
    end
 
86
end
 
87
 
 
88
class LocalLabelReference
 
89
    def asmLabel
 
90
        Assembler.localLabelReference("_offlineasm_"+name[1..-1])
 
91
    end
 
92
    def cLabel
 
93
        Assembler.cLocalLabelReference("_offlineasm_"+name[1..-1])
 
94
    end
 
95
end
 
96
 
 
97
class Skip
 
98
    def lower(name)
 
99
    end
 
100
end
 
101
 
 
102
class Sequence
 
103
    def lower(name)
 
104
        $activeBackend = name
 
105
        if respond_to? "getModifiedList#{name}"
 
106
            newList = send("getModifiedList#{name}")
 
107
            newList.each {
 
108
                | node |
 
109
                node.lower(name)
 
110
            }
 
111
        elsif respond_to? "lower#{name}"
 
112
            send("lower#{name}")
 
113
        else
 
114
            @list.each {
 
115
                | node |
 
116
                node.lower(name)
 
117
            }
 
118
        end
 
119
    end
 
120
end
 
121