[PowerPC] Do not emit record-form rotates when record-form andi/andis suffices
[llvm-core.git] / lib / Target / Mips / MipsAnalyzeImmediate.h
blob1c520242fb8d54eeb7787e7e901816841a30e4bb
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 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
11 #define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
13 #include "llvm/ADT/SmallVector.h"
14 #include <cstdint>
16 namespace llvm {
18 class MipsAnalyzeImmediate {
19 public:
20 struct Inst {
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
29 /// true;
30 const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
32 private:
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);
60 unsigned Size;
61 unsigned ADDiu, ORi, SLL, LUi;
62 InstSeq Insts;
65 } // end namespace llvm
67 #endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H