[yaml2obj][obj2yaml] - Do not create a symbol table by default.
[llvm-complete.git] / lib / Target / Mips / MipsAnalyzeImmediate.h
blob018b9d824526a90dcfaad3daced3d5c5cd3a5fc2
1 //===- MipsAnalyzeImmediate.h - Analyze Immediates -------------*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
10 #define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
12 #include "llvm/ADT/SmallVector.h"
13 #include <cstdint>
15 namespace llvm {
17 class MipsAnalyzeImmediate {
18 public:
19 struct Inst {
20 unsigned Opc, ImmOpnd;
22 Inst(unsigned Opc, unsigned ImmOpnd);
24 using InstSeq = SmallVector<Inst, 7>;
26 /// Analyze - Get an instruction sequence to load immediate Imm. The last
27 /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
28 /// true;
29 const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
31 private:
32 using InstSeqLs = SmallVector<InstSeq, 5>;
34 /// AddInstr - Add I to all instruction sequences in SeqLs.
35 void AddInstr(InstSeqLs &SeqLs, const Inst &I);
37 /// GetInstSeqLsADDiu - Get instruction sequences which end with an ADDiu to
38 /// load immediate Imm
39 void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
41 /// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to
42 /// load immediate Imm
43 void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
45 /// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to
46 /// load immediate Imm
47 void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
49 /// GetInstSeqLs - Get instruction sequences to load immediate Imm.
50 void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
52 /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
53 void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
55 /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
56 /// return it in Insts.
57 void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
59 unsigned Size;
60 unsigned ADDiu, ORi, SLL, LUi;
61 InstSeq Insts;
64 } // end namespace llvm
66 #endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H