blob: 7373613eb2696fe65b6bf558b76171c6945562e3 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===//
Chris Lattner158e1f52006-02-05 05:50:24 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file implements the SPARC specific subclass of TargetSubtargetInfo.
Chris Lattner158e1f52006-02-05 05:50:24 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "SparcSubtarget.h"
Evan Cheng91111d22011-07-09 05:47:46 +000015#include "Sparc.h"
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000016#include "llvm/Support/MathExtras.h"
Evan Cheng2bb40352011-08-24 18:08:43 +000017#include "llvm/Support/TargetRegistry.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000018
Evan Cheng54b68e32011-07-01 20:45:01 +000019#define GET_SUBTARGETINFO_TARGET_DESC
Evan Cheng4d1ca962011-07-08 01:53:10 +000020#define GET_SUBTARGETINFO_CTOR
Evan Chengc9c090d2011-07-01 22:36:09 +000021#include "SparcGenSubtargetInfo.inc"
Evan Cheng54b68e32011-07-01 20:45:01 +000022
Chris Lattner158e1f52006-02-05 05:50:24 +000023using namespace llvm;
24
David Blaikiea379b1812011-12-20 02:50:00 +000025void SparcSubtarget::anchor() { }
26
Evan Chengfe6e4052011-06-30 01:53:36 +000027SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
28 const std::string &FS, bool is64Bit) :
Evan Cheng1a72add62011-07-07 07:07:08 +000029 SparcGenSubtargetInfo(TT, CPU, FS),
Chris Lattner8228b112010-02-04 06:34:01 +000030 IsV9(false),
31 V8DeprecatedInsts(false),
32 IsVIS(false),
Venkatraman Govindaraju35e0c382013-08-25 18:30:06 +000033 Is64Bit(is64Bit),
Jakob Stoklund Olesenead3b3d2014-01-26 06:09:59 +000034 HasHardQuad(false),
35 UsePopc(false) {
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000036
Chris Lattner158e1f52006-02-05 05:50:24 +000037 // Determine default and user specified characteristics
Evan Chengfe6e4052011-06-30 01:53:36 +000038 std::string CPUName = CPU;
Venkatraman Govindarajua66b3142014-01-11 23:56:13 +000039 if (CPUName.empty())
40 CPUName = (is64Bit) ? "v9" : "v8";
Chris Lattner158e1f52006-02-05 05:50:24 +000041
Chris Lattner158e1f52006-02-05 05:50:24 +000042 // Parse features string.
Evan Cheng1a72add62011-07-07 07:07:08 +000043 ParseSubtargetFeatures(CPUName, FS);
Chris Lattneraa2372562006-05-24 17:04:05 +000044}
Venkatraman Govindaraju3521dcd2013-06-01 04:51:18 +000045
46
47int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
48
49 if (is64Bit()) {
50 // All 64-bit stack frames must be 16-byte aligned, and must reserve space
51 // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
52 frameSize += 128;
53 // Frames with calls must also reserve space for 6 outgoing arguments
54 // whether they are used or not. LowerCall_64 takes care of that.
55 assert(frameSize % 16 == 0 && "Stack size not 16-byte aligned");
56 } else {
57 // Emit the correct save instruction based on the number of bytes in
58 // the frame. Minimum stack frame size according to V8 ABI is:
59 // 16 words for register window spill
60 // 1 word for address of returned aggregate-value
61 // + 6 words for passing parameters on the stack
62 // ----------
63 // 23 words * 4 bytes per word = 92 bytes
64 frameSize += 92;
65
66 // Round up to next doubleword boundary -- a double-word boundary
67 // is required by the ABI.
68 frameSize = RoundUpToAlignment(frameSize, 8);
69 }
70 return frameSize;
71}