mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
10839866a1
This patch implements initial backend support for a -mtune CPU controlled by a "tune-cpu" function attribute. If the attribute is not present X86 will use the resolved CPU from target-cpu attribute or command line. This patch adds MC layer support a tune CPU. Each CPU now has two sets of features stored in their GenSubtargetInfo.inc tables . These features lists are passed separately to the Processor and ProcessorModel classes in tablegen. The tune list defaults to an empty list to avoid changes to non-X86. This annoyingly increases the size of static tables on all target as we now store 24 more bytes per CPU. I haven't quantified the overall impact, but I can if we're concerned. One new test is added to X86 to show a few tuning features with mismatched tune-cpu and target-cpu/target-feature attributes to demonstrate independent control. Another new test is added to demonstrate that the scheduler model follows the tune CPU. I have not added a -mtune to llc/opt or MC layer command line yet. With no attributes we'll just use the -mcpu for both. MC layer tools will always follow the normal CPU for tuning. Differential Revision: https://reviews.llvm.org/D85165
126 lines
4.2 KiB
C++
126 lines
4.2 KiB
C++
//===-- AVRSubtarget.h - Define Subtarget for the AVR -----------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares the AVR specific subclass of TargetSubtargetInfo.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_AVR_SUBTARGET_H
|
|
#define LLVM_AVR_SUBTARGET_H
|
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
|
#include "llvm/IR/DataLayout.h"
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "AVRFrameLowering.h"
|
|
#include "AVRISelLowering.h"
|
|
#include "AVRInstrInfo.h"
|
|
#include "AVRSelectionDAGInfo.h"
|
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
#include "AVRGenSubtargetInfo.inc"
|
|
|
|
namespace llvm {
|
|
|
|
/// A specific AVR target MCU.
|
|
class AVRSubtarget : public AVRGenSubtargetInfo {
|
|
public:
|
|
//! Creates an AVR subtarget.
|
|
//! \param TT The target triple.
|
|
//! \param CPU The CPU to target.
|
|
//! \param FS The feature string.
|
|
//! \param TM The target machine.
|
|
AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
|
|
const AVRTargetMachine &TM);
|
|
|
|
const AVRInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
|
const TargetFrameLowering *getFrameLowering() const override { return &FrameLowering; }
|
|
const AVRTargetLowering *getTargetLowering() const override { return &TLInfo; }
|
|
const AVRSelectionDAGInfo *getSelectionDAGInfo() const override { return &TSInfo; }
|
|
const AVRRegisterInfo *getRegisterInfo() const override { return &InstrInfo.getRegisterInfo(); }
|
|
|
|
/// Parses a subtarget feature string, setting appropriate options.
|
|
/// \note Definition of function is auto generated by `tblgen`.
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
|
|
|
|
AVRSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
|
|
const TargetMachine &TM);
|
|
|
|
// Subtarget feature getters.
|
|
// See AVR.td for details.
|
|
bool hasSRAM() const { return m_hasSRAM; }
|
|
bool hasJMPCALL() const { return m_hasJMPCALL; }
|
|
bool hasIJMPCALL() const { return m_hasIJMPCALL; }
|
|
bool hasEIJMPCALL() const { return m_hasEIJMPCALL; }
|
|
bool hasADDSUBIW() const { return m_hasADDSUBIW; }
|
|
bool hasSmallStack() const { return m_hasSmallStack; }
|
|
bool hasMOVW() const { return m_hasMOVW; }
|
|
bool hasLPM() const { return m_hasLPM; }
|
|
bool hasLPMX() const { return m_hasLPMX; }
|
|
bool hasELPM() const { return m_hasELPM; }
|
|
bool hasELPMX() const { return m_hasELPMX; }
|
|
bool hasSPM() const { return m_hasSPM; }
|
|
bool hasSPMX() const { return m_hasSPMX; }
|
|
bool hasDES() const { return m_hasDES; }
|
|
bool supportsRMW() const { return m_supportsRMW; }
|
|
bool supportsMultiplication() const { return m_supportsMultiplication; }
|
|
bool hasBREAK() const { return m_hasBREAK; }
|
|
bool hasTinyEncoding() const { return m_hasTinyEncoding; }
|
|
bool hasMemMappedGPR() const { return m_hasMemMappedGPR; }
|
|
|
|
uint8_t getIORegisterOffset() const { return hasMemMappedGPR() ? 0x20 : 0x0; }
|
|
|
|
/// Gets the ELF architecture for the e_flags field
|
|
/// of an ELF object file.
|
|
unsigned getELFArch() const {
|
|
assert(ELFArch != 0 &&
|
|
"every device must have an associate ELF architecture");
|
|
return ELFArch;
|
|
}
|
|
|
|
private:
|
|
|
|
/// The ELF e_flags architecture.
|
|
unsigned ELFArch;
|
|
|
|
// Subtarget feature settings
|
|
// See AVR.td for details.
|
|
bool m_hasSRAM;
|
|
bool m_hasJMPCALL;
|
|
bool m_hasIJMPCALL;
|
|
bool m_hasEIJMPCALL;
|
|
bool m_hasADDSUBIW;
|
|
bool m_hasSmallStack;
|
|
bool m_hasMOVW;
|
|
bool m_hasLPM;
|
|
bool m_hasLPMX;
|
|
bool m_hasELPM;
|
|
bool m_hasELPMX;
|
|
bool m_hasSPM;
|
|
bool m_hasSPMX;
|
|
bool m_hasDES;
|
|
bool m_supportsRMW;
|
|
bool m_supportsMultiplication;
|
|
bool m_hasBREAK;
|
|
bool m_hasTinyEncoding;
|
|
bool m_hasMemMappedGPR;
|
|
|
|
// Dummy member, used by FeatureSet's. We cannot have a SubtargetFeature with
|
|
// no variable, so we instead bind pseudo features to this variable.
|
|
bool m_FeatureSetDummy;
|
|
|
|
AVRInstrInfo InstrInfo;
|
|
AVRFrameLowering FrameLowering;
|
|
AVRTargetLowering TLInfo;
|
|
AVRSelectionDAGInfo TSInfo;
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_AVR_SUBTARGET_H
|