2012-02-18 13:03:15 +01:00
|
|
|
//===-- ARMSubtarget.h - Define Subtarget for the ARM ----------*- C++ -*--===//
|
2007-01-19 08:51:42 +01:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 08:51:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-01 23:01:15 +02:00
|
|
|
// This file declares the ARM specific subclass of TargetSubtargetInfo.
|
2007-01-19 08:51:42 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ARMSUBTARGET_H
|
|
|
|
#define ARMSUBTARGET_H
|
|
|
|
|
2011-07-07 02:08:19 +02:00
|
|
|
#include "MCTargetDesc/ARMMCTargetDesc.h"
|
2011-07-01 23:01:15 +02:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
2011-06-29 03:14:12 +02:00
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
2011-01-11 22:46:47 +01:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2007-01-19 08:51:42 +01:00
|
|
|
#include <string>
|
|
|
|
|
2011-07-01 22:45:01 +02:00
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
2011-07-02 00:36:09 +02:00
|
|
|
#include "ARMGenSubtargetInfo.inc"
|
2011-07-01 22:45:01 +02:00
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
namespace llvm {
|
2009-08-29 01:18:09 +02:00
|
|
|
class GlobalValue;
|
2011-07-07 09:07:08 +02:00
|
|
|
class StringRef;
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2011-07-01 22:45:01 +02:00
|
|
|
class ARMSubtarget : public ARMGenSubtargetInfo {
|
2007-01-19 08:51:42 +01:00
|
|
|
protected:
|
2010-09-10 03:29:16 +02:00
|
|
|
enum ARMProcFamilyEnum {
|
|
|
|
Others, CortexA8, CortexA9
|
|
|
|
};
|
|
|
|
|
|
|
|
/// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
|
|
|
|
ARMProcFamilyEnum ARMProcFamily;
|
|
|
|
|
2011-07-07 05:55:05 +02:00
|
|
|
/// HasV4TOps, HasV5TOps, HasV5TEOps, HasV6Ops, HasV6T2Ops, HasV7Ops -
|
|
|
|
/// Specify whether target support specific ARM ISA variants.
|
|
|
|
bool HasV4TOps;
|
|
|
|
bool HasV5TOps;
|
|
|
|
bool HasV5TEOps;
|
|
|
|
bool HasV6Ops;
|
|
|
|
bool HasV6T2Ops;
|
|
|
|
bool HasV7Ops;
|
|
|
|
|
2012-04-11 07:33:07 +02:00
|
|
|
/// HasVFPv2, HasVFPv3, HasVFPv4, HasNEON - Specify what
|
2012-01-22 13:07:33 +01:00
|
|
|
/// floating point ISAs are supported.
|
2011-07-07 05:55:05 +02:00
|
|
|
bool HasVFPv2;
|
|
|
|
bool HasVFPv3;
|
2012-01-22 13:07:33 +01:00
|
|
|
bool HasVFPv4;
|
2011-07-07 05:55:05 +02:00
|
|
|
bool HasNEON;
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2009-08-05 18:01:19 +02:00
|
|
|
/// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
|
|
|
|
/// specified. Use the method useNEONForSinglePrecisionFP() to
|
|
|
|
/// determine if NEON should actually be used.
|
2009-08-04 19:53:06 +02:00
|
|
|
bool UseNEONForSinglePrecisionFP;
|
|
|
|
|
2010-12-05 23:04:16 +01:00
|
|
|
/// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
|
|
|
|
/// whether the FP VML[AS] instructions are slow (if so, don't use them).
|
|
|
|
bool SlowFPVMLx;
|
2010-03-24 23:31:46 +01:00
|
|
|
|
2011-03-31 21:38:48 +02:00
|
|
|
/// HasVMLxForwarding - If true, NEON has special multiplier accumulator
|
|
|
|
/// forwarding to allow mul + mla being issued back to back.
|
|
|
|
bool HasVMLxForwarding;
|
|
|
|
|
2010-07-13 21:21:50 +02:00
|
|
|
/// SlowFPBrcc - True if floating point compare + branch is slow.
|
|
|
|
bool SlowFPBrcc;
|
|
|
|
|
2011-07-07 21:09:06 +02:00
|
|
|
/// InThumbMode - True if compiling for Thumb, false for ARM.
|
2011-07-07 21:05:12 +02:00
|
|
|
bool InThumbMode;
|
2009-06-01 22:00:48 +02:00
|
|
|
|
2011-07-07 02:08:19 +02:00
|
|
|
/// HasThumb2 - True if Thumb2 instructions are supported.
|
|
|
|
bool HasThumb2;
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2011-09-28 16:21:38 +02:00
|
|
|
/// IsMClass - True if the subtarget belongs to the 'M' profile of CPUs -
|
|
|
|
/// v6m, v7m for example.
|
|
|
|
bool IsMClass;
|
|
|
|
|
2010-08-11 09:17:46 +02:00
|
|
|
/// NoARM - True if subtarget does not support ARM mode execution.
|
|
|
|
bool NoARM;
|
|
|
|
|
2009-09-30 02:10:16 +02:00
|
|
|
/// PostRAScheduler - True if using post-register-allocation scheduler.
|
|
|
|
bool PostRAScheduler;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// IsR9Reserved - True if R9 is a not available as general purpose register.
|
|
|
|
bool IsR9Reserved;
|
2007-02-13 20:52:28 +01:00
|
|
|
|
2009-11-24 01:44:37 +01:00
|
|
|
/// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
|
|
|
|
/// imms (including global addresses).
|
|
|
|
bool UseMovt;
|
|
|
|
|
2011-10-07 19:17:49 +02:00
|
|
|
/// SupportsTailCall - True if the OS supports tail call. The dynamic linker
|
|
|
|
/// must be able to synthesize call stubs for interworking between ARM and
|
|
|
|
/// Thumb.
|
|
|
|
bool SupportsTailCall;
|
|
|
|
|
2010-03-14 19:42:38 +01:00
|
|
|
/// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
|
|
|
|
/// only so far)
|
|
|
|
bool HasFP16;
|
|
|
|
|
2010-10-12 18:22:47 +02:00
|
|
|
/// HasD16 - True if subtarget is limited to 16 double precision
|
|
|
|
/// FP registers for VFPv3.
|
|
|
|
bool HasD16;
|
|
|
|
|
2010-05-06 01:44:43 +02:00
|
|
|
/// HasHardwareDivide - True if subtarget supports [su]div
|
|
|
|
bool HasHardwareDivide;
|
|
|
|
|
|
|
|
/// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
|
|
|
|
/// instructions.
|
|
|
|
bool HasT2ExtractPack;
|
|
|
|
|
2010-08-11 08:22:01 +02:00
|
|
|
/// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
|
|
|
|
/// instructions.
|
|
|
|
bool HasDataBarrier;
|
|
|
|
|
2010-08-09 20:35:19 +02:00
|
|
|
/// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
|
|
|
|
/// over 16-bit ones.
|
|
|
|
bool Pref32BitThumb;
|
|
|
|
|
2011-04-19 20:11:49 +02:00
|
|
|
/// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
|
|
|
|
/// that partially update CPSR and add false dependency on the previous
|
|
|
|
/// CPSR setting instruction.
|
|
|
|
bool AvoidCPSRPartialUpdate;
|
|
|
|
|
2012-02-28 19:51:51 +01:00
|
|
|
/// HasRAS - Some processors perform return stack prediction. CodeGen should
|
|
|
|
/// avoid issue "normal" call instructions to callees which do not return.
|
|
|
|
bool HasRAS;
|
|
|
|
|
2010-11-03 07:34:55 +01:00
|
|
|
/// HasMPExtension - True if the subtarget supports Multiprocessing
|
|
|
|
/// extension (ARMv7 only).
|
|
|
|
bool HasMPExtension;
|
|
|
|
|
2010-08-11 17:44:15 +02:00
|
|
|
/// FPOnlySP - If true, the floating point unit only supports single
|
|
|
|
/// precision.
|
|
|
|
bool FPOnlySP;
|
|
|
|
|
2010-09-28 06:09:35 +02:00
|
|
|
/// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
|
|
|
|
/// accesses for some types. For details, see
|
|
|
|
/// ARMTargetLowering::allowsUnalignedMemoryAccesses().
|
|
|
|
bool AllowsUnalignedMem;
|
|
|
|
|
2011-07-01 23:12:19 +02:00
|
|
|
/// Thumb2DSP - If true, the subtarget supports the v7 DSP (saturating arith
|
|
|
|
/// and such) instructions in Thumb2 code.
|
|
|
|
bool Thumb2DSP;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
|
|
|
/// entry to the function and which must be maintained by every function.
|
|
|
|
unsigned stackAlignment;
|
|
|
|
|
2009-05-23 21:50:50 +02:00
|
|
|
/// CPUString - String name of used CPU.
|
|
|
|
std::string CPUString;
|
|
|
|
|
2011-01-11 22:46:47 +01:00
|
|
|
/// TargetTriple - What processor and OS we're targeting.
|
|
|
|
Triple TargetTriple;
|
|
|
|
|
2009-06-19 03:51:50 +02:00
|
|
|
/// Selected instruction itineraries (one entry per itinerary class.)
|
|
|
|
InstrItineraryData InstrItins;
|
2009-08-11 17:33:49 +02:00
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
public:
|
2007-01-19 20:22:40 +01:00
|
|
|
enum {
|
|
|
|
isELF, isDarwin
|
|
|
|
} TargetType;
|
|
|
|
|
2007-02-13 20:52:28 +01:00
|
|
|
enum {
|
|
|
|
ARM_ABI_APCS,
|
|
|
|
ARM_ABI_AAPCS // ARM EABI
|
|
|
|
} TargetABI;
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// This constructor initializes the data members to match that
|
2009-08-03 00:11:08 +02:00
|
|
|
/// of the specified triple.
|
2007-01-19 08:51:42 +01:00
|
|
|
///
|
2011-06-30 03:53:36 +02:00
|
|
|
ARMSubtarget(const std::string &TT, const std::string &CPU,
|
2011-07-07 02:08:19 +02:00
|
|
|
const std::string &FS);
|
2007-01-19 08:51:42 +01:00
|
|
|
|
Drop ISD::MEMSET, ISD::MEMMOVE, and ISD::MEMCPY, which are not Legal
on any current target and aren't optimized in DAGCombiner. Instead
of using intermediate nodes, expand the operations, choosing between
simple loads/stores, target-specific code, and library calls,
immediately.
Previously, the code to emit optimized code for these operations
was only used at initial SelectionDAG construction time; now it is
used at all times. This fixes some cases where rep;movs was being
used for small copies where simple loads/stores would be better.
This also cleans up code that checks for alignments less than 4;
let the targets make that decision instead of doing it in
target-independent code. This allows x86 to use rep;movs in
low-alignment cases.
Also, this fixes a bug that resulted in the use of rep;stos for
memsets of 0 with non-constant memory size when the alignment was
at least 4. It's better to use the library in this case, which
can be significantly faster when the size is large.
This also preserves more SourceValue information when memory
intrinsics are lowered into simple loads/stores.
llvm-svn: 49572
2008-04-12 06:36:06 +02:00
|
|
|
/// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
|
|
|
|
/// that still makes it profitable to inline the call.
|
2007-10-31 15:39:58 +01:00
|
|
|
unsigned getMaxInlineSizeThreshold() const {
|
2010-03-11 01:20:49 +01:00
|
|
|
// FIXME: For now, we don't lower memcpy's to loads / stores for Thumb1.
|
|
|
|
// Change this once Thumb1 ldmia / stmia support is added.
|
|
|
|
return isThumb1Only() ? 0 : 64;
|
2007-10-31 15:39:58 +01:00
|
|
|
}
|
2009-05-23 21:51:43 +02:00
|
|
|
/// ParseSubtargetFeatures - Parses features string setting specified
|
2007-01-19 08:51:42 +01:00
|
|
|
/// subtarget options. Definition of function is auto generated by tblgen.
|
2011-07-07 09:07:08 +02:00
|
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
2007-01-19 08:51:42 +01:00
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
void computeIssueWidth();
|
|
|
|
|
2011-07-07 05:55:05 +02:00
|
|
|
bool hasV4TOps() const { return HasV4TOps; }
|
|
|
|
bool hasV5TOps() const { return HasV5TOps; }
|
|
|
|
bool hasV5TEOps() const { return HasV5TEOps; }
|
|
|
|
bool hasV6Ops() const { return HasV6Ops; }
|
|
|
|
bool hasV6T2Ops() const { return HasV6T2Ops; }
|
|
|
|
bool hasV7Ops() const { return HasV7Ops; }
|
2007-01-19 08:51:42 +01:00
|
|
|
|
2010-09-10 03:29:16 +02:00
|
|
|
bool isCortexA8() const { return ARMProcFamily == CortexA8; }
|
|
|
|
bool isCortexA9() const { return ARMProcFamily == CortexA9; }
|
2011-11-09 02:57:03 +01:00
|
|
|
bool isCortexM3() const { return CPUString == "cortex-m3"; }
|
2010-09-10 03:29:16 +02:00
|
|
|
|
2010-08-11 09:17:46 +02:00
|
|
|
bool hasARMOps() const { return !NoARM; }
|
|
|
|
|
2011-07-07 05:55:05 +02:00
|
|
|
bool hasVFP2() const { return HasVFPv2; }
|
|
|
|
bool hasVFP3() const { return HasVFPv3; }
|
2012-01-22 13:07:33 +01:00
|
|
|
bool hasVFP4() const { return HasVFPv4; }
|
2011-07-07 05:55:05 +02:00
|
|
|
bool hasNEON() const { return HasNEON; }
|
2009-08-11 17:33:49 +02:00
|
|
|
bool useNEONForSinglePrecisionFP() const {
|
2009-08-04 19:53:06 +02:00
|
|
|
return hasNEON() && UseNEONForSinglePrecisionFP; }
|
2011-07-07 05:55:05 +02:00
|
|
|
|
2010-05-06 16:57:47 +02:00
|
|
|
bool hasDivide() const { return HasHardwareDivide; }
|
|
|
|
bool hasT2ExtractPack() const { return HasT2ExtractPack; }
|
2010-08-11 08:22:01 +02:00
|
|
|
bool hasDataBarrier() const { return HasDataBarrier; }
|
2010-12-05 23:04:16 +01:00
|
|
|
bool useFPVMLx() const { return !SlowFPVMLx; }
|
2011-03-31 21:38:48 +02:00
|
|
|
bool hasVMLxForwarding() const { return HasVMLxForwarding; }
|
2010-07-13 21:21:50 +02:00
|
|
|
bool isFPBrccSlow() const { return SlowFPBrcc; }
|
2010-08-11 17:44:15 +02:00
|
|
|
bool isFPOnlySP() const { return FPOnlySP; }
|
2010-08-09 20:35:19 +02:00
|
|
|
bool prefers32BitThumb() const { return Pref32BitThumb; }
|
2011-04-19 20:11:49 +02:00
|
|
|
bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
|
2012-02-28 19:51:51 +01:00
|
|
|
bool hasRAS() const { return HasRAS; }
|
2010-11-03 07:34:55 +01:00
|
|
|
bool hasMPExtension() const { return HasMPExtension; }
|
2011-07-01 23:12:19 +02:00
|
|
|
bool hasThumb2DSP() const { return Thumb2DSP; }
|
2009-08-11 17:33:49 +02:00
|
|
|
|
2010-03-14 19:42:38 +01:00
|
|
|
bool hasFP16() const { return HasFP16; }
|
2010-10-12 18:22:47 +02:00
|
|
|
bool hasD16() const { return HasD16; }
|
2010-03-14 19:42:38 +01:00
|
|
|
|
2011-04-21 00:20:12 +02:00
|
|
|
const Triple &getTargetTriple() const { return TargetTriple; }
|
|
|
|
|
2011-12-20 19:26:50 +01:00
|
|
|
bool isTargetIOS() const { return TargetTriple.getOS() == Triple::IOS; }
|
2011-04-19 23:14:45 +02:00
|
|
|
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
2011-09-05 23:51:43 +02:00
|
|
|
bool isTargetNaCl() const {
|
|
|
|
return TargetTriple.getOS() == Triple::NativeClient;
|
|
|
|
}
|
2011-01-11 22:46:47 +01:00
|
|
|
bool isTargetELF() const { return !isTargetDarwin(); }
|
2007-01-19 20:22:40 +01:00
|
|
|
|
2007-02-13 20:52:28 +01:00
|
|
|
bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
|
|
|
|
bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
|
|
|
|
|
2011-07-07 21:05:12 +02:00
|
|
|
bool isThumb() const { return InThumbMode; }
|
|
|
|
bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
|
|
|
|
bool isThumb2() const { return InThumbMode && HasThumb2; }
|
2011-07-07 02:08:19 +02:00
|
|
|
bool hasThumb2() const { return HasThumb2; }
|
2011-09-28 16:21:38 +02:00
|
|
|
bool isMClass() const { return IsMClass; }
|
|
|
|
bool isARClass() const { return !IsMClass; }
|
2007-01-19 08:51:42 +01:00
|
|
|
|
|
|
|
bool isR9Reserved() const { return IsR9Reserved; }
|
|
|
|
|
2009-11-24 01:44:37 +01:00
|
|
|
bool useMovt() const { return UseMovt && hasV6T2Ops(); }
|
2011-10-07 19:17:49 +02:00
|
|
|
bool supportsTailCall() const { return SupportsTailCall; }
|
2009-11-24 01:44:37 +01:00
|
|
|
|
2010-09-28 06:09:35 +02:00
|
|
|
bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
|
|
|
|
|
2009-05-23 21:50:50 +02:00
|
|
|
const std::string & getCPUString() const { return CPUString; }
|
2009-11-24 01:44:37 +01:00
|
|
|
|
2010-09-28 23:57:50 +02:00
|
|
|
unsigned getMispredictionPenalty() const;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2009-11-10 01:48:55 +01:00
|
|
|
/// enablePostRAScheduler - True at 'More' optimization.
|
2009-10-23 01:19:17 +02:00
|
|
|
bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
|
2011-07-01 23:01:15 +02:00
|
|
|
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
2009-11-13 20:52:48 +01:00
|
|
|
RegClassVector& CriticalPathRCs) const;
|
2009-05-23 21:50:50 +02:00
|
|
|
|
2009-08-11 17:33:49 +02:00
|
|
|
/// getInstrItins - Return the instruction itineraies based on subtarget
|
2009-06-19 03:51:50 +02:00
|
|
|
/// selection.
|
|
|
|
const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
|
|
|
|
|
2007-01-19 08:51:42 +01:00
|
|
|
/// getStackAlignment - Returns the minimum alignment known to hold of the
|
|
|
|
/// stack frame on entry to the function and which must be maintained by every
|
|
|
|
/// function for this subtarget.
|
|
|
|
unsigned getStackAlignment() const { return stackAlignment; }
|
2009-08-29 01:18:09 +02:00
|
|
|
|
|
|
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
|
|
|
|
/// symbol.
|
2010-04-15 03:51:59 +02:00
|
|
|
bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
|
2007-01-19 08:51:42 +01:00
|
|
|
};
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif // ARMSUBTARGET_H
|