]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Introduce HInstrVec, HInstrIfThenElse and HInstrSB into host_generic_regs.h.
authorIvo Raisr <ivosh@ivosh.net>
Tue, 8 Aug 2017 04:57:43 +0000 (06:57 +0200)
committerIvo Raisr <ivosh@ivosh.net>
Mon, 28 Aug 2017 21:21:06 +0000 (23:21 +0200)
VEX/priv/host_generic_regs.h

index 3db9ea0813262f5da9c12fc71608c5b7ce6c220e..bc6f230ed28719df9731471162481a1ca177fc38 100644 (file)
@@ -359,41 +359,85 @@ static inline void initHRegRemap ( HRegRemap* map )
 /* A type is needed to refer to pointers to instructions of any
    target.  Defining it like this means that HInstr* can stand in for
    X86Instr*, ArmInstr*, etc. */
-
 typedef  void  HInstr;
 
 
-/* An expandable array of HInstr*'s.  Handy for insn selection and
-   register allocation.  n_vregs indicates the number of virtual
-   registers mentioned in the code, something that reg-alloc needs to
-   know.  These are required to be numbered 0 .. n_vregs-1. 
-*/
+/* An expandable vector of HInstr*'s.  Handy for insn selection and
+   register allocation. */
 typedef
    struct {
-      HInstr** arr;
-      Int      arr_size;
-      Int      arr_used;
-      Int      n_vregs;
+      HInstr** insns;
+      UInt     insns_size;
+      UInt     insns_used;
    }
-   HInstrArray;
+   HInstrVec;
 
-extern HInstrArray* newHInstrArray ( void );
+extern HInstrVec* newHInstrVec(void);
 
 /* Never call this directly.  It's the slow and incomplete path for
    addHInstr. */
 __attribute__((noinline))
-extern void addHInstr_SLOW ( HInstrArray*, HInstr* );
+extern void addHInstr_SLOW(HInstrVec*, HInstr*);
 
-static inline void addHInstr ( HInstrArray* ha, HInstr* instr )
+static inline void addHInstr(HInstrVec* ha, HInstr* instr)
 {
-   if (LIKELY(ha->arr_used < ha->arr_size)) {
-      ha->arr[ha->arr_used] = instr;
-      ha->arr_used++;
+   if (LIKELY(ha->insns_used < ha->insns_size)) {
+      ha->insns[ha->insns_used] = instr;
+      ha->insns_used++;
    } else {
       addHInstr_SLOW(ha, instr);
    }
 }
 
+/* Host-independent condition code. Stands for X86CondCode, ARM64CondCode... */
+typedef UInt HCondCode;
+
+
+/* Phi node expressed in terms of HReg's. Analogy to IRPhi. */
+typedef
+   struct {
+      HReg dst;
+      HReg srcFallThrough;
+      HReg srcOutOfLine;
+   }
+   HPhiNode;
+
+extern void ppHPhiNode(const HPhiNode* phi_node);
+
+
+/* Represents two alternative code paths:
+   - One more likely taken (hot path ~ fall through)
+   - One not so likely taken (cold path ~ out of line, OOL) */
+typedef
+   struct {
+      HCondCode  ccOOL;         // condition code for the OOL branch
+      HInstrVec* fallThrough;   // generated from the likely-taken IR
+      HInstrVec* outOfLine;     // generated from likely-not-taken IR
+      HPhiNode*  phi_nodes;
+      UInt       n_phis;
+   }
+   HInstrIfThenElse;
+
+extern HInstrIfThenElse* newHInstrIfThenElse(HCondCode, HPhiNode* phi_nodes,
+                                             UInt n_phis);
+
+/* Code block of HInstr's.
+   n_vregs indicates the number of virtual registers mentioned in the code,
+   something that reg-alloc needs to know. These are required to be
+   numbered 0 .. n_vregs-1. */
+typedef
+   struct {
+      HInstrVec* insns;
+      UInt       n_vregs;
+   }
+   HInstrSB;
+
+extern HInstrSB* newHInstrSB(void);
+extern void ppHInstrSB(const HInstrSB* code,
+                       HInstrIfThenElse* (*isIfThenElse)(const HInstr*),
+                       void (*ppInstr)(const HInstr*, Bool),
+                       void (*ppCondCode)(HCondCode), Bool mode64);
+
 
 /*---------------------------------------------------------*/
 /*--- C-Call return-location descriptions               ---*/
@@ -481,6 +525,10 @@ typedef
       /* Apply a reg-reg mapping to an insn. */
       void (*mapRegs)(HRegRemap*, HInstr*, Bool);
 
+      /* Is this instruction actually HInstrIfThenElse? Returns pointer to
+         HInstrIfThenElse if yes, NULL otherwise. */
+      HInstrIfThenElse* (*isIfThenElse) (const HInstr*),
+
       /* Return insn(s) to spill/restore a real register to a spill slot offset.
          Also a function to move between registers.
          And optionally a function to do direct reloads. */
@@ -492,6 +540,7 @@ typedef
 
       /* For debug printing only. */
       void (*ppInstr)(const HInstr*, Bool);
+      void (*ppCondCode)(HCondCode),
       UInt (*ppReg)(HReg);
 
       /* 32/64bit mode */
@@ -499,12 +548,12 @@ typedef
    }
    RegAllocControl;
 
-extern HInstrArray* doRegisterAllocation_v2(
-   HInstrArray* instrs_in,
+extern HInstrSB* doRegisterAllocation_v2(
+   HInstrSB* sb_in,
    const RegAllocControl* con
 );
-extern HInstrArray* doRegisterAllocation_v3(
-   HInstrArray* instrs_in,
+extern HInstrSB* doRegisterAllocation_v3(
+   HInstrSB* sb_in,
    const RegAllocControl* con
 );