2017-08-04 06:12:30 +08:00
|
|
|
//===- MipsAnalyzeImmediate.h - Analyze Immediates -------------*- C++ -*--===//
|
2012-01-25 09:43:36 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-08-04 06:12:30 +08:00
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
|
|
|
|
#define LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
|
2012-01-25 09:43:36 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2017-08-04 06:12:30 +08:00
|
|
|
#include <cstdint>
|
2012-01-25 09:43:36 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MipsAnalyzeImmediate {
|
|
|
|
public:
|
|
|
|
struct Inst {
|
|
|
|
unsigned Opc, ImmOpnd;
|
2017-08-04 06:12:30 +08:00
|
|
|
|
2012-01-25 09:43:36 +08:00
|
|
|
Inst(unsigned Opc, unsigned ImmOpnd);
|
|
|
|
};
|
2017-08-04 06:12:30 +08:00
|
|
|
using InstSeq = SmallVector<Inst, 7>;
|
2012-01-25 09:43:36 +08:00
|
|
|
|
2013-09-28 21:42:22 +08:00
|
|
|
/// Analyze - Get an instruction sequence to load immediate Imm. The last
|
2012-01-25 09:43:36 +08:00
|
|
|
/// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
|
|
|
|
/// true;
|
2012-03-09 14:36:45 +08:00
|
|
|
const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
|
2017-08-04 06:12:30 +08:00
|
|
|
|
2012-01-25 09:43:36 +08:00
|
|
|
private:
|
2017-08-04 06:12:30 +08:00
|
|
|
using InstSeqLs = SmallVector<InstSeq, 5>;
|
2012-01-25 09:43:36 +08:00
|
|
|
|
|
|
|
/// AddInstr - Add I to all instruction sequences in SeqLs.
|
|
|
|
void AddInstr(InstSeqLs &SeqLs, const Inst &I);
|
|
|
|
|
2013-09-28 21:42:22 +08:00
|
|
|
/// GetInstSeqLsADDiu - Get instruction sequences which end with an ADDiu to
|
2012-01-25 09:43:36 +08:00
|
|
|
/// load immediate Imm
|
2012-03-09 14:36:45 +08:00
|
|
|
void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
|
2012-01-25 09:43:36 +08:00
|
|
|
|
2013-09-28 21:42:22 +08:00
|
|
|
/// GetInstSeqLsORi - Get instrutcion sequences which end with an ORi to
|
2012-01-25 09:43:36 +08:00
|
|
|
/// load immediate Imm
|
2012-03-09 14:36:45 +08:00
|
|
|
void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
|
2012-01-25 09:43:36 +08:00
|
|
|
|
2013-09-28 21:42:22 +08:00
|
|
|
/// GetInstSeqLsSLL - Get instruction sequences which end with a SLL to
|
2012-01-25 09:43:36 +08:00
|
|
|
/// load immediate Imm
|
2012-03-09 14:36:45 +08:00
|
|
|
void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
|
2012-01-25 09:43:36 +08:00
|
|
|
|
2013-09-28 21:42:22 +08:00
|
|
|
/// GetInstSeqLs - Get instruction sequences to load immediate Imm.
|
2012-03-09 14:36:45 +08:00
|
|
|
void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
|
2012-01-25 09:43:36 +08:00
|
|
|
|
|
|
|
/// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
|
|
|
|
void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
|
|
|
|
|
|
|
|
/// GetShortestSeq - Find the shortest instruction sequence in SeqLs and
|
2012-02-28 15:46:26 +08:00
|
|
|
/// return it in Insts.
|
2012-01-25 09:43:36 +08:00
|
|
|
void GetShortestSeq(InstSeqLs &SeqLs, InstSeq &Insts);
|
|
|
|
|
|
|
|
unsigned Size;
|
|
|
|
unsigned ADDiu, ORi, SLL, LUi;
|
|
|
|
InstSeq Insts;
|
|
|
|
};
|
|
|
|
|
2017-08-04 06:12:30 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_MIPS_MIPSANALYZEIMMEDIATE_H
|