Index: src/compiler/instruction-selector.h |
diff --git a/src/compiler/instruction-selector.h b/src/compiler/instruction-selector.h |
index b6c7039aefd709d5c0f21d438bd3832756a5d947..015879f8603e394f73bfc50fab0843824dedff32 100644 |
--- a/src/compiler/instruction-selector.h |
+++ b/src/compiler/instruction-selector.h |
@@ -22,8 +22,12 @@ class FlagsContinuation; |
class InstructionSelector V8_FINAL { |
public: |
- explicit InstructionSelector(InstructionSequence* sequence, |
- SourcePositionTable* source_positions); |
+ // Forward declarations. |
+ class Features; |
+ |
+ InstructionSelector(InstructionSequence* sequence, |
+ SourcePositionTable* source_positions, |
+ Features features = SupportedFeatures()); |
// Visit code for the entire graph with the included schedule. |
void SelectInstructions(); |
@@ -54,6 +58,32 @@ class InstructionSelector V8_FINAL { |
InstructionOperand* *temps = NULL); |
Instruction* Emit(Instruction* instr); |
+ // =========================================================================== |
+ // ============== Architecture-independent CPU feature methods. ============== |
+ // =========================================================================== |
+ |
+ class Features V8_FINAL { |
+ public: |
+ Features() : bits_(0) {} |
+ explicit Features(unsigned bits) : bits_(bits) {} |
+ explicit Features(CpuFeature f) : bits_(1u << f) {} |
+ Features(CpuFeature f1, CpuFeature f2) : bits_((1u << f1) | (1u << f2)) {} |
+ |
+ bool Contains(CpuFeature f) const { return (bits_ & (1u << f)); } |
+ |
+ private: |
+ unsigned bits_; |
+ }; |
+ |
+ bool IsSupported(CpuFeature feature) const { |
+ return features_.Contains(feature); |
+ } |
+ |
+ // Returns the features supported on the target platform. |
+ static Features SupportedFeatures() { |
+ return Features(CpuFeatures::SupportedFeatures()); |
+ } |
+ |
private: |
friend class OperandGenerator; |
@@ -168,6 +198,7 @@ class InstructionSelector V8_FINAL { |
Zone zone_; |
InstructionSequence* sequence_; |
SourcePositionTable* source_positions_; |
+ Features features_; |
BasicBlock* current_block_; |
Instructions instructions_; |
BoolVector defined_; |