Home | History | Annotate | Download | only in compiler
      1 // Copyright 2014 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_REGISTER_ALLOCATOR_VERIFIER_H_
      6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_
      7 
      8 #include "src/zone-containers.h"
      9 
     10 namespace v8 {
     11 namespace internal {
     12 namespace compiler {
     13 
     14 class InstructionOperand;
     15 class InstructionSequence;
     16 
     17 class RegisterAllocatorVerifier final : public ZoneObject {
     18  public:
     19   RegisterAllocatorVerifier(Zone* zone, const RegisterConfiguration* config,
     20                             const InstructionSequence* sequence);
     21 
     22   void VerifyAssignment();
     23   void VerifyGapMoves();
     24 
     25  private:
     26   enum ConstraintType {
     27     kConstant,
     28     kImmediate,
     29     kRegister,
     30     kFixedRegister,
     31     kDoubleRegister,
     32     kFixedDoubleRegister,
     33     kSlot,
     34     kDoubleSlot,
     35     kFixedSlot,
     36     kNone,
     37     kNoneDouble,
     38     kExplicit,
     39     kSameAsFirst,
     40     kRegisterAndSlot
     41   };
     42 
     43   struct OperandConstraint {
     44     ConstraintType type_;
     45     int value_;  // subkind index when relevant
     46     int spilled_slot_;
     47     int virtual_register_;
     48   };
     49 
     50   struct InstructionConstraint {
     51     const Instruction* instruction_;
     52     size_t operand_constaints_size_;
     53     OperandConstraint* operand_constraints_;
     54   };
     55 
     56   class BlockMaps;
     57 
     58   typedef ZoneVector<InstructionConstraint> Constraints;
     59 
     60   Zone* zone() const { return zone_; }
     61   const RegisterConfiguration* config() { return config_; }
     62   const InstructionSequence* sequence() const { return sequence_; }
     63   Constraints* constraints() { return &constraints_; }
     64 
     65   static void VerifyInput(const OperandConstraint& constraint);
     66   static void VerifyTemp(const OperandConstraint& constraint);
     67   static void VerifyOutput(const OperandConstraint& constraint);
     68 
     69   void BuildConstraint(const InstructionOperand* op,
     70                        OperandConstraint* constraint);
     71   void CheckConstraint(const InstructionOperand* op,
     72                        const OperandConstraint* constraint);
     73 
     74   void VerifyGapMoves(BlockMaps* outgoing_mappings, bool initial_pass);
     75 
     76   Zone* const zone_;
     77   const RegisterConfiguration* config_;
     78   const InstructionSequence* const sequence_;
     79   Constraints constraints_;
     80 
     81   DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier);
     82 };
     83 
     84 }  // namespace compiler
     85 }  // namespace internal
     86 }  // namespace v8
     87 
     88 #endif
     89