mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-05 00:48:08 +00:00
[RISCV] Only emit .option when extension is supported
It maybe emit the .option directive without any follow up. Only emit the .option push/pop when there are supported extension difference between function and module. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D159399
This commit is contained in:
parent
d861b3183c
commit
b83a1ed594
@ -88,8 +88,7 @@ public:
|
||||
void emitEndOfAsmFile(Module &M) override;
|
||||
|
||||
void emitFunctionEntryLabel() override;
|
||||
void emitDirectiveOptionArch();
|
||||
bool isSameAttribute();
|
||||
bool emitDirectiveOptionArch();
|
||||
|
||||
private:
|
||||
void emitAttributes();
|
||||
@ -252,7 +251,7 @@ bool RISCVAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||
return false;
|
||||
}
|
||||
|
||||
void RISCVAsmPrinter::emitDirectiveOptionArch() {
|
||||
bool RISCVAsmPrinter::emitDirectiveOptionArch() {
|
||||
RISCVTargetStreamer &RTS =
|
||||
static_cast<RISCVTargetStreamer &>(*OutStreamer->getTargetStreamer());
|
||||
SmallVector<RISCVOptionArchArg> NeedEmitStdOptionArgs;
|
||||
@ -268,28 +267,26 @@ void RISCVAsmPrinter::emitDirectiveOptionArch() {
|
||||
: RISCVOptionArchArgType::Minus;
|
||||
NeedEmitStdOptionArgs.emplace_back(Delta, Feature.Key);
|
||||
}
|
||||
if (!NeedEmitStdOptionArgs.empty())
|
||||
if (!NeedEmitStdOptionArgs.empty()) {
|
||||
RTS.emitDirectiveOptionPush();
|
||||
RTS.emitDirectiveOptionArch(NeedEmitStdOptionArgs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RISCVAsmPrinter::isSameAttribute() {
|
||||
const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
|
||||
return MCSTI.getFeatureBits() == STI->getFeatureBits();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RISCVAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
STI = &MF.getSubtarget<RISCVSubtarget>();
|
||||
RISCVTargetStreamer &RTS =
|
||||
static_cast<RISCVTargetStreamer &>(*OutStreamer->getTargetStreamer());
|
||||
if (!isSameAttribute()) {
|
||||
RTS.emitDirectiveOptionPush();
|
||||
emitDirectiveOptionArch();
|
||||
}
|
||||
|
||||
bool EmittedOptionArch = emitDirectiveOptionArch();
|
||||
|
||||
SetupMachineFunction(MF);
|
||||
emitFunctionBody();
|
||||
|
||||
if (!isSameAttribute())
|
||||
if (EmittedOptionArch)
|
||||
RTS.emitDirectiveOptionPop();
|
||||
return false;
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: .option push
|
||||
; CHECK-NOT: .option push
|
||||
define void @test5() "target-features"="+unaligned-scalar-mem" {
|
||||
; CHECK-LABEL: test5
|
||||
; CHECK: .option pop
|
||||
; CHECK-NOT: .option pop
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user