2012-02-18 20:03:15 +08:00
|
|
|
//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-02 05:01:15 +08:00
|
|
|
// This file implements the SPARC specific subclass of TargetSubtargetInfo.
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcSubtarget.h"
|
2011-07-09 13:47:46 +08:00
|
|
|
#include "Sparc.h"
|
2013-06-01 12:51:18 +08:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2011-07-02 04:45:01 +08:00
|
|
|
|
2014-04-22 10:03:14 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 06:55:11 +08:00
|
|
|
#define DEBUG_TYPE "sparc-subtarget"
|
|
|
|
|
2011-07-02 04:45:01 +08:00
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
2011-07-08 09:53:10 +08:00
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
2011-07-02 06:36:09 +08:00
|
|
|
#include "SparcGenSubtargetInfo.inc"
|
2011-07-02 04:45:01 +08:00
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void SparcSubtarget::anchor() { }
|
|
|
|
|
2014-06-27 06:33:55 +08:00
|
|
|
SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
StringRef FS) {
|
|
|
|
IsV9 = false;
|
2016-05-09 19:55:15 +08:00
|
|
|
IsLeon = false;
|
2014-06-27 06:33:55 +08:00
|
|
|
V8DeprecatedInsts = false;
|
|
|
|
IsVIS = false;
|
|
|
|
HasHardQuad = false;
|
|
|
|
UsePopc = false;
|
2016-05-18 17:14:13 +08:00
|
|
|
UseSoftFloat = false;
|
2016-05-16 19:02:00 +08:00
|
|
|
|
|
|
|
// Leon features
|
|
|
|
HasLeonCasa = false;
|
2016-05-09 19:55:15 +08:00
|
|
|
HasUmacSmac = false;
|
2016-10-10 16:53:06 +08:00
|
|
|
PerformSDIVReplace = false;
|
2016-08-12 22:48:09 +08:00
|
|
|
InsertNOPLoad = false;
|
2016-06-19 19:03:28 +08:00
|
|
|
FixFSMULD = false;
|
|
|
|
ReplaceFMULS = false;
|
|
|
|
FixAllFDIVSQRT = false;
|
2013-06-05 02:33:25 +08:00
|
|
|
|
2006-02-05 13:50:24 +08:00
|
|
|
// Determine default and user specified characteristics
|
2011-06-30 09:53:36 +08:00
|
|
|
std::string CPUName = CPU;
|
2014-01-12 07:56:13 +08:00
|
|
|
if (CPUName.empty())
|
2014-06-27 06:33:55 +08:00
|
|
|
CPUName = (Is64Bit) ? "v9" : "v8";
|
2006-02-05 13:50:24 +08:00
|
|
|
|
|
|
|
// Parse features string.
|
2011-07-07 15:07:08 +08:00
|
|
|
ParseSubtargetFeatures(CPUName, FS);
|
2014-01-26 16:12:34 +08:00
|
|
|
|
|
|
|
// Popc is a v9-only instruction.
|
|
|
|
if (!IsV9)
|
|
|
|
UsePopc = false;
|
2014-06-27 06:33:55 +08:00
|
|
|
|
|
|
|
return *this;
|
2006-05-25 01:04:05 +08:00
|
|
|
}
|
2013-06-01 12:51:18 +08:00
|
|
|
|
2015-06-10 20:11:26 +08:00
|
|
|
SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
|
2016-05-03 22:57:18 +08:00
|
|
|
const std::string &FS, const TargetMachine &TM,
|
2014-06-27 06:33:55 +08:00
|
|
|
bool is64Bit)
|
2016-04-26 18:37:14 +08:00
|
|
|
: SparcGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT), Is64Bit(is64Bit),
|
2015-01-31 07:46:43 +08:00
|
|
|
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
|
2015-07-09 10:10:08 +08:00
|
|
|
FrameLowering(*this) {}
|
2013-06-01 12:51:18 +08:00
|
|
|
|
|
|
|
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
|
|
|
|
|
|
|
|
if (is64Bit()) {
|
|
|
|
// All 64-bit stack frames must be 16-byte aligned, and must reserve space
|
|
|
|
// for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
|
|
|
|
frameSize += 128;
|
|
|
|
// Frames with calls must also reserve space for 6 outgoing arguments
|
|
|
|
// whether they are used or not. LowerCall_64 takes care of that.
|
2016-01-15 05:06:47 +08:00
|
|
|
frameSize = alignTo(frameSize, 16);
|
2013-06-01 12:51:18 +08:00
|
|
|
} else {
|
|
|
|
// Emit the correct save instruction based on the number of bytes in
|
|
|
|
// the frame. Minimum stack frame size according to V8 ABI is:
|
|
|
|
// 16 words for register window spill
|
|
|
|
// 1 word for address of returned aggregate-value
|
|
|
|
// + 6 words for passing parameters on the stack
|
|
|
|
// ----------
|
|
|
|
// 23 words * 4 bytes per word = 92 bytes
|
|
|
|
frameSize += 92;
|
|
|
|
|
|
|
|
// Round up to next doubleword boundary -- a double-word boundary
|
|
|
|
// is required by the ABI.
|
2016-01-15 05:06:47 +08:00
|
|
|
frameSize = alignTo(frameSize, 8);
|
2013-06-01 12:51:18 +08:00
|
|
|
}
|
|
|
|
return frameSize;
|
|
|
|
}
|
2015-09-11 05:49:06 +08:00
|
|
|
|
|
|
|
bool SparcSubtarget::enableMachineScheduler() const {
|
|
|
|
return true;
|
|
|
|
}
|