For the "C" Standard Extension/Zca, D45560 enabled 2-byte alignment for assembly output (e.g. `clang -S a.c`) and D102052 enabled 2-byte alignment for assembly input and object file output (e.g. `clang -c a.s`). This patch ports the behavior for code generation and object file output by adding RISCVELFTargetObjectFile::getTextSectionAlignment (e.g. `clang -c a.c`). Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D150240
30 lines
1.0 KiB
C++
30 lines
1.0 KiB
C++
//===-- RISCVMCObjectFileInfo.cpp - RISC-V object file properties ---------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the declarations of the RISCVMCObjectFileInfo properties.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "RISCVMCObjectFileInfo.h"
|
|
#include "RISCVMCTargetDesc.h"
|
|
#include "llvm/MC/MCContext.h"
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
|
|
|
using namespace llvm;
|
|
|
|
unsigned
|
|
RISCVMCObjectFileInfo::getTextSectionAlignment(const MCSubtargetInfo &STI) {
|
|
bool RVC = STI.hasFeature(RISCV::FeatureStdExtC) ||
|
|
STI.hasFeature(RISCV::FeatureStdExtZca);
|
|
return RVC ? 2 : 4;
|
|
}
|
|
|
|
unsigned RISCVMCObjectFileInfo::getTextSectionAlignment() const {
|
|
return getTextSectionAlignment(*getContext().getSubtargetInfo());
|
|
}
|