llvm.org GIT mirror llvm / a539d7b
CodeGen: Add a getSectionKind method to MachineConstantPoolEntry This is just a helper routine, no functionality has changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212993 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 6 years ago
3 changed file(s) with 35 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
1616 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
1717
1818 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/MC/SectionKind.h"
1920 #include
2021 #include
2122 #include
118119 /// them.
119120 /// 2: This entry may have arbitrary relocations.
120121 unsigned getRelocationInfo() const;
122
123 SectionKind getSectionKind(const DataLayout *DL) const;
121124 };
122125
123126 /// The MachineConstantPool class keeps track of constants referenced by a
10611061 const MachineConstantPoolEntry &CPE = CP[i];
10621062 unsigned Align = CPE.getAlignment();
10631063
1064 SectionKind Kind;
1065 switch (CPE.getRelocationInfo()) {
1066 default: llvm_unreachable("Unknown section kind");
1067 case 2: Kind = SectionKind::getReadOnlyWithRel(); break;
1068 case 1:
1069 Kind = SectionKind::getReadOnlyWithRelLocal();
1070 break;
1071 case 0:
1072 switch (TM.getDataLayout()->getTypeAllocSize(CPE.getType())) {
1073 case 4: Kind = SectionKind::getMergeableConst4(); break;
1074 case 8: Kind = SectionKind::getMergeableConst8(); break;
1075 case 16: Kind = SectionKind::getMergeableConst16();break;
1076 default: Kind = SectionKind::getMergeableConst(); break;
1077 }
1078 }
1064 SectionKind Kind = CPE.getSectionKind(TM.getDataLayout());
10791065
10801066 const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
10811067
835835 return Val.ConstVal->getRelocationInfo();
836836 }
837837
838 SectionKind
839 MachineConstantPoolEntry::getSectionKind(const DataLayout *DL) const {
840 SectionKind Kind;
841 switch (getRelocationInfo()) {
842 default:
843 llvm_unreachable("Unknown section kind");
844 case 2:
845 Kind = SectionKind::getReadOnlyWithRel();
846 break;
847 case 1:
848 Kind = SectionKind::getReadOnlyWithRelLocal();
849 break;
850 case 0:
851 switch (DL->getTypeAllocSize(getType())) {
852 case 4:
853 Kind = SectionKind::getMergeableConst4();
854 break;
855 case 8:
856 Kind = SectionKind::getMergeableConst8();
857 break;
858 case 16:
859 Kind = SectionKind::getMergeableConst16();
860 break;
861 default:
862 Kind = SectionKind::getMergeableConst();
863 break;
864 }
865 }
866 return Kind;
867 }
868
838869 MachineConstantPool::~MachineConstantPool() {
839870 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
840871 if (Constants[i].isMachineConstantPoolEntry())