1 | /*
|
---|
2 | * Copyright (C) 2008 Apple Inc. All rights reserved.
|
---|
3 | *
|
---|
4 | * Redistribution and use in source and binary forms, with or without
|
---|
5 | * modification, are permitted provided that the following conditions
|
---|
6 | * are met:
|
---|
7 | * 1. Redistributions of source code must retain the above copyright
|
---|
8 | * notice, this list of conditions and the following disclaimer.
|
---|
9 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer in the
|
---|
11 | * documentation and/or other materials provided with the distribution.
|
---|
12 | *
|
---|
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
---|
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
---|
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
---|
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef MacroAssemblerX86_h
|
---|
27 | #define MacroAssemblerX86_h
|
---|
28 |
|
---|
29 | #include <wtf/Platform.h>
|
---|
30 |
|
---|
31 | #if ENABLE(ASSEMBLER) && PLATFORM(X86)
|
---|
32 |
|
---|
33 | #include "MacroAssemblerX86Common.h"
|
---|
34 |
|
---|
35 | namespace JSC {
|
---|
36 |
|
---|
37 | class MacroAssemblerX86 : public MacroAssemblerX86Common {
|
---|
38 | public:
|
---|
39 | static const Scale ScalePtr = TimesFour;
|
---|
40 |
|
---|
41 | using MacroAssemblerX86Common::add32;
|
---|
42 | using MacroAssemblerX86Common::sub32;
|
---|
43 | using MacroAssemblerX86Common::load32;
|
---|
44 | using MacroAssemblerX86Common::store32;
|
---|
45 | using MacroAssemblerX86Common::branch32;
|
---|
46 | using MacroAssemblerX86Common::call;
|
---|
47 |
|
---|
48 | void add32(Imm32 imm, RegisterID src, RegisterID dest)
|
---|
49 | {
|
---|
50 | m_assembler.leal_mr(imm.m_value, src, dest);
|
---|
51 | }
|
---|
52 |
|
---|
53 | void add32(Imm32 imm, AbsoluteAddress address)
|
---|
54 | {
|
---|
55 | m_assembler.addl_im(imm.m_value, address.m_ptr);
|
---|
56 | }
|
---|
57 |
|
---|
58 | void sub32(Imm32 imm, AbsoluteAddress address)
|
---|
59 | {
|
---|
60 | m_assembler.subl_im(imm.m_value, address.m_ptr);
|
---|
61 | }
|
---|
62 |
|
---|
63 | void load32(void* address, RegisterID dest)
|
---|
64 | {
|
---|
65 | m_assembler.movl_mr(address, dest);
|
---|
66 | }
|
---|
67 |
|
---|
68 | void store32(Imm32 imm, void* address)
|
---|
69 | {
|
---|
70 | m_assembler.movl_i32m(imm.m_value, address);
|
---|
71 | }
|
---|
72 |
|
---|
73 | Jump branch32(Condition cond, AbsoluteAddress left, RegisterID right)
|
---|
74 | {
|
---|
75 | m_assembler.cmpl_rm(right, left.m_ptr);
|
---|
76 | return Jump(m_assembler.jCC(cond));
|
---|
77 | }
|
---|
78 |
|
---|
79 | Jump branch32(Condition cond, AbsoluteAddress left, Imm32 right)
|
---|
80 | {
|
---|
81 | m_assembler.cmpl_im(right.m_value, left.m_ptr);
|
---|
82 | return Jump(m_assembler.jCC(cond));
|
---|
83 | }
|
---|
84 |
|
---|
85 | Call call()
|
---|
86 | {
|
---|
87 | return Call(m_assembler.call(), Call::Linkable);
|
---|
88 | }
|
---|
89 |
|
---|
90 | Call tailRecursiveCall()
|
---|
91 | {
|
---|
92 | return Call::fromTailJump(jump());
|
---|
93 | }
|
---|
94 |
|
---|
95 | Call makeTailRecursiveCall(Jump oldJump)
|
---|
96 | {
|
---|
97 | return Call::fromTailJump(oldJump);
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | Jump branchPtrWithPatch(Condition cond, RegisterID left, DataLabelPtr& dataLabel, ImmPtr initialRightValue = ImmPtr(0))
|
---|
102 | {
|
---|
103 | m_assembler.cmpl_ir_force32(initialRightValue.asIntptr(), left);
|
---|
104 | dataLabel = DataLabelPtr(this);
|
---|
105 | return Jump(m_assembler.jCC(cond));
|
---|
106 | }
|
---|
107 |
|
---|
108 | Jump branchPtrWithPatch(Condition cond, Address left, DataLabelPtr& dataLabel, ImmPtr initialRightValue = ImmPtr(0))
|
---|
109 | {
|
---|
110 | m_assembler.cmpl_im_force32(initialRightValue.asIntptr(), left.offset, left.base);
|
---|
111 | dataLabel = DataLabelPtr(this);
|
---|
112 | return Jump(m_assembler.jCC(cond));
|
---|
113 | }
|
---|
114 |
|
---|
115 | DataLabelPtr storePtrWithPatch(Address address)
|
---|
116 | {
|
---|
117 | m_assembler.movl_i32m(0, address.offset, address.base);
|
---|
118 | return DataLabelPtr(this);
|
---|
119 | }
|
---|
120 | };
|
---|
121 |
|
---|
122 | } // namespace JSC
|
---|
123 |
|
---|
124 | #endif // ENABLE(ASSEMBLER)
|
---|
125 |
|
---|
126 | #endif // MacroAssemblerX86_h
|
---|