2014-10-03 21:18:11 +08:00
|
|
|
//===-- HexagonMCCodeEmitter.h - Hexagon Target Descriptions ----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief Definition for classes that emit Hexagon machine code from MCInsts
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef HEXAGONMCCODEEMITTER_H
|
|
|
|
#define HEXAGONMCCODEEMITTER_H
|
|
|
|
|
2017-02-03 03:58:22 +08:00
|
|
|
#include "MCTargetDesc/HexagonFixupKinds.h"
|
2014-10-03 21:18:11 +08:00
|
|
|
#include "llvm/MC/MCCodeEmitter.h"
|
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCInst.h"
|
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class HexagonMCCodeEmitter : public MCCodeEmitter {
|
|
|
|
MCContext &MCT;
|
2015-02-20 03:00:00 +08:00
|
|
|
MCInstrInfo const &MCII;
|
2015-05-02 05:14:21 +08:00
|
|
|
std::unique_ptr<unsigned> Addend;
|
|
|
|
std::unique_ptr<bool> Extended;
|
2015-05-29 22:44:13 +08:00
|
|
|
std::unique_ptr<MCInst const *> CurrentBundle;
|
2017-02-02 23:32:26 +08:00
|
|
|
std::unique_ptr<size_t> CurrentIndex;
|
2015-05-02 05:14:21 +08:00
|
|
|
|
|
|
|
// helper routine for getMachineOpValue()
|
|
|
|
unsigned getExprOpValue(const MCInst &MI, const MCOperand &MO,
|
|
|
|
const MCExpr *ME, SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-10-03 21:18:11 +08:00
|
|
|
|
2017-02-03 03:58:22 +08:00
|
|
|
Hexagon::Fixups getFixupNoBits(MCInstrInfo const &MCII, const MCInst &MI,
|
|
|
|
const MCOperand &MO,
|
|
|
|
const MCSymbolRefExpr::VariantKind kind) const;
|
|
|
|
|
2014-10-03 21:18:11 +08:00
|
|
|
public:
|
2015-03-11 06:03:14 +08:00
|
|
|
HexagonMCCodeEmitter(MCInstrInfo const &aMII, MCContext &aMCT);
|
2014-10-03 21:18:11 +08:00
|
|
|
|
2015-05-29 22:44:13 +08:00
|
|
|
// Return parse bits for instruction `MCI' inside bundle `MCB'
|
2017-02-02 23:32:26 +08:00
|
|
|
uint32_t parseBits(size_t Last, MCInst const &MCB, MCInst const &MCI) const;
|
2015-05-29 22:44:13 +08:00
|
|
|
|
2015-05-16 03:13:16 +08:00
|
|
|
void encodeInstruction(MCInst const &MI, raw_ostream &OS,
|
2014-10-03 21:18:11 +08:00
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
MCSubtargetInfo const &STI) const override;
|
|
|
|
|
2015-05-29 22:44:13 +08:00
|
|
|
void EncodeSingleInstruction(const MCInst &MI, raw_ostream &OS,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI,
|
2017-02-02 23:32:26 +08:00
|
|
|
uint32_t Parse) const;
|
2015-05-29 22:44:13 +08:00
|
|
|
|
2014-10-22 00:03:10 +08:00
|
|
|
// \brief TableGen'erated function for getting the
|
2014-10-03 21:18:11 +08:00
|
|
|
// binary encoding for an instruction.
|
|
|
|
uint64_t getBinaryCodeForInstr(MCInst const &MI,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
MCSubtargetInfo const &STI) const;
|
|
|
|
|
|
|
|
/// \brief Return binary encoding of operand.
|
|
|
|
unsigned getMachineOpValue(MCInst const &MI, MCOperand const &MO,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
MCSubtargetInfo const &STI) const;
|
Check that emitted instructions meet their predicates on all targets except ARM, Mips, and X86.
Summary:
* ARM is omitted from this patch because this check appears to expose bugs in this target.
* Mips is omitted from this patch because this check either detects bugs or deliberate
emission of instructions that don't satisfy their predicates. One deliberate
use is the SYNC instruction where the version with an operand is correctly
defined as requiring MIPS32 while the version without an operand is defined
as an alias of 'SYNC 0' and requires MIPS2.
* X86 is omitted from this patch because it doesn't use the tablegen-erated
MCCodeEmitter infrastructure.
Patches for ARM and Mips will follow.
Depends on D25617
Reviewers: tstellarAMD, jmolloy
Subscribers: wdng, jmolloy, aemerson, rengolin, arsenm, jyknight, nemanjai, nhaehnle, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D25618
llvm-svn: 287439
2016-11-19 21:05:44 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t computeAvailableFeatures(const FeatureBitset &FB) const;
|
|
|
|
void verifyInstructionPredicates(const MCInst &MI,
|
|
|
|
uint64_t AvailableFeatures) const;
|
2014-10-03 21:18:11 +08:00
|
|
|
}; // class HexagonMCCodeEmitter
|
|
|
|
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif /* HEXAGONMCCODEEMITTER_H */
|