Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/machine-operator.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/machine-node-factory.h ('k') | src/compiler/machine-operator-reducer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_H_
7
8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h"
10 #include "src/zone.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 // An enumeration of the storage representations at the machine level.
17 // - Words are uninterpreted bits of a given fixed size that can be used
18 // to store integers and pointers. They are normally allocated to general
19 // purpose registers by the backend and are not tracked for GC.
20 // - Floats are bits of a given fixed size that are used to store floating
21 // point numbers. They are normally allocated to the floating point
22 // registers of the machine and are not tracked for the GC.
23 // - Tagged values are the size of a reference into the heap and can store
24 // small words or references into the heap using a language and potentially
25 // machine-dependent tagging scheme. These values are tracked by the code
26 // generator for precise GC.
27 enum MachineRepresentation {
28 kMachineWord8,
29 kMachineWord16,
30 kMachineWord32,
31 kMachineWord64,
32 kMachineFloat64,
33 kMachineTagged,
34 kMachineLast
35 };
36
37
38 // TODO(turbofan): other write barriers are possible based on type
39 enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier };
40
41
42 // A Store needs a MachineRepresentation and a WriteBarrierKind
43 // in order to emit the correct write barrier.
44 struct StoreRepresentation {
45 MachineRepresentation rep;
46 WriteBarrierKind write_barrier_kind;
47 };
48
49
50 // Interface for building machine-level operators. These operators are
51 // machine-level but machine-independent and thus define a language suitable
52 // for generating code to run on architectures such as ia32, x64, arm, etc.
53 class MachineOperatorBuilder {
54 public:
55 explicit MachineOperatorBuilder(Zone* zone,
56 MachineRepresentation word = pointer_rep())
57 : zone_(zone), word_(word) {
58 CHECK(word == kMachineWord32 || word == kMachineWord64);
59 }
60
61 #define SIMPLE(name, properties, inputs, outputs) \
62 return new (zone_) \
63 SimpleOperator(IrOpcode::k##name, properties, inputs, outputs, #name);
64
65 #define OP1(name, ptype, pname, properties, inputs, outputs) \
66 return new (zone_) \
67 Operator1<ptype>(IrOpcode::k##name, properties | Operator::kNoThrow, \
68 inputs, outputs, #name, pname)
69
70 #define BINOP(name) SIMPLE(name, Operator::kPure, 2, 1)
71 #define BINOP_C(name) \
72 SIMPLE(name, Operator::kCommutative | Operator::kPure, 2, 1)
73 #define BINOP_AC(name) \
74 SIMPLE(name, \
75 Operator::kAssociative | Operator::kCommutative | Operator::kPure, 2, \
76 1)
77 #define UNOP(name) SIMPLE(name, Operator::kPure, 1, 1)
78
79 #define WORD_SIZE(x) return is64() ? Word64##x() : Word32##x()
80
81 Operator* Load(MachineRepresentation rep) { // load [base + index]
82 OP1(Load, MachineRepresentation, rep, Operator::kNoWrite, 2, 1);
83 }
84 // store [base + index], value
85 Operator* Store(MachineRepresentation rep,
86 WriteBarrierKind kind = kNoWriteBarrier) {
87 StoreRepresentation store_rep = {rep, kind};
88 OP1(Store, StoreRepresentation, store_rep, Operator::kNoRead, 3, 0);
89 }
90
91 Operator* WordAnd() { WORD_SIZE(And); }
92 Operator* WordOr() { WORD_SIZE(Or); }
93 Operator* WordXor() { WORD_SIZE(Xor); }
94 Operator* WordShl() { WORD_SIZE(Shl); }
95 Operator* WordShr() { WORD_SIZE(Shr); }
96 Operator* WordSar() { WORD_SIZE(Sar); }
97 Operator* WordEqual() { WORD_SIZE(Equal); }
98
99 Operator* Word32And() { BINOP_AC(Word32And); }
100 Operator* Word32Or() { BINOP_AC(Word32Or); }
101 Operator* Word32Xor() { BINOP_AC(Word32Xor); }
102 Operator* Word32Shl() { BINOP(Word32Shl); }
103 Operator* Word32Shr() { BINOP(Word32Shr); }
104 Operator* Word32Sar() { BINOP(Word32Sar); }
105 Operator* Word32Equal() { BINOP_C(Word32Equal); }
106
107 Operator* Word64And() { BINOP_AC(Word64And); }
108 Operator* Word64Or() { BINOP_AC(Word64Or); }
109 Operator* Word64Xor() { BINOP_AC(Word64Xor); }
110 Operator* Word64Shl() { BINOP(Word64Shl); }
111 Operator* Word64Shr() { BINOP(Word64Shr); }
112 Operator* Word64Sar() { BINOP(Word64Sar); }
113 Operator* Word64Equal() { BINOP_C(Word64Equal); }
114
115 Operator* Int32Add() { BINOP_AC(Int32Add); }
116 Operator* Int32Sub() { BINOP(Int32Sub); }
117 Operator* Int32Mul() { BINOP_AC(Int32Mul); }
118 Operator* Int32Div() { BINOP(Int32Div); }
119 Operator* Int32UDiv() { BINOP(Int32UDiv); }
120 Operator* Int32Mod() { BINOP(Int32Mod); }
121 Operator* Int32UMod() { BINOP(Int32UMod); }
122 Operator* Int32LessThan() { BINOP(Int32LessThan); }
123 Operator* Int32LessThanOrEqual() { BINOP(Int32LessThanOrEqual); }
124 Operator* Uint32LessThan() { BINOP(Uint32LessThan); }
125 Operator* Uint32LessThanOrEqual() { BINOP(Uint32LessThanOrEqual); }
126
127 Operator* Int64Add() { BINOP_AC(Int64Add); }
128 Operator* Int64Sub() { BINOP(Int64Sub); }
129 Operator* Int64Mul() { BINOP_AC(Int64Mul); }
130 Operator* Int64Div() { BINOP(Int64Div); }
131 Operator* Int64UDiv() { BINOP(Int64UDiv); }
132 Operator* Int64Mod() { BINOP(Int64Mod); }
133 Operator* Int64UMod() { BINOP(Int64UMod); }
134 Operator* Int64LessThan() { BINOP(Int64LessThan); }
135 Operator* Int64LessThanOrEqual() { BINOP(Int64LessThanOrEqual); }
136
137 Operator* ConvertInt32ToInt64() { UNOP(ConvertInt32ToInt64); }
138 Operator* ConvertInt64ToInt32() { UNOP(ConvertInt64ToInt32); }
139 Operator* ConvertInt32ToFloat64() { UNOP(ConvertInt32ToFloat64); }
140 Operator* ConvertUint32ToFloat64() { UNOP(ConvertUint32ToFloat64); }
141 // TODO(titzer): add rounding mode to floating point conversion.
142 Operator* ConvertFloat64ToInt32() { UNOP(ConvertFloat64ToInt32); }
143 Operator* ConvertFloat64ToUint32() { UNOP(ConvertFloat64ToUint32); }
144
145 // TODO(titzer): do we need different rounding modes for float arithmetic?
146 Operator* Float64Add() { BINOP_C(Float64Add); }
147 Operator* Float64Sub() { BINOP(Float64Sub); }
148 Operator* Float64Mul() { BINOP_C(Float64Mul); }
149 Operator* Float64Div() { BINOP(Float64Div); }
150 Operator* Float64Mod() { BINOP(Float64Mod); }
151 Operator* Float64Equal() { BINOP_C(Float64Equal); }
152 Operator* Float64LessThan() { BINOP(Float64LessThan); }
153 Operator* Float64LessThanOrEqual() { BINOP(Float64LessThanOrEqual); }
154
155 inline bool is32() const { return word_ == kMachineWord32; }
156 inline bool is64() const { return word_ == kMachineWord64; }
157 inline MachineRepresentation word() const { return word_; }
158
159 static inline MachineRepresentation pointer_rep() {
160 return kPointerSize == 8 ? kMachineWord64 : kMachineWord32;
161 }
162
163 #undef WORD_SIZE
164 #undef UNOP
165 #undef BINOP
166 #undef OP1
167 #undef SIMPLE
168
169 private:
170 Zone* zone_;
171 MachineRepresentation word_;
172 };
173 }
174 }
175 } // namespace v8::internal::compiler
176
177 #endif // V8_COMPILER_MACHINE_OPERATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-node-factory.h ('k') | src/compiler/machine-operator-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698