brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 018b9d8 Raw
67 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H10#define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H11 12#include "llvm/ADT/SmallVector.h"13#include <cstdint>14 15namespace 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 last27    /// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is28    /// 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 to38    /// load immediate Imm39    void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);40 41    /// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to42    /// load immediate Imm43    void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);44 45    /// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to46    /// load immediate Imm47    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 and56    /// 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 llvm65 66#endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H67