1 //===- MipsAnalyzeImmediate.h - Analyze Immediates -------------*- C++ -*--===//
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 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
11 #define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
13 #include "llvm/ADT/SmallVector.h"
18 class MipsAnalyzeImmediate
{
21 unsigned Opc
, ImmOpnd
;
23 Inst(unsigned Opc
, unsigned ImmOpnd
);
25 using InstSeq
= SmallVector
<Inst
, 7>;
27 /// Analyze - Get an instruction sequence to load immediate Imm. The last
28 /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
30 const InstSeq
&Analyze(uint64_t Imm
, unsigned Size
, bool LastInstrIsADDiu
);
33 using InstSeqLs
= SmallVector
<InstSeq
, 5>;
35 /// AddInstr - Add I to all instruction sequences in SeqLs.
36 void AddInstr(InstSeqLs
&SeqLs
, const Inst
&I
);
38 /// GetInstSeqLsADDiu - Get instruction sequences which end with an ADDiu to
39 /// load immediate Imm
40 void GetInstSeqLsADDiu(uint64_t Imm
, unsigned RemSize
, InstSeqLs
&SeqLs
);
42 /// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to
43 /// load immediate Imm
44 void GetInstSeqLsORi(uint64_t Imm
, unsigned RemSize
, InstSeqLs
&SeqLs
);
46 /// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to
47 /// load immediate Imm
48 void GetInstSeqLsSLL(uint64_t Imm
, unsigned RemSize
, InstSeqLs
&SeqLs
);
50 /// GetInstSeqLs - Get instruction sequences to load immediate Imm.
51 void GetInstSeqLs(uint64_t Imm
, unsigned RemSize
, InstSeqLs
&SeqLs
);
53 /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
54 void ReplaceADDiuSLLWithLUi(InstSeq
&Seq
);
56 /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
57 /// return it in Insts.
58 void GetShortestSeq(InstSeqLs
&SeqLs
, InstSeq
&Insts
);
61 unsigned ADDiu
, ORi
, SLL
, LUi
;
65 } // end namespace llvm
67 #endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H