Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MipsAnalyzeImmediate.h
35269 views
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
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
10
#define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
11
12
#include "llvm/ADT/SmallVector.h"
13
#include <cstdint>
14
15
namespace llvm {
16
17
class MipsAnalyzeImmediate {
18
public:
19
struct Inst {
20
unsigned Opc, ImmOpnd;
21
22
Inst(unsigned Opc, unsigned ImmOpnd);
23
};
24
using InstSeq = SmallVector<Inst, 7>;
25
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);
30
31
private:
32
using InstSeqLs = SmallVector<InstSeq, 5>;
33
34
/// AddInstr - Add I to all instruction sequences in SeqLs.
35
void AddInstr(InstSeqLs &SeqLs, const Inst &I);
36
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);
40
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);
44
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);
48
49
/// GetInstSeqLs - Get instruction sequences to load immediate Imm.
50
void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
51
52
/// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
53
void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
54
55
/// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
56
/// return it in Insts.
57
void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
58
59
unsigned Size;
60
unsigned ADDiu, ORi, SLL, LUi;
61
InstSeq Insts;
62
};
63
64
} // end namespace llvm
65
66
#endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
67
68