Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MipsAnalyzeImmediate.h
35269 views
//===- MipsAnalyzeImmediate.h - Analyze Immediates -------------*- C++ -*--===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H9#define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H1011#include "llvm/ADT/SmallVector.h"12#include <cstdint>1314namespace llvm {1516class MipsAnalyzeImmediate {17public:18struct Inst {19unsigned Opc, ImmOpnd;2021Inst(unsigned Opc, unsigned ImmOpnd);22};23using InstSeq = SmallVector<Inst, 7>;2425/// Analyze - Get an instruction sequence to load immediate Imm. The last26/// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is27/// true;28const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);2930private:31using InstSeqLs = SmallVector<InstSeq, 5>;3233/// AddInstr - Add I to all instruction sequences in SeqLs.34void AddInstr(InstSeqLs &SeqLs, const Inst &I);3536/// GetInstSeqLsADDiu - Get instruction sequences which end with an ADDiu to37/// load immediate Imm38void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);3940/// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to41/// load immediate Imm42void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);4344/// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to45/// load immediate Imm46void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);4748/// GetInstSeqLs - Get instruction sequences to load immediate Imm.49void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);5051/// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.52void ReplaceADDiuSLLWithLUi(InstSeq &Seq);5354/// GetShortestSeq - Find the shortest instruction sequence in SeqLs and55/// return it in Insts.56void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);5758unsigned Size;59unsigned ADDiu, ORi, SLL, LUi;60InstSeq Insts;61};6263} // end namespace llvm6465#endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H666768