Home | History | Annotate | Download | only in Mips
      1 //===-- MipsAnalyzeImmediate.h - Analyze Immediates ------------*- C++ -*--===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 #ifndef MIPS_ANALYZE_IMMEDIATE_H
     10 #define MIPS_ANALYZE_IMMEDIATE_H
     11 
     12 #include "llvm/ADT/SmallVector.h"
     13 #include "llvm/Support/DataTypes.h"
     14 
     15 namespace llvm {
     16 
     17   class MipsAnalyzeImmediate {
     18   public:
     19     struct Inst {
     20       unsigned Opc, ImmOpnd;
     21       Inst(unsigned Opc, unsigned ImmOpnd);
     22     };
     23     typedef SmallVector<Inst, 7 > InstSeq;
     24 
     25     /// Analyze - Get an instrucion sequence to load immediate Imm. The last
     26     /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
     27     /// true;
     28     const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
     29   private:
     30     typedef SmallVector<InstSeq, 5> InstSeqLs;
     31 
     32     /// AddInstr - Add I to all instruction sequences in SeqLs.
     33     void AddInstr(InstSeqLs &SeqLs, const Inst &I);
     34 
     35     /// GetInstSeqLsADDiu - Get instrucion sequences which end with an ADDiu to
     36     /// load immediate Imm
     37     void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
     38 
     39     /// GetInstSeqLsORi - Get instrucion sequences which end with an ORi to
     40     /// load immediate Imm
     41     void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
     42 
     43     /// GetInstSeqLsSLL - Get instrucion sequences which end with a SLL to
     44     /// load immediate Imm
     45     void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
     46 
     47     /// GetInstSeqLs - Get instrucion sequences to load immediate Imm.
     48     void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
     49 
     50     /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
     51     void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
     52 
     53     /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
     54     /// return it in Insts.
     55     void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
     56 
     57     unsigned Size;
     58     unsigned ADDiu, ORi, SLL, LUi;
     59     InstSeq Insts;
     60   };
     61 }
     62 
     63 #endif
     64