LLVM API Documentation

MipsAnalyzeImmediate.h
Go to the documentation of this file.
00001 //===-- MipsAnalyzeImmediate.h - Analyze Immediates ------------*- C++ -*--===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 #ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
00010 #define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
00011 
00012 #include "llvm/ADT/SmallVector.h"
00013 #include "llvm/Support/DataTypes.h"
00014 
00015 namespace llvm {
00016 
00017   class MipsAnalyzeImmediate {
00018   public:
00019     struct Inst {
00020       unsigned Opc, ImmOpnd;
00021       Inst(unsigned Opc, unsigned ImmOpnd);
00022     };
00023     typedef SmallVector<Inst, 7 > InstSeq;
00024 
00025     /// Analyze - Get an instruction sequence to load immediate Imm. The last
00026     /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
00027     /// true;
00028     const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
00029   private:
00030     typedef SmallVector<InstSeq, 5> InstSeqLs;
00031 
00032     /// AddInstr - Add I to all instruction sequences in SeqLs.
00033     void AddInstr(InstSeqLs &SeqLs, const Inst &I);
00034 
00035     /// GetInstSeqLsADDiu - Get instruction sequences which end with an ADDiu to
00036     /// load immediate Imm
00037     void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
00038 
00039     /// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to
00040     /// load immediate Imm
00041     void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
00042 
00043     /// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to
00044     /// load immediate Imm
00045     void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
00046 
00047     /// GetInstSeqLs - Get instruction sequences to load immediate Imm.
00048     void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
00049 
00050     /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
00051     void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
00052 
00053     /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
00054     /// return it in Insts.
00055     void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
00056 
00057     unsigned Size;
00058     unsigned ADDiu, ORi, SLL, LUi;
00059     InstSeq Insts;
00060   };
00061 }
00062 
00063 #endif