Skip to content

Commit e9de1ee

Browse files
committed
MC: Move useCodeAlign from MCSection to MCAsmInfo
To centralize assembly-related virtual functions to MCAsmInfo and move toward making MCSection non-virtual.
1 parent b5c7482 commit e9de1ee

27 files changed

+33
-38
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ class LLVM_ABI MCAsmInfo {
494494
/// returns true => .text
495495
virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
496496

497+
// Return true if a .align directive should use "optimized nops" to fill
498+
// instead of 0s.
499+
virtual bool useCodeAlign(const MCSection &Sec) const { return false; }
500+
497501
bool usesSunStyleELFSectionSwitchSyntax() const {
498502
return SunStyleELFSectionSwitchSyntax;
499503
}

llvm/include/llvm/MC/MCAsmInfoCOFF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace llvm {
1515

1616
class MCAsmInfoCOFF : public MCAsmInfo {
1717
virtual void anchor();
18+
bool useCodeAlign(const MCSection &Sec) const final;
1819

1920
protected:
2021
explicit MCAsmInfoCOFF();

llvm/include/llvm/MC/MCAsmInfoDarwin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace llvm {
2121
class MCAsmInfoDarwin : public MCAsmInfo {
2222
public:
2323
explicit MCAsmInfoDarwin();
24+
bool useCodeAlign(const MCSection &Sec) const final;
2425

2526
/// True if the section is atomized using the symbols in it.
2627
/// This is false if the section is atomized based on its contents (MachO' __TEXT,__cstring for

llvm/include/llvm/MC/MCAsmInfoELF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace llvm {
1616
class MCAsmInfoELF : public MCAsmInfo {
1717
virtual void anchor();
1818
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;
19+
bool useCodeAlign(const MCSection &Sec) const final;
1920

2021
protected:
2122
MCAsmInfoELF();

llvm/include/llvm/MC/MCAsmInfoXCOFF.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
namespace llvm {
1515

1616
class MCAsmInfoXCOFF : public MCAsmInfo {
17-
virtual void anchor();
18-
1917
protected:
2018
MCAsmInfoXCOFF();
19+
bool useCodeAlign(const MCSection &Sec) const final;
2120

2221
public:
2322
// Return true only when C is an acceptable character inside a

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,6 @@ class LLVM_ABI MCSection {
652652
raw_ostream &OS,
653653
uint32_t Subsection) const = 0;
654654

655-
/// Return true if a .align directive should use "optimized nops" to fill
656-
/// instead of 0s.
657-
virtual bool useCodeAlign() const { return false; }
658-
659655
/// Check whether this section is "virtual", that is has no actual object
660656
/// file contents.
661657
bool isBssSection() const { return IsBss; }

llvm/include/llvm/MC/MCSectionCOFF.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class MCSectionCOFF final : public MCSection {
8181
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
8282
raw_ostream &OS,
8383
uint32_t Subsection) const override;
84-
bool useCodeAlign() const override;
8584

8685
unsigned getOrAssignWinCFISectionID(unsigned *NextID) const {
8786
if (WinCFISectionID == ~0U)

llvm/include/llvm/MC/MCSectionELF.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class MCSectionELF final : public MCSection {
8383
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
8484
raw_ostream &OS,
8585
uint32_t Subsection) const override;
86-
bool useCodeAlign() const override;
8786

8887
bool isUnique() const { return UniqueID != NonUniqueID; }
8988
unsigned getUniqueID() const { return UniqueID; }

llvm/include/llvm/MC/MCSectionMachO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class LLVM_ABI MCSectionMachO final : public MCSection {
7979
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
8080
raw_ostream &OS,
8181
uint32_t Subsection) const override;
82-
bool useCodeAlign() const override;
8382

8483
void allocAtoms();
8584
const MCSymbol *getAtom(size_t I) const;

llvm/include/llvm/MC/MCSectionWasm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class MCSectionWasm final : public MCSection {
6767
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
6868
raw_ostream &OS,
6969
uint32_t Subsection) const override;
70-
bool useCodeAlign() const override;
7170

7271
bool isWasmData() const { return IsWasmData; }
7372
bool isMetadata() const { return IsMetadata; }

0 commit comments

Comments
 (0)