Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- SparcSubtarget.cpp - SPARC Subtarget Information ------------------===// |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file implements the SPARC specific subclass of TargetSubtargetInfo. |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | 7c90f73 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 14 | #include "SparcSubtarget.h" |
Evan Cheng | ffc0e73 | 2011-07-09 05:47:46 +0000 | [diff] [blame] | 15 | #include "Sparc.h" |
Venkatraman Govindaraju | 72ad17c | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 16 | #include "llvm/Support/MathExtras.h" |
Evan Cheng | 3e74d6f | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 17 | #include "llvm/Support/TargetRegistry.h" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 18 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 19 | #define GET_SUBTARGETINFO_TARGET_DESC |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 20 | #define GET_SUBTARGETINFO_CTOR |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 21 | #include "SparcGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 25 | void SparcSubtarget::anchor() { } |
| 26 | |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 27 | SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU, |
| 28 | const std::string &FS, bool is64Bit) : |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 29 | SparcGenSubtargetInfo(TT, CPU, FS), |
Chris Lattner | 87c06d6 | 2010-02-04 06:34:01 +0000 | [diff] [blame] | 30 | IsV9(false), |
| 31 | V8DeprecatedInsts(false), |
| 32 | IsVIS(false), |
Venkatraman Govindaraju | 2f17d0f | 2013-08-25 18:30:06 +0000 | [diff] [blame] | 33 | Is64Bit(is64Bit), |
| 34 | HasHardQuad(false) { |
Venkatraman Govindaraju | 1e06bcb | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 35 | |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 36 | // Determine default and user specified characteristics |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 37 | std::string CPUName = CPU; |
| 38 | if (CPUName.empty()) { |
| 39 | if (is64Bit) |
| 40 | CPUName = "v9"; |
| 41 | else |
| 42 | CPUName = "v8"; |
Chris Lattner | 87c06d6 | 2010-02-04 06:34:01 +0000 | [diff] [blame] | 43 | } |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 44 | IsV9 = CPUName == "v9"; |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 45 | |
Chris Lattner | 0d170a7 | 2006-01-26 06:51:21 +0000 | [diff] [blame] | 46 | // Parse features string. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 47 | ParseSubtargetFeatures(CPUName, FS); |
Chris Lattner | d74ea2b | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 48 | } |
Venkatraman Govindaraju | 72ad17c | 2013-06-01 04:51:18 +0000 | [diff] [blame] | 49 | |
| 50 | |
| 51 | int SparcSubtarget::getAdjustedFrameSize(int frameSize) const { |
| 52 | |
| 53 | if (is64Bit()) { |
| 54 | // All 64-bit stack frames must be 16-byte aligned, and must reserve space |
| 55 | // for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128. |
| 56 | frameSize += 128; |
| 57 | // Frames with calls must also reserve space for 6 outgoing arguments |
| 58 | // whether they are used or not. LowerCall_64 takes care of that. |
| 59 | assert(frameSize % 16 == 0 && "Stack size not 16-byte aligned"); |
| 60 | } else { |
| 61 | // Emit the correct save instruction based on the number of bytes in |
| 62 | // the frame. Minimum stack frame size according to V8 ABI is: |
| 63 | // 16 words for register window spill |
| 64 | // 1 word for address of returned aggregate-value |
| 65 | // + 6 words for passing parameters on the stack |
| 66 | // ---------- |
| 67 | // 23 words * 4 bytes per word = 92 bytes |
| 68 | frameSize += 92; |
| 69 | |
| 70 | // Round up to next doubleword boundary -- a double-word boundary |
| 71 | // is required by the ABI. |
| 72 | frameSize = RoundUpToAlignment(frameSize, 8); |
| 73 | } |
| 74 | return frameSize; |
| 75 | } |