Mercurial > hg > CbC > CbC_llvm
comparison lib/CodeGen/MachineFrameInfo.cpp @ 134:3a76565eade5 LLVM5.0.1
update 5.0.1
author | mir3636 |
---|---|
date | Sat, 17 Feb 2018 09:57:20 +0900 |
parents | 803732b1fca8 |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
133:c60214abe0e8 | 134:3a76565eade5 |
---|---|
14 #include "llvm/CodeGen/MachineFrameInfo.h" | 14 #include "llvm/CodeGen/MachineFrameInfo.h" |
15 | 15 |
16 #include "llvm/ADT/BitVector.h" | 16 #include "llvm/ADT/BitVector.h" |
17 #include "llvm/CodeGen/MachineFunction.h" | 17 #include "llvm/CodeGen/MachineFunction.h" |
18 #include "llvm/CodeGen/MachineRegisterInfo.h" | 18 #include "llvm/CodeGen/MachineRegisterInfo.h" |
19 #include "llvm/CodeGen/TargetFrameLowering.h" | |
20 #include "llvm/CodeGen/TargetInstrInfo.h" | |
21 #include "llvm/CodeGen/TargetRegisterInfo.h" | |
22 #include "llvm/CodeGen/TargetSubtargetInfo.h" | |
19 #include "llvm/Support/Debug.h" | 23 #include "llvm/Support/Debug.h" |
20 #include "llvm/Support/raw_ostream.h" | 24 #include "llvm/Support/raw_ostream.h" |
21 #include "llvm/Target/TargetFrameLowering.h" | |
22 #include "llvm/Target/TargetInstrInfo.h" | |
23 #include "llvm/Target/TargetRegisterInfo.h" | |
24 #include "llvm/Target/TargetSubtargetInfo.h" | |
25 #include <cassert> | 25 #include <cassert> |
26 | 26 |
27 #define DEBUG_TYPE "codegen" | 27 #define DEBUG_TYPE "codegen" |
28 | 28 |
29 using namespace llvm; | 29 using namespace llvm; |
45 << " when stack realignment is off" << '\n'); | 45 << " when stack realignment is off" << '\n'); |
46 return StackAlign; | 46 return StackAlign; |
47 } | 47 } |
48 | 48 |
49 int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment, | 49 int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment, |
50 bool isSS, const AllocaInst *Alloca, | 50 bool IsSpillSlot, |
51 uint8_t ID) { | 51 const AllocaInst *Alloca, |
52 uint8_t StackID) { | |
52 assert(Size != 0 && "Cannot allocate zero size stack objects!"); | 53 assert(Size != 0 && "Cannot allocate zero size stack objects!"); |
53 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); | 54 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); |
54 Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, Alloca, | 55 Objects.push_back(StackObject(Size, Alignment, 0, false, IsSpillSlot, Alloca, |
55 !isSS, ID)); | 56 !IsSpillSlot, StackID)); |
56 int Index = (int)Objects.size() - NumFixedObjects - 1; | 57 int Index = (int)Objects.size() - NumFixedObjects - 1; |
57 assert(Index >= 0 && "Bad frame index!"); | 58 assert(Index >= 0 && "Bad frame index!"); |
58 ensureMaxAlignment(Alignment); | 59 ensureMaxAlignment(Alignment); |
59 return Index; | 60 return Index; |
60 } | 61 } |
76 ensureMaxAlignment(Alignment); | 77 ensureMaxAlignment(Alignment); |
77 return (int)Objects.size()-NumFixedObjects-1; | 78 return (int)Objects.size()-NumFixedObjects-1; |
78 } | 79 } |
79 | 80 |
80 int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset, | 81 int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset, |
81 bool Immutable, bool isAliased) { | 82 bool IsImmutable, bool IsAliased) { |
82 assert(Size != 0 && "Cannot allocate zero size fixed stack objects!"); | 83 assert(Size != 0 && "Cannot allocate zero size fixed stack objects!"); |
83 // The alignment of the frame index can be determined from its offset from | 84 // The alignment of the frame index can be determined from its offset from |
84 // the incoming frame position. If the frame object is at offset 32 and | 85 // the incoming frame position. If the frame object is at offset 32 and |
85 // the stack is guaranteed to be 16-byte aligned, then we know that the | 86 // the stack is guaranteed to be 16-byte aligned, then we know that the |
86 // object is 16-byte aligned. Note that unlike the non-fixed case, if the | 87 // object is 16-byte aligned. Note that unlike the non-fixed case, if the |
87 // stack needs realignment, we can't assume that the stack will in fact be | 88 // stack needs realignment, we can't assume that the stack will in fact be |
88 // aligned. | 89 // aligned. |
89 unsigned Align = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment); | 90 unsigned Alignment = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment); |
90 Align = clampStackAlignment(!StackRealignable, Align, StackAlignment); | 91 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); |
91 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable, | 92 Objects.insert(Objects.begin(), |
92 /*isSS*/ false, | 93 StackObject(Size, Alignment, SPOffset, IsImmutable, |
93 /*Alloca*/ nullptr, isAliased)); | 94 /*isSpillSlot=*/false, /*Alloca=*/nullptr, |
95 IsAliased)); | |
94 return -++NumFixedObjects; | 96 return -++NumFixedObjects; |
95 } | 97 } |
96 | 98 |
97 int MachineFrameInfo::CreateFixedSpillStackObject(uint64_t Size, | 99 int MachineFrameInfo::CreateFixedSpillStackObject(uint64_t Size, |
98 int64_t SPOffset, | 100 int64_t SPOffset, |
99 bool Immutable) { | 101 bool IsImmutable) { |
100 unsigned Align = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment); | 102 unsigned Alignment = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment); |
101 Align = clampStackAlignment(!StackRealignable, Align, StackAlignment); | 103 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); |
102 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable, | 104 Objects.insert(Objects.begin(), |
103 /*isSS*/ true, | 105 StackObject(Size, Alignment, SPOffset, IsImmutable, |
104 /*Alloca*/ nullptr, | 106 /*IsSpillSlot=*/true, /*Alloca=*/nullptr, |
105 /*isAliased*/ false)); | 107 /*IsAliased=*/false)); |
106 return -++NumFixedObjects; | 108 return -++NumFixedObjects; |
107 } | 109 } |
108 | 110 |
109 BitVector MachineFrameInfo::getPristineRegs(const MachineFunction &MF) const { | 111 BitVector MachineFrameInfo::getPristineRegs(const MachineFunction &MF) const { |
110 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); | 112 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); |