]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Mips/MipsAnalyzeImmediate.h
Merge clang trunk r321017 to contrib/llvm/tools/clang.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Mips / MipsAnalyzeImmediate.h
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
10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
11 #define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
12
13 #include "llvm/ADT/SmallVector.h"
14 #include <cstdint>
15
16 namespace llvm {
17
18   class MipsAnalyzeImmediate {
19   public:
20     struct Inst {
21       unsigned Opc, ImmOpnd;
22
23       Inst(unsigned Opc, unsigned ImmOpnd);
24     };
25     using InstSeq = SmallVector<Inst, 7>;
26
27     /// Analyze - Get an instruction sequence to load immediate Imm. The last
28     /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
29     /// true;
30     const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
31
32   private:
33     using InstSeqLs = SmallVector<InstSeq, 5>;
34
35     /// AddInstr - Add I to all instruction sequences in SeqLs.
36     void AddInstr(InstSeqLs &SeqLs, const Inst &I);
37
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);
41
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);
45
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);
49
50     /// GetInstSeqLs - Get instruction sequences to load immediate Imm.
51     void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
52
53     /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
54     void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
55
56     /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
57     /// return it in Insts.
58     void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
59
60     unsigned Size;
61     unsigned ADDiu, ORi, SLL, LUi;
62     InstSeq Insts;
63   };
64
65 } // end namespace llvm
66
67 #endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H