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 //===----------------------------------------------------------------------===//
9 #ifndef MIPS_ANALYZE_IMMEDIATE_H
10 #define MIPS_ANALYZE_IMMEDIATE_H
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/Support/DataTypes.h"
17 class MipsAnalyzeImmediate {
20 unsigned Opc, ImmOpnd;
21 Inst(unsigned Opc, unsigned ImmOpnd);
23 typedef SmallVector<Inst, 7 > InstSeq;
25 /// Analyze - Get an instrucion sequence to load immediate Imm. The last
26 /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
28 const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
30 typedef SmallVector<InstSeq, 5> InstSeqLs;
32 /// AddInstr - Add I to all instruction sequences in SeqLs.
33 void AddInstr(InstSeqLs &SeqLs, const Inst &I);
35 /// GetInstSeqLsADDiu - Get instrucion sequences which end with an ADDiu to
36 /// load immediate Imm
37 void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
39 /// GetInstSeqLsORi - Get instrucion sequences which end with an ORi to
40 /// load immediate Imm
41 void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
43 /// GetInstSeqLsSLL - Get instrucion sequences which end with a SLL to
44 /// load immediate Imm
45 void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
47 /// GetInstSeqLs - Get instrucion sequences to load immediate Imm.
48 void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
50 /// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
51 void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
53 /// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
54 /// return it in Insts.
55 void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
58 unsigned ADDiu, ORi, SLL, LUi;