1 //===-- MipsAnalyzeImmediate.h - Analyze immediates -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #ifndef MIPS_ANALYZE_IMMEDIATE_H
10 #define MIPS_ANALYZE_IMMEDIATE_H
12 #include "llvm/ADT/SmallVector.h"
16 class MipsAnalyzeImmediate {
19 unsigned Opc, ImmOpnd;
20 Inst(unsigned Opc, unsigned ImmOpnd);
22 typedef SmallVector<Inst, 7 > InstSeq;
24 /// Analyze - Get an instrucion sequence to load immediate Imm. The last
25 /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
27 const InstSeq &Analyze(int64_t Imm, unsigned Size, bool LastInstrIsADDiu);
29 typedef SmallVector<InstSeq, 5> InstSeqLs;
31 /// AddInstr - Add I to all instruction sequences in SeqLs.
32 void AddInstr(InstSeqLs &SeqLs, const Inst &I);
34 /// GetInstSeqLsADDiu - Get instrucion sequences which end with an ADDiu to
35 /// load immediate Imm
36 void GetInstSeqLsADDiu(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
38 /// GetInstSeqLsORi - Get instrucion sequences which end with an ORi to
39 /// load immediate Imm
40 void GetInstSeqLsORi(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
42 /// GetInstSeqLsSLL - Get instrucion sequences which end with a SLL to
43 /// load immediate Imm
44 void GetInstSeqLsSLL(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
46 /// GetInstSeqLs - Get instrucion sequences to load immediate Imm.
47 void GetInstSeqLs(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
49 /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
50 void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
52 /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
53 /// return it in Insts.
54 void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
57 unsigned ADDiu, ORi, SLL, LUi;