MipsSubtarget.h revision c91cbb9b0c90a480299cc7deaef166d47a61d9df
1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===//
2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//
3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//                     The LLVM Compiler Infrastructure
4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//
5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// This file is distributed under the University of Illinois Open Source
6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com// License. See LICENSE.TXT for details.
7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//
8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//===----------------------------------------------------------------------===//
9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com//
108cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com// This file declares the Mips specific subclass of TargetSubtargetInfo.
118cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com//
128cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com//===----------------------------------------------------------------------===//
138cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
148cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#ifndef MIPSSUBTARGET_H
158cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define MIPSSUBTARGET_H
168cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
178cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MCTargetDesc/MipsReginfo.h"
188cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "llvm/MC/MCInstrItineraries.h"
198cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "llvm/Target/TargetSubtargetInfo.h"
208cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include <string>
218cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
228cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define GET_SUBTARGETINFO_HEADER
238cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#include "MipsGenSubtargetInfo.inc"
248cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
258cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comnamespace llvm {
268cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass StringRef;
278cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
288cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comclass MipsSubtarget : public MipsGenSubtargetInfo {
298cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  virtual void anchor();
308cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
318cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.compublic:
328cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // NOTE: O64 will not be supported.
338cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  enum MipsABIEnum {
348cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com    UnknownABI, O32, N32, N64, EABI
358cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  };
368cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
378cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comprotected:
388cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
398cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  enum MipsArchEnum {
408cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com    Mips32, Mips32r2, Mips64, Mips64r2
418cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  };
428cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
438cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // Mips architecture version
448cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  MipsArchEnum MipsArchVersion;
458cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
468cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // Mips supported ABIs
478cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  MipsABIEnum MipsABI;
488cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
498cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // IsLittle - The target is Little Endian
508cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsLittle;
518cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
528cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // IsSingleFloat - The target only supports single precision float
538cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // point operations. This enable the target to use all 32 32-bit
548cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // floating point registers instead of only using even ones.
558cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsSingleFloat;
568cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
578cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // IsFP64bit - The target processor has 64-bit floating point registers.
588cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsFP64bit;
598cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
608cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // IsFP64bit - General-purpose registers are 64 bits wide
618cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsGP64bit;
628cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
638cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasVFPU - Processor has a vector floating point unit.
648cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasVFPU;
658cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
668cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // isLinux - Target system is Linux. Is false we consider ELFOS for now.
678cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsLinux;
688cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
698cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // UseSmallSection - Small section is used.
708cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool UseSmallSection;
718cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
728cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// Features related to the presence of specific instructions.
738cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
748cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasSEInReg - SEB and SEH (signext in register) instructions.
758cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasSEInReg;
768cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
778cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasCondMov - Conditional mov (MOVZ, MOVN) instructions.
788cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasCondMov;
798cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
808cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasSwap - Byte and half swap instructions.
818cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasSwap;
828cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
838cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasBitCount - Count leading '1' and '0' bits.
848cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasBitCount;
858cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
868cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasFPIdx -- Floating point indexed load/store instructions.
878cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasFPIdx;
888cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
898cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // InMips16 -- can process Mips16 instructions
908cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool InMips16Mode;
918cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
928cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // HasDSP, HasDSPR2 -- supports DSP ASE.
938cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool HasDSP, HasDSPR2;
948cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
958cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // IsAndroid -- target is android
968cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool IsAndroid;
978cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
988cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  InstrItineraryData InstrItins;
998cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1008cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // The instance to the register info section object
1018cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  MipsReginfo MRI;
1028cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1038cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.compublic:
1048cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
1058cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com                                     AntiDepBreakMode& Mode,
1068cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com                                     RegClassVector& CriticalPathRCs) const;
1078cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1088cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// Only O32 and EABI supported right now.
1098cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isABI_EABI() const { return MipsABI == EABI; }
1108cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isABI_N64() const { return MipsABI == N64; }
1118cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isABI_N32() const { return MipsABI == N32; }
1128cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isABI_O32() const { return MipsABI == O32; }
1138cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  unsigned getTargetABI() const { return MipsABI; }
1148cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1158cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// This constructor initializes the data members to match that
1168cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// of the specified triple.
1178cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  MipsSubtarget(const std::string &TT, const std::string &CPU,
1188cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com                const std::string &FS, bool little, Reloc::Model RM);
1198cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1208cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// ParseSubtargetFeatures - Parses features string setting specified
1218cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// subtarget options.  Definition of function is auto generated by tblgen.
1228cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
1238cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1248cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasMips32() const { return MipsArchVersion >= Mips32; }
1258cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasMips32r2() const { return MipsArchVersion == Mips32r2 ||
1268cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com                                   MipsArchVersion == Mips64r2; }
1278cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasMips64() const { return MipsArchVersion >= Mips64; }
1288cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasMips64r2() const { return MipsArchVersion == Mips64r2; }
1298cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1308cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isLittle() const { return IsLittle; }
1318cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isFP64bit() const { return IsFP64bit; }
1328cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isGP64bit() const { return IsGP64bit; }
1338cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isGP32bit() const { return !IsGP64bit; }
1348cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isSingleFloat() const { return IsSingleFloat; }
1358cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isNotSingleFloat() const { return !IsSingleFloat; }
1368cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasVFPU() const { return HasVFPU; }
1378cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool inMips16Mode() const { return InMips16Mode; }
1388cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasDSP() const { return HasDSP; }
1398cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasDSPR2() const { return HasDSPR2; }
1408cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isAndroid() const { return IsAndroid; }
1418cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool isLinux() const { return IsLinux; }
1428cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool useSmallSection() const { return UseSmallSection; }
1438cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1448cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasStandardEncoding() const { return !inMips16Mode(); }
1458cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1468cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  /// Features related to the presence of specific instructions.
1478cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasSEInReg()   const { return HasSEInReg; }
1488cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasCondMov()   const { return HasCondMov; }
1498cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasSwap()      const { return HasSwap; }
1508cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasBitCount()  const { return HasBitCount; }
1518cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  bool hasFPIdx()     const { return HasFPIdx; }
1528cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1538cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  // Grab MipsRegInfo object
1548cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com  const MipsReginfo &getMReginfo() const { return MRI; }
1558cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com};
1568cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com} // End llvm namespace
1578cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com
1588cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#endif
1598cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com