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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 15085006: Inline Uint32x4 operations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 V(_Float32x4, _reciprocalSqrt, Float32x4ReciprocalSqrt, 42621627) \ 96 V(_Float32x4, _reciprocalSqrt, Float32x4ReciprocalSqrt, 42621627) \
97 V(_Float32x4, _reciprocal, Float32x4Reciprocal, 42621627) \ 97 V(_Float32x4, _reciprocal, Float32x4Reciprocal, 42621627) \
98 V(_Float32x4, _negate, Float32x4Negate, 42621627) \ 98 V(_Float32x4, _negate, Float32x4Negate, 42621627) \
99 V(_Float32x4, _abs, Float32x4Absolute, 42621627) \ 99 V(_Float32x4, _abs, Float32x4Absolute, 42621627) \
100 V(_Float32x4, _clamp, Float32x4Clamp, 615895313) \ 100 V(_Float32x4, _clamp, Float32x4Clamp, 615895313) \
101 V(_Float32x4, withX, Float32x4WithX, 219466242) \ 101 V(_Float32x4, withX, Float32x4WithX, 219466242) \
102 V(_Float32x4, withY, Float32x4WithY, 219466242) \ 102 V(_Float32x4, withY, Float32x4WithY, 219466242) \
103 V(_Float32x4, withZ, Float32x4WithZ, 219466242) \ 103 V(_Float32x4, withZ, Float32x4WithZ, 219466242) \
104 V(_Float32x4, withW, Float32x4WithW, 219466242) \ 104 V(_Float32x4, withW, Float32x4WithW, 219466242) \
105 V(_Float32x4, _toUint32x4, Float32x4ToUint32x4, 1044409108) \ 105 V(_Float32x4, _toUint32x4, Float32x4ToUint32x4, 1044409108) \
106 V(Uint32x4, Uint32x4.bool, Uint32x4BoolConstructor, 1489869343) \
107 V(_Uint32x4, get:flagX, Uint32x4GetFlagX, 782547529) \
108 V(_Uint32x4, get:flagY, Uint32x4GetFlagY, 782547529) \
109 V(_Uint32x4, get:flagZ, Uint32x4GetFlagZ, 782547529) \
110 V(_Uint32x4, get:flagW, Uint32x4GetFlagW, 782547529) \
111 V(_Uint32x4, select, Uint32x4Select, 405662786) \
112 V(_Uint32x4, withFlagX, Uint32x4WithFlagX, 980864994) \
113 V(_Uint32x4, withFlagY, Uint32x4WithFlagY, 980864994) \
114 V(_Uint32x4, withFlagZ, Uint32x4WithFlagZ, 980864994) \
115 V(_Uint32x4, withFlagW, Uint32x4WithFlagW, 980864994) \
116 V(_Uint32x4, _toFloat32x4, Uint32x4ToUint32x4, 311564070) \
106 117
107 118
108 // Class that recognizes the name and owner of a function and returns the 119 // Class that recognizes the name and owner of a function and returns the
109 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable 120 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable
110 // functions. 121 // functions.
111 class MethodRecognizer : public AllStatic { 122 class MethodRecognizer : public AllStatic {
112 public: 123 public:
113 enum Kind { 124 enum Kind {
114 kUnknown, 125 kUnknown,
115 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, 126 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name,
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 M(Float32x4Splat) \ 592 M(Float32x4Splat) \
582 M(Float32x4Comparison) \ 593 M(Float32x4Comparison) \
583 M(Float32x4MinMax) \ 594 M(Float32x4MinMax) \
584 M(Float32x4Scale) \ 595 M(Float32x4Scale) \
585 M(Float32x4Sqrt) \ 596 M(Float32x4Sqrt) \
586 M(Float32x4ZeroArg) \ 597 M(Float32x4ZeroArg) \
587 M(Float32x4Clamp) \ 598 M(Float32x4Clamp) \
588 M(Float32x4With) \ 599 M(Float32x4With) \
589 M(Float32x4ToUint32x4) \ 600 M(Float32x4ToUint32x4) \
590 M(MaterializeObject) \ 601 M(MaterializeObject) \
602 M(Uint32x4BoolConstructor) \
603 M(Uint32x4GetFlag) \
604 M(Uint32x4Select) \
605 M(Uint32x4SetFlag) \
606 M(Uint32x4ToFloat32x4) \
607 M(BinaryUint32x4Op) \
608
591 609
592 #define FORWARD_DECLARATION(type) class type##Instr; 610 #define FORWARD_DECLARATION(type) class type##Instr;
593 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 611 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
594 #undef FORWARD_DECLARATION 612 #undef FORWARD_DECLARATION
595 613
596 614
597 // Functions required in all concrete instruction classes. 615 // Functions required in all concrete instruction classes.
598 #define DECLARE_INSTRUCTION(type) \ 616 #define DECLARE_INSTRUCTION(type) \
599 virtual Tag tag() const { return k##type; } \ 617 virtual Tag tag() const { return k##type; } \
600 virtual void Accept(FlowGraphVisitor* visitor); \ 618 virtual void Accept(FlowGraphVisitor* visitor); \
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 friend class Float32x4ShuffleInstr; 866 friend class Float32x4ShuffleInstr;
849 friend class Float32x4ConstructorInstr; 867 friend class Float32x4ConstructorInstr;
850 friend class Float32x4ComparisonInstr; 868 friend class Float32x4ComparisonInstr;
851 friend class Float32x4MinMaxInstr; 869 friend class Float32x4MinMaxInstr;
852 friend class Float32x4ScaleInstr; 870 friend class Float32x4ScaleInstr;
853 friend class Float32x4SqrtInstr; 871 friend class Float32x4SqrtInstr;
854 friend class Float32x4ZeroArgInstr; 872 friend class Float32x4ZeroArgInstr;
855 friend class Float32x4ClampInstr; 873 friend class Float32x4ClampInstr;
856 friend class Float32x4WithInstr; 874 friend class Float32x4WithInstr;
857 friend class Float32x4ToUint32x4Instr; 875 friend class Float32x4ToUint32x4Instr;
876 friend class Uint32x4BoolConstructorInstr;
877 friend class Uint32x4GetFlagInstr;
878 friend class Uint32x4SetFlagInstr;
879 friend class Uint32x4SelectInstr;
880 friend class Uint32x4ToFloat32x4Instr;
881 friend class BinaryUint32x4OpInstr;
858 friend class BinaryMintOpInstr; 882 friend class BinaryMintOpInstr;
859 friend class BinarySmiOpInstr; 883 friend class BinarySmiOpInstr;
860 friend class UnarySmiOpInstr; 884 friend class UnarySmiOpInstr;
861 friend class ShiftMintOpInstr; 885 friend class ShiftMintOpInstr;
862 friend class UnaryMintOpInstr; 886 friend class UnaryMintOpInstr;
863 friend class MathSqrtInstr; 887 friend class MathSqrtInstr;
864 friend class CheckClassInstr; 888 friend class CheckClassInstr;
865 friend class GuardFieldInstr; 889 friend class GuardFieldInstr;
866 friend class CheckSmiInstr; 890 friend class CheckSmiInstr;
867 friend class CheckArrayBoundInstr; 891 friend class CheckArrayBoundInstr;
(...skipping 4156 matching lines...) Expand 10 before | Expand all | Expand 10 after
5024 virtual bool AllowsCSE() const { return true; } 5048 virtual bool AllowsCSE() const { return true; }
5025 virtual EffectSet Effects() const { return EffectSet::None(); } 5049 virtual EffectSet Effects() const { return EffectSet::None(); }
5026 virtual EffectSet Dependencies() const { return EffectSet::None(); } 5050 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5027 virtual bool AttributesEqual(Instruction* other) const { return true; } 5051 virtual bool AttributesEqual(Instruction* other) const { return true; }
5028 5052
5029 private: 5053 private:
5030 DISALLOW_COPY_AND_ASSIGN(Float32x4ToUint32x4Instr); 5054 DISALLOW_COPY_AND_ASSIGN(Float32x4ToUint32x4Instr);
5031 }; 5055 };
5032 5056
5033 5057
5058 class Uint32x4BoolConstructorInstr : public TemplateDefinition<4> {
5059 public:
5060 Uint32x4BoolConstructorInstr(Value* value0, Value* value1, Value* value2,
5061 Value* value3, StaticCallInstr* static_call) {
5062 SetInputAt(0, value0);
5063 SetInputAt(1, value1);
5064 SetInputAt(2, value2);
5065 SetInputAt(3, value3);
5066 deopt_id_ = static_call->deopt_id();
srdjan 2013/05/10 18:36:58 If you do not need the call, pass the deopt_id onl
Cutch 2013/05/13 19:40:24 Done.
5067 }
5068
5069 Value* value0() const { return inputs_[0]; }
5070 Value* value1() const { return inputs_[1]; }
5071 Value* value2() const { return inputs_[2]; }
5072 Value* value3() const { return inputs_[3]; }
5073
5074 virtual void PrintOperandsTo(BufferFormatter* f) const;
5075
5076 virtual bool CanDeoptimize() const { return false; }
5077
5078 virtual Representation representation() const {
5079 return kUnboxedUint32x4;
5080 }
5081
5082 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5083 ASSERT(idx >= 0 && idx < 4);
5084 return kTagged;
5085 }
5086
5087 virtual intptr_t DeoptimizationTarget() const {
5088 // Direct access since this instruction cannot deoptimize, and the deopt-id
5089 // was inherited from another instruction that could deoptimize.
5090 return deopt_id_;
5091 }
5092
5093 DECLARE_INSTRUCTION(Uint32x4BoolConstructor)
5094 virtual CompileType ComputeType() const;
5095
5096 virtual bool AllowsCSE() const { return true; }
5097 virtual EffectSet Effects() const { return EffectSet::None(); }
5098 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5099 virtual bool AttributesEqual(Instruction* other) const { return true; }
5100
5101 private:
5102 DISALLOW_COPY_AND_ASSIGN(Uint32x4BoolConstructorInstr);
5103 };
5104
5105
5106 class Uint32x4GetFlagInstr : public TemplateDefinition<1> {
5107 public:
5108 Uint32x4GetFlagInstr(MethodRecognizer::Kind op_kind, Value* value,
5109 InstanceCallInstr* instance_call)
5110 : op_kind_(op_kind) {
5111 SetInputAt(0, value);
5112 deopt_id_ = instance_call->deopt_id();
5113 }
5114
5115 Value* value() const { return inputs_[0]; }
5116
5117 MethodRecognizer::Kind op_kind() const { return op_kind_; }
5118
5119 virtual void PrintOperandsTo(BufferFormatter* f) const;
5120
5121 virtual bool CanDeoptimize() const { return false; }
5122
5123 virtual Representation representation() const {
5124 return kTagged;
5125 }
5126
5127 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5128 ASSERT(idx == 0);
5129 return kUnboxedUint32x4;
5130 }
5131
5132 virtual intptr_t DeoptimizationTarget() const {
5133 // Direct access since this instruction cannot deoptimize, and the deopt-id
5134 // was inherited from another instruction that could deoptimize.
5135 return deopt_id_;
5136 }
5137
5138 DECLARE_INSTRUCTION(Uint32x4GetFlag)
5139 virtual CompileType ComputeType() const;
5140
5141 virtual bool AllowsCSE() const { return true; }
5142 virtual EffectSet Effects() const { return EffectSet::None(); }
5143 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5144 virtual bool AttributesEqual(Instruction* other) const {
5145 return op_kind() == other->AsUint32x4GetFlag()->op_kind();
5146 }
5147
5148 private:
5149 const MethodRecognizer::Kind op_kind_;
5150
5151 DISALLOW_COPY_AND_ASSIGN(Uint32x4GetFlagInstr);
5152 };
5153
5154
5155 class Uint32x4SelectInstr : public TemplateDefinition<3> {
5156 public:
5157 Uint32x4SelectInstr(Value* mask, Value* trueValue, Value* falseValue,
5158 InstanceCallInstr* instance_call) {
5159 SetInputAt(0, mask);
5160 SetInputAt(1, trueValue);
5161 SetInputAt(2, falseValue);
5162 deopt_id_ = instance_call->deopt_id();
5163 }
5164
5165 Value* mask() const { return inputs_[0]; }
5166 Value* trueValue() const { return inputs_[1]; }
5167 Value* falseValue() const { return inputs_[2]; }
5168
5169 virtual void PrintOperandsTo(BufferFormatter* f) const;
5170
5171 virtual bool CanDeoptimize() const { return false; }
5172
5173 virtual Representation representation() const {
5174 return kUnboxedFloat32x4;
5175 }
5176
5177 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5178 ASSERT((idx == 0) || (idx == 1) || (idx == 2));
5179 if (idx == 0) {
5180 return kUnboxedUint32x4;
5181 }
5182 return kUnboxedFloat32x4;
5183 }
5184
5185 virtual intptr_t DeoptimizationTarget() const {
5186 // Direct access since this instruction cannot deoptimize, and the deopt-id
5187 // was inherited from another instruction that could deoptimize.
5188 return deopt_id_;
5189 }
5190
5191 DECLARE_INSTRUCTION(Uint32x4Select)
5192 virtual CompileType ComputeType() const;
5193
5194 virtual bool AllowsCSE() const { return true; }
5195 virtual EffectSet Effects() const { return EffectSet::None(); }
5196 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5197 virtual bool AttributesEqual(Instruction* other) const { return true; }
5198
5199 private:
5200 DISALLOW_COPY_AND_ASSIGN(Uint32x4SelectInstr);
5201 };
5202
5203
5204 class Uint32x4SetFlagInstr : public TemplateDefinition<2> {
5205 public:
5206 Uint32x4SetFlagInstr(MethodRecognizer::Kind op_kind, Value* value,
5207 Value* flagValue, InstanceCallInstr* instance_call)
5208 : op_kind_(op_kind) {
5209 SetInputAt(0, value);
5210 SetInputAt(1, flagValue);
5211 deopt_id_ = instance_call->deopt_id();
5212 }
5213
5214 Value* value() const { return inputs_[0]; }
5215 Value* flagValue() const { return inputs_[1]; }
5216
5217 MethodRecognizer::Kind op_kind() const { return op_kind_; }
5218
5219 virtual void PrintOperandsTo(BufferFormatter* f) const;
5220
5221 virtual bool CanDeoptimize() const { return false; }
5222
5223 virtual Representation representation() const {
5224 return kUnboxedUint32x4;
5225 }
5226
5227 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5228 ASSERT((idx == 0) || (idx == 1));
5229 if (idx == 1) {
5230 return kTagged;
5231 }
5232 return kUnboxedUint32x4;
5233 }
5234
5235 virtual intptr_t DeoptimizationTarget() const {
5236 // Direct access since this instruction cannot deoptimize, and the deopt-id
5237 // was inherited from another instruction that could deoptimize.
5238 return deopt_id_;
5239 }
5240
5241 DECLARE_INSTRUCTION(Uint32x4SetFlag)
5242 virtual CompileType ComputeType() const;
5243
5244 virtual bool AllowsCSE() const { return true; }
5245 virtual EffectSet Effects() const { return EffectSet::None(); }
5246 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5247 virtual bool AttributesEqual(Instruction* other) const {
5248 return op_kind() == other->AsUint32x4SetFlag()->op_kind();
5249 }
5250
5251 private:
5252 const MethodRecognizer::Kind op_kind_;
5253
5254 DISALLOW_COPY_AND_ASSIGN(Uint32x4SetFlagInstr);
5255 };
5256
5257
5258 class Uint32x4ToFloat32x4Instr : public TemplateDefinition<1> {
5259 public:
5260 Uint32x4ToFloat32x4Instr(Value* left, InstanceCallInstr* instance_call) {
5261 SetInputAt(0, left);
5262 deopt_id_ = instance_call->deopt_id();
5263 }
5264
5265 Value* left() const { return inputs_[0]; }
5266
5267 virtual void PrintOperandsTo(BufferFormatter* f) const;
5268
5269 virtual bool CanDeoptimize() const { return false; }
5270
5271 virtual Representation representation() const {
5272 return kUnboxedFloat32x4;
5273 }
5274
5275 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5276 ASSERT(idx == 0);
5277 return kUnboxedUint32x4;
5278 }
5279
5280 virtual intptr_t DeoptimizationTarget() const {
5281 // Direct access since this instruction cannot deoptimize, and the deopt-id
5282 // was inherited from another instruction that could deoptimize.
5283 return deopt_id_;
5284 }
5285
5286 DECLARE_INSTRUCTION(Uint32x4ToFloat32x4)
5287 virtual CompileType ComputeType() const;
5288
5289 virtual bool AllowsCSE() const { return true; }
5290 virtual EffectSet Effects() const { return EffectSet::None(); }
5291 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5292 virtual bool AttributesEqual(Instruction* other) const { return true; }
5293
5294 private:
5295 DISALLOW_COPY_AND_ASSIGN(Uint32x4ToFloat32x4Instr);
5296 };
5297
5298
5299 class BinaryUint32x4OpInstr : public TemplateDefinition<2> {
5300 public:
5301 BinaryUint32x4OpInstr(Token::Kind op_kind,
5302 Value* left,
5303 Value* right,
5304 InstanceCallInstr* instance_call)
5305 : op_kind_(op_kind) {
5306 SetInputAt(0, left);
5307 SetInputAt(1, right);
5308 deopt_id_ = instance_call->deopt_id();
5309 }
5310
5311 Value* left() const { return inputs_[0]; }
5312 Value* right() const { return inputs_[1]; }
5313
5314 Token::Kind op_kind() const { return op_kind_; }
5315
5316 virtual void PrintOperandsTo(BufferFormatter* f) const;
5317
5318 virtual bool CanDeoptimize() const { return false; }
5319
5320 virtual Representation representation() const {
5321 return kUnboxedUint32x4;
5322 }
5323
5324 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
5325 ASSERT((idx == 0) || (idx == 1));
5326 return kUnboxedUint32x4;
5327 }
5328
5329 virtual intptr_t DeoptimizationTarget() const {
5330 // Direct access since this instruction cannot deoptimize, and the deopt-id
5331 // was inherited from another instruction that could deoptimize.
5332 return deopt_id_;
5333 }
5334
5335 DECLARE_INSTRUCTION(BinaryUint32x4Op)
5336 virtual CompileType ComputeType() const;
5337
5338 virtual bool AllowsCSE() const { return true; }
5339 virtual EffectSet Effects() const { return EffectSet::None(); }
5340 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5341 virtual bool AttributesEqual(Instruction* other) const {
5342 return op_kind() == other->AsBinaryUint32x4Op()->op_kind();
5343 }
5344
5345 private:
5346 const Token::Kind op_kind_;
5347
5348 DISALLOW_COPY_AND_ASSIGN(BinaryUint32x4OpInstr);
5349 };
5350
5034 class BinaryMintOpInstr : public TemplateDefinition<2> { 5351 class BinaryMintOpInstr : public TemplateDefinition<2> {
5035 public: 5352 public:
5036 BinaryMintOpInstr(Token::Kind op_kind, 5353 BinaryMintOpInstr(Token::Kind op_kind,
5037 Value* left, 5354 Value* left,
5038 Value* right, 5355 Value* right,
5039 InstanceCallInstr* instance_call) 5356 InstanceCallInstr* instance_call)
5040 : op_kind_(op_kind), 5357 : op_kind_(op_kind),
5041 instance_call_(instance_call) { 5358 instance_call_(instance_call) {
5042 SetInputAt(0, left); 5359 SetInputAt(0, left);
5043 SetInputAt(1, right); 5360 SetInputAt(1, right);
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
5842 ForwardInstructionIterator* current_iterator_; 6159 ForwardInstructionIterator* current_iterator_;
5843 6160
5844 private: 6161 private:
5845 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6162 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
5846 }; 6163 };
5847 6164
5848 6165
5849 } // namespace dart 6166 } // namespace dart
5850 6167
5851 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6168 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698