1 //===-- VESubtarget.cpp - VE Subtarget Information ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the VE specific subclass of TargetSubtargetInfo.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "VESubtarget.h"
14 #include "VE.h"
15 #include "llvm/Support/MathExtras.h"
16 #include "llvm/Support/TargetRegistry.h"
17 
18 using namespace llvm;
19 
20 #define DEBUG_TYPE "ve-subtarget"
21 
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "VEGenSubtargetInfo.inc"
25 
26 void VESubtarget::anchor() {}
27 
28 VESubtarget &VESubtarget::initializeSubtargetDependencies(StringRef CPU,
29                                                           StringRef FS) {
30   // Determine default and user specified characteristics
31   std::string CPUName = std::string(CPU);
32   if (CPUName.empty())
33     CPUName = "ve";
34 
35   // Parse features string.
36   ParseSubtargetFeatures(CPUName, FS);
37 
38   return *this;
39 }
40 
41 VESubtarget::VESubtarget(const Triple &TT, const std::string &CPU,
42                          const std::string &FS, const TargetMachine &TM)
43     : VEGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
44       InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
45       FrameLowering(*this) {}
46 
47 int VESubtarget::getAdjustedFrameSize(int frameSize) const {
48 
49   // VE stack frame:
50   //
51   //         +----------------------------------------+
52   //         | Locals and temporaries                 |
53   //         +----------------------------------------+
54   //         | Parameter area for callee              |
55   // 176(fp) |                                        |
56   //         +----------------------------------------+
57   //         | Register save area (RSA) for callee    |
58   //         |                                        |
59   //  16(fp) |                         20 * 8 bytes   |
60   //         +----------------------------------------+
61   //   8(fp) | Return address                         |
62   //         +----------------------------------------+
63   //   0(fp) | Frame pointer of caller                |
64   // --------+----------------------------------------+--------
65   //         | Locals and temporaries for callee      |
66   //         +----------------------------------------+
67   //         | Parameter area for callee of callee    |
68   //         +----------------------------------------+
69   //  16(sp) | RSA for callee of callee               |
70   //         +----------------------------------------+
71   //   8(sp) | Return address                         |
72   //         +----------------------------------------+
73   //   0(sp) | Frame pointer of callee                |
74   //         +----------------------------------------+
75 
76   // RSA frame:
77   //         +----------------------------------------------+
78   // 168(fp) | %s33                                         |
79   //         +----------------------------------------------+
80   //         | %s19...%s32                                  |
81   //         +----------------------------------------------+
82   //  48(fp) | %s18                                         |
83   //         +----------------------------------------------+
84   //  40(fp) | Linkage area register (%s17)                 |
85   //         +----------------------------------------------+
86   //  32(fp) | Procedure linkage table register (%plt=%s16) |
87   //         +----------------------------------------------+
88   //  24(fp) | Global offset table register (%got=%s15)     |
89   //         +----------------------------------------------+
90   //  16(fp) | Thread pointer register (%tp=%s14)           |
91   //         +----------------------------------------------+
92 
93   frameSize += 176;                   // for RSA, RA, and FP
94   frameSize = alignTo(frameSize, 16); // requires 16 bytes alignment
95 
96   return frameSize;
97 }
98 
99 bool VESubtarget::enableMachineScheduler() const { return true; }
100