mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
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
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
||||||
|
|
||||||
#include "llvm/ADT/DenseSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
|
#include "llvm/MC/SectionKind.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -119,6 +120,8 @@ public:
|
|||||||
/// them.
|
/// them.
|
||||||
/// 2: This entry may have arbitrary relocations.
|
/// 2: This entry may have arbitrary relocations.
|
||||||
unsigned getRelocationInfo() const;
|
unsigned getRelocationInfo() const;
|
||||||
|
|
||||||
|
SectionKind getSectionKind(const DataLayout *DL) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The MachineConstantPool class keeps track of constants referenced by a
|
/// The MachineConstantPool class keeps track of constants referenced by a
|
||||||
|
@@ -1062,21 +1062,7 @@ void AsmPrinter::EmitConstantPool() {
|
|||||||
const MachineConstantPoolEntry &CPE = CP[i];
|
const MachineConstantPoolEntry &CPE = CP[i];
|
||||||
unsigned Align = CPE.getAlignment();
|
unsigned Align = CPE.getAlignment();
|
||||||
|
|
||||||
SectionKind Kind;
|
SectionKind Kind = CPE.getSectionKind(TM.getDataLayout());
|
||||||
switch (CPE.getRelocationInfo()) {
|
|
||||||
default: llvm_unreachable("Unknown section kind");
|
|
||||||
case 2: Kind = SectionKind::getReadOnlyWithRel(); break;
|
|
||||||
case 1:
|
|
||||||
Kind = SectionKind::getReadOnlyWithRelLocal();
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
switch (TM.getDataLayout()->getTypeAllocSize(CPE.getType())) {
|
|
||||||
case 4: Kind = SectionKind::getMergeableConst4(); break;
|
|
||||||
case 8: Kind = SectionKind::getMergeableConst8(); break;
|
|
||||||
case 16: Kind = SectionKind::getMergeableConst16();break;
|
|
||||||
default: Kind = SectionKind::getMergeableConst(); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
|
const MCSection *S = getObjFileLowering().getSectionForConstant(Kind);
|
||||||
|
|
||||||
|
@@ -836,6 +836,37 @@ unsigned MachineConstantPoolEntry::getRelocationInfo() const {
|
|||||||
return Val.ConstVal->getRelocationInfo();
|
return Val.ConstVal->getRelocationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SectionKind
|
||||||
|
MachineConstantPoolEntry::getSectionKind(const DataLayout *DL) const {
|
||||||
|
SectionKind Kind;
|
||||||
|
switch (getRelocationInfo()) {
|
||||||
|
default:
|
||||||
|
llvm_unreachable("Unknown section kind");
|
||||||
|
case 2:
|
||||||
|
Kind = SectionKind::getReadOnlyWithRel();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Kind = SectionKind::getReadOnlyWithRelLocal();
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
switch (DL->getTypeAllocSize(getType())) {
|
||||||
|
case 4:
|
||||||
|
Kind = SectionKind::getMergeableConst4();
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
Kind = SectionKind::getMergeableConst8();
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
Kind = SectionKind::getMergeableConst16();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Kind = SectionKind::getMergeableConst();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Kind;
|
||||||
|
}
|
||||||
|
|
||||||
MachineConstantPool::~MachineConstantPool() {
|
MachineConstantPool::~MachineConstantPool() {
|
||||||
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
|
||||||
if (Constants[i].isMachineConstantPoolEntry())
|
if (Constants[i].isMachineConstantPoolEntry())
|
||||||
|
Reference in New Issue
Block a user